summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile8
-rwxr-xr-xmake_sitemap.sh74
-rwxr-xr-xtemplate.py13
-rw-r--r--template/architecture.html.j2 (renamed from architecture.html.j2)0
-rw-r--r--template/bibliography.html.j2 (renamed from bibliography.html.j2)0
-rw-r--r--template/contact.html.j2 (renamed from contact.html.j2)0
-rw-r--r--template/copyright.html.j2 (renamed from copyright.html.j2)0
-rw-r--r--template/developers.html.j2 (renamed from developers.html.j2)0
-rw-r--r--template/docs.html.j2 (renamed from docs.html.j2)0
-rw-r--r--template/faq.html.j2 (renamed from faq.html.j2)0
-rw-r--r--template/features.html.j2 (renamed from features.html.j2)0
-rw-r--r--template/financial-news.html.j2 (renamed from financial-news.html.j2)0
-rw-r--r--template/glossary.html.j2 (renamed from glossary.html.j2)0
-rw-r--r--template/governments.html.j2 (renamed from governments.html.j2)0
-rw-r--r--template/gsoc-codeless.html.j2 (renamed from gsoc-codeless.html.j2)0
-rw-r--r--template/index.html.j2 (renamed from index.html.j2)0
-rw-r--r--template/investors.html.j2 (renamed from investors.html.j2)0
-rw-r--r--template/javascript.html (renamed from javascript.html)0
-rw-r--r--template/merchants.html.j2 (renamed from merchants.html.j2)0
-rw-r--r--template/news.html.j2 (renamed from news.html.j2)0
-rw-r--r--template/old-news.html.j2 (renamed from old-news.html.j2)0
-rw-r--r--template/press.html.j2 (renamed from press.html.j2)0
-rw-r--r--template/principles.html.j2 (renamed from principles.html.j2)0
-rw-r--r--template/schemafuzz.html.j2 (renamed from schemafuzz.html.j2)0
-rw-r--r--template/team.html.j2 (renamed from team.html.j2)0
-rw-r--r--template/wallet.html.j2 (renamed from wallet.html.j2)0
27 files changed, 88 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 762061b3..e1ce6c4e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ locale/messages.pot
videos/grothoff2014fossa.webm
videos/grothoff2014fossa.ogv
+rendered/
en/
de/
fr/
diff --git a/Makefile b/Makefile
index 1600d2c8..fd17366a 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,10 @@ include config.mk
# TypeScript logic in web-common.
all: locale template
cd web-common && $(TSC)
+ /bin/sh make_sitemap.sh
+ for x in en de fr it es ru pt ; do cp robots.txt rendered/$$x ; done
+ for x in en de fr it es ru pt ; do cp favicon.ico rendered/$$x ; done
+ for x in en de fr it es ru pt ; do cp rendered/sitemap.xml rendered/$$x ; done
# Extract translateable strings from jinja2 templates.
locale/messages.pot: *.j2 common/*.j2 common/*.j2.inc
@@ -19,7 +23,7 @@ locale/messages.pot: *.j2 common/*.j2 common/*.j2.inc
# Update translation (.po) files with new strings.
locale-update: locale/messages.pot
- msgmerge -U -m --previous locale/en/LC_MESSAGES/messages.po locale/messages.pot
+ msgmerge -U -m --previous locale/en/LC_MESSAGES/messages.po locale/messages.pot
msgmerge -U -m --previous locale/de/LC_MESSAGES/messages.po locale/messages.pot
msgmerge -U -m --previous locale/fr/LC_MESSAGES/messages.po locale/messages.pot
msgmerge -U -m --previous locale/es/LC_MESSAGES/messages.po locale/messages.pot
@@ -54,7 +58,7 @@ run: all
$(PYTHON) -m http.server
clean:
- rm -rf __pycache__
+ rm -rf __pycache__ *.pyc *~ \.*~ \#*\#
rm -rf en/ de/ fr/ it/ es/ ru/
rm -rf rendered/
diff --git a/make_sitemap.sh b/make_sitemap.sh
new file mode 100755
index 00000000..bc2578d7
--- /dev/null
+++ b/make_sitemap.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+# Copyright (C) 2018, 2019 GNUnet e.V.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved. This file is offered as-is,
+# without any warranty.
+#
+# This initial version builds on code from ssg4
+# copyright is as follows:
+# -----
+# https://www.romanzolotarev.com/bin/ssg4
+# Copyright 2018 Roman Zolotarev <hi@romanzolotarev.com>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+# -----
+
+list_pages(){
+cd rendered && find . -type f ! -path '*/.*' ! -path '*/_*' -name '*.html' | sed 's#^./##;#'
+}
+
+main(){
+ dst=rendered
+ base_url="$4"
+ date=$(date +%Y-%m-%d)
+ urls=$(list_pages "$src")
+
+ test -n "$urls" &&
+ render_sitemap "$urls" "$base_url" "$date" > "$dst/sitemap.xml"
+
+ print_status 'url' 'urls' "$urls" >&2
+ echo >&2
+}
+
+print_status() {
+ test -z "$3" && printf 'no %s' "$2" && return
+
+ echo "$3" | awk -v singular="$1" -v plural="$2" '
+ END {
+ if (NR==1) printf NR " " singular
+ if (NR>1) printf NR " " plural
+ }'
+}
+
+render_sitemap() {
+ urls="$1"
+ base_url="$2"
+ date="$3"
+
+ echo '<?xml version="1.0" encoding="UTF-8"?>'
+ echo '<urlset'
+ echo 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
+ echo 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9'
+ echo 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"'
+ echo 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
+ echo "$urls" |
+ sed -E 's#^(.*)$#<url><loc>'"$base_url"'/\1</loc><lastmod>'\
+"$date"'</lastmod><priority>1.0</priority></url>#'
+ echo '</urlset>'
+}
+
+main "$@"
+
diff --git a/template.py b/template.py
index a055a33e..d7be569f 100755
--- a/template.py
+++ b/template.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python3
+# coding: utf-8
+#
# This file is in the public domain.
#
# This script runs the jinja2 templating engine on an input template-file
@@ -34,7 +36,7 @@ langs_full = {"en": "English",
"ru": "Ру́сский язы́к",
"pt": "Português"}
-for in_file in glob.glob("*.j2"):
+for in_file in glob.glob("template/*.j2"):
name, ext = re.match(r"(.*)\.([^.]+)$", in_file.rstrip(".j2")).groups()
tmpl = env.get_template(in_file)
@@ -42,7 +44,7 @@ for in_file in glob.glob("*.j2"):
"""
Return URL for the current page in another locale.
"""
- return "../" + other_locale + "/" + in_file.rstrip(".j2")
+ return "../" + other_locale + "/" + in_file.replace('template/', '').rstrip(".j2")
def url_localized(filename):
return "../" + locale + "/" + filename
@@ -70,7 +72,6 @@ for in_file in glob.glob("*.j2"):
env.install_gettext_translations(tr, newstyle=True)
-
content = tmpl.render(
docshost="docs.taler.net",
lang=locale,
@@ -80,7 +81,7 @@ for in_file in glob.glob("*.j2"):
url_localized=url_localized,
svg_localized=svg_localized,
filename=name + "." + ext)
- out_name = "./" + locale + "/" + in_file.rstrip(".j2")
- os.makedirs("./" + locale, exist_ok=True)
- with codecs.open(out_name, "w", "utf-8") as f:
+ out_name = "./rendered/" + locale + "/" + in_file.replace('template/', '').rstrip(".j2")
+ os.makedirs("./rendered/" + locale, exist_ok=True)
+ with codecs.open(out_name, "w", encoding='utf-8') as f:
f.write(content)
diff --git a/architecture.html.j2 b/template/architecture.html.j2
index 21fd6ba7..21fd6ba7 100644
--- a/architecture.html.j2
+++ b/template/architecture.html.j2
diff --git a/bibliography.html.j2 b/template/bibliography.html.j2
index 5026a71b..5026a71b 100644
--- a/bibliography.html.j2
+++ b/template/bibliography.html.j2
diff --git a/contact.html.j2 b/template/contact.html.j2
index f576ad1b..f576ad1b 100644
--- a/contact.html.j2
+++ b/template/contact.html.j2
diff --git a/copyright.html.j2 b/template/copyright.html.j2
index 1c5201b9..1c5201b9 100644
--- a/copyright.html.j2
+++ b/template/copyright.html.j2
diff --git a/developers.html.j2 b/template/developers.html.j2
index 61ae63c0..61ae63c0 100644
--- a/developers.html.j2
+++ b/template/developers.html.j2
diff --git a/docs.html.j2 b/template/docs.html.j2
index 46fd154e..46fd154e 100644
--- a/docs.html.j2
+++ b/template/docs.html.j2
diff --git a/faq.html.j2 b/template/faq.html.j2
index f3657f7c..f3657f7c 100644
--- a/faq.html.j2
+++ b/template/faq.html.j2
diff --git a/features.html.j2 b/template/features.html.j2
index 5d94cb12..5d94cb12 100644
--- a/features.html.j2
+++ b/template/features.html.j2
diff --git a/financial-news.html.j2 b/template/financial-news.html.j2
index 8ebe2d42..8ebe2d42 100644
--- a/financial-news.html.j2
+++ b/template/financial-news.html.j2
diff --git a/glossary.html.j2 b/template/glossary.html.j2
index 2736935e..2736935e 100644
--- a/glossary.html.j2
+++ b/template/glossary.html.j2
diff --git a/governments.html.j2 b/template/governments.html.j2
index be7ce52a..be7ce52a 100644
--- a/governments.html.j2
+++ b/template/governments.html.j2
diff --git a/gsoc-codeless.html.j2 b/template/gsoc-codeless.html.j2
index 1ffce885..1ffce885 100644
--- a/gsoc-codeless.html.j2
+++ b/template/gsoc-codeless.html.j2
diff --git a/index.html.j2 b/template/index.html.j2
index 0c8124ce..0c8124ce 100644
--- a/index.html.j2
+++ b/template/index.html.j2
diff --git a/investors.html.j2 b/template/investors.html.j2
index 0cce3977..0cce3977 100644
--- a/investors.html.j2
+++ b/template/investors.html.j2
diff --git a/javascript.html b/template/javascript.html
index 02e0c3d8..02e0c3d8 100644
--- a/javascript.html
+++ b/template/javascript.html
diff --git a/merchants.html.j2 b/template/merchants.html.j2
index fff24bf3..fff24bf3 100644
--- a/merchants.html.j2
+++ b/template/merchants.html.j2
diff --git a/news.html.j2 b/template/news.html.j2
index 8984afa5..8984afa5 100644
--- a/news.html.j2
+++ b/template/news.html.j2
diff --git a/old-news.html.j2 b/template/old-news.html.j2
index fe339cd8..fe339cd8 100644
--- a/old-news.html.j2
+++ b/template/old-news.html.j2
diff --git a/press.html.j2 b/template/press.html.j2
index 336ec36c..336ec36c 100644
--- a/press.html.j2
+++ b/template/press.html.j2
diff --git a/principles.html.j2 b/template/principles.html.j2
index e1b94e14..e1b94e14 100644
--- a/principles.html.j2
+++ b/template/principles.html.j2
diff --git a/schemafuzz.html.j2 b/template/schemafuzz.html.j2
index d4bb2770..d4bb2770 100644
--- a/schemafuzz.html.j2
+++ b/template/schemafuzz.html.j2
diff --git a/team.html.j2 b/template/team.html.j2
index 96182b98..96182b98 100644
--- a/team.html.j2
+++ b/template/team.html.j2
diff --git a/wallet.html.j2 b/template/wallet.html.j2
index c18fc4ef..c18fc4ef 100644
--- a/wallet.html.j2
+++ b/template/wallet.html.j2