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:
parent
e75232761a
commit
889e844d73
3 changed files with 10 additions and 17 deletions
|
|
@ -13,7 +13,7 @@ fn blagh_init {
|
||||||
status='Use default handler'
|
status='Use default handler'
|
||||||
|
|
||||||
if not if(~ $req_path */index */) {
|
if not if(~ $req_path */index */) {
|
||||||
app_body_handler='blagh_body'
|
handler_body_main=blagh_body
|
||||||
u=$blagh_uri'index'
|
u=$blagh_uri'index'
|
||||||
extraHeaders=$"extraHeaders ^ \
|
extraHeaders=$"extraHeaders ^ \
|
||||||
'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" />
|
'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" />
|
||||||
|
|
|
||||||
|
|
@ -279,19 +279,10 @@ fn make_blog_post {
|
||||||
# App framework
|
# App framework
|
||||||
|
|
||||||
fn init_apps {
|
fn init_apps {
|
||||||
found=()
|
|
||||||
for(a in $enabled_apps) {
|
for(a in $enabled_apps) {
|
||||||
. ./apps/$a/app.rc
|
. ./apps/$a/app.rc
|
||||||
if($a^'_init')
|
$a^'_init'
|
||||||
found=yes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~ $#found 1 # Set status
|
|
||||||
}
|
|
||||||
|
|
||||||
fn app_handler {
|
|
||||||
if(! ~ $#app_body_handler 0)
|
|
||||||
$app_body_handler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
14
bin/werc.rc
14
bin/werc.rc
|
|
@ -103,17 +103,19 @@ fn setup_handlers {
|
||||||
init_apps
|
init_apps
|
||||||
|
|
||||||
# Dir listing
|
# Dir listing
|
||||||
if(~ $#handler_body_main 0 && ~ $local_path */index)
|
if(! ~ $#handler_body_main 0)
|
||||||
set_handler dir_listing_handler $local_path
|
{ } # 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!
|
# 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$//' }
|
perm_redirect `{ echo $req_path|sed 's/.html$//' }
|
||||||
# Fallback static file handler
|
# 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
|
static_file $local_path
|
||||||
# File not found
|
# File not found
|
||||||
if not if(~ $#handler_body_main 0) {
|
if not {
|
||||||
set_handler tpl_handler `{get_lib_file 404.tpl}
|
handler_body_main=(tpl_handler `{get_lib_file 404.tpl})
|
||||||
dprint 'NOT FOUND: '$SERVER_NAME^$"REQUEST_URI^' - '^$"HTTP_REFERER^' - '^$"HTTP_USER_AGENT
|
dprint 'NOT FOUND: '$SERVER_NAME^$"REQUEST_URI^' - '^$"HTTP_REFERER^' - '^$"HTTP_USER_AGENT
|
||||||
echo 'Status: 404 Not Found'
|
echo 'Status: 404 Not Found'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue