shithub: werc

Download patch

ref: faf49f344dc26b84ddaf1a312a63d947fcdb1ec8
parent: 11ad40a9f0acb6739de336c78e2043fb348e0920
author: uriel <uriel@suckless.org>
date: Thu Sep 4 21:07:56 EDT 2008

Considerably simplify sitemap.tpl, also makes 'dirfilter' application more
consistent between menu listing and sitemap.

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