summaryrefslogtreecommitdiff
path: root/makerss.sh
blob: a63c412011b70dcbd0f089db61b5324529d309bc (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
#!/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' ! -path '*/publications/2*' | sed -e 's/^\.//g' -e 's/\.txt$//g'`
pubs=`find ./publications -name '2*.txt' | sed -e 's/^\.//g' -e '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 bibo: <http://purl.org/ontology/bibo/>.
@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 $pubs; 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;

sed -e '/^@/d' -e "s|http://njw.me.uk|${siteurl}|g" < publications/index.ttl