From 9691a4c56b8d22888235af43d0f1131577616b36 Mon Sep 17 00:00:00 2001 From: Nuno Sempere Date: Mon, 25 Jul 2022 22:03:56 +0000 Subject: [PATCH] feat: Add sitemap2, which is a bit more readable This is a work in progress To do: - Hide special directories (like images) - In cases where a directory only has one element, display that directly --- tpl/blogroll.tpl | 69 ++++++++++++++++++++++++++++++++++++++++++++++ tpl/sitemap.tpl | 0 tpl/sitemap2.tpl | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100755 tpl/blogroll.tpl mode change 100755 => 100644 tpl/sitemap.tpl create mode 100644 tpl/sitemap2.tpl diff --git a/tpl/blogroll.tpl b/tpl/blogroll.tpl new file mode 100755 index 0000000..4a37147 --- /dev/null +++ b/tpl/blogroll.tpl @@ -0,0 +1,69 @@ +

Site map

+ +%{ +tmpfile=/tmp/werc_sitemap_$pid.txt +tmpfilex=/tmp/werc_sitemapx_$pid.txt +saveddf=$dirfilter + +MON2NUM='s/Jan/01/; s/Feb/02/; s/Mar/03/; s/Apr/04/; s/May/05/; s/Jun/06/; s/Jul/07/; s/Aug/08/; s/Sep/09/; s/Oct/10/; s/Nov/11/; s/Dec/12/;' + +fn get_mdate { + t=`{mtime $1} + t=`{date $t(1) | sed -e $MON2NUM -e 's/ ([0-9]) / 0\1 /g'} # Make sure day of the month is two digits. + echo $t(6)^'-'^$t(2)^'-'^$t(3) +} + +fn listDir { + d=$1 + dirfilter=$saveddf + if(test -f $d/_werc/config) + . $d/_werc/config + + if(~ $#perm_redir_to 0) { + echo '' + } +} + + +fltr_cache listDir $sitedir/ + +if(test -s $tmpfile) { + mv $tmpfile $sitedir/sitemap.txt & +} +if not if(test -f $tmpfile) + rm $tmpfile + +if(test -s $tmpfilex) { + { + echo ' +' + + cat $tmpfilex + rm $tmpfilex & + echo '' + # TODO Enable automaic search engine update notification. + #hget 'http://google.com/ping?sitemap='^`{url_encode $base_url'/sitemap.gz'} > /dev/null + + } | gzip > $sitedir/sitemap.gz & + #} > $sitedir/sitemap.xml & +} +if not if(test -f $tmpfilex) + rm $tmpfilex + +%} diff --git a/tpl/sitemap.tpl b/tpl/sitemap.tpl old mode 100755 new mode 100644 diff --git a/tpl/sitemap2.tpl b/tpl/sitemap2.tpl new file mode 100644 index 0000000..4807856 --- /dev/null +++ b/tpl/sitemap2.tpl @@ -0,0 +1,71 @@ +

Site map

+ +%{ +tmpfile=/tmp/werc_sitemap2_$pid.txt +tmpfilex=/tmp/werc_sitemap2_$pid.txt +saveddf=$dirfilter + +MON2NUM='s/Jan/01/; s/Feb/02/; s/Mar/03/; s/Apr/04/; s/May/05/; s/Jun/06/; s/Jul/07/; s/Aug/08/; s/Sep/09/; s/Oct/10/; s/Nov/11/; s/Dec/12/;' + +fn get_mdate { + t=`{mtime $1} + t=`{date $t(1) | sed -e $MON2NUM -e 's/ ([0-9]) / 0\1 /g'} # Make sure day of the month is two digits. + echo $t(6)^'-'^$t(2)^'-'^$t(3) +} + +fn listDir { + d=$1 + dirfilter=$saveddf + if(test -f $d/_werc/config) + . $d/_werc/config + + if(~ $#perm_redir_to 0) { + echo '' + } +} + + +fltr_cache listDir $sitedir/ + +if(test -s $tmpfile) { + mv $tmpfile $sitedir/sitemap.txt & +} +if not if(test -f $tmpfile) + rm $tmpfile + +if(test -s $tmpfilex) { + { + echo ' +' + + cat $tmpfilex + rm $tmpfilex & + echo '' + # TODO Enable automaic search engine update notification. + #hget 'http://google.com/ping?sitemap='^`{url_encode $base_url'/sitemap.gz'} > /dev/null + + } | gzip > $sitedir/sitemap.gz & + #} > $sitedir/sitemap.xml & +} +if not if(test -f $tmpfilex) + rm $tmpfilex + +%}