remove markdown include
All checks were successful
Gitea Actions Demo / compile-html (push) Successful in 57s

This commit is contained in:
vitrinekast 2025-01-07 20:40:12 +01:00
parent 296b5c7ad1
commit 2be76fd0c1
7 changed files with 127 additions and 13 deletions

26
app.py
View File

@ -8,13 +8,8 @@ from datetime import datetime
from jinja2 import Environment, PackageLoader, select_autoescape from jinja2 import Environment, PackageLoader, select_autoescape
import frontmatter import frontmatter
import markdown import markdown
from markdown_include.include import MarkdownInclude
from slugify import slugify from slugify import slugify
markdown_include = MarkdownInclude(
configs={'base_path': 'src/content/'}
)
env = Environment( env = Environment(
loader=PackageLoader("src"), loader=PackageLoader("src"),
autoescape=select_autoescape() autoescape=select_autoescape()
@ -33,6 +28,21 @@ def listDocuments(params):
return html return html
def detail(params):
param = params.split(" ")
modifier = False
if len(param)> 2:
modifier = param[2]
for doc in documents[param[0]]:
if doc.filename == param[1]:
template = env.select_template([f"snippets/detail.jinja"])
html = template.render(document=doc, modifier = modifier)
return html
return ""
def listEvents(params): def listEvents(params):
param = params.split(" ") param = params.split(" ")
@ -58,7 +68,8 @@ def shortcode_filter(value):
shortcode_callbacks = { shortcode_callbacks = {
"show": listDocuments, "show": listDocuments,
"events": listEvents "events": listEvents,
"detail": detail
} }
def shortcode_replacer(match): def shortcode_replacer(match):
@ -107,8 +118,7 @@ def get_page_data(path):
page.content, page.content,
extensions=[ extensions=[
'def_list', 'def_list',
'footnotes', 'footnotes'])
markdown_include])
return page return page

View File

@ -2,7 +2,6 @@ import os
from pathlib import Path from pathlib import Path
import requests import requests
import frontmatter import frontmatter
from datetime import datetime
def get_API(URL): def get_API(URL):
@ -43,7 +42,6 @@ def get_calendar_events():
items = get_API("https://calendar.klank.school/api/events?tags=repair&start=-1") items = get_API("https://calendar.klank.school/api/events?tags=repair&start=-1")
for item in items: for item in items:
start_date = datetime.fromtimestamp(item["start_datetime"]).strftime('%Y%m%d')
filename = f"{item['slug']}.md" filename = f"{item['slug']}.md"
filepath = os.path.join("src/content/events", filename) filepath = os.path.join("src/content/events", filename)

View File

@ -1,10 +1,10 @@
importlib_metadata==8.5.0 importlib_metadata==8.5.0
Jinja2==3.1.4 Jinja2==3.1.4
Markdown==3.7 Markdown==3.7
markdown-include==0.8.1
MarkupSafe==3.0.2 MarkupSafe==3.0.2
python-frontmatter==1.1.0 python-frontmatter==1.1.0
python-slugify==8.0.4 python-slugify==8.0.4
PyYAML==5.1 PyYAML==5.1
requests==2.32.3
text-unidecode==1.3 text-unidecode==1.3
zipp==3.21.0 zipp==3.21.0

View File

@ -0,0 +1,41 @@
---
boost: []
description: <p>Bring your (un)broken devices and sound makers!</p>
end_datetime: 1734040800
id: 19
image_path: null
isAnon: false
isMine: false
is_visible: true
likes: []
media: []
multidate: null
next: lets-unrepair-things-together-7
online_locations: []
parent:
id: 9
is_visible: false
recurrent:
frequency: 1w
start_datetime: 1730998800
parentId: 9
place:
address: Catullusweg 11
id: 1
latitude: 51.8766465
longitude: 4.5242688
name: Catu
plain_description: Bring your (un)broken devices and sound makers!
prev: lets-unrepair-things-together-analog-video-edition
recurrent: null
resources: []
slug: lets-unrepair-things-together-6
start_datetime: 1734022800
tags:
- klankschool
- noise
- repair
title: Let's (un)repair things together!
---
<p>Bring your (un)broken devices and sound makers!</p>

View File

@ -6,5 +6,4 @@ title: A newsletter for december
Hello world, this is a newsletter being generated for the month December. Keen to check out what has been happening? Here are some repair logs i wanted to share with you. Hello world, this is a newsletter being generated for the month December. Keen to check out what has been happening? Here are some repair logs i wanted to share with you.
### Repair logs in december ### Repair logs in december
{{ detail repair-logs 20241031 }}
{! repair-logs/20241031.md !}

View File

@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="shortcut icon" type="image/x-icon" href="/assets/favicon.ico">
<link rel="apple-touch-icon" sizes="76x76" href="/assets/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/assets/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#ffc40d">
<meta name="theme-color" content="#000">
<meta name="keywords" content="">
<meta name="robots" content="noarchive, noimageindex">
<style>
body {
max-width: 800px;
margin: 2rem auto;
font-family: sans-serif;
}
</style>
{% block title %}
{% if page['title'] %}
<title>{{ page['title'] }}</title>
{% else %}
<title>The title</title>
{% endif %}
{% endblock %}
</head>
</head>
<body>
<main>
<section>
<article>
{{ page['body'] | shortcode }}
</article>
</section>
</main>
</body>
</html>

View File

@ -0,0 +1,9 @@
<h4>{{document.title}}</h4>
<article>
{% if modifier %}
{{ document[modifier] | shortcode }}
{% else %}
{{ document['body'] | shortcode }}
{% endif %}
</article>