stagit-breadcrumb (1086B)
1 #!/bin/rc 2 # 3 # This script is very slow. 4 # Hence the option to use find's -newer. 5 # A file can be created before stagit runs, 6 # and this script will only modify files created after. 7 # 8 # stagit will not modify files in the commit/ dir once created 9 # It does however recreate everything at HEAD. 10 # This isn't ideal. 11 # 12 # Most of the time taken in this script is most likely NOT cpu time. 13 # It may be a good idea to run the main loop portion of this script in parallel. 14 15 wwwdir = /var/www/htdocs/src.hhvn.uk 16 newer = $1 17 cd $wwwdir 18 19 if (!~ $newer ()) { 20 fargs = (-newer $1) 21 } 22 23 fn breadcrumb { 24 printf %s '<h1>' 25 www/generate/breadcrumb $* | sed 's~&~\\\\\&~g' 26 printf %s '</h1>' 27 } 28 29 files = `$nl{find . $fargs -type f -name '*.html'} 30 estatus = 0 31 for (f in $files) { 32 printf %s 'BREADCRUMB ' ^ $f ^ '... ' 33 breadcrumb = `''{breadcrumb $f hhvn.uk src} 34 awk -v breadcrumb=$breadcrumb '{ sub(/<h1>.*<\/h1>/, breadcrumb); sub(/<span class="desc">Repositories<\/span>/, breadcrumb) }1' < $f > $f.awk 35 if (~ $status 0) { 36 echo success 37 mv $f.awk $f 38 } else { 39 rm $f.awk 40 estatus = $status 41 } 42 }