ref: c259faa1987f69d517a6650452fad1e4573319da
parent: 8a815ac16c161c8f9625335f40aa748914519716
author: uriel <[email protected]>
date: Wed Sep 24 16:21:32 EDT 2008
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.
--- a/bin/controller.rc
+++ b/bin/controller.rc
@@ -15,17 +15,37 @@
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
+}
+
# Title
fn gentitle {
echo '<h1 class="headerTitle"><a href="/">' ^ $"siteTitle ^ ' <span id="headerSubTitle">' ^ $"siteSubTitle ^ '</span></a></h1>'
@@ -34,7 +54,7 @@
# 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 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 @@
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 @@
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 @@
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,8 +326,13 @@
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 @@
}
if(! ~ $REQUEST_URI */index.rss) {
- cat $headers $template | template
+ cat $headers $master_template | template
echo '</body></html>'
exit
}
@@ -376,4 +403,4 @@
}
}
-cat pub/feeds/rss20.tpl | template
+cat lib/feeds/rss20.tpl | template
--- a/etc/initrc
+++ b/etc/initrc
@@ -23,7 +23,7 @@
# 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'
--- a/inc/404.tpl
+++ /dev/null
@@ -1,7 +1,0 @@
-<!-- To have a custom 404 page copy this template to your site's (or masterSite) _inc director and edit it as you like -->
-
-<h1>The page requested for <i>
-% echo ''''$"title''''
-</i> doesn't exist</h1>
-
-% # TODO: Use http://www.google.com/support/webmasters/bin/answer.py?answer=100044&hl=en by default?
--- a/inc/headers.tpl
+++ /dev/null
@@ -1,36 +1,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>
-
--- /dev/null
+++ b/lib/404.tpl
@@ -1,0 +1,7 @@
+<!-- To have a custom 404 page copy this template to your site's (or masterSite) _inc director and edit it as you like -->
+
+<h1>The page requested for <i>
+% echo ''''$"title''''
+</i> doesn't exist</h1>
+
+% # TODO: Use http://www.google.com/support/webmasters/bin/answer.py?answer=100044&hl=en by default?
--- /dev/null
+++ b/lib/feeds/rss20.tpl
@@ -1,0 +1,35 @@
+Content-Type: text/xml; charset=utf-8
+
+<?xml version="1.0" encoding="UTF-8"?>
+<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+ <channel>
+ <atom:link href="%('http://'$site^$REQUEST_URI%)" rel="self" type="application/rss+xml" />
+ <title>%($siteTitle%)</title>
+ <link>%($uri%)</link>
+ <description>%($blogDesc%)</description>
+ <language>en-us</language>
+ <generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator>
+ <webMaster>[email protected] (Uriel)</webMaster>
+%{
+ for(f in `{sortedBlogPostList $blogDirs}) {
+ statpost $f
+ # Hack to aproximate the last build date
+ #(use the mdate from last posted item)
+ # Commented out for now because maybe a wrong value is worse than no value
+ #if(~ $#last_build_date 0) {
+ #last_build_date='<lastBuildDate>'^$"mdate'</lastBuildDate>'
+ #echo $last_build_date
+ #}
+%}
+ <item>
+ <title>%($title%)</title>
+ <author>%($by%)@noreply.cat-v.org (%($by%))</author>
+ <link>%($uri%)</link>
+ <guid isPermaLink="true">%($uri%)</guid>
+ <pubDate>%($date%)</pubDate>
+ <description><![CDATA[<pre>%($summary%)</pre>]]></description>
+ </item>
+% }
+
+ </channel>
+</rss>
--- /dev/null
+++ b/lib/headers.tpl
@@ -1,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>
+
--- /dev/null
+++ b/lib/sitemap.tpl
@@ -1,0 +1,52 @@
+<h1>Site map</h1>
+
+%{
+
+saveddf = $dirfilter
+
+fn getMdDesc {
+ sed 's/^(.......................................................................................................[^ ]*).*$/\1/g; 1q' < $1
+}
+
+fn listDir {
+ d=$1
+ dirfilter = $saveddf
+ blogDirs = ()
+ if (test -f $d/_config)
+ . $d/_config
+
+ echo '<ul>'
+
+ if (! ~ $#blogDirs 0 || ~ $1 blog Blog )
+ echo ''
+ if not {
+
+ for ( i in `{ ls -d $d/*/ $d/*.md $d/*.html $d/*.txt >[2]/dev/null |sed $dirfilter^'/index$/d;' } ) {
+ desc = ''
+ if (test -f $i.md) {
+ desc = `{ getMdDesc $i.md }
+ }
+ if (test -f $i/index.md) {
+ desc = `{ getMdDesc $i/index.md }
+ }
+ if (test -f $i.html) {
+ # H1 is not reliable because htmlroff doesn't use it :(
+ #desc = `{ cat $i.html |sed 32q | grep '<[Hh]1>' |sed 's/<[Hh]1>(.*)(<\/[Hh]1>|$)/\1/;s/<[^>]*>//g;1q' }
+ # Pick the first line of body instead
+ desc = `{ /bin/sed -e '0,/<[Bb][Oo][Dd][Yy]/d;s/<[^>]*>//g;/^$/d' < $i.html >[2]/dev/null | sed 1q }
+ }
+ if (! ~ $desc '')
+ desc = ' - '$"desc
+ tit = `{basename $i|sed 's/_/ /g'}
+ echo '<li><a style="text-transform: capitalize" href="'$i'">'^$"tit^'</a>' $desc '</li>'
+ if (test -d $i)
+ @{ listDir $i }
+ }
+ }
+ echo '</ul>'
+}
+
+cd $sitedir
+listDir .
+
+%}
--- a/pub/feeds/rss20.tpl
+++ /dev/null
@@ -1,35 +1,0 @@
-Content-Type: text/xml; charset=utf-8
-
-<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
- <channel>
- <atom:link href="%('http://'$site^$REQUEST_URI%)" rel="self" type="application/rss+xml" />
- <title>%($siteTitle%)</title>
- <link>%($uri%)</link>
- <description>%($blogDesc%)</description>
- <language>en-us</language>
- <generator>Tom Duff's rc, and Kris Maglione's clever hackery</generator>
- <webMaster>[email protected] (Uriel)</webMaster>
-%{
- for(f in `{sortedBlogPostList $blogDirs}) {
- statpost $f
- # Hack to aproximate the last build date
- #(use the mdate from last posted item)
- # Commented out for now because maybe a wrong value is worse than no value
- #if(~ $#last_build_date 0) {
- #last_build_date='<lastBuildDate>'^$"mdate'</lastBuildDate>'
- #echo $last_build_date
- #}
-%}
- <item>
- <title>%($title%)</title>
- <author>%($by%)@noreply.cat-v.org (%($by%))</author>
- <link>%($uri%)</link>
- <guid isPermaLink="true">%($uri%)</guid>
- <pubDate>%($date%)</pubDate>
- <description><![CDATA[<pre>%($summary%)</pre>]]></description>
- </item>
-% }
-
- </channel>
-</rss>
--- a/pub/sitemap.tpl
+++ /dev/null
@@ -1,52 +1,0 @@
-<h1>Site map</h1>
-
-%{
-
-saveddf = $dirfilter
-
-fn getMdDesc {
- sed 's/^(.......................................................................................................[^ ]*).*$/\1/g; 1q' < $1
-}
-
-fn listDir {
- d=$1
- dirfilter = $saveddf
- blogDirs = ()
- if (test -f $d/_config)
- . $d/_config
-
- echo '<ul>'
-
- if (! ~ $#blogDirs 0 || ~ $1 blog Blog )
- echo ''
- if not {
-
- for ( i in `{ ls -d $d/*/ $d/*.md $d/*.html $d/*.txt >[2]/dev/null |sed $dirfilter^'/index$/d;' } ) {
- desc = ''
- if (test -f $i.md) {
- desc = `{ getMdDesc $i.md }
- }
- if (test -f $i/index.md) {
- desc = `{ getMdDesc $i/index.md }
- }
- if (test -f $i.html) {
- # H1 is not reliable because htmlroff doesn't use it :(
- #desc = `{ cat $i.html |sed 32q | grep '<[Hh]1>' |sed 's/<[Hh]1>(.*)(<\/[Hh]1>|$)/\1/;s/<[^>]*>//g;1q' }
- # Pick the first line of body instead
- desc = `{ /bin/sed -e '0,/<[Bb][Oo][Dd][Yy]/d;s/<[^>]*>//g;/^$/d' < $i.html >[2]/dev/null | sed 1q }
- }
- if (! ~ $desc '')
- desc = ' - '$"desc
- tit = `{basename $i|sed 's/_/ /g'}
- echo '<li><a style="text-transform: capitalize" href="'$i'">'^$"tit^'</a>' $desc '</li>'
- if (test -d $i)
- @{ listDir $i }
- }
- }
- echo '</ul>'
-}
-
-cd $sitedir
-listDir .
-
-%}