2007-06-17 17:45:45 -06:00
|
|
|
<h1>Site map</h1>
|
|
|
|
|
|
|
|
%{
|
2008-09-26 06:48:31 -06:00
|
|
|
tmpfile=/tmp/werc_sitemap_$pid.txt
|
2009-07-28 17:41:18 -06:00
|
|
|
tmpfilex=/tmp/werc_sitemapx_$pid.txt
|
2008-12-20 05:20:31 -07:00
|
|
|
saveddf=$dirfilter
|
2007-06-17 17:45:45 -06:00
|
|
|
|
2009-08-07 21:32:42 -06:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2007-06-17 17:45:45 -06:00
|
|
|
fn listDir {
|
2008-09-04 17:07:56 -06:00
|
|
|
d=$1
|
2008-12-20 05:20:31 -07:00
|
|
|
dirfilter=$saveddf
|
|
|
|
if(test -f $d/_werc/config)
|
2009-08-09 13:02:42 -06:00
|
|
|
. $d/_werc/config
|
2007-06-17 17:45:45 -06:00
|
|
|
|
2009-02-14 00:09:27 -07:00
|
|
|
if(~ $#perm_redir_to 0) {
|
|
|
|
echo '<ul class="sitemap-list">'
|
|
|
|
|
|
|
|
for(i in `{ls -dF $d^*/ $d^*.md $d^*.html $d^*.txt >[2]/dev/null | sed $dirfilter}) {
|
|
|
|
desc=`{get_file_title $i}
|
|
|
|
u=`{echo $i|sed 's!'$sitedir'!!; '$dirclean's!/index$!/!; '}
|
|
|
|
if(! ~ $#desc 0 && ! ~ $desc '')
|
|
|
|
desc=' - '$"desc
|
2009-07-19 00:01:42 -06:00
|
|
|
n=`{echo /$u|sed 's/[\-_]/ /g; s,.*/([^/]+)/?$,\1,'}
|
2009-07-24 19:11:15 -06:00
|
|
|
echo '<li><a href="'$u'">'^$"n^'</a>' $"desc '</li>'
|
2009-02-14 00:09:27 -07:00
|
|
|
echo $base_url^$u >> $tmpfile
|
2009-08-07 21:32:42 -06:00
|
|
|
echo '<url><loc>'$base_url^$u'</loc><lastmod>'^`{get_mdate $i}^'</lastmod></url>' >> $tmpfilex
|
2009-02-14 00:09:27 -07:00
|
|
|
if(test -d $i)
|
|
|
|
@{ listDir $i }
|
|
|
|
}
|
|
|
|
echo '</ul>'
|
2007-06-25 20:25:20 -06:00
|
|
|
}
|
2007-06-17 17:45:45 -06:00
|
|
|
}
|
2008-09-04 17:07:56 -06:00
|
|
|
|
2009-07-28 17:41:18 -06:00
|
|
|
|
2009-02-06 14:09:32 -07:00
|
|
|
fltr_cache listDir $sitedir/
|
2007-06-17 17:45:45 -06:00
|
|
|
|
2009-07-28 17:41:18 -06:00
|
|
|
if(test -s $tmpfile) {
|
2009-02-06 12:43:11 -07:00
|
|
|
mv $tmpfile $sitedir/sitemap.txt &
|
2009-07-28 17:41:18 -06:00
|
|
|
}
|
|
|
|
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
|
2008-09-25 03:04:57 -06:00
|
|
|
|
2007-06-17 17:45:45 -06:00
|
|
|
%}
|