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.
This commit is contained in:
Uriel 2008-09-24 20:21:32 +02:00
parent de1d5b1e54
commit 83a10c526a
6 changed files with 45 additions and 18 deletions

View file

@ -15,14 +15,34 @@ Location: '^$1^'
exit exit
} }
fn get_inc_file { fn get_lib_file {
wantedfile = $1 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 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 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 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! # 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,,; ' 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 { fn hide_paths {
for(i in $*) { for(i in $*) {
dirfilter = $dirfilter^'/^'$i'$/d; ' dirfilter = $dirfilter^'/^'$i'$/d; '
@ -139,7 +159,7 @@ fn dir_listing_handler {
} }
fn 404_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 { fn blog_dir_handler {
@ -202,8 +222,8 @@ dprint $body
blogDirs = `{basename -d $body} blogDirs = `{basename -d $body}
# Global tpl (eg sitemap.tpl) # Global tpl (eg sitemap.tpl)
if not if (test -f pub/^$uri^.tpl) if not if (test -f lib/^$uri^.tpl)
set_handler tpl_handler pub/^$uri^.tpl set_handler tpl_handler lib/^$uri^.tpl
if not if (test -f $body.txt) if not if (test -f $body.txt)
set_handler txt_handler $body.txt set_handler txt_handler $body.txt
@ -234,8 +254,8 @@ fn genbody {
path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin) path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin)
site=$SERVER_NAME site=$SERVER_NAME
headers=inc/headers.tpl headers=lib/headers.tpl
template=_default master_template=default_master.tpl
sidebar=sidebar sidebar=sidebar
baseuri=http://$site/ baseuri=http://$site/
for(i in siteTitle siteSubTitle pageTitle extraHeaders) for(i in siteTitle siteSubTitle pageTitle extraHeaders)
@ -280,6 +300,8 @@ for (i in ('' $args)) {
if (test -f $fpath/_config) if (test -f $fpath/_config)
. $fpath/_config . $fpath/_config
if (test -f $fpath/_werc/config)
. $fpath/_werc/config
if (~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log) if (~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log)
inBlog = 'yes' inBlog = 'yes'
@ -304,7 +326,12 @@ if not
pageTitle=$"pageTitle^' | '^$"siteTitle^' '^$"siteSubTitle pageTitle=$"pageTitle^' | '^$"siteTitle^' '^$"siteSubTitle
# Template/body selection # 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 body=$sitedir/$body
rssuri=$uri rssuri=$uri
@ -341,7 +368,7 @@ fn template {
} }
if(! ~ $REQUEST_URI */index.rss) { if(! ~ $REQUEST_URI */index.rss) {
cat $headers $template | template cat $headers $master_template | template
echo '</body></html>' echo '</body></html>'
exit exit
} }
@ -376,4 +403,4 @@ fn statpost {
} }
} }
cat pub/feeds/rss20.tpl | template cat lib/feeds/rss20.tpl | template

View file

@ -23,7 +23,7 @@ formatter=md_cache
# Enable debugging, to disable set to () # Enable debugging, to disable set to ()
debug=true debug=true
# Default site variables (Should be set on the _config file of each site or master site) # Default site variables, must be set in initrc.local or _werc/config, only siteTitle is required.
masterSite=cat-v.org #masterSite=cat-v.org # Not required!
siteTitle='cat-v' #siteTitle='cat-v'
siteSubTitle='Considered harmful' #siteSubTitle='Considered harmful'

View file

@ -25,7 +25,7 @@ Content-Type: text/html
<link rel="stylesheet" href="/_style.css" type="text/css" media="screen" title="default" /> <link rel="stylesheet" href="/_style.css" type="text/css" media="screen" title="default" />
% } % }
% h = `{ get_inc_file headers.inc} % h = `{ get_lib_file headers.inc}
% if(! ~ $#h 0) % if(! ~ $#h 0)
% cat $h % cat $h