Files: a14c063f83540c0e01a1dc609be8768cca9978f1 / feed.sh
1413 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 | cmd= |
8 | xslt_sheet= |
9 | for arg; do |
10 | case $cmd in |
11 | '') case "$arg" in |
12 | --xslt) cmd=xslt;; |
13 | xslt) xslt_sheet="$arg"; cmd=;; |
14 | esac;; |
15 | esac |
16 | done |
17 | |
18 | hash uuidgen >&2 || uuidgen() { |
19 | cat /proc/sys/kernel/random/uuid 2>&- ||\ # Linux |
20 | cat /compat/linux/proc/sys/kernel/random/uuid 2>&- ||\ # FreeBSD |
21 | python -c 'import uuid; print uuid.uuid1()' |
22 | } |
23 | |
24 | : ${SITE_TITLE:=My Cool Site} |
25 | : ${SITE_ID:=$(cat site_id 2>&- || echo urn:uuid:$(uuidgen) | tee site_id)} |
26 | : ${FEED_ENTRIES:=15} |
27 | : ${FEED_WIDTH:=80} |
28 | |
29 | echo '<?xml version="1.0" encoding="utf-8"?>' |
30 | if [ "$xslt_sheet" ]; then |
31 | echo '<?xml-stylesheet type="text/xsl" href="'$xslt_sheet'" version="1.0"?>' |
32 | fi |
33 | cat <<EOF |
34 | <feed xmlns="http://www.w3.org/2005/Atom"> |
35 | <title>$SITE_TITLE</title> |
36 | <link rel="alternate" type="text/html" href="$SITE_URL"/> |
37 | <link rel="self" type="application/rss+xml" href="${SITE_URL}feed.xml"/> |
38 | <updated>$(date --iso-8601=seconds | sed 's/..$/:&/')</updated> |
39 | <id>$SITE_ID</id> |
40 | |
41 | EOF |
42 | |
43 | content_delim=$(uuidgen) |
44 | |
45 | git log -$FEED_ENTRIES --stat=$FEED_WIDTH --format=format:"entry $content_delim |
46 | title %s |
47 | id %H |
48 | name %aN |
49 | email %aE |
50 | updated %ai |
51 | content $content_delim |
52 | commit %H |
53 | |
54 | %B |
55 | stat $content_delim" $@ | awk -f "$dir/xml.awk" -v site="$SITE_URL" |
56 | |
57 | cat <<EOF |
58 | </feed> |
59 | |
60 | EOF |
61 |
Built with git-ssb-web