shithub: werc

Download patch

ref: cba00e0700259e5681d7e212726edd3e8b991405
parent: 53c303ffd1d3acfae2d9199106b5a6cedc76a398
author: uriel <uriel@engel.se.cat-v.org>
date: Sun Jan 4 02:57:13 EST 2009

Very minor dirfilter cleanups and some extra comments.

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -20,8 +20,9 @@
 }
 
 # 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='s/\*$//; s,/+\./+,/,g; /\/[._]/d; /'^$forbidden_uri_chars^'/d; /^\/(robots|sitemap)\.txt$|\/index\.(md|html|txt|tpl)$/d; /_werc\/?$/d; s,^\./,,; '
+# ls -F style input of the form: $sitedir/path/to/files/
+#          <ls -F+x><symlink hack><Useless?><hiden files  >
+dirfilter='s/\*$//; s,/+\./+,/,g; s,^\./,,; /\/[._][^\/]/d; /'^$forbidden_uri_chars^'/d; /^\/(robots|sitemap)\.txt$|\/index\.(md|html|txt|tpl)$/d; /_werc\/?$/d; '
 dirclean=' s/\.(md|html|txt)$//; '
 
 # To be used from config files
@@ -33,7 +34,8 @@
 # Sidebar 
 fn gensidebar {
     # Ignore stderr, last path element might be a file that doesn't exist (eg., foo for foo.md)
-    ls -F $sitedir^/./^$req_paths_list >[2]/dev/null|sed 's!^'$sitedir'!!; '^$dirfilter^'/\/[^_.\/][^\/]*(\.(md|txt|html)|\/)$/!d; '^$dirclean|sort -u|awk -F/ ' 
+    # /./ to deal with p9p's ls failure to follow dir symlinks otherwise
+    ls -F $sitedir/./$req_paths_list >[2]/dev/null|sed 's!^'$sitedir'!!; '^$dirfilter^'/\/[^_.\/][^\/]*(\.(md|txt|html)|\/)$/!d; '^$dirclean|sort -u|tee /tmp/d|awk -F/ ' 
     function p(x, y, s) {
         for(i=0; i < x-y; i+=1)
             print s