21 @ oct
RSS feed generated thanks to a simple shell script
I've written a simple CGI shell script that generates a RSS feed. It is based on the filesystem.
Here is the code:
1 #!/bin/sh
2 DIR=.
3 PRIOFILES="Resume.md Curriculum_Vitae.md index.md"
4 URLENCODE=/usr/local/bin/urlencode.sh
5
6 PRIO_index.md="0.8"
7 PRIO_Curriculum_Vitae.md="0.7"
8 PRIO_Resume.md="0.6"
9
10
11 echo 'Content-Type: text/xml'
12 echo ''
13 echo '<?xml version="1.0" encoding="UTF-8"?>'
14 echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
16 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'
17
18 for file in $(find $DIR -name \*.md)
19 do
20
21 file=$(echo $file | sed -n 's/\.\///p')
22
23 prio=0.5
24
25 for priofile in $PRIOFILES;
26 do
27 if [ "$priofile" = "$file" ]; then
28 prio="0.6"
29 [ "$PRIO_${file}" -ne "" ] && prio=$PRIO_${file}
30 fi
31 done
32
33 lastmod=$(stat -f %Sm -t %Y-%m-%d $file)
34 file=$(echo $file | sed 's/\.md/\.html/' | $URLENCODE | sed 's/%2F/\//g')
35
36 echo '<url>'
37 echo '<loc>http://zecrazytux.net/'$file'</loc>'
38 echo '<lastmod>'$lastmod'</lastmod>'
39 echo '<priority>'$prio'</priority>'
40 echo '</url>'
41
42 done
43
44 echo '</urlset>'
2 DIR=.
3 PRIOFILES="Resume.md Curriculum_Vitae.md index.md"
4 URLENCODE=/usr/local/bin/urlencode.sh
5
6 PRIO_index.md="0.8"
7 PRIO_Curriculum_Vitae.md="0.7"
8 PRIO_Resume.md="0.6"
9
10
11 echo 'Content-Type: text/xml'
12 echo ''
13 echo '<?xml version="1.0" encoding="UTF-8"?>'
14 echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
16 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'
17
18 for file in $(find $DIR -name \*.md)
19 do
20
21 file=$(echo $file | sed -n 's/\.\///p')
22
23 prio=0.5
24
25 for priofile in $PRIOFILES;
26 do
27 if [ "$priofile" = "$file" ]; then
28 prio="0.6"
29 [ "$PRIO_${file}" -ne "" ] && prio=$PRIO_${file}
30 fi
31 done
32
33 lastmod=$(stat -f %Sm -t %Y-%m-%d $file)
34 file=$(echo $file | sed 's/\.md/\.html/' | $URLENCODE | sed 's/%2F/\//g')
35
36 echo '<url>'
37 echo '<loc>http://zecrazytux.net/'$file'</loc>'
38 echo '<lastmod>'$lastmod'</lastmod>'
39 echo '<priority>'$prio'</priority>'
40 echo '</url>'
41
42 done
43
44 echo '</urlset>'