shithub: werc

Download patch

ref: 5b1239bd6253f34178436af28df0987d1ada1df8
parent: d3824bd9a1d16afc8fa4cc39e2d6b84048353ab4
author: uriel <[email protected]>
date: Sun Jan 4 17:49:05 EST 2009

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

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -66,10 +66,7 @@
 
 
 # Handlers
-fn set_handler {
-    handler=$1
-    handler_args=$*(2-)
-}
+fn set_handler { handler=$* }
 
 fn md_handler { cat $* | $formatter }
 
@@ -159,26 +156,29 @@
 
 }
 
-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
--- a/etc/initrc
+++ b/etc/initrc
@@ -15,10 +15,6 @@
 # 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)