shithub: werc

Download patch

ref: 01626cf351e8fe82f391e83e9ca205ecff4add7c
parent: 6c0f20019d6955a3375ebb50b4fb58340f4f3734
author: uriel <uriel@engel.se.cat-v.org>
date: Sat Nov 29 11:20:08 EST 2008

Improve dirfilter, simplified and made more reliable. Also strip trailing * from ls -F output (not sure if this should be added to dirfilter itself.

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -22,7 +22,7 @@
 
 # Don't change var name or trailing ';', dirfilter might be changed from _werc/config!
 # TODO: Specify the canonical path input format handled by dirfilter
-dirfilter = '/\/[._]/d; /'^$forbidden_uri_chars^'/d; /\/(robots\.txt|sitemap\.txt|index\.(md|html|txt|tpl))$/d; /_werc$/d; s,^\./,,; s,\.md$,,; s,\.html,,; s,\.txt,,; '
+dirfilter = '/\/[._]/d; /'^$forbidden_uri_chars^'/d; /\/(robots\.txt|sitemap\.txt|index\.(md|html|txt|tpl))$/d; /_werc\/?$/d; s,^\./,,; s,\.(md|html|txt)$,,; '
 
 # To be used from config files
 fn hide_paths {
@@ -39,7 +39,7 @@
        dirs = ( $dd $dirs )
     }
     # Ignore stderr, last item in path might be a file that doesn't exist (eg., foo for foo.md)
-    ls -F $dirs >[2]/dev/null | sed 's/[@*]$//; '^$dirfilter|sort -u | awk -F/ ' 
+    ls -F $dirs >[2]/dev/null | sed 's/\*$//; '^$dirfilter|sort -u | awk -F/ ' 
     function p(x, y, s) {
         for( i=0; i < x-y; i+=1)
             print s 
@@ -125,7 +125,7 @@
     dt = `{echo $d|sed -e 's,.*//,,g' -e 's,/$,,' -e 's,/, / ,g'} 
     echo '<h1 class="dir-list-head">'^$"dt^'</h1> <ul class="dir-list">'
     # XXX I'm not sure what the [^$] does there
-    ls -F $d | sed -e $dirfilter' s,^'$sitedir'/.*/([^$].*),<li><a href="\1">\1</a></li>,'
+    ls -F $d | sed -e 's/\*$//; '^$dirfilter' s,^'$sitedir'/.*/([^$].*),<li><a href="\1">\1</a></li>,'
     echo '</ul>'
 }