commit 8c3f101878d54b8feb1e4415a49cb650ee064e50
parent 4183850e8921dffc6e2083871780f5e5b3b129c5
Author: uriel@engel.se.cat-v.org <unknown>
Date: Wed, 24 Sep 2008 20:21:32 +0200
Reorganization of included and template files, made more consistent and logical. inc/ is now called lib/, and all non-staic files in pub/ have moved to lib/.
In site dirs _config and _default.tpl have moved to _werc/ in preparation for things like comments.
Diffstat:
7 files changed, 80 insertions(+), 53 deletions(-)
diff --git a/bin/controller.rc b/bin/controller.rc
@@ -15,14 +15,34 @@ Location: '^$1^'
exit
}
-fn get_inc_file {
+fn get_lib_file {
wantedfile = $1
- if (test -f $sitedir/_inc/$wantedfile)
+ if (test -f $sitedir/_werc/lib/$wantedfile)
+ echo -n $sitedir/_werc/lib/$wantedfile
+ if not if(! ~ $masterSite 0 && test -f sites/$masterSite/_werc/lib/$wantedfile)
+ echo -n sites/$masterSite/_werc/lib/$wantedfile
+ if not if (test -f lib/$wantedfile)
+ echo -n lib/$wantedfile
+
+ # DEPRECATED
+ if (test -f $sitedir/_inc/$wantedfile) {
echo -n $sitedir/_inc/$wantedfile
- if not if(test -f sites/$masterSite/_inc/$wantedfile)
+ dprint DEPRECATION WARNING: Using file in depracted path: $sitedir/_inc/$wantedfile XXX
+ }
+ if not if(! ~ $masterSite 0 && test -f sites/$masterSite/_inc/$wantedfile) {
echo -n sites/$masterSite/_inc/$wantedfile
- if not if (test -f inc/$wantedfile)
+ dprint DEPRECATION WARNING: Using file in depracted path: sites/$masterSite/_inc/$wantedfile XXX
+ }
+ if not if (test -f inc/$wantedfile) {
echo -n inc/$wantedfile
+ dprint DEPRECATION WARNING: Using file in depracted path: inc/$wantedfile XXX
+ }
+}
+
+# DEPRECATED
+fn get_inc_file {
+ get_lib_file $*
+ dprint DEPRECATION WARNING: Called get_inc_file, should call get_lib_file
}
@@ -34,7 +54,7 @@ fn gentitle {
# Don't change var name or trailing ';', some dirs change the filter!
dirfilter = '/\/[._]/d; /\/robots.\txt$/d; /\/sitemap\.txt$/d; s,^\./,,; s,\.md$,,; s,\.html,,; s,\.txt,,; '
-# To be used from _config files
+# To be used from config files
fn hide_paths {
for(i in $*) {
dirfilter = $dirfilter^'/^'$i'$/d; '
@@ -139,7 +159,7 @@ fn dir_listing_handler {
}
fn 404_handler {
- template.awk `{get_inc_file 404.tpl } | rc $rcargs
+ template.awk `{get_lib_file 404.tpl } | rc $rcargs
}
fn blog_dir_handler {
@@ -202,8 +222,8 @@ dprint $body
blogDirs = `{basename -d $body}
# Global tpl (eg sitemap.tpl)
- if not if (test -f pub/^$uri^.tpl)
- set_handler tpl_handler pub/^$uri^.tpl
+ if not if (test -f lib/^$uri^.tpl)
+ set_handler tpl_handler lib/^$uri^.tpl
if not if (test -f $body.txt)
set_handler txt_handler $body.txt
@@ -234,8 +254,8 @@ fn genbody {
path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin)
site=$SERVER_NAME
-headers=inc/headers.tpl
-template=_default
+headers=lib/headers.tpl
+master_template=default_master.tpl
sidebar=sidebar
baseuri=http://$site/
for(i in siteTitle siteSubTitle pageTitle extraHeaders)
@@ -280,6 +300,8 @@ for (i in ('' $args)) {
if (test -f $fpath/_config)
. $fpath/_config
+ if (test -f $fpath/_werc/config)
+ . $fpath/_werc/config
if (~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log)
inBlog = 'yes'
@@ -304,7 +326,12 @@ if not
pageTitle=$"pageTitle^' | '^$"siteTitle^' '^$"siteSubTitle
# Template/body selection
-template=$sitedir/$template.tpl
+master_template= `{get_lib_file $master_template }
+
+# DEPRECATED
+if(~ $master_template 0)
+ master_template=$sitedir/_default.tpl
+
body=$sitedir/$body
rssuri=$uri
@@ -341,7 +368,7 @@ fn template {
}
if(! ~ $REQUEST_URI */index.rss) {
- cat $headers $template | template
+ cat $headers $master_template | template
echo '</body></html>'
exit
}
@@ -376,4 +403,4 @@ fn statpost {
}
}
-cat pub/feeds/rss20.tpl | template
+cat lib/feeds/rss20.tpl | template
diff --git a/etc/initrc b/etc/initrc
@@ -23,7 +23,7 @@ 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'
+# Default site variables, must be set in initrc.local or _werc/config, only siteTitle is required.
+#masterSite=cat-v.org # Not required!
+#siteTitle='cat-v'
+#siteSubTitle='Considered harmful'
diff --git a/inc/headers.tpl b/inc/headers.tpl
@@ -1,36 +0,0 @@
-Content-Type: text/html
-
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
-<head>
-
-<meta name="verify-v1" content="6zEoK0WMlnLmIS/w7Pnh6+srZECHsvnMGN0kQmowSGk=" />
-
- <title>%($pageTitle%)</title>
-
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta name="author" content="k" />
-
-% if (! ~ $#meta_description 0)
-% echo ' <meta name="description" content="'$"meta_description'" />'
-% if (! ~ $#meta_keywords 0)
-% echo ' <meta name="keywords" content="'$"meta_keywords'" />'
-
- <link rel="stylesheet" href="/pub/style/style.css" type="text/css" media="screen, handheld" title="default" />
- <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />
-%# <link rel="stylesheet alternative" type="text/css" href="/pub/style/style_old.css" media="screen" title="Old Style" />
-% if (test -f $sitedir/_style.css) {
- <link rel="stylesheet" href="/_style.css" type="text/css" media="screen" title="default" />
-% }
-
-% h = `{ get_inc_file headers.inc}
-% if(! ~ $#h 0)
-% cat $h
-
- %($extraHeaders%)
-
-</head>
-<body>
-
diff --git a/inc/404.tpl b/lib/404.tpl
diff --git a/pub/feeds/rss20.tpl b/lib/feeds/rss20.tpl
diff --git a/lib/headers.tpl b/lib/headers.tpl
@@ -0,0 +1,36 @@
+Content-Type: text/html
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head>
+
+<meta name="verify-v1" content="6zEoK0WMlnLmIS/w7Pnh6+srZECHsvnMGN0kQmowSGk=" />
+
+ <title>%($pageTitle%)</title>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta name="author" content="k" />
+
+% if (! ~ $#meta_description 0)
+% echo ' <meta name="description" content="'$"meta_description'" />'
+% if (! ~ $#meta_keywords 0)
+% echo ' <meta name="keywords" content="'$"meta_keywords'" />'
+
+ <link rel="stylesheet" href="/pub/style/style.css" type="text/css" media="screen, handheld" title="default" />
+ <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon" />
+%# <link rel="stylesheet alternative" type="text/css" href="/pub/style/style_old.css" media="screen" title="Old Style" />
+% if (test -f $sitedir/_style.css) {
+ <link rel="stylesheet" href="/_style.css" type="text/css" media="screen" title="default" />
+% }
+
+% h = `{ get_lib_file headers.inc}
+% if(! ~ $#h 0)
+% cat $h
+
+ %($extraHeaders%)
+
+</head>
+<body>
+
diff --git a/pub/sitemap.tpl b/lib/sitemap.tpl