Simplify genbody/set_handler and reorg some env vars, including moving sitedirs/sitedir out of default initrc.

This commit is contained in:
Uriel 2009-01-04 22:49:05 +01:00
parent a19758645c
commit 2b29543b68
2 changed files with 10 additions and 14 deletions

View file

@ -66,10 +66,7 @@ fn gensidebar {
# Handlers # Handlers
fn set_handler { fn set_handler { handler=$* }
handler=$1
handler_args=$*(2-)
}
fn md_handler { cat $* | $formatter } 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 # Careful, the proper p9p path might not be set until initrc.local is sourced
path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin) path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin)
site=$SERVER_NAME
headers=lib/headers.tpl headers=lib/headers.tpl
master_template=default_master.tpl master_template=default_master.tpl
sidebar=sidebar sidebar=sidebar
base_url=http://$site/ werc_root=`{pwd}
current_date_time=`{date}
for(i in siteTitle siteSubTitle pageTitle extraHeaders) for(i in siteTitle siteSubTitle pageTitle extraHeaders)
$i = '' $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 . ./etc/initrc
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
# NOTE: $REQUEST_URI is not officially in CGI 1.1, but seems to be de-facto # 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'} req_path=`{echo -n $REQUEST_URI | sed 's/\?.*//; s/'^$forbidden_uri_chars^'//g; s/\.\.*/./g; 1q'}

View file

@ -15,10 +15,6 @@ plan9port=$PLAN9
# Keep '.' in path! It is needed. # Keep '.' in path! It is needed.
path=($plan9port/bin/ . ./bin/ ./bin/contrib/ /bin/ /usr/bin/) 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 # 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 # is a wrapper around a script it takes as an argument, in the default
# configuration markdown.pl, that caches output) # configuration markdown.pl, that caches output)