From 677a928bc21448d046de993a10090af8879152a9 Mon Sep 17 00:00:00 2001 From: uriel Date: Sat, 8 Aug 2009 05:32:42 +0200 Subject: [PATCH] Add lastmod support to sitemap.xml --- tpl/sitemap.tpl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tpl/sitemap.tpl b/tpl/sitemap.tpl index b84d209..1f5d07a 100644 --- a/tpl/sitemap.tpl +++ b/tpl/sitemap.tpl @@ -5,6 +5,14 @@ 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 @@ -22,7 +30,7 @@ fn listDir { n=`{echo /$u|sed 's/[\-_]/ /g; s,.*/([^/]+)/?$,\1,'} echo '
  • '^$"n^'' $"desc '
  • ' echo $base_url^$u >> $tmpfile - echo ''$base_url^$u'' >> $tmpfilex + echo ''$base_url^$u''^`{get_mdate $i}^'' >> $tmpfilex if(test -d $i) @{ listDir $i } }