shithub: werc

Download patch

ref: 915cf56683960ab92d485a271c087a83645c1237
parent: faf49f344dc26b84ddaf1a312a63d947fcdb1ec8
author: uriel <uriel@suckless.org>
date: Thu Sep 4 21:11:14 EDT 2008

New get_inc_file function to be used in templates and other places to get
includes/templates that can be overriden on a per-site (and group of sites)
basis.

--- a/bin/controller.rc
+++ b/bin/controller.rc
@@ -33,7 +33,17 @@
     exit
 }
 
+fn get_inc_file {
+    wantedfile = $1
+    if (test -f $sitedir/_inc/$wantedfile)
+    	echo -n $sitedir/_inc/$wantedfile
+    if not if(test -f sites/$masterSite/_inc/$wantedfile)
+    	echo -n       sites/$masterSite/_inc/$wantedfile
+    if not if (test -f inc/$wantedfile)
+    	echo -n        inc/$wantedfile
+}
 
+
 # Title
 fn gentitle {
     echo '<h1 class="headerTitle"><a href="/">' ^ $"siteTitle ^ ' <span id="headerSubTitle">' ^ $"siteSubTitle ^ '</span></a></h1>'
@@ -147,7 +157,7 @@
 }
 
 fn 404_handler {
-    template.awk inc/404.tpl | rc $rcargs
+    template.awk `{get_inc_file 404.tpl } | rc $rcargs
 }
 
 fn blog_dir_handler {
@@ -287,8 +297,6 @@
 
 # Template/body selection
 template=$sitedir/$template.tpl
-if (! ~ $#sidebar 0)
-    sidebar=tpl/_inc/$sidebar.tpl
 
 body=$sitedir/$body
 rssuri=$uri