summaryrefslogtreecommitdiff
path: root/makerss.sh
blob: d98ac66d90650ef9a2834b6eee518ec619255bfa (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
#!/bin/sh
# See COPYING file for copyright, license and warranty details.

[[ "$1" ]] && siteurl="$1" || siteurl=""
[[ "$2" ]] && creator="$2" || creator=""

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

title=`head -n 1 index.txt`
cat << EOF
@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rss:  <http://purl.org/rss/1.0/>.
@prefix dc:   <http://purl.org/dc/elements/1.1/>.
@prefix cc:   <http://creativecommons.org/ns#>.

<>  a rss:channel;
    rss:title "${title}";
    rss:link <${siteurl}>;
    dc:creator <${creator}>;
    cc:license <http://creativecommons.org/licenses/by-sa/3.0/>;
    rss:items [ a rdf:Seq;
EOF

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

echo "    ]."

for item in $items; do
    title=`head -n 1 ./${item}.txt`
    moddate=`ls -lc --time-style=+%Y-%m-%d ./${item}.txt|awk '{print $6}'`
    link="${siteurl}${item}"
    cat << EOF

<${link}> a rss:item;
    rss:title "${title}";
    rss:link <${link}>;
    dc:date "${moddate}";
    dc:creator <${creator}>;
    cc:license <http://creativecommons.org/licenses/by-sa/3.0/>.
EOF
done;