shithub: werc

Download patch

ref: e9d149ec59a8201bcb7036e207b8a184612e7a19
parent: 188a226bf5d56ae7f3fdca2d75576fe437e0dd19
author: uriel <[email protected]>
date: Wed Dec 24 07:19:06 EST 2008

New blagh app

diff: cannot open b/apps/blagh//null: file does not exist: 'b/apps/blagh//null'
--- /dev/null
+++ b/apps/blagh/app.rc
@@ -1,0 +1,19 @@
+fn blagh_test {
+    ! ~ $#blaghDirs 0 # && test -d / `{echo '-a -d '^blaghDirs}
+}
+
+fn blagh_setup {
+    app_body_handler='blagh_body'
+}
+
+fn blagh_body {
+    posts=`{ls  -F $blaghDirs^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/ | sed -n 's,/\./,/|/,; /\/$/p' | sort -r '-t|' +1 | sed 's,/+\|/+,/,'}
+    for(p in $posts)
+        show_post $p | $formatter 
+}
+
+fn show_post {
+    bds=$blaghDirs^'|'
+    l=`{echo $1 |sed 's,'$bds'XXX,,g'}
+    sed '1s|.*|[&]('$l') -'^$l'|' < $1/index.md  
+}
--- /dev/null
+++ b/apps/blagh/convert.rc
@@ -1,0 +1,20 @@
+#!/usr/bin/env rc
+
+path=($PLAN9/bin/ $path)
+
+for(p in *.md) {
+    echo
+    echo '========================='
+    echo p $p
+    pp=`{echo $p | sed 's/^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])[\-_](.*).md$/\1 \2 \3 \4/' }
+    echo pp $pp
+
+    d=$pp(1)^'/'^$pp(2)^'/'^$pp(3)^'/'^$pp(4)^'/'
+
+    mkdir -p $d
+    echo $pp(4) | sed -e 's/^[0-9]_//; s/_/ /g;' > $d/index.md
+    echo '=================================' >> $d/index.md
+    echo >> $d/index.md
+    cat $p >> $d/index.md
+
+}