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