2012-10-07 08:23:31 -04:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Generates an RSS feed from Git commit messages
|
|
|
|
#
|
|
|
|
# Copyright (C) 2012 Mike Gerwitz
|
|
|
|
#
|
2012-10-07 11:22:49 -04:00
|
|
|
# This file is part of repo2html.
|
2012-10-07 08:23:31 -04:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# #
|
|
|
|
|
2012-10-08 22:19:55 -04:00
|
|
|
repotype="${1?Missing repository type}"
|
|
|
|
url="${2?Missing URL}"
|
2012-10-07 08:23:31 -04:00
|
|
|
count=10
|
|
|
|
|
|
|
|
# rss header
|
|
|
|
cat <<EOH
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
<rss version="2.0">
|
|
|
|
<channel>
|
|
|
|
<title>Mike Gerwitz's Thoughts and Ramblings</title>
|
|
|
|
<link>$url</link>
|
|
|
|
<description>
|
|
|
|
The miscellaneous thoughts and ramblings of a free software hacker
|
|
|
|
</description>
|
|
|
|
EOH
|
|
|
|
|
|
|
|
|
|
|
|
# output recent commits as entries (assuming no funny business in the output)
|
2012-10-08 22:19:55 -04:00
|
|
|
while read hash commit ts id subject; do
|
2012-10-11 00:48:51 -04:00
|
|
|
# ignore commits that begin with ':'
|
|
|
|
[[ "$subject" == :* ]] && {
|
|
|
|
echo "[RSS] Ignoring $commit: $subject" >&2
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2012-10-08 22:19:55 -04:00
|
|
|
echo "[RSS] Found $commit: $subject" >&2
|
2012-10-07 08:23:31 -04:00
|
|
|
|
|
|
|
# TODO: avoid HTML entities where browsers may decide not to render them (e.g.
|
|
|
|
# the title)
|
|
|
|
cat <<EOE
|
|
|
|
<item>
|
|
|
|
<title><![CDATA[$( ./msgfmt < <( echo "$subject"; echo ) )]]></title>
|
2012-10-08 22:50:39 -04:00
|
|
|
<link>$(
|
|
|
|
printf "%s/%s/%s.html" \
|
2012-10-09 18:08:51 -04:00
|
|
|
"${url/%\/}" "$( ./tsdate "$ts" %Y/%m )" "$id"
|
2012-10-08 22:50:39 -04:00
|
|
|
)
|
|
|
|
</link>
|
|
|
|
<pubDate>$( ./tsdate "$ts" %Y-%m-%d )</pubDate>
|
2012-10-07 08:23:31 -04:00
|
|
|
<description>
|
|
|
|
<![CDATA[
|
2012-10-08 22:19:55 -04:00
|
|
|
$( ./"$repotype"/commit2html "$commit" )
|
2012-10-07 08:23:31 -04:00
|
|
|
]]>
|
|
|
|
</description>
|
|
|
|
</item>
|
|
|
|
EOE
|
2012-10-08 22:19:55 -04:00
|
|
|
done
|
2012-10-07 08:23:31 -04:00
|
|
|
|
|
|
|
# footer
|
|
|
|
cat <<EOF
|
|
|
|
</channel>
|
|
|
|
</rss>
|
|
|
|
EOF
|