Fix blah to work with new handler interfaces.

Remove outdated app-framework code.
Clanup some of the fallback handler setting code.
This commit is contained in:
Uriel 2009-01-11 04:40:40 +01:00
parent e75232761a
commit 889e844d73
3 changed files with 10 additions and 17 deletions

View file

@ -13,7 +13,7 @@ fn blagh_init {
status='Use default handler'
if not if(~ $req_path */index */) {
app_body_handler='blagh_body'
handler_body_main=blagh_body
u=$blagh_uri'index'
extraHeaders=$"extraHeaders ^ \
'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" />

View file

@ -279,19 +279,10 @@ fn make_blog_post {
# App framework
fn init_apps {
found=()
for(a in $enabled_apps) {
. ./apps/$a/app.rc
if($a^'_init')
found=yes
$a^'_init'
}
~ $#found 1 # Set status
}
fn app_handler {
if(! ~ $#app_body_handler 0)
$app_body_handler
}

View file

@ -103,17 +103,19 @@ fn setup_handlers {
init_apps
# Dir listing
if(~ $#handler_body_main 0 && ~ $local_path */index)
set_handler dir_listing_handler $local_path
if(! ~ $#handler_body_main 0)
{ } # Pass
if not if(~ $local_path */index)
handler_body_main=(dir_listing_handler $local_path)
# Explicit .html urls, the web server might handle this first!
if not if(~ $#handler_body_main 0 && ~ $local_path *.html && test -f $local_path)
if not if(~ $local_path *.html && test -f $local_path)
perm_redirect `{ echo $req_path|sed 's/.html$//' }
# Fallback static file handler
if not if(~ $#handler_body_main 0 && test -f $local_path)
if not if(test -f $local_path)
static_file $local_path
# File not found
if not if(~ $#handler_body_main 0) {
set_handler tpl_handler `{get_lib_file 404.tpl}
if not {
handler_body_main=(tpl_handler `{get_lib_file 404.tpl})
dprint 'NOT FOUND: '$SERVER_NAME^$"REQUEST_URI^' - '^$"HTTP_REFERER^' - '^$"HTTP_USER_AGENT
echo 'Status: 404 Not Found'
}