2024-07-12 11:19:40 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys as _sys
|
|
|
|
import json as _json
|
|
|
|
import argparse as _argparse
|
|
|
|
|
|
|
|
from lib import *
|
|
|
|
|
|
|
|
|
|
|
|
_template_cache = {}
|
|
|
|
|
|
|
|
|
|
|
|
def coin(template, arguments):
|
|
|
|
return string_coin(
|
|
|
|
template,
|
|
|
|
arguments,
|
|
|
|
{"open": "<<", "close": ">>"}
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def render(template_name, arguments):
|
|
|
|
global _template_cache
|
|
|
|
if (not (template_name in _template_cache)):
|
|
|
|
template_content = file_read("source/tex/%s.tex.tpl" % template_name)
|
|
|
|
_template_cache[template_name] = template_content
|
|
|
|
else:
|
|
|
|
template_content = _template_cache[template_name]
|
|
|
|
return coin(
|
|
|
|
template_content,
|
|
|
|
arguments
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def macro_applist(node):
|
|
|
|
return convey(
|
|
|
|
node["order"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda y: render(
|
|
|
|
"app",
|
|
|
|
{
|
|
|
|
"id": y,
|
|
|
|
"name": node["pool"][y]["name"],
|
|
|
|
"link": node["pool"][y]["link"],
|
|
|
|
"icon": node["pool"][y]["icon"],
|
|
|
|
"desc": node["pool"][y]["desc"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def macro_todolist(node):
|
|
|
|
return convey(
|
|
|
|
node,
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda entry: render(
|
|
|
|
"todo",
|
|
|
|
{
|
|
|
|
"name": entry["name"],
|
|
|
|
"link": entry["link"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
## args
|
|
|
|
argument_parser = _argparse.ArgumentParser()
|
|
|
|
argument_parser.add_argument(
|
|
|
|
"-d",
|
|
|
|
"--data-path",
|
|
|
|
type = str,
|
|
|
|
dest = "data_path",
|
|
|
|
metavar = "<data-path>",
|
|
|
|
default = "source/data.json",
|
|
|
|
)
|
|
|
|
argument_parser.add_argument(
|
|
|
|
"-r",
|
|
|
|
"--include-resources",
|
|
|
|
action = "store_true",
|
|
|
|
dest = "include_resources",
|
|
|
|
default = False,
|
|
|
|
)
|
|
|
|
args = argument_parser.parse_args()
|
|
|
|
|
|
|
|
## exec
|
|
|
|
data = _json.loads(file_read(args.data_path))
|
|
|
|
_sys.stdout.write(
|
|
|
|
render(
|
|
|
|
"master",
|
|
|
|
{
|
|
|
|
"meta-date": data["meta"]["date"],
|
|
|
|
"meta-author": data["meta"]["author"],
|
|
|
|
"meta-title": data["meta"]["title"],
|
|
|
|
"meta-contact-email_address": data["meta"]["contact"]["email_address"],
|
2024-07-13 09:27:24 +02:00
|
|
|
"motivation-situation-items": convey(
|
|
|
|
data["motivation"]["situation"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda entry: coin("\\pause \\item{<<entry>>}\n", {"entry": entry}),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
),
|
2024-07-12 11:19:40 +02:00
|
|
|
"service-theory-frames": convey(
|
|
|
|
data["services"]["theory"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda y: render(
|
|
|
|
"service-theory-frame",
|
|
|
|
y
|
|
|
|
),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
),
|
|
|
|
"service-practice-example-link": data["services"]["practice"]["example"]["link"],
|
|
|
|
"service-practice-example-label": data["services"]["practice"]["example"]["label"],
|
|
|
|
"service-practice-technologies-items": macro_applist(data["services"]["practice"]["technologies"]),
|
|
|
|
"service-practice-basics-items": macro_applist(data["services"]["practice"]["basics"]),
|
|
|
|
"service-practice-existing-items": macro_applist(data["services"]["practice"]["concrete_present"]),
|
|
|
|
"service-practice-future-items": macro_applist(data["services"]["practice"]["concrete_planned"]),
|
|
|
|
"services-alternatives-list-items": convey(
|
|
|
|
data["services"]["alternatives"]["list"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda entry: coin("\\item{<<entry>>}\n", {"entry": entry}),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
),
|
|
|
|
"services-alternatives-problems-items": convey(
|
|
|
|
data["services"]["alternatives"]["problems"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda entry: coin("\\item{<<entry>>}\n", {"entry": entry}),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
),
|
|
|
|
"user_management-schema-frames": convey(
|
|
|
|
data["user_management"]["schema"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda y: render(
|
|
|
|
"user_management-frame",
|
|
|
|
({"title": "Aufbau"} | y)
|
|
|
|
),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
),
|
|
|
|
"user_management-process-entry-frames": convey(
|
|
|
|
data["user_management"]["processes"]["entry"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda y: render(
|
|
|
|
"user_management-frame",
|
|
|
|
({"title": "Ablauf"} | y)
|
|
|
|
),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
),
|
|
|
|
"user_management-example-link": data["user_management"]["example"]["link"],
|
|
|
|
"user_management-example-label": data["user_management"]["example"]["label"],
|
|
|
|
"user_management-example-remark": data["user_management"]["example"]["remark"],
|
|
|
|
"resources-frame": (
|
|
|
|
render(
|
|
|
|
"resources-frame",
|
|
|
|
{
|
|
|
|
"resource-items": convey(
|
|
|
|
data["resources"],
|
|
|
|
[
|
|
|
|
lambda x: map(
|
|
|
|
lambda resource: render(
|
|
|
|
"resource-item",
|
|
|
|
{
|
|
|
|
"name": resource["name"],
|
|
|
|
"link": resource["link"],
|
|
|
|
}
|
|
|
|
),
|
|
|
|
x
|
|
|
|
),
|
|
|
|
"".join,
|
|
|
|
]
|
|
|
|
),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
if args.include_resources else
|
|
|
|
""
|
|
|
|
),
|
|
|
|
"todos-technical-items": macro_todolist(data["realization"]["todos_technical"]),
|
|
|
|
"todos-social-items": macro_todolist(data["realization"]["todos_social"]),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
|