From 83c2db9dca7f0738cc9e39a8f7b1556a629d7e84 Mon Sep 17 00:00:00 2001 From: Thomas Dedek Date: Thu, 9 Apr 2020 11:39:01 +0200 Subject: [PATCH] replace hugo by a self provided python script --- README.md | 25 +++++++++---------- build+deploy.sh | 7 +++++- build.py | 46 +++++++++++++++++++++++++++++++++++ config.toml | 5 ---- content/index.tmpl.html | 18 ++++++++++++++ content/item.tmpl.html | 5 ++++ content/index.md => items.yml | 5 +--- layouts/_default/baseof.html | 15 ------------ layouts/_default/single.html | 17 ------------- 9 files changed, 87 insertions(+), 56 deletions(-) create mode 100755 build.py delete mode 100644 config.toml create mode 100644 content/index.tmpl.html create mode 100644 content/item.tmpl.html rename content/index.md => items.yml (94%) delete mode 100644 layouts/_default/baseof.html delete mode 100644 layouts/_default/single.html diff --git a/README.md b/README.md index e915e28..cd42699 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,31 @@ # Ecogood Portal Page -This SPA shows a list of available web applications of ecogood. +This SPA shows a list of the available ECG web applications. ![screenshot](docs/screenshot.png "Screenshot") ## Features -- generated static website powered by [Hugo](https://gohugo.io/) +- generated static website powered a small python script - easily extensible by a YAML definition - responsive layout -- Respects Privacy and Security by setting CSP and RP -- Apache based basic Authentication included +- Respects Privacy and Security by being ready for CSP and RP -## Development +## Build -A live server can be started as usual with hugo: - - hugo server + python3 build.py items.yml ## Deployment The build and deploy workflow is provided by the contained shell script `build+deploy.sh`. -**Tasks:** +```bash +chmod +x build+deploy.sh +./build+deploy.sh +``` + +**Executed tasks:** - clean the output folder - build the project - upload to the remote SSH target - -```bash -chmod +x build+deploy.sh -./build+deploy.sh -``` \ No newline at end of file diff --git a/build+deploy.sh b/build+deploy.sh index dc64d48..144a935 100755 --- a/build+deploy.sh +++ b/build+deploy.sh @@ -4,8 +4,13 @@ set -o nounset ## set -u : exit the script if you try to use an uninitialised set -o errexit ## set -e : exit the script if any statement returns a non-true return value #set -o xtrace ## set -x : Print command traces before executing command +# clean up rm -rf public -hugo + +# build +python3 build.py items.yml + +# deploy rsync -v --archive --delete public/ \ ecg00-portal@ecg00.hostsharing.net:doms/my.ecogood.org/htdocs-ssl/ diff --git a/build.py b/build.py new file mode 100755 index 0000000..5ba09c6 --- /dev/null +++ b/build.py @@ -0,0 +1,46 @@ +import codecs +import os +import shutil +import sys +from distutils import dir_util +from string import Template + +from ruamel.yaml import YAML + +__location__ = os.path.realpath(os.path.dirname(__file__)) +static_folder = os.path.join(__location__, 'static') +content_folder = os.path.join(__location__, 'content') +output_folder = os.path.join(__location__, 'public') + +config_file = sys.argv[1] + +yaml = YAML(typ='safe') + +with codecs.open(config_file, 'r', encoding='utf-8') as stream: + try: + config = yaml.load(stream) + except yaml.YAMLError as exc: + print(exc) + exit(1) + +template_item_text = codecs.open(os.path.join(content_folder, 'item.tmpl.html'), 'r', + encoding='utf-8').read() +template_item = Template(template_item_text) + +items = '' + +for config_item in config['items']: + items += template_item.substitute(config_item) + +template_page_text = codecs.open(os.path.join(content_folder, 'index.tmpl.html'), 'r', encoding='utf-8').read() +template_page = Template(template_page_text) +outcome = template_page.substitute(items=items) + +os.makedirs(output_folder, exist_ok=True) + +outfile_index = os.path.join(output_folder, 'index.html') + +from distutils.dir_util import copy_tree +copy_tree(static_folder, output_folder) + +html = codecs.open(outfile_index, 'w', encoding='utf-8').write(outcome) diff --git a/config.toml b/config.toml deleted file mode 100644 index cdd94e1..0000000 --- a/config.toml +++ /dev/null @@ -1,5 +0,0 @@ -baseURL = "/" -languageCode = "en" -title = "ECG Portal" - -disableKinds = ["RSS", "sitemap", "taxonomy", "taxonomyTerm"] diff --git a/content/index.tmpl.html b/content/index.tmpl.html new file mode 100644 index 0000000..647a87e --- /dev/null +++ b/content/index.tmpl.html @@ -0,0 +1,18 @@ + + + + ECG portal + + + + + + + + + +
+ $items +
+ + diff --git a/content/item.tmpl.html b/content/item.tmpl.html new file mode 100644 index 0000000..b3a5e84 --- /dev/null +++ b/content/item.tmpl.html @@ -0,0 +1,5 @@ + +
+
$title
+
$solution
+
diff --git a/content/index.md b/items.yml similarity index 94% rename from content/index.md rename to items.yml index a40d40f..d3fad0b 100644 --- a/content/index.md +++ b/items.yml @@ -1,4 +1,3 @@ ---- items: # - url: https://forum.ecogood.org # solution: Discourse @@ -26,7 +25,7 @@ items: solution: SmartWE title: Membership admin cssClass: smartwe - - url: https://git.ecogood.world + - url: https://git.ecogood.org solution: Gitea title: Code hosting cssClass: code @@ -34,5 +33,3 @@ items: solution: JIRA title: Ticket system cssClass: projekte - ---- diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html deleted file mode 100644 index 40ef342..0000000 --- a/layouts/_default/baseof.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - ECG portal - - - - - - - - - {{ block "main" . }}{{ end }} - - diff --git a/layouts/_default/single.html b/layouts/_default/single.html deleted file mode 100644 index 7ba2f3b..0000000 --- a/layouts/_default/single.html +++ /dev/null @@ -1,17 +0,0 @@ -{{ define "main" }} - - -
- {{ .Content }} -
- -
- {{ range .Params.items }} - -
-
{{ .title }}
-
{{ .solution }}
-
- {{ end }} -
-{{ end }}