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.
This commit is contained in:
Uriel 2008-12-20 03:42:43 +01:00
parent 33b98d278e
commit 750a46f3fd

View file

@ -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 {