Source _werc/config files with their container dir as working directory (allows for relative references in config variables, for example: blaghDirs=(../people/*/blog/)). NOTE: this require some config files to be updated, specially ones with blogDirs in them, $sitedir/ references and full paths are not required anymore.

Added two new global vars: $werc_root and $req_paths_list.
Change sidebar menu generation to use $req_paths_list.
This commit is contained in:
Uriel 2008-12-27 11:53:58 +01:00
parent d01e553bab
commit 079d4b43e4

View file

@ -31,12 +31,8 @@ fn hide_paths {
# Sidebar # Sidebar
fn gensidebar { 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) # 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,^'$sitedir',,; '^$dirfilter | sort -u | awk -F/ ' ls -F $sitedir^/./^$req_paths_list >[2]/dev/null | sed 's,^'$sitedir',,; '^$dirfilter | sort -u | awk -F/ '
function p(x, y, s) { function p(x, y, s) {
for(i=0; i < x-y; i+=1) for(i=0; i < x-y; i+=1)
print s print s
@ -226,6 +222,7 @@ for(i in siteTitle siteSubTitle pageTitle extraHeaders)
if(test -f etc/initrc.local) if(test -f etc/initrc.local)
. ./etc/initrc.local . ./etc/initrc.local
werc_root=`{pwd}
# Parse request URL # Parse request URL
uri=`{echo -n $REQUEST_URI | sed 's/\?.*//; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'} uri=`{echo -n $REQUEST_URI | sed 's/\?.*//; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'}
@ -248,22 +245,27 @@ if not {
req_path='/' req_path='/'
} }
fpath=$sitedir p=()
cd $sitedir
for(i in ('' $args)) { for(i in ('' $args)) {
# TODO We can build a list of paths here that can be used in sidebar, instead of iterating args twice # TODO We can build a list of paths here that can be used in sidebar, instead of iterating args twice
fpath=$fpath/$i p=($"p^/^$i)
req_paths_list=($req_paths_list $p)
# We don't want blog settings to cascade into posts, note that we are inBlog instead # We don't want blog settings to cascade into posts, note that we are inBlog instead
if(! ~ $#blogDirs 0 && ! ~ $req_path */index.rss */index.atom */[bB]log */[bB]log/) { if(! ~ $#blogDirs 0 && ! ~ $req_path */index.rss */index.atom */[bB]log */[bB]log/) {
inBlog = $blogDirs inBlog = $blogDirs
blogDirs = () blogDirs = ()
} }
if(test -d $i) {
if(test -f $fpath/_werc/config) cd $i
. ./$fpath/_werc/config if(test -f _werc/config)
. _werc/config
}
if(~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log) if(~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log)
inBlog = 'yes' inBlog = 'yes'
} }
cd $werc_root
# Redirections and other preprocessing # Redirections and other preprocessing
if(~ $#redirectPermanent 1) if(~ $#redirectPermanent 1)