big document wip, bleedHandler

master
km0 2 years ago
parent 41b814c1e7
commit 6668af3bb9

File diff suppressed because one or more lines are too long

@ -4,10 +4,14 @@ import os
import string import string
def dump(): def dump(order=None):
# list all the folders # list all the folders
path = "postit/static/contents" path = "postit/static/contents"
folders = [f.name for f in os.scandir(path) if f.is_dir()]
folders = order
if folders == None:
folders = [f.name for f in os.scandir(path) if f.is_dir()]
contents = [] contents = []

@ -3,6 +3,8 @@ import json
from . import dump from . import dump
import os import os
index = ['what-is-a-loot-box', 'crosswords', 'one-sentence-game-ideas', 'nim', 'mimic', 'unfinished-thoughts', 'the-leader', 'connect-less', 'xquisite', 'katamari', 'life-hacks', 'karaoke']
bp = Blueprint( bp = Blueprint(
"generate", "generate",
@ -14,17 +16,17 @@ bp = Blueprint(
@bp.route("/") @bp.route("/")
def blocks(): def blocks():
# temporary, eventually we will dump contents only when they are updated (git hooks + git pull ?) # temporary, eventually we will dump contents only when they are updated (git hooks + git pull ?)
dump.dump() dump.dump(index)
with open("postit/contents.json", "r") as f: with open("postit/contents.json", "r") as f:
contents = json.load(f) contents = json.load(f)
return render_template("postit.html", contents=contents) return render_template("postit-single.html", contents=contents)
@bp.route("/<slug>") @bp.route("/<slug>")
def block(slug=None): def block(slug=None):
dump.dump() dump.dump([slug])
with open("postit/contents.json", "r") as f: with open("postit/contents.json", "r") as f:
contents = json.load(f) contents = json.load(f)

@ -1 +1 @@
Subproject commit 4f0bc1f4d7ecb421ceaa711bc45d7b80b59d9f9c Subproject commit 128c32bee02212dfc44f41c6465fe58c6c683bf6

@ -6,8 +6,29 @@
} }
:root { :root {
--background: #8f00ff33; --color: var(--purple);
--color: #8f00ff; --background: var(--purple-bg);
--bar-opacity: var(--purple-opacity);
/* --color: var(--orange);
--background: var(--orange-bg);
--bar-opacity: var(--orange-opacity);
--color: var(--orange2);
--background: var(--orange-bg2);
--bar-opacity: var(--orange-opacity2); */
--purple: #8f00ff;
--purple-bg: #e8cdfe;
--purple-opacity: 1;
--orange: #fc074f;
--orange-bg: #f95951;
--orange-opacity: 0.5;
--orange2: #ff5416;
--orange-bg2: #fca577;
--orange-opacity2: 1;
} }
html, html,
@ -66,6 +87,8 @@ img {
font-weight: normal; font-weight: normal;
text-transform: uppercase; text-transform: uppercase;
font-size: 14px; font-size: 14px;
position: relative;
z-index: 10;
} }
.description { .description {
@ -113,10 +136,11 @@ a {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
opacity: 0.5;
} }
@media screen { @media screen {
.post-it { .post-it {
border: 1px solid var(--background); border: 1px solid #ddd;
} }
} }

@ -1,11 +1,22 @@
// Wait for Flask, Jinja2, and Paged.js to do their things class BleedHandler extends Paged.Handler {
setTimeout(getImages, 2500); constructor(chunker, polisher, caller) {
super(chunker, polisher, caller);
}
function getImages() { afterPageLayout(pageFragment, page) {
const images = document.querySelectorAll("[data-image]"); let img = pageFragment.querySelector("img");
Array.from(images).forEach((img) => moveImage(img)); if (img) {
moveImage(img);
}
}
afterRendered(pages) {
console.log("Ready!");
}
} }
Paged.registerHandlers(BleedHandler);
function moveImage(img) { function moveImage(img) {
let parent = img.closest(".pagedjs_sheet"); let parent = img.closest(".pagedjs_sheet");
parent.prepend(img); parent.prepend(img);

@ -8,7 +8,7 @@
<link rel="stylesheet" href="{{url_for('static', filename='css/postit.css')}}" /> <link rel="stylesheet" href="{{url_for('static', filename='css/postit.css')}}" />
<link rel="stylesheet" href="{{url_for('static', filename='css/contents.css')}}" /> <link rel="stylesheet" href="{{url_for('static', filename='css/contents.css')}}" />
<script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script> <script src="https://unpkg.com/pagedjs/dist/paged.polyfill.js"></script>
<script src="{{url_for('static', filename='js/bleed.js')}}" defer></script> <script src="{{url_for('static', filename='js/bleed.js')}}"></script>
</head> </head>
<body> <body>
{% for content in contents %} {% for content in contents %}

Loading…
Cancel
Save