taler-www

Main taler.net website
Log | Files | Refs | Submodules | README | LICENSE

commit cf9958da7c7a8d8522937d7c4706c7ab2fc5fd73
parent bd9bfe737deddf63ae931e1f2990632d0698a952
Author: ng0 <ng0@taler.net>
Date:   Mon,  2 Sep 2019 10:54:27 +0000

Adjust repository layout (resolves #5596), add sitemap.xml generator.

Diffstat:
M.gitignore | 1+
MMakefile | 8++++++--
Amake_sitemap.sh | 74++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mtemplate.py | 13+++++++------
Rarchitecture.html.j2 -> template/architecture.html.j2 | 0
Rbibliography.html.j2 -> template/bibliography.html.j2 | 0
Rcontact.html.j2 -> template/contact.html.j2 | 0
Rcopyright.html.j2 -> template/copyright.html.j2 | 0
Rdevelopers.html.j2 -> template/developers.html.j2 | 0
Rdocs.html.j2 -> template/docs.html.j2 | 0
Rfaq.html.j2 -> template/faq.html.j2 | 0
Rfeatures.html.j2 -> template/features.html.j2 | 0
Rfinancial-news.html.j2 -> template/financial-news.html.j2 | 0
Rglossary.html.j2 -> template/glossary.html.j2 | 0
Rgovernments.html.j2 -> template/governments.html.j2 | 0
Rgsoc-codeless.html.j2 -> template/gsoc-codeless.html.j2 | 0
Rindex.html.j2 -> template/index.html.j2 | 0
Rinvestors.html.j2 -> template/investors.html.j2 | 0
Rjavascript.html -> template/javascript.html | 0
Rmerchants.html.j2 -> template/merchants.html.j2 | 0
Rnews.html.j2 -> template/news.html.j2 | 0
Rold-news.html.j2 -> template/old-news.html.j2 | 0
Rpress.html.j2 -> template/press.html.j2 | 0
Rprinciples.html.j2 -> template/principles.html.j2 | 0
Rschemafuzz.html.j2 -> template/schemafuzz.html.j2 | 0
Rteam.html.j2 -> template/team.html.j2 | 0
Rwallet.html.j2 -> template/wallet.html.j2 | 0
27 files changed, 88 insertions(+), 8 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 diff --git a/bibliography.html.j2 b/template/bibliography.html.j2 diff --git a/contact.html.j2 b/template/contact.html.j2 diff --git a/copyright.html.j2 b/template/copyright.html.j2 diff --git a/developers.html.j2 b/template/developers.html.j2 diff --git a/docs.html.j2 b/template/docs.html.j2 diff --git a/faq.html.j2 b/template/faq.html.j2 diff --git a/features.html.j2 b/template/features.html.j2 diff --git a/financial-news.html.j2 b/template/financial-news.html.j2 diff --git a/glossary.html.j2 b/template/glossary.html.j2 diff --git a/governments.html.j2 b/template/governments.html.j2 diff --git a/gsoc-codeless.html.j2 b/template/gsoc-codeless.html.j2 diff --git a/index.html.j2 b/template/index.html.j2 diff --git a/investors.html.j2 b/template/investors.html.j2 diff --git a/javascript.html b/template/javascript.html diff --git a/merchants.html.j2 b/template/merchants.html.j2 diff --git a/news.html.j2 b/template/news.html.j2 diff --git a/old-news.html.j2 b/template/old-news.html.j2 diff --git a/press.html.j2 b/template/press.html.j2 diff --git a/principles.html.j2 b/template/principles.html.j2 diff --git a/schemafuzz.html.j2 b/template/schemafuzz.html.j2 diff --git a/team.html.j2 b/template/team.html.j2 diff --git a/wallet.html.j2 b/template/wallet.html.j2