git ssb

0+

cel / gitfeed



Tree: a14c063f83540c0e01a1dc609be8768cca9978f1

Files: a14c063f83540c0e01a1dc609be8768cca9978f1 / feed.sh

1413 bytesRaw
1#!/bin/sh
2
3test -z "$SITE_URL" && echo 'Define the SITE_URL env variable' >&2 && exit 1
4
5dir=$(dirname $([ -L $0 ] && readlink -f $0 || echo $0))
6
7cmd=
8xslt_sheet=
9for arg; do
10 case $cmd in
11 '') case "$arg" in
12 --xslt) cmd=xslt;;
13 xslt) xslt_sheet="$arg"; cmd=;;
14 esac;;
15 esac
16done
17
18hash 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
29echo '<?xml version="1.0" encoding="utf-8"?>'
30if [ "$xslt_sheet" ]; then
31 echo '<?xml-stylesheet type="text/xsl" href="'$xslt_sheet'" version="1.0"?>'
32fi
33cat <<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
41EOF
42
43content_delim=$(uuidgen)
44
45git log -$FEED_ENTRIES --stat=$FEED_WIDTH --format=format:"entry $content_delim
46title %s
47id %H
48name %aN
49email %aE
50updated %ai
51content $content_delim
52commit %H
53
54%B
55stat $content_delim" $@ | awk -f "$dir/xml.awk" -v site="$SITE_URL"
56
57cat <<EOF
58 </feed>
59
60EOF
61

Built with git-ssb-web