[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-www] branch master updated: Adjust repository layout
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-www] branch master updated: Adjust repository layout (resolves #5596), add sitemap.xml generator. |
Date: |
Mon, 02 Sep 2019 12:56:25 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository www.
The following commit(s) were added to refs/heads/master by this push:
new cf9958d Adjust repository layout (resolves #5596), add sitemap.xml
generator.
cf9958d is described below
commit cf9958da7c7a8d8522937d7c4706c7ab2fc5fd73
Author: ng0 <address@hidden>
AuthorDate: Mon Sep 2 10:54:27 2019 +0000
Adjust repository layout (resolves #5596), add sitemap.xml generator.
---
.gitignore | 1 +
Makefile | 8 ++-
make_sitemap.sh | 74 ++++++++++++++++++++++
template.py | 13 ++--
.../architecture.html.j2 | 0
.../bibliography.html.j2 | 0
contact.html.j2 => template/contact.html.j2 | 0
copyright.html.j2 => template/copyright.html.j2 | 0
developers.html.j2 => template/developers.html.j2 | 0
docs.html.j2 => template/docs.html.j2 | 0
faq.html.j2 => template/faq.html.j2 | 0
features.html.j2 => template/features.html.j2 | 0
.../financial-news.html.j2 | 0
glossary.html.j2 => template/glossary.html.j2 | 0
.../governments.html.j2 | 0
.../gsoc-codeless.html.j2 | 0
index.html.j2 => template/index.html.j2 | 0
investors.html.j2 => template/investors.html.j2 | 0
javascript.html => template/javascript.html | 0
merchants.html.j2 => template/merchants.html.j2 | 0
news.html.j2 => template/news.html.j2 | 0
old-news.html.j2 => template/old-news.html.j2 | 0
press.html.j2 => template/press.html.j2 | 0
principles.html.j2 => template/principles.html.j2 | 0
schemafuzz.html.j2 => template/schemafuzz.html.j2 | 0
team.html.j2 => template/team.html.j2 | 0
wallet.html.j2 => template/wallet.html.j2 | 0
27 files changed, 88 insertions(+), 8 deletions(-)
diff --git a/.gitignore b/.gitignore
index 762061b..e1ce6c4 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 1600d2c..fd17366 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 0000000..bc2578d
--- /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 <address@hidden>
+#
+# 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 a055a33..d7be569 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
similarity index 100%
rename from architecture.html.j2
rename to template/architecture.html.j2
diff --git a/bibliography.html.j2 b/template/bibliography.html.j2
similarity index 100%
rename from bibliography.html.j2
rename to template/bibliography.html.j2
diff --git a/contact.html.j2 b/template/contact.html.j2
similarity index 100%
rename from contact.html.j2
rename to template/contact.html.j2
diff --git a/copyright.html.j2 b/template/copyright.html.j2
similarity index 100%
rename from copyright.html.j2
rename to template/copyright.html.j2
diff --git a/developers.html.j2 b/template/developers.html.j2
similarity index 100%
rename from developers.html.j2
rename to template/developers.html.j2
diff --git a/docs.html.j2 b/template/docs.html.j2
similarity index 100%
rename from docs.html.j2
rename to template/docs.html.j2
diff --git a/faq.html.j2 b/template/faq.html.j2
similarity index 100%
rename from faq.html.j2
rename to template/faq.html.j2
diff --git a/features.html.j2 b/template/features.html.j2
similarity index 100%
rename from features.html.j2
rename to template/features.html.j2
diff --git a/financial-news.html.j2 b/template/financial-news.html.j2
similarity index 100%
rename from financial-news.html.j2
rename to template/financial-news.html.j2
diff --git a/glossary.html.j2 b/template/glossary.html.j2
similarity index 100%
rename from glossary.html.j2
rename to template/glossary.html.j2
diff --git a/governments.html.j2 b/template/governments.html.j2
similarity index 100%
rename from governments.html.j2
rename to template/governments.html.j2
diff --git a/gsoc-codeless.html.j2 b/template/gsoc-codeless.html.j2
similarity index 100%
rename from gsoc-codeless.html.j2
rename to template/gsoc-codeless.html.j2
diff --git a/index.html.j2 b/template/index.html.j2
similarity index 100%
rename from index.html.j2
rename to template/index.html.j2
diff --git a/investors.html.j2 b/template/investors.html.j2
similarity index 100%
rename from investors.html.j2
rename to template/investors.html.j2
diff --git a/javascript.html b/template/javascript.html
similarity index 100%
rename from javascript.html
rename to template/javascript.html
diff --git a/merchants.html.j2 b/template/merchants.html.j2
similarity index 100%
rename from merchants.html.j2
rename to template/merchants.html.j2
diff --git a/news.html.j2 b/template/news.html.j2
similarity index 100%
rename from news.html.j2
rename to template/news.html.j2
diff --git a/old-news.html.j2 b/template/old-news.html.j2
similarity index 100%
rename from old-news.html.j2
rename to template/old-news.html.j2
diff --git a/press.html.j2 b/template/press.html.j2
similarity index 100%
rename from press.html.j2
rename to template/press.html.j2
diff --git a/principles.html.j2 b/template/principles.html.j2
similarity index 100%
rename from principles.html.j2
rename to template/principles.html.j2
diff --git a/schemafuzz.html.j2 b/template/schemafuzz.html.j2
similarity index 100%
rename from schemafuzz.html.j2
rename to template/schemafuzz.html.j2
diff --git a/team.html.j2 b/template/team.html.j2
similarity index 100%
rename from team.html.j2
rename to template/team.html.j2
diff --git a/wallet.html.j2 b/template/wallet.html.j2
similarity index 100%
rename from wallet.html.j2
rename to template/wallet.html.j2
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-www] branch master updated: Adjust repository layout (resolves #5596), add sitemap.xml generator.,
gnunet <=