diff --git a/source/index.html b/source/index.html.tpl
similarity index 97%
rename from source/index.html
rename to source/index.html.tpl
index 957ccbc..f9696e4 100644
--- a/source/index.html
+++ b/source/index.html.tpl
@@ -22,6 +22,7 @@ document.addEventListener(
);
+{{templates}}
diff --git a/source/logic/helpers.ts b/source/logic/helpers.ts
index 740a0cf..024fe18 100644
--- a/source/logic/helpers.ts
+++ b/source/logic/helpers.ts
@@ -10,21 +10,29 @@ namespace _zeitbild.frontend_web.helpers
/**
- * @todo caching
*/
export async function template_coin(
+ group : string,
name : string,
data : Record
) : Promise
{
let content : string;
- if (! (name in _template_cache)) {
+ const key : string = lib_plankton.string.coin(
+ "{{group}}/{{name}}",
+ {
+ "group": group,
+ "name": name,
+ }
+ );
+ if (! (key in _template_cache)) {
content = (
(
await lib_plankton.file.read(
lib_plankton.string.coin(
- "templates/{{name}}.html.tpl",
+ "templates/{{group}}/{{name}}.html.tpl",
{
+ "group": group,
"name": name,
}
)
@@ -32,10 +40,10 @@ namespace _zeitbild.frontend_web.helpers
)
.toString()
);
- _template_cache[name] = content;
+ _template_cache[key] = content;
}
else {
- content = _template_cache[name];
+ content = _template_cache[key];
}
return Promise.resolve(
lib_plankton.string.coin(
diff --git a/source/logic/view.ts b/source/logic/view.ts
index eadd1e3..0d0414c 100644
--- a/source/logic/view.ts
+++ b/source/logic/view.ts
@@ -495,6 +495,7 @@ namespace _zeitbild.frontend_web.view
)
);
return _zeitbild.frontend_web.helpers.template_coin(
+ "events",
"tableview",
{
"sources": (
@@ -502,6 +503,7 @@ namespace _zeitbild.frontend_web.view
lib_plankton.map.dump(sources)
.map(
({"key": calendar_id, "value": data}) => async () => _zeitbild.frontend_web.helpers.template_coin(
+ "events",
"tableview-sources-entry",
{
"name": data.name,
@@ -518,6 +520,7 @@ namespace _zeitbild.frontend_web.view
stuff.rows
.map(
(row) => async () => _zeitbild.frontend_web.helpers.template_coin(
+ "events",
"tableview-row",
{
"week": row.week.toFixed(0).padStart(2, "0"),
@@ -526,6 +529,7 @@ namespace _zeitbild.frontend_web.view
row.data
.map(
(cell) => async () => _zeitbild.frontend_web.helpers.template_coin(
+ "events",
"tableview-cell",
{
"extra_classes": (
@@ -580,6 +584,7 @@ namespace _zeitbild.frontend_web.view
cell.entries
.map(
(entry) => () => _zeitbild.frontend_web.helpers.template_coin(
+ "events",
"tableview-cell-entry",
{
"color": lib_plankton.color.output_hex(
diff --git a/source/pages/calendar_add/logic.ts b/source/pages/calendar_add/logic.ts
index 6b912eb..eccc542 100644
--- a/source/pages/calendar_add/logic.ts
+++ b/source/pages/calendar_add/logic.ts
@@ -9,6 +9,7 @@ namespace _zeitbild.frontend_web.pages
target_element.innerHTML = "";
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
"calendar_add",
+ "default",
{
"label": lib_plankton.translate.get("page.calendar_add.title")
}
diff --git a/source/pages/calendar_add/structure.html.tpl b/source/pages/calendar_add/structure.html.tpl
deleted file mode 100644
index 8b13789..0000000
--- a/source/pages/calendar_add/structure.html.tpl
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/source/templates/calendar_add.html.tpl b/source/pages/calendar_add/templates/default.html.tpl
similarity index 100%
rename from source/templates/calendar_add.html.tpl
rename to source/pages/calendar_add/templates/default.html.tpl
diff --git a/source/pages/calendar_edit/logic.ts b/source/pages/calendar_edit/logic.ts
index ee46bd8..310b2bd 100644
--- a/source/pages/calendar_edit/logic.ts
+++ b/source/pages/calendar_edit/logic.ts
@@ -11,6 +11,7 @@ namespace _zeitbild.frontend_web.pages
target_element.innerHTML = "";
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
"calendar_edit",
+ "default",
{
"label": lib_plankton.translate.get("page.calendar_edit.title.regular")
}
diff --git a/source/pages/calendar_edit/structure.html.tpl b/source/pages/calendar_edit/structure.html.tpl
deleted file mode 100644
index 8b13789..0000000
--- a/source/pages/calendar_edit/structure.html.tpl
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/source/templates/calendar_edit.html.tpl b/source/pages/calendar_edit/templates/default.html.tpl
similarity index 100%
rename from source/templates/calendar_edit.html.tpl
rename to source/pages/calendar_edit/templates/default.html.tpl
diff --git a/source/pages/event_add/logic.ts b/source/pages/event_add/logic.ts
index e63a5db..dc36376 100644
--- a/source/pages/event_add/logic.ts
+++ b/source/pages/event_add/logic.ts
@@ -54,6 +54,7 @@ namespace _zeitbild.frontend_web.pages
target_element.innerHTML = "";
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
"event_add",
+ "default",
{
"label": lib_plankton.translate.get("page.event_add.title")
}
diff --git a/source/pages/event_add/structure.html.tpl b/source/pages/event_add/structure.html.tpl
deleted file mode 100644
index e69de29..0000000
diff --git a/source/templates/event_add.html.tpl b/source/pages/event_add/templates/default.html.tpl
similarity index 100%
rename from source/templates/event_add.html.tpl
rename to source/pages/event_add/templates/default.html.tpl
diff --git a/source/pages/event_edit/logic.ts b/source/pages/event_edit/logic.ts
index ab0231a..50d663c 100644
--- a/source/pages/event_edit/logic.ts
+++ b/source/pages/event_edit/logic.ts
@@ -12,6 +12,7 @@ namespace _zeitbild.frontend_web.pages
target_element.innerHTML = "";
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
"event_edit",
+ "default",
{
"label": (
read_only
diff --git a/source/pages/event_edit/structure.html.tpl b/source/pages/event_edit/structure.html.tpl
deleted file mode 100644
index e69de29..0000000
diff --git a/source/templates/event_edit.html.tpl b/source/pages/event_edit/templates/default.html.tpl
similarity index 100%
rename from source/templates/event_edit.html.tpl
rename to source/pages/event_edit/templates/default.html.tpl
diff --git a/source/pages/events/logic.ts b/source/pages/events/logic.ts
index c3399ee..f2e85fa 100644
--- a/source/pages/events/logic.ts
+++ b/source/pages/events/logic.ts
@@ -154,6 +154,7 @@ namespace _zeitbild.frontend_web.pages
target_element.innerHTML = "";
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
+ "events",
"events",
{
"label_control_year": lib_plankton.translate.get("page.events.controls.year"),
diff --git a/source/pages/events/structure.html.tpl b/source/pages/events/structure.html.tpl
deleted file mode 100644
index e69de29..0000000
diff --git a/source/pages/events/templates/events.html.tpl b/source/pages/events/templates/events.html.tpl
new file mode 100644
index 0000000..b5be00f
--- /dev/null
+++ b/source/pages/events/templates/events.html.tpl
@@ -0,0 +1,19 @@
+
diff --git a/source/templates/tableview-cell-entry.html.tpl b/source/pages/events/templates/tableview-cell-entry.html.tpl
similarity index 100%
rename from source/templates/tableview-cell-entry.html.tpl
rename to source/pages/events/templates/tableview-cell-entry.html.tpl
diff --git a/source/templates/tableview-cell.html.tpl b/source/pages/events/templates/tableview-cell.html.tpl
similarity index 100%
rename from source/templates/tableview-cell.html.tpl
rename to source/pages/events/templates/tableview-cell.html.tpl
diff --git a/source/templates/tableview-row.html.tpl b/source/pages/events/templates/tableview-row.html.tpl
similarity index 100%
rename from source/templates/tableview-row.html.tpl
rename to source/pages/events/templates/tableview-row.html.tpl
diff --git a/source/templates/tableview-sources-entry.html.tpl b/source/pages/events/templates/tableview-sources-entry.html.tpl
similarity index 100%
rename from source/templates/tableview-sources-entry.html.tpl
rename to source/pages/events/templates/tableview-sources-entry.html.tpl
diff --git a/source/pages/events/templates/tableview.html.tpl b/source/pages/events/templates/tableview.html.tpl
new file mode 100644
index 0000000..4028def
--- /dev/null
+++ b/source/pages/events/templates/tableview.html.tpl
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ |
+ Mo |
+ Di |
+ Mi |
+ Do |
+ Fr |
+ Sa |
+ So |
+
+
+
+{{rows}}
+
+
+
+
diff --git a/source/pages/login/logic.ts b/source/pages/login/logic.ts
index f75e278..208c157 100644
--- a/source/pages/login/logic.ts
+++ b/source/pages/login/logic.ts
@@ -16,6 +16,7 @@ namespace _zeitbild.frontend_web.pages
case "internal": {
target_element.innerHTML = await _zeitbild.frontend_web.helpers.template_coin(
"login",
+ "default",
{
}
);
diff --git a/source/pages/login/structure.html.tpl b/source/pages/login/structure.html.tpl
deleted file mode 100644
index e69de29..0000000
diff --git a/source/templates/login.html.tpl b/source/pages/login/templates/default.html.tpl
similarity index 100%
rename from source/templates/login.html.tpl
rename to source/pages/login/templates/default.html.tpl
diff --git a/source/templates/events.html.tpl b/source/templates/events.html.tpl
deleted file mode 100644
index 30f8968..0000000
--- a/source/templates/events.html.tpl
+++ /dev/null
@@ -1,19 +0,0 @@
-
diff --git a/source/templates/main.html.tpl b/source/templates/main.html.tpl
deleted file mode 100644
index db89e2e..0000000
--- a/source/templates/main.html.tpl
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/source/templates/tableview.html.tpl b/source/templates/tableview.html.tpl
deleted file mode 100644
index b476b5a..0000000
--- a/source/templates/tableview.html.tpl
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
- |
- Mo |
- Di |
- Mi |
- Do |
- Fr |
- Sa |
- So |
-
-
-
-{{rows}}
-
-
-
-
-
diff --git a/tools/make-index b/tools/make-index
new file mode 100755
index 0000000..dc1f8d8
--- /dev/null
+++ b/tools/make-index
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+
+import sys as _sys
+import argparse as _argparse
+
+
+def file_read(
+ path
+):
+ handle = open(path, "r")
+ content = handle.read()
+ handle.close()
+ return content
+
+
+def string_coin(
+ template,
+ arguments
+):
+ result = template
+ for (key, value, ) in arguments.items():
+ result = result.replace("{{%s}}" % key, value)
+ return result
+
+
+def main(
+):
+ ## args
+ argument_parser = _argparse.ArgumentParser()
+ argument_parser.add_argument(
+ dest = "index_template_path",
+ type = str,
+ )
+ argument_parser.add_argument(
+ "-t",
+ "--template",
+ dest = "template_paths",
+ type = str,
+ action = "append",
+ default = []
+ )
+ args = argument_parser.parse_args()
+
+ ## exec
+ _sys.stdout.write(
+ string_coin(
+ file_read(args.index_template_path),
+ {
+ "templates": "".join(
+ map(
+ file_read,
+ args.template_paths
+ )
+ ),
+ }
+ )
+ )
+
+
+main()
+
diff --git a/tools/makefile b/tools/makefile
index 6271f76..67bda0b 100644
--- a/tools/makefile
+++ b/tools/makefile
@@ -23,17 +23,63 @@ default: index templates style logic data
index: ${dir_build}/index.html
${dir_build}/index.html: \
- ${dir_source}/index.html
+ ${dir_source}/index.html.tpl
@ ${cmd_log} "index …"
@ ${cmd_mkdir} $(dir $@)
- @ ${cmd_cp} -u -v $^ $@
+ @ tools/make-index \
+ ${dir_source}/index.html.tpl \
+ > $@
.PHONY: templates
templates: \
- $(wildcard ${dir_source}/templates/*)
- @ ${cmd_log} "templates …"
- @ ${cmd_mkdir} ${dir_build}/templates
- @ ${cmd_cp} -r -u -v ${dir_source}/templates/* ${dir_build}/templates/
+ templates-pages-calendar_add \
+ templates-pages-calendar_edit \
+ templates-pages-event_add \
+ templates-pages-event_edit \
+ templates-pages-events \
+ templates-pages-login
+
+.PHONY: templates-pages-calendar_add
+templates-pages-calendar_add: \
+ $(wildcard ${dir_source}/pages/calendar_add/templates/*)
+ @ ${cmd_log} "templates:calendar_add …"
+ @ ${cmd_mkdir} ${dir_build}/templates/calendar_add
+ @ ${cmd_cp} -r -u -v ${dir_source}/pages/calendar_add/templates/* ${dir_build}/templates/calendar_add/
+
+.PHONY: templates-pages-calendar_edit
+templates-pages-calendar_edit: \
+ $(wildcard ${dir_source}/pages/calendar_edit/templates/*)
+ @ ${cmd_log} "templates:calendar_edit …"
+ @ ${cmd_mkdir} ${dir_build}/templates/calendar_edit
+ @ ${cmd_cp} -r -u -v ${dir_source}/pages/calendar_edit/templates/* ${dir_build}/templates/calendar_edit/
+
+.PHONY: templates-pages-event_add
+templates-pages-event_add: \
+ $(wildcard ${dir_source}/pages/event_add/templates/*)
+ @ ${cmd_log} "templates:event_add …"
+ @ ${cmd_mkdir} ${dir_build}/templates/event_add
+ @ ${cmd_cp} -r -u -v ${dir_source}/pages/event_add/templates/* ${dir_build}/templates/event_add/
+
+.PHONY: templates-pages-event_edit
+templates-pages-event_edit: \
+ $(wildcard ${dir_source}/pages/event_edit/templates/*)
+ @ ${cmd_log} "templates:event_edit …"
+ @ ${cmd_mkdir} ${dir_build}/templates/event_edit
+ @ ${cmd_cp} -r -u -v ${dir_source}/pages/event_edit/templates/* ${dir_build}/templates/event_edit/
+
+.PHONY: templates-pages-events
+templates-pages-events: \
+ $(wildcard ${dir_source}/pages/events/templates/*)
+ @ ${cmd_log} "templates:events …"
+ @ ${cmd_mkdir} ${dir_build}/templates/events
+ @ ${cmd_cp} -r -u -v ${dir_source}/pages/events/templates/* ${dir_build}/templates/events/
+
+.PHONY: templates-pages-login
+templates-pages-login: \
+ $(wildcard ${dir_source}/pages/login/templates/*)
+ @ ${cmd_log} "templates:login …"
+ @ ${cmd_mkdir} ${dir_build}/templates/login
+ @ ${cmd_cp} -r -u -v ${dir_source}/pages/login/templates/* ${dir_build}/templates/login/
.PHONY: style
style: \