feature: swl build process
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
if (!value) return [];
|
if (!value) return [];
|
||||||
var seen = new Set();
|
var seen = new Set();
|
||||||
return value.toUpperCase().split(/[\s+,]+/).filter(function (questionId) {
|
return value.toUpperCase().split(/[\s+,]+/).filter(function (questionId) {
|
||||||
if (!/^[A-Z]{2}\d{3}$/.test(questionId) || seen.has(questionId)) return false;
|
if (!/^[A-Z]{2,3}\d{3}$/.test(questionId) || seen.has(questionId)) return false;
|
||||||
seen.add(questionId);
|
seen.add(questionId);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var COURSE_CHOICES = [
|
var COURSE_CHOICES = [
|
||||||
|
{ edition: "SWL", label: "SWL-Kurs", detail: "Kurzwellenhören", color: "#FFFFFF" },
|
||||||
{ edition: "N", label: "N-Kurs", detail: "N", color: "#47ABE8" },
|
{ edition: "N", label: "N-Kurs", detail: "N", color: "#47ABE8" },
|
||||||
{ edition: "NE", label: "E-Kurs", detail: "N + E", color: "#FE756C" },
|
{ edition: "NE", label: "E-Kurs", detail: "N + E", color: "#FE756C" },
|
||||||
{ edition: "NEA", label: "A-Kurs", detail: "N + E + A", color: "#3BB583" },
|
{ edition: "NEA", label: "A-Kurs", detail: "N + E + A", color: "#3BB583" },
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
function walk(section, sectionIndex, category) {
|
function walk(section, sectionIndex, category) {
|
||||||
(section.questions || []).forEach(function (question) {
|
(section.questions || []).forEach(function (question) {
|
||||||
var part = sectionIndex === 0
|
var part = String(question.class) === "SWL"
|
||||||
? partForClass[String(question.class)]
|
? "SWL"
|
||||||
: partForSection[sectionIndex];
|
: (sectionIndex === 0 ? partForClass[String(question.class)] : partForSection[sectionIndex]);
|
||||||
if (!part) return;
|
if (!part) return;
|
||||||
|
|
||||||
var questionMetadata = metadata[question.number] || {};
|
var questionMetadata = metadata[question.number] || {};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ conf = config.Config()
|
|||||||
# Build Everything:
|
# Build Everything:
|
||||||
bd = build.Build(conf)
|
bd = build.Build(conf)
|
||||||
bd.build_website()
|
bd.build_website()
|
||||||
|
bd.build_edition("SWL")
|
||||||
bd.build_edition("N")
|
bd.build_edition("N")
|
||||||
bd.build_edition("E")
|
bd.build_edition("E")
|
||||||
bd.build_edition("A")
|
bd.build_edition("A")
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ app = typer.Typer()
|
|||||||
@app.command()
|
@app.command()
|
||||||
def main(
|
def main(
|
||||||
edition: Annotated[list[Edition], typer.Option(help="Edition to build, can be specified multiple times.")] = [ # noqa: B006 -- default value is required for typer
|
edition: Annotated[list[Edition], typer.Option(help="Edition to build, can be specified multiple times.")] = [ # noqa: B006 -- default value is required for typer
|
||||||
|
Edition.swl,
|
||||||
Edition.n,
|
Edition.n,
|
||||||
Edition.e,
|
Edition.e,
|
||||||
Edition.a,
|
Edition.a,
|
||||||
|
|||||||
+14
-6
@@ -215,8 +215,11 @@ class Build:
|
|||||||
def __build_homework_tool(self):
|
def __build_homework_tool(self):
|
||||||
toc_target = self.config.p_build_assets / "toc"
|
toc_target = self.config.p_build_assets / "toc"
|
||||||
toc_target.mkdir(parents=True, exist_ok=True)
|
toc_target.mkdir(parents=True, exist_ok=True)
|
||||||
for edition in ("N", "NE", "NEA", "E", "EA", "A"):
|
for edition in ("SWL", "N", "NE", "NEA", "E", "EA", "A"):
|
||||||
shutil.copyfile(self.config.p_data_toc / f"{edition}.json", toc_target / f"{edition}.json")
|
source = self.config.p_data_toc / f"{edition}.json"
|
||||||
|
if not source.exists():
|
||||||
|
source = self.config.p_data_toc / f"{edition.lower()}.json"
|
||||||
|
shutil.copyfile(source, toc_target / f"{edition}.json")
|
||||||
|
|
||||||
homework_template = self.env.get_template("html/homework.html")
|
homework_template = self.env.get_template("html/homework.html")
|
||||||
page = self.__build_page(
|
page = self.__build_page(
|
||||||
@@ -439,9 +442,12 @@ class Build:
|
|||||||
self.config.p_build.mkdir(exist_ok=True)
|
self.config.p_build.mkdir(exist_ok=True)
|
||||||
|
|
||||||
edition = edition.upper()
|
edition = edition.upper()
|
||||||
|
toc_file = self.config.p_data_toc / f"{edition}.json"
|
||||||
|
if not toc_file.exists():
|
||||||
|
toc_file = self.config.p_data_toc / f"{edition.lower()}.json"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
(self.config.p_data_toc / f"{edition}.json").open(encoding="utf-8") as file,
|
toc_file.open(encoding="utf-8") as file,
|
||||||
Progress(
|
Progress(
|
||||||
TaskProgressColumn(),
|
TaskProgressColumn(),
|
||||||
BarColumn(),
|
BarColumn(),
|
||||||
@@ -480,9 +486,11 @@ class Build:
|
|||||||
with (self.config.p_data_sections / f"{ident}.md").open(encoding="utf-8") as sfile:
|
with (self.config.p_data_sections / f"{ident}.md").open(encoding="utf-8") as sfile:
|
||||||
section_content = sfile.read()
|
section_content = sfile.read()
|
||||||
section["content"] = section_content
|
section["content"] = section_content
|
||||||
with (self.config.p_data_slides / f"{ident}.md").open(encoding="utf-8") as sfile:
|
slide_file = self.config.p_data_slides / f"{ident}.md"
|
||||||
section_content = sfile.read()
|
if slide_file.exists():
|
||||||
section["slide"] = section_content
|
with slide_file.open(encoding="utf-8") as sfile:
|
||||||
|
section_content = sfile.read()
|
||||||
|
section["slide"] = section_content
|
||||||
|
|
||||||
if section["content"] is not None:
|
if section["content"] is not None:
|
||||||
self.__collect_question_occurrences(
|
self.__collect_question_occurrences(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from enum import StrEnum
|
|||||||
|
|
||||||
|
|
||||||
class Edition(StrEnum):
|
class Edition(StrEnum):
|
||||||
|
swl = "SWL"
|
||||||
n = "N"
|
n = "N"
|
||||||
e = "E"
|
e = "E"
|
||||||
a = "A"
|
a = "A"
|
||||||
|
|||||||
@@ -71,3 +71,34 @@ def test_missing_optional_swl_catalog_is_allowed(tmp_path):
|
|||||||
|
|
||||||
assert set(build.questions) == {"NA101"}
|
assert set(build.questions) == {"NA101"}
|
||||||
assert len(build.fragenkatalog["sections"]) == 1
|
assert len(build.fragenkatalog["sections"]) == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_lowercase_swl_toc_is_supported(tmp_path):
|
||||||
|
prepare_content(tmp_path, include_swl=True)
|
||||||
|
toc_path = tmp_path / "toc"
|
||||||
|
section_path = tmp_path / "contents" / "sections"
|
||||||
|
toc_path.mkdir()
|
||||||
|
section_path.mkdir()
|
||||||
|
(section_path / "swl_intro.md").write_text("Einführung", encoding="utf-8")
|
||||||
|
(toc_path / "swl.json").write_text(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"title": "SWL-Kurs",
|
||||||
|
"edition": "SWL",
|
||||||
|
"chapters": [
|
||||||
|
{
|
||||||
|
"title": "Einstieg",
|
||||||
|
"ident": "swl_einstieg",
|
||||||
|
"sections": [{"title": "Einführung", "ident": "swl_intro"}],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
),
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
|
||||||
|
build = Build(Config(content_path=tmp_path, build_path=tmp_path / "build"))
|
||||||
|
|
||||||
|
build.build_edition("SWL")
|
||||||
|
assert (tmp_path / "build" / "SWL_course_index.html").exists()
|
||||||
|
assert (tmp_path / "build" / "SWL_swl_intro.html").exists()
|
||||||
|
|||||||
Reference in New Issue
Block a user