Make coding style more consistent.

This commit is contained in:
Uriel 2008-12-20 06:32:37 +01:00
parent 2e62c824cc
commit 17225d69b4
2 changed files with 104 additions and 116 deletions

View file

@ -215,7 +215,6 @@ fn auth_user {
# Blog stuff # Blog stuff
fn make_blog_post { fn make_blog_post {
bdir=$1 bdir=$1
btitle=$2 btitle=$2
@ -280,7 +279,6 @@ fn select_apps {
fn app_handler { fn app_handler {
$app_body_handler $app_body_handler
} }

View file

@ -94,7 +94,7 @@ fn dir_listing_handler {
d=`{basename -d $1} d=`{basename -d $1}
echo $d|sed 's,.*//,,g; s,/$,,; s,/, / ,g; s,.*,<h1 class="dir-list-head">&</h1> <ul class="dir-list">,' echo $d|sed 's,.*//,,g; s,/$,,; s,/, / ,g; s,.*,<h1 class="dir-list-head">&</h1> <ul class="dir-list">,'
# Symlinks suck: '/.' forces ls to list the linked dir if $d is a symlink. # Symlinks suck: '/.' forces ls to list the linked dir if $d is a symlink.
ls -F $d/. | sed -e 's/\*$//; '^$dirfilter' s,.*/([^/]+/?)$,<li><a href="\1">\1</a></li>,' ls -F $d/. | sed 's/\*$//; '^$dirfilter' s,.*/([^/]+/?)$,<li><a href="\1">\1</a></li>,'
echo '</ul>' echo '</ul>'
} }
@ -154,21 +154,18 @@ fn select_handler {
# Rss feeds. TODO: we should check that the request is for a real blog dir # Rss feeds. TODO: we should check that the request is for a real blog dir
if not if(~ $REQUEST_URI */index.rss */index.atom) { if not if(~ $REQUEST_URI */index.rss */index.atom) {
response_format=raw
uri=`{echo $uri | sed 's/index.(rss|atom)$//'} uri=`{echo $uri | sed 's/index.(rss|atom)$//'}
if(~ $#blogDirs 0) if(~ $#blogDirs 0)
blogDirs=$sitedir^'/'$uri blogDirs=$sitedir^'/'$uri
uri=$baseuri$"uri uri=$baseuri$"uri
if (~ $REQUEST_URI */index.rss) { if(~ $REQUEST_URI */index.rss)
master_template=feeds/rss20.tpl master_template=feeds/rss20.tpl
} if not if(~ $REQUEST_URI */index.atom)
if not if (~ $REQUEST_URI */index.atom) {
master_template=feeds/atom.tpl master_template=feeds/atom.tpl
} }
response_format=raw
}
# Blog handler # Blog handler
if not if(~ $body */[bB]log/index */[bB]log//index || ! ~ $#blogDirs 0) { if not if(~ $body */[bB]log/index */[bB]log//index || ! ~ $#blogDirs 0) {
if(~ $#blogDirs 0) if(~ $#blogDirs 0)
@ -177,9 +174,7 @@ fn select_handler {
u=`{cleanname $baseuri^`{basename -d '/'^$uri}|sed 's,:/,://,'} # Sed recovers '/' in 'http:/' stripped by cleanname u=`{cleanname $baseuri^`{basename -d '/'^$uri}|sed 's,:/,://,'} # Sed recovers '/' in 'http:/' stripped by cleanname
extraHeaders=$"extraHeaders ^ \ extraHeaders=$"extraHeaders ^ \
'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'/index.rss" /> '<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'/index.rss" />
<link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'/index.atom" /> <link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'/index.atom" />'
'
set_handler tpl_handler lib/feeds/html.tpl set_handler tpl_handler lib/feeds/html.tpl
} }
@ -207,11 +202,7 @@ fn select_handler {
} }
fn genbody { $handler $handler_args }
fn genbody {
$handler $handler_args
}
# Careful, the proper p9p path might not be set until initrc.local is sourced # Careful, the proper p9p path might not be set until initrc.local is sourced
path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin) path=(. $PLAN9/bin ./bin/ /bin/ /usr/bin)
@ -257,6 +248,7 @@ if not {
fpath=$sitedir fpath=$sitedir
for(i in ('' $args)) { for(i in ('' $args)) {
# TODO We can build a list of paths here that can be used in sidebar, instead of iterating args twice
fpath=$fpath/$i fpath=$fpath/$i
# We don't want blog settings to cascade into posts, note that we are inBlog instead # We don't want blog settings to cascade into posts, note that we are inBlog instead
if(! ~ $#blogDirs 0 && ! ~ $req_path */index.rss */index.atom */[bB]log */[bB]log/) { if(! ~ $#blogDirs 0 && ! ~ $req_path */index.rss */index.atom */[bB]log */[bB]log/) {
@ -277,7 +269,6 @@ if (~ $#redirectPermanent 1)
if not if(~ $#redirectPermanent 2 && {echo $SERVER_NAME^$REQUEST_URI|grep -s $redirectPermanent(1) }) { if not if(~ $#redirectPermanent 2 && {echo $SERVER_NAME^$REQUEST_URI|grep -s $redirectPermanent(1) }) {
# Experimental regexp sub-based redirect, probably should find a nicer interface # Experimental regexp sub-based redirect, probably should find a nicer interface
# For now only used at sites/harmful.cat-v.org/software/OO_programming/_werc/config
to=`{echo $SERVER_NAME^$REQUEST_URI|sed 's@'^$redirectPermanent(1)^'@'^$redirectPermanent(2)^'@'} to=`{echo $SERVER_NAME^$REQUEST_URI|sed 's@'^$redirectPermanent(1)^'@'^$redirectPermanent(2)^'@'}
if(! ~ $to $REQUEST_URI) if(! ~ $to $REQUEST_URI)
perm_redirect $to perm_redirect $to
@ -309,6 +300,5 @@ if(~ $response_format html) {
template $headers $master_template | awk_buffer template $headers $master_template | awk_buffer
echo '</body></html>' echo '</body></html>'
} }
if not if (~ $response_format raw) { if not if(~ $response_format raw)
template < $master_template template < $master_template
}