ref: 4f55ee44dd0b402ff44b6ac47a088b334d6c0301
parent: 31bbd02bc477e884f96bef9abc6cd6381fd159c5
author: phil9 <[email protected]>
date: Thu Feb 4 05:14:51 EST 2021
implement RSS feed for latest changes log page now shows a link to get an RSS feed for the last 10 commits
--- /dev/null
+++ b/feed
@@ -1,0 +1,77 @@
+#!/bin/rc -e
+
+. /sys/lib/shithub/common.rc
+
+fn rssitem {
+ puser=$1
+ prepo=$2
+ phash=$3
+
+ d=`{pwd}
+ guid='http://shithub.us/git/'$puser/$prepo/$phash'/commit.html'
+ message=`{htcat /mnt/git/object/$phash/msg | sed 1q}
+ description=`''{htcat /mnt/git/object/$phash/msg}
+ date=`{date -m `{mtime /mnt/git/object/$phash/msg |awk '{print $1}'}}
+ author=`"{htcat /mnt/git/object/$phash/author |awk '{print $1}'}
+ echo ' <item>
+ <guid>'$"guid'</guid>
+ <pubDate>'$"date'</pubDate>
+ <title>'$"message'</title>
+ <author>'$"author'</author>
+ <link>'$guid'</link>
+ <description><![CDATA[ <pre>'$description'</pre> ]]></description>
+ </item>'
+ cd $d
+}
+
+cd $1
+shift
+
+rfork ne
+nl='
+'
+
+gituser=$1
+repo=$2
+refname=$3
+
+repons $gituser $repo
+repodir=/mnt/$repo/.git
+if(! ref=`{resolveref $refname}){
+ echo '<b>invalid ref '$refname'</b>'
+ exit
+}
+
+if(test -f /mnt/git/$ref/hash)
+ hash=`{cat /mnt/git/$ref/hash}
+if not
+ hash=$ref
+
+echo '<?xml version="1.0" encoding="utf-8" ?>
+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
+ <channel>
+ <atom:link href="http://shithub.us/git/'$gituser/$repo/'HEAD/log.rss" rel="self" type="application/rss+xml" />
+ <title>'$gituser/$repo' git log</title>
+ <link>http://shithub.us/git/'$gituser/$repo/'HEAD/log.html</link>
+ <description>shithub git/log for repository '$gituser/$repo'</description>
+ <lastBuildDate>'`"{date -m}'</lastBuildDate>
+ <language>en-us</language>
+'
+
+if(! test -d /mnt/git/$ref/tree){
+ echo ' </channel>
+ </rss>
+ '
+ exit
+}
+cd /mnt/git/$ref/tree
+commithash=`{cat /mnt/git/HEAD/hash | sed 1q}
+count=()
+while (! ~ $#commithash 0 && ! ~ $#count 10) {
+ count=($count 1)
+ rssitem $gituser $repo $commithash
+ commithash=`{cat /mnt/git/object/$commithash/parent | sed 1q}
+}
+echo ' </channel>
+ </rss>
+'
--- a/gitrules
+++ b/gitrules
@@ -1,9 +1,10 @@
-/repos.html /bin/shithub /usr/git list
-/([^'/]+)/([^'/]+)/([^'/]+)/info.html /bin/shithub /usr/git info '\1' '\2' '\3'
-/([^'/]+)/([^'/]+)/([^'/]+)/files.html /bin/shithub /usr/git files '\1' '\2' '\3'
-/([^'/]+)/([^'/]+)/([^'/]+)/snap.tar.gz /bin/shithub /usr/git tar '\1' '\2' '\3'
-/([^'/]+)/([^'/]+)/([^'/]+)/(([^']+)/)?f.html /bin/shithub /usr/git view '\1' '\2' '\3' '\5'
-/([^'/]+)/([^'/]+)/([^'/]+)/(([^']+)/)?raw /bin/shithub /usr/git viewraw '\1' '\2' '\3' '\5'
-/([^'/]+)/([^'/]+)/([^'/]+)/log.html /bin/shithub /usr/git log '\1' '\2' '\3'
-/([^'/]+)/([^'/]+)/([^'/]+)/commit.html /bin/shithub /usr/git show '\1' '\2' '\3'
-/([^'/]+)/([^'/]+)/([^'/]+)/patch /bin/shithub /usr/git patch '\1' '\2' '\3'
+/repos.html /bin/shithub/list /usr/git
+/([^'/]+)/([^'/]+)/([^'/]+)/info.html /bin/shithub/info /usr/git '\1' '\2' '\3'
+/([^'/]+)/([^'/]+)/([^'/]+)/files.html /bin/shithub/files /usr/git '\1' '\2' '\3'
+/([^'/]+)/([^'/]+)/([^'/]+)/snap.tar.gz /bin/shithub/tar /usr/git '\1' '\2' '\3'
+/([^'/]+)/([^'/]+)/([^'/]+)/(([^']+)/)?f.html /bin/shithub/view /usr/git '\1' '\2' '\3' '\5'
+/([^'/]+)/([^'/]+)/([^'/]+)/(([^']+)/)?raw /bin/shithub/viewraw /usr/git '\1' '\2' '\3' '\5'
+/([^'/]+)/([^'/]+)/([^'/]+)/log.html /bin/shithub/log /usr/git '\1' '\2' '\3'
+/([^'/]+)/([^'/]+)/([^'/]+)/commit.html /bin/shithub/show /usr/git '\1' '\2' '\3'
+/([^'/]+)/([^'/]+)/([^'/]+)/patch /bin/shithub/patch /usr/git '\1' '\2' '\3'
+/([^'/]+)/([^'/]+)/([^'/]+)/feed.rss /bin/shithub/feed /usr/git '\1' '\2' '\3'
--- a/log
+++ b/log
@@ -35,7 +35,10 @@
exit
}
cd /mnt/git/$ref/tree
-echo ' <p>'
+echo ' <p>
+ <a href="/git/'$gituser/$repo'/HEAD/feed.rss">RSS feed</a>
+ </p>
+ <p>'
shortlog $gituser $repo $ref 100
echo ' </p>'
echo ' </body>
--- a/mkfile
+++ b/mkfile
@@ -10,7 +10,8 @@
viewraw\
log\
show\
- patch
+ patch\
+ feed
LIBFILES=\
common.rc