summaryrefslogtreecommitdiff
path: root/makerss.sh
blob: 0709f42a53d54ddfa88d7333d5a8a26a4e57b97d (plain)
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
#!/bin/sh

[[ "$1" ]] && siteurl="http://${1}" || siteurl=""
[[ "$2" ]] && rssuri="${siteurl}/$2" || rssuri=""

items=`find . -name '*.txt' ! -name 'robots.txt' | sed 's/^\.//g' | sed 's/\.txt$//g'`

title=`head -n 1 index.txt`
cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns="http://purl.org/rss/1.0/">
	<channel rdf:about="${rssuri}">
		<title>${title}</title>
		<link>${siteurl}</link>
		<items>
			<rdf:Seq>
EOF

for item in $items; do
	echo "				<rdf:li rdf:resource=\"${siteurl}${item}\" />"
done

cat << EOF
			</rdf:Seq>
		</items>
	</channel>
EOF

for item in $items; do
	itemtxt=`echo ${item}.txt`
	title=`head -n 1 ./${itemtxt}`
	moddate=`ls -lc ./${item}.txt|awk '{print $6}'`
	content=`smu < ./${item}.txt`
	cat << EOF
	<item rdf:about="${siteurl}${item}">
		<title>${title}</title>
		<link>${siteurl}${item}</link>
		<dc:date>${moddate}</dc:date>
		<content:encoded><![CDATA[${content}]]></content:encoded>
	</item>
EOF
done;

echo "</rdf:RDF>"