File: make_sitemap

package info (click to toggle)
pyke 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,196 kB
  • ctags: 1,159
  • sloc: python: 12,866; sh: 446; xml: 203; sql: 39; makefile: 5
file content (54 lines) | stat: -rwxr-xr-x 1,327 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash

# make_sitemap

STATUS_FILE=/tmp/make_sitemap.$$

set -e
set -o pipefail

hg status | sed -n '\, doc/source/,s,, ,p' | sort > $STATUS_FILE

trap "rm $STATUS_FILE" 0

echo '<?xml version="1.0" encoding="UTF-8"?>'
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'

find . -name '*.txt' | sort |
while read f
do
    if [ "$f" != ./template.txt ]
    then
	f_clean=`expr "$f" : '\./\(.*\)'`
        code=`sed -n '\,^\(.\) '"$f_clean"'$,s,,\1,p' "$STATUS_FILE" | tr -d '\n'`
	#echo "$f_clean: >$code<" >&2
        if [ "$code" != R ]
        then
            html=`expr "$f_clean" : '\(.*\)\.txt'`.html
            url="http://pyke.sourceforge.net/$html"
            if [ "$code" ]
            then
                date=`date --iso-8601 -u`
                #echo "$f_clean: using system date: $date" >&2
            else
                date=`sed -n '1s/.*\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\).*/\1/p' "$f"`
                if [ ! "$date" ]
                then
                    echo "$f: missing date" >&2
                    exit 1
                fi
                #echo "$f_clean: using hg date: $date" >&2
            fi
            cat <<-!
		 <url>
		  <loc>$url</loc>
		  <lastmod>$date</lastmod>
		  <changefreq>monthly</changefreq>
		 </url>
		!
        fi
    fi
done

echo '</urlset>'