From 2b29543b68aca9746e861a8c18d9eb762185e530 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sun, 4 Jan 2009 22:49:05 +0100 Subject: [PATCH] Simplify genbody/set_handler and reorg some env vars, including moving sitedirs/sitedir out of default initrc. --- bin/werc.rc | 20 ++++++++++---------- etc/initrc | 4 ---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/bin/werc.rc b/bin/werc.rc index 9820a0d..e8f4d48 100755 --- a/bin/werc.rc +++ b/bin/werc.rc @@ -66,10 +66,7 @@ fn gensidebar { # Handlers -fn set_handler { - handler=$1 - handler_args=$*(2-) -} +fn set_handler { handler=$* } fn md_handler { cat $* | $formatter } @@ -159,27 +156,30 @@ fn select_handler { } -fn genbody { $handler $handler_args } +fn genbody { $handler(1) $handler(2-) } # Careful, the proper p9p path might not be set until initrc.local is sourced path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin) -site=$SERVER_NAME headers=lib/headers.tpl master_template=default_master.tpl sidebar=sidebar -base_url=http://$site/ -current_date_time=`{date} +werc_root=`{pwd} for(i in siteTitle siteSubTitle pageTitle extraHeaders) $i = '' +# TODO: Per-req variables should move after initrc loading. +site=$SERVER_NAME +base_url=http://$site/ +sitesdir=sites +sitedir=$sitesdir/$site +current_date_time=`{date} + . ./etc/initrc if(test -f etc/initrc.local) . ./etc/initrc.local -werc_root=`{pwd} - # Parse request URL # NOTE: $REQUEST_URI is not officially in CGI 1.1, but seems to be de-facto req_path=`{echo -n $REQUEST_URI | sed 's/\?.*//; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'} diff --git a/etc/initrc b/etc/initrc index a4d2194..c59769e 100644 --- a/etc/initrc +++ b/etc/initrc @@ -15,10 +15,6 @@ plan9port=$PLAN9 # Keep '.' in path! It is needed. path=($plan9port/bin/ . ./bin/ ./bin/contrib/ /bin/ /usr/bin/) -# Directories where your site(s) live ($site here is your domain name, eg., example.com) -sitesdir=sites -sitedir=$sitesdir/$site - # Set this to your favorite markdown formatter, eg., markdown.pl (fproc_cache # is a wrapper around a script it takes as an argument, in the default # configuration markdown.pl, that caches output)