git ssb

0+

cel / gitfeed



Tree: 3077b00cc9073a00c865eee83fdc91b2f77acacb

Files: 3077b00cc9073a00c865eee83fdc91b2f77acacb / feed.sh

1156 bytesRaw
1#!/bin/sh
2
3test -z "$SITE_URL" && echo 'Define the SITE_URL env variable' >&2 && exit 1
4
5hash uuidgen >&2 || uuidgen() {
6 cat /proc/sys/kernel/random/uuid 2>&- ||\ # Linux
7 cat /compat/linux/proc/sys/kernel/random/uuid 2>&- ||\ # FreeBSD
8 python -c 'import uuid; print uuid.uuid1()'
9}
10
11: ${SITE_TITLE:=My Cool Site}
12: ${SITE_AUTHOR:=$(grep $(id -u) /etc/passwd | cut -d: -f 5 | cut -d, -f1)}
13: ${SITE_ID:=$(cat site_id 2>&- || echo urn:uuid:$(uuidgen) | tee site_id)}
14: ${FEED_ENTRIES:=15}
15: ${FEED_WIDTH:=80}
16
17cat <<EOF
18<?xml version="1.0" encoding="utf-8"?>
19 <feed xmlns="http://www.w3.org/2005/Atom">
20 <title>$SITE_TITLE</title>
21 <link rel="alternate" type="text/html" href="$SITE_URL"/>
22 <link rel="self" type="application/rss+xml" href="${SITE_URL}feed.xml"/>
23 <updated>$(date --iso-8601=seconds | sed 's/..$/:&/')</updated>
24 <id>$SITE_ID</id>
25
26EOF
27
28content_delim=$(uuidgen)
29
30git log -$FEED_ENTRIES --stat=$FEED_WIDTH --format=format:"entry $content_delim
31title %s
32id %H
33name %aN
34email %aE
35updated %ai
36content $content_delim
37commit %H
38
39%B
40stat $content_delim" $@ | awk -f xml.awk -v site="$SITE_URL"
41
42cat <<EOF
43 </feed>
44
45EOF
46

Built with git-ssb-web