added johnvertisement

This commit is contained in:
TriMill 2022-08-04 13:21:39 -04:00
parent 52369e77b1
commit 6d08c5bf79
2 changed files with 24 additions and 12 deletions

View file

@ -62,18 +62,21 @@ def index_blog(app):
blogposts = [] blogposts = []
blog_dir = os.path.join(app.root_path, "blog") blog_dir = os.path.join(app.root_path, "blog")
for file in os.listdir(blog_dir): for file in os.listdir(blog_dir):
with open(os.path.join(blog_dir, file)) as f: try:
contents = f.read() with open(os.path.join(blog_dir, file)) as f:
html = markdown2.markdown(contents, extras=markdown_extras) contents = f.read()
meta = html.metadata html = markdown2.markdown(contents, extras=markdown_extras)
meta["file"] = file meta = html.metadata
date_parts = file.removesuffix(".md").split("-") meta["file"] = file
date = datetime.date(int(date_parts[0]), int(date_parts[1]), int(date_parts[2])) date_parts = file.removesuffix(".md").split("-")
meta["timestamp"] = datetime.datetime.fromisoformat(meta["timestamp"]) date = datetime.date(int(date_parts[0]), int(date_parts[1]), int(date_parts[2]))
meta["date"] = date meta["timestamp"] = datetime.datetime.fromisoformat(meta["timestamp"])
meta["n"] = int(date_parts[3]) meta["date"] = date
meta["url"] = f"/blog/{date.isoformat().replace('-','/')}/{meta['n']}" meta["n"] = int(date_parts[3])
blogposts.append(meta) meta["url"] = f"/blog/{date.isoformat().replace('-','/')}/{meta['n']}"
blogposts.append(meta)
except Exception as e:
print("Error indexing blog post %s: %s" % (file, e))
return sorted(blogposts, key=lambda post:[post["date"], post["n"]], reverse=True) return sorted(blogposts, key=lambda post:[post["date"], post["n"]], reverse=True)
def create_app(): def create_app():

View file

@ -48,4 +48,13 @@ It is built using the <a href="https://flask.palletsprojects.com/en/2.1.x/">Flas
icons from <a href="https://useiconic.com/open">Open Iconic</a>. icons from <a href="https://useiconic.com/open">Open Iconic</a>.
</p> </p>
<br />
<div style="color: var(--fg-faded); text-align: center;">johnvertisement</div>
<p>
<iframe src="https://john.citrons.xyz/embed?ref=trimill.xyz" style="margin-left:auto;display:block;margin-right:auto;max-width:732px;width:100%;height:94px;border:none;"></iframe>
</p>
<br />
{% endblock %} {% endblock %}