shithub: werc

Download patch

ref: 9c6cf1c4ef9250ba4d56f52fe164ad83b66c02bf
parent: 036fedba3325981676bfafb3fe3432fd7fca44db
author: uriel <uriel@engel.se.cat-v.org>
date: Sun Mar 8 19:58:49 EDT 2009

New api to allow 'synthetic' dirs, only for sidebar for now.

--- a/bin/corehandlers.rc
+++ b/bin/corehandlers.rc
@@ -1,5 +1,10 @@
 # Werc builtin handlers
 
+# API
+fn add_synth_paths {
+    synth_paths=($synth_paths $conf_wd^$*)
+}
+
 fn nav_tree {
     if(! ~ $#sideBarNavTitle 0)
         echo '<p class="sideBarTitle">'$"sideBarNavTitle':</p>'
@@ -6,8 +11,10 @@
     # Ignore stderr, last path element might be a file that doesn't exist (eg., foo for foo.md)
     # /./ to deal with p9p's ls failure to follow dir symlinks otherwise
     ls -F $sitedir/./$req_paths_list >[2]/dev/null \
-        | sed $dirfilter'/\/[^_.\/][^\/]*(\.(md|txt|html)|\/)$/!d; s!^'$sitedir'!!; '$dirclean \
-        | sort -u | awk -F/ ' 
+        | { 
+            sed $dirfilter'/\/[^_.\/][^\/]*(\.(md|txt|html)|\/)$/!d; s!^'$sitedir'!!; '$dirclean 
+            if(! ~ $#synth_paths 0) echo $synth_paths | tr ' ' $NEW_LINE 
+        } | sort -u | awk -F/ ' 
     function p(x, y, s) { for(i=0; i < x-y; i+=1) print s }
     BEGIN { lNF=2; print "<ul>" }
     {