shithub: werc

Download patch

ref: 1f53110e407ac71970333c6753c18fa533b7b4ef
parent: b862d00443c95bf5ab8bc8dc396f42a4b4e5a46f
author: uriel <uriel@engel.se.cat-v.org>
date: Sat Dec 20 00:46:41 EST 2008

A couple of minor code simplifications and add a comment about some code that probably should be killed.

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -36,13 +36,15 @@
        dirs = ( $sitedir^$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/\*$//; s,^'$sitedir',,; '^$dirfilter^' s,^/,,'|sort -u | awk -F/ ' 
+    ls -F $dirs >[2]/dev/null | sed 's/\*$//; s,^'$sitedir',,; '^$dirfilter | sort -u | awk -F/ ' 
     function p(x, y, s) {
         for( i=0; i < x-y; i+=1)
             print s 
     }
-    /^([a-zA-Z0-9+_\-]+[*\/]?)+$/ {
 
+    # XXX Regexp to hide non-document/non-dir stuff, there must be a better way, if we really want this.
+    /^\/([a-zA-Z0-9+_\-]+[*\/]?)+$/ { 
+
         d = ""
         if(match($0, "/$"))
             d = "/"
@@ -53,7 +55,7 @@
         lNF = NF
 
         bname = $NF d
-        path = "/" $0 d
+        path = $0 d
         gsub("_", " ", bname)
 
         if(index(ENVIRON["REQUEST_URI"] "/", path) == 1)
@@ -69,8 +71,7 @@
 # Handlers
 fn set_handler {
     handler = $1
-    shift
-    handler_args = $*
+    handler_args = $*(2-)
 }
 
 fn md_handler { cat $* | $formatter }