-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss.sh
executable file
·57 lines (51 loc) · 1.03 KB
/
rss.sh
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
55
56
#!/usr/bin/env bash
set -eu
src=$(dirname "$0")
if [ -f $src/vars.sh ]; then
source $src/vars.sh
else
echo "vars.sh: not found"
exit
fi
cd $1
cat << EOF > $RSSFILE
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>$TITLE</title>
<link>$BASEURL</link>
<description>$DESCRIPTION</description>
<lastBuildDate>$DATE</lastBuildDate>
EOF
for item in $(find -type f); do
name=${item##*/}
path=${item#\./}
category=$(echo $path | cut -f1 -d/)
modified=$(date -Rr $item)
if [[ "$item" == *"/."* ]]; then
echo "skipping hidden: $name"
continue
fi
if [[ " ${IGNORED_FILES[@]} " =~ " $name " ]]; then
echo "skipping ignored: $name"
continue
fi
cat << EOF >> $RSSFILE
<item>
<title>$name</title>
<link>$BASEURL/$path</link>
<pubDate>$modified</pubDate>
EOF
if [[ "$name" != "$category" ]]; then
cat << EOF >> $RSSFILE
<category>$category</category>
EOF
fi
cat << EOF >> $RSSFILE
</item>
EOF
done
cat << EOF >> $RSSFILE
</channel>
</rss>
EOF