swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit fba68f47c79cddfb22927ba799e5cdee2a43b009
parent 73d0cb7634b2d15d9e778f3c3886b2065e0f87b1
Author: uriel@engel.se.cat-v.org <unknown>
Date:   Sun, 26 Oct 2008 05:29:42 +0100

Use explicitly relative paths when sourcing now that . is not in path
Add comment about perf issues with menu()
Diffstat:
Abin/fproc_cache.rc | 18++++++++++++++++++
Dbin/md_cache.rc | 17-----------------
Mbin/werc.rc | 8+++++---
Metc/initrc | 4++--
4 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/bin/fproc_cache.rc b/bin/fproc_cache.rc @@ -0,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 diff --git a/bin/md_cache.rc b/bin/md_cache.rc @@ -1,17 +0,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 diff --git a/bin/werc.rc b/bin/werc.rc @@ -30,6 +30,8 @@ fn hide_paths { } # 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 @@ baseuri=http://$site/ 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 @@ for (i in ('' $args)) { } if (test -f $fpath/_werc/config) - . $fpath/_werc/config + . ./$fpath/_werc/config if (~ $#blogDirs 0 && ~ $#inBlog 0 && ~ $i [Bb]log) inBlog = 'yes' diff --git 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 @@ sitedir=sites/$site # 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