changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > werc / changeset: Implement the sitemaps.org standard 'protocol' with sitemap.xml.

changeset 563: ccfdb0fb8c2f
parent 562: 95e961eebfbd
child 564: 7f0505f8e891
author: uriel@vm41.cat-v.org
date: Wed, 29 Jul 2009 01:41:18 +0200
files: tpl/sitemap.tpl
description: Implement the sitemaps.org standard 'protocol' with sitemap.xml.
     1.1--- a/tpl/sitemap.tpl	Wed Jul 29 01:21:24 2009 +0200
     1.2+++ b/tpl/sitemap.tpl	Wed Jul 29 01:41:18 2009 +0200
     1.3@@ -2,6 +2,7 @@
     1.4 
     1.5 %{
     1.6 tmpfile=/tmp/werc_sitemap_$pid.txt
     1.7+tmpfilex=/tmp/werc_sitemapx_$pid.txt
     1.8 saveddf=$dirfilter
     1.9 
    1.10 fn listDir {
    1.11@@ -21,6 +22,7 @@
    1.12             n=`{echo /$u|sed 's/[\-_]/ /g; s,.*/([^/]+)/?$,\1,'}
    1.13             echo '<li><a href="'$u'">'^$"n^'</a>' $"desc '</li>' 
    1.14             echo $base_url^$u >> $tmpfile
    1.15+            echo '<url><loc>'$base_url^$u'</loc></url>' >> $tmpfilex
    1.16             if(test -d $i)
    1.17                 @{ listDir $i }
    1.18         }
    1.19@@ -28,9 +30,30 @@
    1.20     }
    1.21 }
    1.22 
    1.23+
    1.24 fltr_cache listDir $sitedir/
    1.25 
    1.26-if(test -s $tmpfile)
    1.27+if(test -s $tmpfile) {
    1.28     mv $tmpfile $sitedir/sitemap.txt &
    1.29+}
    1.30+if not if(test -f $tmpfile)
    1.31+    rm $tmpfile
    1.32+
    1.33+if(test -s $tmpfilex) {
    1.34+    {
    1.35+        echo '<?xml version="1.0" encoding="UTF-8"?>
    1.36+<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
    1.37+
    1.38+        cat $tmpfilex
    1.39+        rm $tmpfilex &
    1.40+        echo '</urlset>'
    1.41+        # TODO Enable automaic search engine update notification.
    1.42+        #hget 'http://google.com/ping?sitemap='^`{url_encode $base_url'/sitemap.gz'} > /dev/null
    1.43+    
    1.44+    } | gzip > $sitedir/sitemap.gz &
    1.45+    #} > $sitedir/sitemap.xml &
    1.46+}
    1.47+if not if(test -f $tmpfilex)
    1.48+    rm $tmpfilex
    1.49 
    1.50 %}