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
|
2008-12-20 05:20:31 -07:00
|
|
|
saveddf=$dirfilter
|
2007-06-17 17:45:45 -06:00
|
|
|
|
2009-02-06 12:43:11 -07:00
|
|
|
fn get_md_title {
|
|
|
|
sed 's/^(................................................................[^ ]*).*$/\1/g; 1q' < $1
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_html_title {
|
|
|
|
# H1 is not reliable because htmlroff doesn't use it :(
|
|
|
|
#desc=`{cat $1 | sed 32q | grep '<[Hh]1>' | sed 's/<[Hh]1>(.*)(<\/[Hh]1>|$)/\1/;s/<[^>]*>//g;1q'}
|
|
|
|
# Pick the first line of body instead
|
|
|
|
desc=`{sed -n '/<[Bb][Oo][Dd][Yy]/,/./s/(<[^>]*>|$)//gp' < $1}
|
|
|
|
if(~ $#desc 0)
|
|
|
|
desc=`{sed 's/<[^>]*>//g; 1q' < $1}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_file_title {
|
|
|
|
|
|
|
|
if(~ $1 */) {
|
|
|
|
if(test -f $1/index.md)
|
|
|
|
get_md_title $1/index.md
|
|
|
|
if not if(test -f $1/index.html)
|
|
|
|
get_html_title $1/index.html
|
|
|
|
}
|
|
|
|
if not if(~ $1 *.md)
|
|
|
|
get_md_title $1
|
|
|
|
if not if(~ $1 *.html)
|
|
|
|
get_html_title $1
|
|
|
|
if not
|
|
|
|
echo ''
|
2007-06-23 17:21:17 -06:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
. ./$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
|
|
|
|
n=`{echo /$u|sed 's/_/ /g; s,.*/([^/]+)/?$,\1,'}
|
|
|
|
echo '<li><a href="'$base_url$u'">'^$"n^'</a>' $"desc '</li>'
|
|
|
|
echo $base_url^$u >> $tmpfile
|
|
|
|
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-02-06 14:09:32 -07:00
|
|
|
fltr_cache listDir $sitedir/
|
2007-06-17 17:45:45 -06:00
|
|
|
|
2009-02-06 12:43:11 -07:00
|
|
|
if(test -s $tmpfile)
|
|
|
|
mv $tmpfile $sitedir/sitemap.txt &
|
2008-09-25 03:04:57 -06:00
|
|
|
|
2007-06-17 17:45:45 -06:00
|
|
|
%}
|