git ssb

0+

cel / gitfeed



Tree: a979b4bd9ced3058c1add1818513541e6955cc66

Files: a979b4bd9ced3058c1add1818513541e6955cc66 / feed.sh

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

Built with git-ssb-web