From 89a5535257a66d98aa8acb2bbc4faecdb2a09e30 Mon Sep 17 00:00:00 2001 From: uriel Date: Wed, 30 May 2007 11:52:05 +0200 Subject: [PATCH] Various small fixes and code improvements, mostly for the blog code --- bin/controller.rc | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/bin/controller.rc b/bin/controller.rc index a43bdf8..34861ec 100755 --- a/bin/controller.rc +++ b/bin/controller.rc @@ -1,7 +1,7 @@ #!/usr/local/plan9/bin/rc path=(. ./bin $PLAN9/bin /bin/ /usr/bin) -ifs='/' { args = `{ echo -n $REQUEST_URI | sed -e 's/[^a-zA-Z0-9_\-\/]//g' -e 's/\?.*//' } } +ifs='/' { args = `{ echo -n $REQUEST_URI | sed -e 's/[^a-zA-Z0-9_+\-\/]//g' -e 's/\?.*//' } } args=`{echo $args | tr -d ' '} cd .. @@ -52,7 +52,7 @@ fn menu { ls -F $1 | grep -v '/_[^/]*' | sed -e 's,^./,,' -e 's,\.md$,,' | awk ' BEGIN { print "" } - /^([a-zA-Z0-9_\-]+[\/*]?)+$/ && ! /index$/ { + /^([a-zA-Z0-9+_\-]+[\/*]?)+$/ && ! /index$/ { isdir = match($0, "/$") sub("[*/]$", "") # The '*' makes no sense to me @@ -91,29 +91,33 @@ fn gensidebar { # Body fn genbody { - if ( test -f $body ) { cat $body | markdown.pl } + if ( test -f $body ) { + cat $body | markdown.pl + } if not { - - if ( ~ $body */index.md ) { - echo '

' `{basename `{basename -d $body}}'

' - echo '' + if ( ! ~ $blog 'yes' ) { + if ( ~ $body */index.md ) { + echo '

' `{basename `{basename -d $body}}'

' + echo '' + } + if not { template.awk inc/404.tpl | rc } } - if not { template.awk inc/404.tpl | rc } } - ld = `{basename -d $body }^/_log/ - if ( test -d $ld ) { - for ( i in `{ ls $ld/ | grep '.*\.md$'| sort -n } ) { - t=`{basename $i|sed -e 's/[0-9\-]*_//' -e 's,\.md$,,' -e 's/_/ /' } - d=`{ls -l $i |awk '{print $7 " " $8 " " $9}'} - u=`{ls -l $i |awk '{print $4 }'} - echo '

' $"t 'by '$"u' - '$"d'

' - cat $i | markdown.pl - echo '
' - } - } + if ( ~ $blog 'yes' && ~ $body */index.md ) { + if ( ! ~ $#blogTitle 0 ) + echo '

'$"blogTitle'

' + for ( i in `{ ls $blogDirs | grep '[0-9]+.*\.md$'| sort -r -t. +1 } ) { + t=`{basename $i|sed -e 's/^[0-9\-]*_//' -e 's,\.md$,,' -e 's/_/ /g' } + du=`{ls -l $i } + #echo '

' $"t 'by '$"$du(4)' (Last mod: '$du(7) $du(8) $du(9)')

' + echo '## ' $"t '*(By '$du(4)' Last mod: ' ( $du(7 8 9) ) ')*' + cat $i + echo + } | markdown.pl + } } template.awk $headers | rc