git ssb

0+

cel / gitfeed



Tree: 77402cf1fed7ee86eb3be5c747df3e0429652d98

Files: 77402cf1fed7ee86eb3be5c747df3e0429652d98 / feed.sh

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

Built with git-ssb-web