Considerably simplify sitemap.tpl, also makes 'dirfilter' application more

consistent between menu listing and sitemap.
This commit is contained in:
Uriel 2008-09-05 01:07:56 +02:00
parent 2356cf98a9
commit 17fd5c9100

View file

@ -3,20 +3,17 @@
%{ %{
saveddf = $dirfilter saveddf = $dirfilter
cpath = ''
rpath = `{pwd}
rpath = $rpath^'/'^$sitedir
fn getMdDesc { fn getMdDesc {
sed 's/^(.......................................................................................................[^ ]*).*$/\1/g; 1q' < $1 sed 's/^(.......................................................................................................[^ ]*).*$/\1/g; 1q' < $1
} }
fn listDir { fn listDir {
cd $1 d=$1
dirfilter = $saveddf dirfilter = $saveddf
blogDirs = () blogDirs = ()
if (test -f _config) if (test -f $d/_config)
. _config . $d/_config
echo '<ul>' echo '<ul>'
@ -24,11 +21,7 @@ fn listDir {
echo '' echo ''
if not { if not {
for ( i in `{ ls -d */ *.md *.html >[2]/dev/null |sed $dirfilter^'/index$/d;' } ) { for ( i in `{ ls -d $d/*/ $d/*.md $d/*.html >[2]/dev/null |sed $dirfilter^'/index$/d;' } ) {
cpath = `{ pwd | sed 's,^'^$"rpath/?^',,; s,//*,/,;' }
if( ~ $#cpath 0 )
cpath = ''
desc = '' desc = ''
if (test -f $i.md) { if (test -f $i.md) {
desc = `{ getMdDesc $i.md } desc = `{ getMdDesc $i.md }
@ -44,15 +37,15 @@ fn listDir {
} }
if (! ~ $desc '') if (! ~ $desc '')
desc = ' - '$"desc desc = ' - '$"desc
tit = `{echo $i|sed 's/_/ /g'} tit = `{basename $i|sed 's/_/ /g'}
echo '<li><a style="text-transform: capitalize" href="'$cpath/$i'">'^$"tit^'</a>' $desc '</li>' echo '<li><a style="text-transform: capitalize" href="'$i'">'^$"tit^'</a>' $desc '</li>'
if (test -d $i) if (test -d $i)
listDir $i @{ listDir $i }
} }
} }
echo '</ul>' echo '</ul>'
cd ..
} }
cd $sitedir cd $sitedir
listDir . listDir .