shithub: werc

Download patch

ref: a9c977708a758653bea09ecb976262371d891496
parent: 615ddef295ac8497fdf05fe40c6e44ceaf78f1ff
author: uriel <uriel@engel.se.cat-v.org>
date: Sun Oct 26 01:29:42 EDT 2008

Use explicitly relative paths when sourcing now that . is not in path
Add comment about perf issues with menu()

--- /dev/null
+++ b/bin/fproc_cache.rc
@@ -1,0 +1,18 @@
+#!/usr/bin/env rc
+#. 9.rc # Not really needed when calling from werc, only would be needed if you use fproc_cache.rc standalone
+
+proc=$1
+
+tmpfile=/tmp/fmttmp.$pid
+score=`{{tee $tmpfile || exit 1} | sha1sum}
+
+cachedir=/tmp/fproc_cache/$score
+mkdir -p $cachedir >[2]/dev/null
+
+if(test -f $cachedir/$proc)
+    cat $cachedir/$proc
+if not {
+    $proc < $tmpfile | tee $cachedir/$pid
+    mv $cachedir/$pid $cachedir/$proc
+}
+rm $tmpfile >[2]/dev/null
--- a/bin/md_cache.rc
+++ /dev/null
@@ -1,17 +1,0 @@
-#!/usr/bin/env rc
-. 9.rc
-
-cachedir=/tmp/md_cache
-mkdir -p $cachedir >[2]/dev/null
-
-tmpfile=$cachedir/mdtmp.$pid
-score=`{{tee $tmpfile || exit 1} | sha1sum}
-cachefile=$cachedir/$score
-
-if(test -f $cachefile)
-    cat $cachefile
-if not {
-    markdown.pl < $tmpfile | tee $cachefile.$pid
-    mv $cachefile.$pid $cachefile
-}
-rm $tmpfile >[2]/dev/null
--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -30,6 +30,8 @@
 }
 
 # Sidebar 
+# PERF: menu takes ~30% of werc's runtime, even for top level pages.
+# Maybe a combination of du -a/find|sort could let us avoid the recursive awk calls... 
 fn menu {
     ls -F $1 | sed $dirfilter | awk -F/ '
     BEGIN { print "<ul class=\"side-bar\">" }
@@ -234,10 +236,10 @@
 for(i in siteTitle siteSubTitle pageTitle extraHeaders)
     $i = ''
 
-. etc/initrc
+. ./etc/initrc
 
 if(test -f etc/initrc.local)
-    . etc/initrc.local
+    . ./etc/initrc.local
 
 
 # Parse request URL
@@ -275,7 +277,7 @@
     }
 
     if (test -f $fpath/_werc/config)
-        . $fpath/_werc/config
+        . ./$fpath/_werc/config
 
     if (~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log)
         inBlog = 'yes'
--- a/etc/initrc
+++ b/etc/initrc
@@ -12,7 +12,7 @@
 plan9port=$PLAN9
 
 # Path, make sure the plan9port /bin directory is included before /bin
-path=($plan9port/bin/ ./bin/ /bin/ /usr/bin/)
+path=($plan9port/bin/ ./bin/ /bin/ /usr/bin/ ./bin/contrib/)
 
 # Directory where your site(s) live ($site here is your domain name, eg., example.com)
 sitedir=sites/$site
@@ -22,7 +22,7 @@
 # configuration markdown.pl, that caches output)
 # Note that some werc components assume a markdown-like formatter, but all
 # major functionality should should be formatter agnostic.
-formatter=(fproc_cache.rc bin/contrib/markdown.pl)
+formatter=(fproc_cache.rc markdown.pl)
 
 # Enable debugging, to disable set to ()
 debug=true