porting dump draft
parent
3e68cace8e
commit
b419cd5c31
@ -0,0 +1 @@
|
||||
[]
|
@ -0,0 +1,35 @@
|
||||
import json
|
||||
import frontmatter
|
||||
import os
|
||||
|
||||
|
||||
def dump():
|
||||
# list all the folders
|
||||
folders = [
|
||||
name
|
||||
for name in os.listdir()
|
||||
if os.path.isdir(os.path.join("", name))
|
||||
and not name.startswith(".")
|
||||
and not name == "miri-the-leader"
|
||||
]
|
||||
|
||||
print(folders)
|
||||
|
||||
contents = []
|
||||
|
||||
for folder in folders:
|
||||
with open(f"{folder}/contents.md", "r") as f:
|
||||
metadata, body = frontmatter.parse(f.read())
|
||||
for content in metadata["contents"]:
|
||||
if type(content) == dict and content["img"]:
|
||||
postit = {
|
||||
"title": metadata["title"],
|
||||
"description": content["alt"],
|
||||
"img": content["img"],
|
||||
}
|
||||
else:
|
||||
postit = {"title": metadata["title"], "description": content}
|
||||
contents.append(postit)
|
||||
|
||||
with open("postit/contents.json", "w") as f:
|
||||
f.write(json.dumps(contents))
|
@ -0,0 +1,24 @@
|
||||
from flask import Blueprint, render_template
|
||||
import json
|
||||
|
||||
from . import dump
|
||||
|
||||
|
||||
bp = Blueprint("generate", __name__, url_prefix="/generate")
|
||||
|
||||
|
||||
def generate():
|
||||
pass
|
||||
|
||||
|
||||
@bp.route("/")
|
||||
def postit():
|
||||
|
||||
dump.dump()
|
||||
|
||||
return "hello"
|
||||
|
||||
# with open("contents.json", "r") as f:
|
||||
# contents = json.load(f)
|
||||
|
||||
# return render_template("postit.html", contents=contents)
|
@ -0,0 +1,71 @@
|
||||
@page {
|
||||
size: A3;
|
||||
margin: 5mm;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.container {
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.post-it {
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
width: 90mm;
|
||||
height: 90mm;
|
||||
border: 1px solid #ddd;
|
||||
margin: 0;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
line-height: 1.4;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
img {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
text-align: center;
|
||||
margin: 4mm;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.description {
|
||||
display: inline-block;
|
||||
margin: 4mm;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
background-color: white;
|
||||
font-size: 18px;
|
||||
text-align: center;
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: 4mm;
|
||||
transform: translate(-50%, 0);
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #ddd;
|
||||
font-size: 12px;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<!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')}}" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
{% for content in contents %} {% for i in range(12)%}
|
||||
<div class="post-it">
|
||||
{%if content['img'] %}
|
||||
<img src="{{content['img']}}" alt="{{content['description']}}" />
|
||||
<figcaption>{{content['description']}}</figcaption>
|
||||
{%else%}
|
||||
<h2 class="title">{{content['title']}}</h2>
|
||||
<p class="description">{{content['description']}}</p>
|
||||
{%endif%}
|
||||
</div>
|
||||
{%endfor%} {% endfor %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue