Fix coding style

This commit is contained in:
Uriel 2008-06-28 06:07:59 +02:00
parent d8e656839b
commit 7e735ba4a7

View file

@ -30,7 +30,7 @@ dirfilter = '/\/[._]/d; s,^\.\.*/,.,; s,\.md$,,; s,\.html,,;'
# Sidebar # Sidebar
fn menu { fn menu {
lsArgs = ( '-F' ) lsArgs = ('-F')
# XXX will not work properly for $#blogDirs > 1 and matching is hackish # XXX will not work properly for $#blogDirs > 1 and matching is hackish
if ( (! ~ $#inBlog 0) || ! ~ $#blogDirs 0 && (~ $blogDirs^/ *$1 *$1/) ) { # Work in progress XXX if ( (! ~ $#inBlog 0) || ! ~ $#blogDirs 0 && (~ $blogDirs^/ *$1 *$1/) ) { # Work in progress XXX
lsArgs = ($lsArgs -r) lsArgs = ($lsArgs -r)
@ -88,27 +88,27 @@ fn blogTitle {
# Body # Body
fn genbody { fn genbody {
if ( test -f $body.md ) { if (test -f $body.md) {
if ( ! ~ $#inBlog 0 ) if (! ~ $#inBlog 0)
blogTitle $body.md | $formatter blogTitle $body.md | $formatter
$formatter < $body.md $formatter < $body.md
} }
if not if ( test -f $body.tpl ) if not if (test -f $body.tpl)
template.awk $body.tpl | rc $rcargs template.awk $body.tpl | rc $rcargs
if not if ( test -f $body.txt ) { if not if (test -f $body.txt) {
echo '<pre>' echo '<pre>'
# XXX Insering a blank line between lines in input is good for fortunes.txt, but probably not for other .txt files # XXX Insering a blank line between lines in input is good for fortunes.txt, but probably not for other .txt files
# XXX Words are not broken, even if they are way beyond 82 chars long # XXX Words are not broken, even if they are way beyond 82 chars long
cat $body.txt |sed 's/$/\n/g; s/</\&gt;/g; s/>/\&lt;/g' |fmt -l 82 -j cat $body.txt |sed 's/$/\n/g; s/</\&gt;/g; s/>/\&lt;/g' |fmt -l 82 -j
echo '</pre>' echo '</pre>'
} }
if not if ( test -f $body.html ) if not if (test -f $body.html)
cat $body.html | /bin/sed '0,/<[Bb][Oo][Dd][Yy][^>]*>/d; /<\/[Bb][Oo][Dd][Yy]>/,$d' cat $body.html | /bin/sed '0,/<[Bb][Oo][Dd][Yy][^>]*>/d; /<\/[Bb][Oo][Dd][Yy]>/,$d'
if not if (~ $body *.html && test -f $body ) if not if (~ $body *.html && test -f $body)
cat $body | /bin/sed -i '0,/<body[^>]*>/d;/<\/body>/,$d' # This branch is never taken? cat $body | /bin/sed -i '0,/<body[^>]*>/d;/<\/body>/,$d' # This branch is never taken?
if not if ( ~ $body */[bB]log/index */[bB]log//index && ~ $#blogDirs 0 ) if not if (~ $body */[bB]log/index */[bB]log//index && ~ $#blogDirs 0)
blogDirs = `{basename -d $body} blogDirs = `{basename -d $body}
if not if ( test -f pub/^$reqpath^.tpl ) if not if (test -f pub/^$reqpath^.tpl)
template.awk pub/^$reqpath^.tpl | rc $rcargs template.awk pub/^$reqpath^.tpl | rc $rcargs
if not if(~ $body */index && ~ $#blogDirs 0) { if not if(~ $body */index && ~ $#blogDirs 0) {
echo '<h1 style="text-transform: capitalize;">' `{basename -d $body|sed -e 's,.*//,,g' -e 's,/$,,' -e 's,/, / ,g' } '</h1>' echo '<h1 style="text-transform: capitalize;">' `{basename -d $body|sed -e 's,.*//,,g' -e 's,/$,,' -e 's,/, / ,g' } '</h1>'
@ -122,10 +122,10 @@ fn genbody {
} }
if(! ~ $#blogDirs 0) { if(! ~ $#blogDirs 0) {
if ( ! ~ $blogTitle '' ) if (! ~ $blogTitle '')
echo '<h1>'$"blogTitle'</h1>' echo '<h1>'$"blogTitle'</h1>'
echo '<div style="text-align:right">(<a href="index.rss">rss feed</a>)</div>' echo '<div style="text-align:right">(<a href="index.rss">rss feed</a>)</div>'
for ( f in `{ sortedBlogPostList $blogDirs } ) { for (f in `{ sortedBlogPostList $blogDirs }) {
#title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' } #title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
#du=`{ls -l $f} #du=`{ls -l $f}
#echo '##' $title '*('By $du(4) Last mod: $du(7 8 9) ')*' #echo '##' $title '*('By $du(4) Last mod: $du(7 8 9) ')*'
@ -147,18 +147,18 @@ if (! ~ $args '') {
} }
fpath=$sitedir fpath=$sitedir
for ( i in ('' $args) ) { for (i in ('' $args)) {
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 && ! ~ $body */index.rss */[bB]log */[bB]log/ ) { if (! ~ $#blogDirs 0 && ! ~ $body */index.rss */[bB]log */[bB]log/) {
inBlog = $blogDirs inBlog = $blogDirs
blogDirs = () blogDirs = ()
} }
if ( test -f $fpath/_config ) if (test -f $fpath/_config)
. $fpath/_config . $fpath/_config
if ( ~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log ) if (~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log)
inBlog = 'yes' inBlog = 'yes'
} }
@ -214,7 +214,7 @@ if(! ~ $REQUEST_URI */index.rss) {
} }
# RSS # RSS
if ( ~ $body */[bB]log/index.rss */[bB]log//index.rss && ~ $#blogDirs 0 ) if (~ $body */[bB]log/index.rss */[bB]log//index.rss && ~ $#blogDirs 0)
blogDirs = `{basename -d $body} blogDirs = `{basename -d $body}