refactor: removed redaktions-directus

This commit is contained in:
Matthias Jung
2026-02-01 21:37:52 +01:00
parent 2139685192
commit 74554dd821
5 changed files with 63 additions and 48 deletions
+1 -5
View File
@@ -10,11 +10,7 @@ dl = download.Download(content_api, conf)
# Download the content files:
dl.download_git_content()
# Download additional files:
dl.download_snippets()
dl.download_content()
## Build Everything:
# Build Everything:
bd = build.Build(conf)
bd.build_website()
bd.build_edition("N")
-2
View File
@@ -1,5 +1,3 @@
{
"directus_content_base_url" : "https://redaktion.50ohm.de/",
"directus_content_api_key" : "",
"git_url" : "[email protected]:DARC-e-V/50ohm-contents-dl.git",
}
+22
View File
@@ -0,0 +1,22 @@
{
"index_btn_start": "Jetzt starten",
"lernen_vor_ort_teaser": "Einige unserer Ortsverbände bieten Präsenzkurse mit erfahrenen Ausbildern an. Finde heraus, ob es einen für dich passenden Kurs bei dir in der Nähe gibt!",
"lernen_selbst_btn_n": "Kurs Klasse N",
"index_btn_was_ist_afu": "Was ist Amateurfunk?",
"lernen_selbst_btn_ne": "Kurs Klasse E (mit N)",
"lernen_vor_ort_btn": "Zur Lehrgangskarte",
"lernen_paten_btn": "Zur Patenkarte",
"index_teaser": "Wir bereiten dich auf die Prüfung zum Funkamateur vor. Unsere erfahrenen Ausbilder unterstützen dich auf dem gesamten Weg!",
"lernen_vor_ort_title": "Kurse vor Ort und Online",
"lernen_paten_teaser": "Unsere Ausbildungspaten sind erfahrene Funkamateure, die dich gerne unterstützen. Sie können mit dir auch praktischen Funkbetrieb üben.",
"lernen_selbst_teaser": "Bringe dir das nötige Wissen für die Amateurfunkprüfung einfach selber bei. Unser Lernmaterial hilft dir auf deinem Weg!",
"lernen_selbst_btn_a": "Aufstockungskurs E nach A",
"lernen_selbst_btn_e": "Aufstockungskurs N nach E",
"index_content": "50ohm.de hat die die BETA-Phase verlassen! Viel Spaß beim Lernen für die Klassen N, E und A wünscht das gesamte 50ohm.de-Team.</p><p>Fehler und Feedback in Prüfungsfragen bitte an <a href=\"mailto:[email protected]\">[email protected]</a>, Fehler und Feedback zur Plattform bitte über <a href=\"mailto:[email protected]\">[email protected]</a> melden.</p><p>Lust mitzuarbeiten? Das Projekt findest du auf <a href=\"https://github.com/DARC-e-V/50ohm\">GitHub</a>, auch unsere App ist auf <a href=\"https://github.com/DARC-e-V/50ohm-pocket\">GitHub</a> zu finden.</p><p>Informationen für Ausbilder und Informationen über weitere geplante Features gibt es auf der <a href=\"https://www.darc.de/der-club/referate/ajw/ausbildungsunterlagen-n-e-a\">Website</a> des AJW-Referats.",
"lernen_paten_title": "Ausbildungspaten",
"index_title": "Werde Funkamateur!",
"lernen_selbst_btn_nea": "Kurs Klasse&#160;A (mit N und E)",
"lernen_selbst_btn_ea": "Aufstockungskurs N nach A",
"lernen_selbst_btn_digi": "Auszug Digitaltechnik (E und A)",
"lernen_selbst_title": "Selbst-Studium"
}
+40 -15
View File
@@ -1,6 +1,7 @@
import json
import random
import shutil
from pathlib import Path
from jinja2 import Environment, FileSystemLoader
from joblib import Memory
@@ -385,25 +386,49 @@ class Build:
)
def __parse_snippets(self):
with (self.config.p_data / "snippets.json").open() as file:
snippets = json.load(file)
snippets_dir = self.config.p_data / "git_content/contents/snippets/"
snippets = {}
for md_file in Path(snippets_dir).glob("*.md"):
with md_file.open() as file:
snippets[md_file.stem] = file.read()
with FiftyOhmHtmlRenderer(
question_renderer=self.__build_question,
picture_handler=self.__picture_handler,
photo_handler=self.__photo_handler,
include_handler=self.__include_handler,
) as renderer:
for key, value in snippets.items():
snippets[key] = renderer.render_inner(Document(value))
# Remove leading <p> and trailing </p>:
snippets[key] = snippets[key][3:-4]
with FiftyOhmHtmlRenderer(
question_renderer=self.__build_question,
picture_handler=self.__picture_handler,
photo_handler=self.__photo_handler,
include_handler=self.__include_handler,
) as renderer:
for key, value in snippets.items():
snippets[key] = renderer.render_inner(Document(value))
# Remove leading <p> and trailing </p>:
snippets[key] = snippets[key][3:-4]
return snippets
def __parse_contents(self):
with (self.config.p_data / "content.json").open() as file:
contents = json.load(file)
return contents
static_dir = self.config.p_data / "git_content/contents/static/"
static = []
for static_file in Path(static_dir).glob("*.html"):
if "sidebar" not in static_file.stem:
with static_file.open() as file:
content = file.read()
sidebar_file = static_dir / f"{static_file.stem}_sidebar.html"
if not sidebar_file.exists():
sidebar = ""
else:
with sidebar_file.open() as file:
sidebar = file.read()
static.append(
{
"url_part": static_file.stem,
"content": content,
"sidebar": sidebar if sidebar != "" else None,
}
)
return static
def __build_index(self, snippets):
template = self.env.get_template("html/index.html")
-26
View File
@@ -1,7 +1,4 @@
import json
from git import Repo
from tqdm import tqdm
from api.directus import DirectusAPI
@@ -13,29 +10,6 @@ class Download:
self.config = config
self.content_api = content_api
def download_snippets(self):
snippets = {}
for snippet in tqdm(self.content_api.get("items/snippet"), desc="Downloading snippets"):
snippets[snippet["ident"]] = snippet["content"]
with (self.config.p_data / "snippets.json").open("w", encoding="utf-8") as file:
json.dump(snippets, file, ensure_ascii=False, indent=4)
def download_content(self):
contents = []
for content in self.content_api.get(
"items/content"
): # tqdm(self.content_api.get("items/content"), desc="Downloading content"):
contents.append(
{
"url_part": content["url_part"],
"content": content["content"],
"sidebar": content["sidebar"],
}
)
with (self.config.p_data / "content.json").open("w", encoding="utf-8") as file:
json.dump(contents, file, ensure_ascii=False, indent=4)
def download_git_content(self):
repo_path = self.config.p_data / "git_content"
if not repo_path.exists():