Files: f0c709532d3d86f2e3360b5d43577c65562665f9 / feed.sh
1145 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_ID:=$(cat site_id 2>&- || echo urn:uuid:$(uuidgen) | tee site_id)} |
15 | : ${FEED_ENTRIES:=15} |
16 | : ${FEED_WIDTH:=80} |
17 | |
18 | cat <<EOF |
19 | <?xml version="1.0" encoding="utf-8"?> |
20 | <feed xmlns="http://www.w3.org/2005/Atom"> |
21 | <title>$SITE_TITLE</title> |
22 | <link rel="alternate" type="text/html" href="$SITE_URL"/> |
23 | <link rel="self" type="application/rss+xml" href="${SITE_URL}feed.xml"/> |
24 | <updated>$(date --iso-8601=seconds | sed 's/..$/:&/')</updated> |
25 | <id>$SITE_ID</id> |
26 | |
27 | EOF |
28 | |
29 | content_delim=$(uuidgen) |
30 | |
31 | git log -$FEED_ENTRIES --stat=$FEED_WIDTH --format=format:"entry $content_delim |
32 | title %s |
33 | id %H |
34 | name %aN |
35 | email %aE |
36 | updated %ai |
37 | content $content_delim |
38 | commit %H |
39 | |
40 | %B |
41 | stat $content_delim" $@ | awk -f "$dir/xml.awk" -v site="$SITE_URL" |
42 | |
43 | cat <<EOF |
44 | </feed> |
45 | |
46 | EOF |
47 |
Built with git-ssb-web