yiyus.info
view map.tpl @ 13:c5f13ef66e4c
img updates
| author | yiyus |
|---|---|
| date | Wed May 18 10:15:44 2011 +0200 (12 months ago ago) |
| parents | |
| children |
1 % cat `{get_lib_file about.inc}
2 %{
3 tmpfile=/tmp/werc_sitemap_$pid.txt
4 saveddf=$dirfilter
6 fn get_md_title {
7 sed 's/^(................................................................[^ ]*).*$/\1/g; 1q' < $1
8 }
10 fn get_html_title {
11 # H1 is not reliable because htmlroff doesn't use it :(
12 #desc=`{cat $1 | sed 32q | grep '<[Hh]1>' | sed 's/<[Hh]1>(.*)(<\/[Hh]1>|$)/\1/;s/<[^>]*>//g;1q'}
13 # Pick the first line of body instead
14 desc=`{sed -n '/<[Bb][Oo][Dd][Yy]/,/./s/(<[^>]*>|$)//gp' < $1}
15 if(~ $#desc 0)
16 desc=`{sed 's/<[^>]*>//g; 1q' < $1}
17 }
19 fn get_file_title {
21 if(~ $1 */) {
22 if(test -f $1/index.md)
23 get_md_title $1/index.md
24 if not if(test -f $1/index.html)
25 get_html_title $1/index.html
26 }
27 if not if(~ $1 *.md)
28 get_md_title $1
29 if not if(~ $1 *.html)
30 get_html_title $1
31 if not
32 echo ''
33 }
35 fn listDir {
36 d=$1
37 dirfilter=$saveddf
38 if(test -f $d/_werc/config)
39 . ./$d/_werc/config
41 if(~ $#perm_redir_to 0) {
42 echo '<ul class="sitemap-list">'
44 for(i in `{ls -dF $d^*/ $d^*.md $d^*.html $d^*.txt >[2]/dev/null | sed $dirfilter}) {
45 desc=`{get_file_title $i}
46 u=`{echo $i|sed 's!'$sitedir'!!; '$dirclean's!/index$!/!; '}
47 if(! ~ $#desc 0 && ! ~ $desc '')
48 desc=' - '$"desc
49 n=`{echo /$u|sed 's/_/ /g; s,.*/([^/]+)/?$,\1,'}
50 echo '<li><a href="'$base_url$u'">'^$"n^'</a>' $"desc '</li>'
51 echo $base_url^$u >> $tmpfile
52 if(test -d $i)
53 @{ listDir $i }
54 }
55 echo '</ul>'
56 }
57 }
59 fltr_cache listDir $sitedir/
61 if(test -s $tmpfile)
62 mv $tmpfile $sitedir/sitemap.txt &
64 %}
65 <br>
67 </div>