commit 2f9c4660cf0ffdc3bc394daa0cddb713d35c9ff9
parent 885fed741dab4c82a5b83014ff88cac743214a4d
Author: uriel@engel.se.cat-v.org <unknown>
Date: Sat, 20 Dec 2008 03:42:43 +0100
Simplification of sidebar code: do away with fn menu, and merge code directly into gensidebar.
No need to run sidebar code in a subshell anymore.
Diffstat:
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/bin/werc.rc b/bin/werc.rc
@@ -21,7 +21,7 @@ fn gentitle {
# 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,/\./,/,g; /\/[._]/d; /'^$forbidden_uri_chars^'/d; /\/(robots\.txt|sitemap\.txt|index\.(md|html|txt|tpl))$/d; /_werc\/?$/d; s,^\./,,; s,\.(md|html|txt)$,,; '
+dirfilter = 's,/+\./+,/,g; /\/[._]/d; /'^$forbidden_uri_chars^'/d; /^\/(robots|sitemap)\.txt$|\/index\.(md|html|txt|tpl)$/d; /_werc\/?$/d; s,^\./,,; s,\.(md|html|txt)$,,; '
# To be used from config files
fn hide_paths {
@@ -30,15 +30,13 @@ fn hide_paths {
}
# Sidebar
-fn menu {
- dirs = ./
- dd = .
- for(d in $args) {
- dd=$dd^'/'^$d
- dirs = ( $dd $dirs )
+fn gensidebar {
+ for(d in ./ $args) {
+ dd=$"dd^'/'^$d
+ 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/\*$//; '^$dirfilter|sort -u | awk -F/ '
+ ls -F $dirs >[2]/dev/null | sed 's/\*$//; s,^'$sitedir',,; '^$dirfilter^' s,^/,,'|sort -u | awk -F/ '
function p(x, y, s) {
for( i=0; i < x-y; i+=1)
print s
@@ -67,13 +65,6 @@ fn menu {
'
}
-fn gensidebar {
- @{
- cd $sitedir
- menu .
- }
-}
-
# Handlers
fn set_handler {