git ssb

0+

cel / gitfeed



Tree: f0c709532d3d86f2e3360b5d43577c65562665f9

Files: f0c709532d3d86f2e3360b5d43577c65562665f9 / feed.sh

1145 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
7hash 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
18cat <<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
27EOF
28
29content_delim=$(uuidgen)
30
31git log -$FEED_ENTRIES --stat=$FEED_WIDTH --format=format:"entry $content_delim
32title %s
33id %H
34name %aN
35email %aE
36updated %ai
37content $content_delim
38commit %H
39
40%B
41stat $content_delim" $@ | awk -f "$dir/xml.awk" -v site="$SITE_URL"
42
43cat <<EOF
44 </feed>
45
46EOF
47

Built with git-ssb-web