shithub: werc

Download patch

ref: 9a3a9c26111ff179b2cfea3a8ec464b01ede7182
parent: 2a20cb62a8d59f2ae7c0901b1196c4682823cda8
author: uriel <[email protected]>
date: Sat Aug 8 01:32:42 EDT 2009

Add lastmod support to sitemap.xml

--- a/tpl/sitemap.tpl
+++ b/tpl/sitemap.tpl
@@ -5,6 +5,14 @@
 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 @@
             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
+            echo '<url><loc>'$base_url^$u'</loc><lastmod>'^`{get_mdate $i}^'</lastmod></url>' >> $tmpfilex
             if(test -d $i)
                 @{ listDir $i }
         }