changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > werc / changeset: Add lastmod support to sitemap.xml

changeset 572: caacd7316fbf
parent 571: 0bee45ab2630
child 573: 031642d8124b
author: uriel@vm41.cat-v.org
date: Sat, 08 Aug 2009 05:32:42 +0200
files: tpl/sitemap.tpl
description: Add lastmod support to sitemap.xml
     1.1--- a/tpl/sitemap.tpl	Sat Aug 08 03:17:28 2009 +0200
     1.2+++ b/tpl/sitemap.tpl	Sat Aug 08 05:32:42 2009 +0200
     1.3@@ -5,6 +5,14 @@
     1.4 tmpfilex=/tmp/werc_sitemapx_$pid.txt
     1.5 saveddf=$dirfilter
     1.6 
     1.7+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/;'
     1.8+
     1.9+fn get_mdate {
    1.10+    t=`{mtime $1}
    1.11+    t=`{date $t(1) | sed -e $MON2NUM -e 's/  ([0-9]) / 0\1 /g'} # Make sure day of the month is two digits.
    1.12+    echo $t(6)^'-'^$t(2)^'-'^$t(3)
    1.13+}
    1.14+
    1.15 fn listDir {
    1.16     d=$1
    1.17     dirfilter=$saveddf
    1.18@@ -22,7 +30,7 @@
    1.19             n=`{echo /$u|sed 's/[\-_]/ /g; s,.*/([^/]+)/?$,\1,'}
    1.20             echo '<li><a href="'$u'">'^$"n^'</a>' $"desc '</li>' 
    1.21             echo $base_url^$u >> $tmpfile
    1.22-            echo '<url><loc>'$base_url^$u'</loc></url>' >> $tmpfilex
    1.23+            echo '<url><loc>'$base_url^$u'</loc><lastmod>'^`{get_mdate $i}^'</lastmod></url>' >> $tmpfilex
    1.24             if(test -d $i)
    1.25                 @{ listDir $i }
    1.26         }