swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit 55d7075ba764df6038931c25e18d4908bd6f73d7
parent 788dd1e3ad63579677a17d8eaa964c9a76b13bfc
Author: uriel@vm41.cat-v.org <unknown>
Date:   Wed, 29 Jul 2009 01:41:18 +0200

Implement the sitemaps.org standard 'protocol' with sitemap.xml.
Diffstat:
Mtpl/sitemap.tpl | 25++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/tpl/sitemap.tpl b/tpl/sitemap.tpl @@ -2,6 +2,7 @@ %{ tmpfile=/tmp/werc_sitemap_$pid.txt +tmpfilex=/tmp/werc_sitemapx_$pid.txt saveddf=$dirfilter fn listDir { @@ -21,6 +22,7 @@ fn listDir { n=`{echo /$u|sed 's/[\-_]/ /g; s,.*/([^/]+)/?$,\1,'} echo '<li><a href="'$u'">'^$"n^'</a>' $"desc '</li>' echo $base_url^$u >> $tmpfile + echo '<url><loc>'$base_url^$u'</loc></url>' >> $tmpfilex if(test -d $i) @{ listDir $i } } @@ -28,9 +30,30 @@ fn listDir { } } + fltr_cache listDir $sitedir/ -if(test -s $tmpfile) +if(test -s $tmpfile) { mv $tmpfile $sitedir/sitemap.txt & +} +if not if(test -f $tmpfile) + rm $tmpfile + +if(test -s $tmpfilex) { + { + echo '<?xml version="1.0" encoding="UTF-8"?> +<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' + + cat $tmpfilex + rm $tmpfilex & + echo '</urlset>' + # 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 %}