ref: b22c5073d4e7f3ea1729c9f6d6f04e18a57c57bd
parent: 2b31fa7840de07746fee6eb1eaaa97e6274d9e26
author: uriel <[email protected]>
date: Sat Dec 20 08:20:31 EST 2008
Sitemap improvemnts and cleanups: - Avoid nedless tests - Replace reference to /bin/sed with faster, simpler and probably more correct plan9 sed call. - Move inline html styling to style.css - Various code cleanups, bring source style in line with other werc source.
--- a/lib/sitemap.tpl
+++ b/lib/sitemap.tpl
@@ -3,7 +3,7 @@
%{
tmpfile=/tmp/werc_sitemap_$pid.txt
echo '' > $tmpfile
-saveddf = $dirfilter
+saveddf=$dirfilter
fn getMdDesc {
sed 's/^(.......................................................................................................[^ ]*).*$/\1/g; 1q' < $1
@@ -11,44 +11,49 @@
fn listDir {
d=$1
- dirfilter = $saveddf
- blogDirs = ()
- if (test -f $d/_werc/config)
- . $d/_werc/config
+ if(~ $#d 0)
+ d=''
+ dirfilter=$saveddf
+ blogDirs=()
+ if(test -f $d/_werc/config)
+ . ./$d/_werc/config
- echo '<ul>'
+ echo '<ul class="sitemap-list">'
# Don't hide blog dirs for now
- #if (! ~ $#blogDirs 0 || ~ $1 */blog */Blog )
+ #if(! ~ $#blogDirs 0 || ~ $1 */blog */Blog)
# echo ''
#if not
if(! ~ $#redirectPermanent 1)
{
- for ( i in `{ ls -d $d/*/ $d/*.md $d/*.html $d/*.txt >[2]/dev/null |sed $dirfilter} ) {
- desc = ''
- if (test -f $i.md) {
- desc = `{ getMdDesc $i.md }
- }
- if (test -f $i/index.md) {
- desc = `{ getMdDesc $i/index.md }
- }
- if (test -f $i.html) {
+ for(i in `{ls -dF $d^*/ $d^*.md $d^*.html $d^*.txt >[2]/dev/null | sed $dirfilter}) {
+ desc=''
+ if(test -f $i.md)
+ desc=`{getMdDesc $i.md}
+ if not if(~ $i */ && test -f $i/index.md)
+ desc=`{getMdDesc $i/index.md}
+ if not if(test -f $i.html) {
# H1 is not reliable because htmlroff doesn't use it :(
- #desc = `{ cat $i.html |sed 32q | grep '<[Hh]1>' |sed 's/<[Hh]1>(.*)(<\/[Hh]1>|$)/\1/;s/<[^>]*>//g;1q' }
+ #desc = `{cat $i.html |sed 32q | grep '<[Hh]1>' |sed 's/<[Hh]1>(.*)(<\/[Hh]1>|$)/\1/;s/<[^>]*>//g;1q'}
# Pick the first line of body instead
- desc = `{ /bin/sed -e '0,/<[Bb][Oo][Dd][Yy]/d;s/<[^>]*>//g;/^$/d' < $i.html >[2]/dev/null | sed 1q }
+ desc=`{sed -n '/<[Bb][Oo][Dd][Yy]/,/./s/(<[^>]*>|$)//gp' < $i.html}
+ if(~ $#desc 0)
+ desc=`{sed 's/<[^>]*>//g; 1q' < $i.html}
+ #desc=`{/bin/sed -e '0,/<[Bb][Oo][Dd][Yy]/d;s/<[^>]*>//g;/^$/d' < $i.html >[2]/dev/null | sed 1q}
}
- if (! ~ $desc '')
- desc = ' - '$"desc
- tit = `{basename $i|sed 's/_/ /g'}
- echo '<li><a style="text-transform: capitalize" href="/'$i'">'^$"tit^'</a>' $desc '</li>'
+
+ if(! ~ $#desc 0 && ! ~ $desc '')
+ desc=' - '$"desc
+ tit=`{echo /$i|sed 's/_/ /g; s,.*/([^/]+)/?$,\1,'}
+ echo '<li><a href="/'$i'">'^$"tit^'</a>' $"desc '</li>'
echo -n $baseuri^$i >> $tmpfile
- if (test -d $i) {
+ if(test -d $i) {
echo / >> $tmpfile
@{ listDir $i }
}
- if not echo >> $tmpfile
+ if not
+ echo >> $tmpfile
}
}
echo '</ul>'
@@ -55,7 +60,7 @@
}
cd $sitedir
-listDir .
+listDir ''
cp $tmpfile ./sitemap.txt
rm $tmpfile
--- a/pub/style/style.css
+++ b/pub/style/style.css
@@ -369,3 +369,6 @@
text-transform: capitalize;
font-weight: bold;
}
+ul.sitemap-list a {
+ text-transform: capitalize;
+}