aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-11-13 00:06:15 +0000
committerng0 <ng0@n0.is>2019-11-13 00:06:15 +0000
commit3a14d8f71b24cd09fc61c729be9762eff4a56d07 (patch)
treea488867b302c55de4b329768b82200002993bc38
parent980fc91485f1332c1b9d57876be2c5b9c7ec49ac (diff)
downloadwww-3a14d8f71b24cd09fc61c729be9762eff4a56d07.tar.gz
www-3a14d8f71b24cd09fc61c729be9762eff4a56d07.zip
use make_sitemap.py
-rw-r--r--.gitignore1
-rw-r--r--GNUmakefile7
m---------inc0
-rwxr-xr-xmake_sitemap.sh74
4 files changed, 3 insertions, 79 deletions
diff --git a/.gitignore b/.gitignore
index b25ec1e2..201a9c1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ __pycache__
24static/styles.css 24static/styles.css
25 25
26sitemap.html 26sitemap.html
27sitemap.xml
27 28
28*~ 29*~
29\#*\# 30\#*\#
diff --git a/GNUmakefile b/GNUmakefile
index 4dc2b729..19a79353 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -20,17 +20,14 @@
20include config.mk 20include config.mk
21 21
22all: css locale template 22all: css locale template
23 ($(cp) -R dist rendered/)
24 ($(cp) -R static rendered/)
25 ($(cp) rendered/static/robots.txt rendered/robots.txt) 23 ($(cp) rendered/static/robots.txt rendered/robots.txt)
26 ($(cp) rendered/static/stage.robots.txt rendered/stage.robots.txt) 24 ($(cp) rendered/static/stage.robots.txt rendered/stage.robots.txt)
27 ($(cp) rendered/static/robots.txt rendered/dist/robots.txt) 25 ($(cp) rendered/static/robots.txt rendered/dist/robots.txt)
28 (for lang in en de es fr it ; do \ 26 (for lang in en de es fr it ; do \
29 $(cp) rendered/static/robots.txt rendered/$$lang/robots.txt ; \ 27 $(cp) rendered/static/robots.txt rendered/$$lang/robots.txt ; \
30 done) 28 done)
31 #($(cp) favicon.ico rendered/favicon.ico) 29 ($(python) inc/make_sitemap.py -i rendered)
32 ($(sh) make_sitemap.sh) 30 ($(cp) sitemap.xml rendered/en/sitemap.xml)
33 ($(cp) rendered/sitemap.xml rendered/en/sitemap.xml)
34 ($(cp) static/moved.html rendered/frontpage.html) 31 ($(cp) static/moved.html rendered/frontpage.html)
35 (cd rendered; $(ln) -fs frontpage.html frontpage) 32 (cd rendered; $(ln) -fs frontpage.html frontpage)
36 ($(cp) static/moved_gsoc.html rendered/gsoc.html) 33 ($(cp) static/moved_gsoc.html rendered/gsoc.html)
diff --git a/inc b/inc
Subproject 4a65973d9a1aae2925d2fada9eed70833d628e3 Subproject b91d7308fc9ab4f0658d180ff563ed0bee35f16
diff --git a/make_sitemap.sh b/make_sitemap.sh
deleted file mode 100755
index bc2578d7..00000000
--- a/make_sitemap.sh
+++ /dev/null
@@ -1,74 +0,0 @@
1#!/bin/sh
2
3# Copyright (C) 2018, 2019 GNUnet e.V.
4#
5# Copying and distribution of this file, with or without modification,
6# are permitted in any medium without royalty provided the copyright
7# notice and this notice are preserved. This file is offered as-is,
8# without any warranty.
9#
10# This initial version builds on code from ssg4
11# copyright is as follows:
12# -----
13# https://www.romanzolotarev.com/bin/ssg4
14# Copyright 2018 Roman Zolotarev <hi@romanzolotarev.com>
15#
16# Permission to use, copy, modify, and/or distribute this software for any
17# purpose with or without fee is hereby granted, provided that the above
18# copyright notice and this permission notice appear in all copies.
19#
20# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
21# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
22# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
23# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
25# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
26# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27# -----
28
29list_pages(){
30cd rendered && find . -type f ! -path '*/.*' ! -path '*/_*' -name '*.html' | sed 's#^./##;#'
31}
32
33main(){
34 dst=rendered
35 base_url="$4"
36 date=$(date +%Y-%m-%d)
37 urls=$(list_pages "$src")
38
39 test -n "$urls" &&
40 render_sitemap "$urls" "$base_url" "$date" > "$dst/sitemap.xml"
41
42 print_status 'url' 'urls' "$urls" >&2
43 echo >&2
44}
45
46print_status() {
47 test -z "$3" && printf 'no %s' "$2" && return
48
49 echo "$3" | awk -v singular="$1" -v plural="$2" '
50 END {
51 if (NR==1) printf NR " " singular
52 if (NR>1) printf NR " " plural
53 }'
54}
55
56render_sitemap() {
57 urls="$1"
58 base_url="$2"
59 date="$3"
60
61 echo '<?xml version="1.0" encoding="UTF-8"?>'
62 echo '<urlset'
63 echo 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
64 echo 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9'
65 echo 'http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"'
66 echo 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
67 echo "$urls" |
68 sed -E 's#^(.*)$#<url><loc>'"$base_url"'/\1</loc><lastmod>'\
69"$date"'</lastmod><priority>1.0</priority></url>#'
70 echo '</urlset>'
71}
72
73main "$@"
74