swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit 4410cbb48b47ebedb129095fa42342a1a3fcc3e8
parent 19f9587899391c50b5af95723a250eb39838ba26
Author: uriel@engel.se.cat-v.org <unknown>
Date:   Sun,  4 Jan 2009 22:49:05 +0100

Simplify genbody/set_handler and reorg some env vars, including moving sitedirs/sitedir out of default initrc.
Diffstat:
Mbin/werc.rc | 20++++++++++----------
Metc/initrc | 4----
2 files changed, 10 insertions(+), 14 deletions(-)

diff --git 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 @@ -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)