Files: a979b4bd9ced3058c1add1818513541e6955cc66 / feed.sh
1221 bytesRaw
1 | |
2 | |
3 | test -z "$SITE_URL" && echo 'Define the SITE_URL env variable' >&2 && exit 1 |
4 | |
5 | dir=$(dirname $([ -L $0 ] && readlink -f $0 || echo $0)) |
6 | |
7 | hash uuidgen >&2 || uuidgen() { |
8 | cat /proc/sys/kernel/random/uuid 2>&- ||\ # Linux |
9 | cat /compat/linux/proc/sys/kernel/random/uuid 2>&- ||\ # FreeBSD |
10 | python -c 'import uuid; print uuid.uuid1()' |
11 | } |
12 | |
13 | : ${SITE_TITLE:=My Cool Site} |
14 | : ${SITE_AUTHOR:=$(grep $(id -u) /etc/passwd | cut -d: -f 5 | cut -d, -f1)} |
15 | : ${SITE_ID:=$(cat site_id 2>&- || echo urn:uuid:$(uuidgen) | tee site_id)} |
16 | : ${FEED_ENTRIES:=15} |
17 | : ${FEED_WIDTH:=80} |
18 | |
19 | cat <<EOF |
20 | <?xml version="1.0" encoding="utf-8"?> |
21 | <feed xmlns="http://www.w3.org/2005/Atom"> |
22 | <title>$SITE_TITLE</title> |
23 | <link rel="alternate" type="text/html" href="$SITE_URL"/> |
24 | <link rel="self" type="application/rss+xml" href="${SITE_URL}feed.xml"/> |
25 | <updated>$(date --iso-8601=seconds | sed 's/..$/:&/')</updated> |
26 | <id>$SITE_ID</id> |
27 | |
28 | EOF |
29 | |
30 | content_delim=$(uuidgen) |
31 | |
32 | git log -$FEED_ENTRIES --stat=$FEED_WIDTH --format=format:"entry $content_delim |
33 | title %s |
34 | id %H |
35 | name %aN |
36 | email %aE |
37 | updated %ai |
38 | content $content_delim |
39 | commit %H |
40 | |
41 | %B |
42 | stat $content_delim" $@ | awk -f "$dir/xml.awk" -v site="$SITE_URL" |
43 | |
44 | cat <<EOF |
45 | </feed> |
46 | |
47 | EOF |
48 |
Built with git-ssb-web