git ssb

0+

cel / gitfeed



Tree: c11155c722b1a469d80bf04f861a06f47d220f6b

Files: c11155c722b1a469d80bf04f861a06f47d220f6b / feed.sh

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

Built with git-ssb-web