single pages

master
km0 3 years ago
parent 7f7ee446a1
commit f8ffde2858

File diff suppressed because one or more lines are too long

@ -12,11 +12,22 @@ bp = Blueprint(
@bp.route("/") @bp.route("/")
def postit(): def blocks():
# temporary, eventually we will dump contents only when they are updated (git hooks + git pull ?)
dump.dump() dump.dump()
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.html", contents=contents)
@bp.route("/<slug>")
def block(slug=None):
dump.dump()
with open("postit/contents.json", "r") as f:
contents = json.load(f)
block = [post for post in contents if post["slug"] == slug]
return render_template("postit-single.html", contents=block)

@ -1,8 +1,13 @@
from flask import Blueprint, render_template, request, url_for from flask import Blueprint, render_template, request, url_for
import os
bp = Blueprint("home", __name__, url_prefix="/") bp = Blueprint("home", __name__, url_prefix="/")
@bp.route("/") @bp.route("/")
def home(): def home():
return "Home"
path = "postit/static/contents"
pages = [f.name for f in os.scandir(path) if f.is_dir()]
return render_template("home.html", pages=pages)

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Post-it</title>
</head>
<body>
<h1>🚩 90 000 post-it</h1>
<ul>
{%for page in pages %}
<li>
<a href="{{url_for('generate.block', slug=page)}}">{{page}}</a>
</li>
{%endfor%}
</ul>
</body>
</html>

@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Post it</title>
<link rel="stylesheet" href="{{url_for('static', filename='css/postit.css')}}" />
<link rel="stylesheet" href="{{url_for('static', filename='css/contents.css')}}" />
</head>
<body>
<div class="container">
{% for content in contents %}
<div class="post-it {{content['slug']}}">
{%if content['img'] %}
<img
src="{{url_for('static', filename='contents/' + content['slug'] + '/' + content['img'] )}}"
alt="{{content['description']}}"
/>
<figcaption>{{content['description']}}</figcaption>
{%elif content['card']%}
<div class="card">{{content['card']}}</div>
<div class="quote">{{content['quote']}}</div>
<dl>
<dt>Motivation</dt>
<dd>{{content['motivation']}}</dd>
<dt>Emphaty</dt>
<dd>{{content['emphaty']}}</dd>
<dt>Vision</dt>
<dd>{{content['vision']}}</dd>
<dt>Positivity</dt>
<dd>{{content['positivity']}}</dd>
</dl>
{%else%}
<h2 class="title">{{content['title']}}</h2>
<p class="description">{{content['description']}}</p>
{%endif%}
</div>
{% endfor %}
</div>
</body>
</html>
Loading…
Cancel
Save