Various changes:
- New generic http_redirect function, and two shortcuts for 303: post_redirect and 301: perm_redirect - Allow get_lib_file to take a default value, and change where master_template is set. - Fix bugs in auth code and properly trim ^M from post data. - Other cosmetic/minor improvements.
This commit is contained in:
parent
4b43af43ff
commit
316d4c4e57
2 changed files with 33 additions and 23 deletions
17
bin/werc.rc
17
bin/werc.rc
|
|
@ -4,15 +4,6 @@ cd ..
|
|||
|
||||
forbidden_uri_chars='[^a-zA-Z0-9_+\-\/\.]'
|
||||
|
||||
fn get_lib_file {
|
||||
if(test -f $sitedir/_werc/lib/$1)
|
||||
echo -n $sitedir/_werc/lib/$1
|
||||
if not if(! ~ $#masterSite 0 && test -f $sitesdir/$masterSite/_werc/lib/$1)
|
||||
echo -n $sitesdir/$masterSite/_werc/lib/$1
|
||||
if not if(test -f lib/$1)
|
||||
echo -n lib/$1
|
||||
}
|
||||
|
||||
# Expected input: ls -F style, $sitedir/path/to/files/
|
||||
# <ls -F+x><symlink hack><Useless?><hiden files >
|
||||
dirfilter='s/\*$//; s,/+\./+,/,g; s,^\./,,; /\/[._][^\/]/d; /'^$forbidden_uri_chars^'/d; /^\/(robots|sitemap)\.txt$|\/index\.(md|html|txt|tpl)$/d; /_werc\/?$/d; '
|
||||
|
|
@ -132,19 +123,19 @@ fn run_handler { $*(1) $*(2-) }
|
|||
path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin)
|
||||
|
||||
headers=lib/headers.tpl
|
||||
master_template=default_master.tpl
|
||||
res_tail='</body></html>'
|
||||
ll_add handlers_bar_left nav_tree
|
||||
werc_apps=( apps/* )
|
||||
werc_root=`{pwd}
|
||||
sitesdir=sites
|
||||
for(i in siteTitle siteSubTitle pageTitle extraHeaders)
|
||||
$i = ''
|
||||
|
||||
# TODO: Per-req variables should move after initrc loading.
|
||||
site=$SERVER_NAME
|
||||
base_url=http://$site/
|
||||
sitesdir=sites
|
||||
sitedir=$sitesdir/$site
|
||||
master_template=`{get_lib_file default_master.tpl}
|
||||
current_date_time=`{date}
|
||||
|
||||
. ./etc/initrc
|
||||
|
|
@ -219,7 +210,7 @@ if not
|
|||
setup_handlers
|
||||
|
||||
if(! ~ $#debug 0)
|
||||
dprint ' '$"SERVER_NAME^$"REQUEST_URI' - '$"HTTP_USER_AGENT' - '$"REQUEST_METHOD' - '$"handler_body_main
|
||||
dprint ' '$"SERVER_NAME^$"REQUEST_URI' - '$"HTTP_USER_AGENT' - '$"REQUEST_METHOD' - '$"handler_body_main - $"master_template
|
||||
|
||||
template $headers `{get_lib_file $master_template} | awk_buffer
|
||||
template $headers $master_template | awk_buffer
|
||||
echo $res_tail
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue