Various small fixes and code improvements, mostly for the blog code
This commit is contained in:
parent
321eda21b6
commit
89a5535257
@ -1,7 +1,7 @@
|
|||||||
#!/usr/local/plan9/bin/rc
|
#!/usr/local/plan9/bin/rc
|
||||||
|
|
||||||
path=(. ./bin $PLAN9/bin /bin/ /usr/bin)
|
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 '
|
args=`{echo $args | tr -d '
|
||||||
'}
|
'}
|
||||||
cd ..
|
cd ..
|
||||||
@ -52,7 +52,7 @@ fn menu {
|
|||||||
ls -F $1 | grep -v '/_[^/]*' | sed -e 's,^./,,' -e 's,\.md$,,' | awk '
|
ls -F $1 | grep -v '/_[^/]*' | sed -e 's,^./,,' -e 's,\.md$,,' | awk '
|
||||||
BEGIN { print "<ul class=\"sidebar\">" }
|
BEGIN { print "<ul class=\"sidebar\">" }
|
||||||
END { print "</ul>" }
|
END { print "</ul>" }
|
||||||
/^([a-zA-Z0-9_\-]+[\/*]?)+$/ && ! /index$/ {
|
/^([a-zA-Z0-9+_\-]+[\/*]?)+$/ && ! /index$/ {
|
||||||
isdir = match($0, "/$")
|
isdir = match($0, "/$")
|
||||||
sub("[*/]$", "") # The '*' makes no sense to me
|
sub("[*/]$", "") # The '*' makes no sense to me
|
||||||
|
|
||||||
@ -91,29 +91,33 @@ fn gensidebar {
|
|||||||
|
|
||||||
# Body
|
# Body
|
||||||
fn genbody {
|
fn genbody {
|
||||||
if ( test -f $body ) { cat $body | markdown.pl }
|
if ( test -f $body ) {
|
||||||
|
cat $body | markdown.pl
|
||||||
|
}
|
||||||
if not {
|
if not {
|
||||||
|
if ( ! ~ $blog 'yes' ) {
|
||||||
if ( ~ $body */index.md ) {
|
if ( ~ $body */index.md ) {
|
||||||
echo '<h1>' `{basename `{basename -d $body}}'</h1>'
|
echo '<h1>' `{basename `{basename -d $body}}'</h1>'
|
||||||
echo '<ul>'
|
echo '<ul>'
|
||||||
ls -F `{ basename -d $body } | sed -e 's,^./,,' -e 's,\.md$,,' -e 's,^'$sitedir'/([^/]*[/]?)+,<li><a href="\1">\1</a></li>,'
|
ls -F `{ basename -d $body } |grep -v '(^.|/_[^/]*$)' | sed -e 's,^./,,' -e 's,\.md$,,' -e 's,^'$sitedir'/([^/]*[/]?)+,<li><a href="\1">\1</a></li>,'
|
||||||
echo '</ul>'
|
echo '</ul>'
|
||||||
|
}
|
||||||
|
if not { template.awk inc/404.tpl | rc }
|
||||||
}
|
}
|
||||||
if not { template.awk inc/404.tpl | rc }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ld = `{basename -d $body }^/_log/
|
if ( ~ $blog 'yes' && ~ $body */index.md ) {
|
||||||
if ( test -d $ld ) {
|
if ( ! ~ $#blogTitle 0 )
|
||||||
for ( i in `{ ls $ld/ | grep '.*\.md$'| sort -n } ) {
|
echo '<h1>'$"blogTitle'</h1>'
|
||||||
t=`{basename $i|sed -e 's/[0-9\-]*_//' -e 's,\.md$,,' -e 's/_/ /' }
|
for ( i in `{ ls $blogDirs | grep '[0-9]+.*\.md$'| sort -r -t. +1 } ) {
|
||||||
d=`{ls -l $i |awk '{print $7 " " $8 " " $9}'}
|
t=`{basename $i|sed -e 's/^[0-9\-]*_//' -e 's,\.md$,,' -e 's/_/ /g' }
|
||||||
u=`{ls -l $i |awk '{print $4 }'}
|
du=`{ls -l $i }
|
||||||
echo '<h2>' $"t '<small style="font-size: 70%">by '$"u' - '$"d'</small></h2>'
|
#echo '<h2>' $"t '<small style="font-size: 70%">by '$"$du(4)' (Last mod: '$du(7) $du(8) $du(9)')</small></h2>'
|
||||||
cat $i | markdown.pl
|
echo '## ' $"t '*(By '$du(4)' Last mod: ' ( $du(7 8 9) ) ')*'
|
||||||
echo '<hr />'
|
cat $i
|
||||||
}
|
echo
|
||||||
}
|
} | markdown.pl
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template.awk $headers | rc
|
template.awk $headers | rc
|
||||||
|
Loading…
Reference in New Issue
Block a user