Skip to content
Snippets Groups Projects
Commit 87f8bd35 authored by chrissi^'s avatar chrissi^
Browse files

Add infos.json based on main event infos

This commit adds an auto-generated `infos.json` to our website based on
information provided in the `settings.py`.
These infos are now also used to fill some infos on the website.
parent 0476e280
Branches 1-inhalte-erstellen-basisinformation
No related tags found
No related merge requests found
Pipeline #3441 passed
import datetime
import os
import json
import flamingo
from flamingo.core.context import Context
from flamingo.core.data_model import Content, ContentSet
from flamingo.core.templating import TemplatingEngine
# Event Core Infos
EVENT_INFO = {
"next": {
"start": "2025-07-01",
"end": "2025-07-05",
"event": "Hacken Open Air 2::25",
"location_city": "Gifhorn",
}
}
THEME_PATHS = [
'theme/',
......@@ -30,3 +45,20 @@ def fix_headings(context):
POST_BUILD_LAYERS = [
'downloads',
]
@flamingo.hook("templating_engine_setup")
def event_info_templates(_context: Context, templating_engine: TemplatingEngine):
"""Add the Event-Info to the template context."""
start = datetime.date.fromisoformat(EVENT_INFO["next"]["start"])
end = datetime.date.fromisoformat(EVENT_INFO["next"]["end"])
templating_engine.env.globals["EVENT_HEADLINE"] = EVENT_INFO["next"]["event"]
templating_engine.env.globals["EVENT_TAGLINE"] = \
f"{start.strftime('%d.%m.')} - {end.strftime('%d.%m.%Y')} in {EVENT_INFO['next']['location_city']}"
@flamingo.hook("contents_parsed")
def event_info_json(context: Context):
"""Write the event info as infos.json into the output."""
contents: ContentSet = context.contents
contents.add(Content(output="infos.json", content_body=json.dumps(EVENT_INFO), path=""))
......@@ -6,7 +6,7 @@
<meta property="og:image" content="https://hackenopenair.de/media/pool.jpeg">
<link rel="icon" href="./static/img/favicon.png" type="image/png">
<title>
{% block title %}Hacken Open Air 2::25{% endblock %}
{% block title %}{{ EVENT_HEADLINE }}{% endblock %}
</title>
<link rel="stylesheet" href="./static/css/hoa.css">
</head>
......
......@@ -4,7 +4,7 @@
<header>
<div id="top"></div>
<div class="headers">
<h1>Hacken Open Air 2::25</h1>
<h1>{{ EVENT_HEADLINE }}</h1>
</div>
</header>
<aside>
......@@ -32,7 +32,7 @@
<div class="main">
<article>
<div align="center">
<h3>01.07 bis 05.07.2025 in Gifhorn</h3>
<h3>{{ EVENT_TAGLINE }}</h3>
<img id="specht" src="./static/img/specht.svg" alt="logo">
</div>
{{ content.content_body }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment