shithub: werc

Download patch

ref: a6c5cabea6297b88ef678451f15a8b7153351244
parent: e17e2cc54934b5acadccc146eb9b85586b234ed7
author: uriel <uriel@suckless.org>
date: Tue Sep 16 22:16:33 EDT 2008

Reorganize configuration variables, now all settings can be customized from initrc.local and the default initrc documents the available options

--- a/bin/controller.rc
+++ b/bin/controller.rc
@@ -1,25 +1,7 @@
 #!/usr/local/plan9/bin/rc
-path=(. ./bin $PLAN9/bin /bin/ /usr/bin)
-
-uri = `{echo -n $REQUEST_URI | sed -e 's/\?.*//; s/[^a-zA-Z0-9_+\-\/\.]//g; s/\.\.*/./g;' -e '1q'}
-ifs='/' {
-	args = `{echo -n $uri}
-}
 cd ..
 
-# default config
-formatter=markdown.pl
-formatter=md_cache # markdown cacher
-site=$SERVER_NAME
-sitedir=sites/$site
-headers=inc/headers.tpl
-template=_default
-sidebar=sidebar
-baseuri=http://$site/
-for(i in siteTitle siteSubTitle title extraHeaders)
-    $i = ''
 
-
 # Useful functions
 fn dprint {
     echo $* >[1=2]
@@ -242,12 +224,34 @@
 }
 
 
-
 fn genbody {
     # Actually execute request
     $handler $handler_args
 }
+
+
+# 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=inc/headers.tpl
+template=_default
+sidebar=sidebar
+baseuri=http://$site/
+for(i in siteTitle siteSubTitle title extraHeaders)
+    $i = ''
+
 . etc/initrc
+
+if(test -f etc/initrc.local)
+    . etc/initrc.local
+
+
+# Parse request URL
+uri = `{echo -n $REQUEST_URI | sed -e 's/\?.*//; s/[^a-zA-Z0-9_+\-\/\.]//g; s/\.\.*/./g;' -e '1q'}
+ifs='/' {
+	args = `{echo -n $uri}
+}
 
 
 if(! ~ $#debug 0)
--- a/etc/initrc
+++ b/etc/initrc
@@ -1,4 +1,29 @@
+# This file contains the default werc settings.
+# To change any of this settings globally, copy them to etc/initrc.local
+# and customize them there.
+#
+# Some settings can also be set for a specific site in their respective _config
+# or their master-site _config file.
+
+# General options
+
+# Location of your Plan 9 from User Space installation (usually /usr/local/plan9)
+plan9port=$PLAN9
+
+# Path, make sure the plan9port /bin directory is included before /bin and /usr/bin
+path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin)
+
+# Directory where your site(s) live ($site here is your domain name, eg., example.com)
+sitedir=sites/$site
+
+# Set this to your favorite markdown formatter, eg., markdown.pl
+# (md_cache is a wrapper around markdown.pl that caches output)
+formatter=md_cache 
+
+# Enable debugging, to disable set to ()
+debug=true
+
+# Default site variables (Should be set on the _config file of each site or master site)
 masterSite=cat-v.org
 siteTitle='cat-v'
 siteSubTitle='Considered harmful'
-debug=true