[m-rev.] for review: add RSS feed to Mercury site

Ian MacLarty maclarty at csse.unimelb.edu.au
Mon Feb 9 17:07:56 AEDT 2009


For review by anyone.

Estimated hours taken: 1

Add RSS feed to Mercury site.

Makefile:
Makefile.common:
	Add rules to build and install the rss.xml file.

rss.php3:
	Build the RSS feed from the news database.

include/functions.inc:
	Add a function to format a news item as an RSS
	item.

include/index.inc:
	Add a link to the RSS feed from the home page.

news/newsdb.inc:
	Mention the new feature in the news.

Index: Makefile
===================================================================
RCS file: /home/mercury1/repository/w3/Makefile,v
retrieving revision 1.19
diff -u -r1.19 Makefile
--- Makefile	18 Feb 2008 01:14:40 -0000	1.19
+++ Makefile	9 Feb 2009 04:23:48 -0000
@@ -18,6 +18,8 @@
 	contributions.html	\
 	search.html
 
+XML=    rss.xml
+
 DIRS=contact download htdig information mailing-lists tutorial
 ROOT=.
 
Index: Makefile.common
===================================================================
RCS file: /home/mercury1/repository/w3/Makefile.common,v
retrieving revision 1.20
diff -u -r1.20 Makefile.common
--- Makefile.common	6 Jan 2009 06:16:32 -0000	1.20
+++ Makefile.common	9 Feb 2009 05:28:29 -0000
@@ -27,6 +27,7 @@
 vpath %.inc $(ROOT)/news
 
 $(HTML): %.html: %.php3 %.inc globals.inc menubar.inc template.inc functions.inc
+$(XML): %.xml: %.php3 functions.inc
 
 #-----------------------------------------------------------------------------#
 
@@ -34,7 +35,7 @@
 
 
 .PHONY: html
-html: $(HTML)
+html: $(HTML) $(XML)
 ifdef DIRS
 	for dir in $(DIRS); 				\
 	do 						\
@@ -61,6 +62,9 @@
 ifdef HTML
 	$(CP) $(HTML) $(INSTALL_WEBDIR)/
 endif
+ifdef XML
+	$(CP) $(XML) $(INSTALL_WEBDIR)/
+endif
 ifdef DIRS
 	for dir in $(DIRS);						\
 	do				        			\
@@ -95,5 +99,8 @@
 %.html: %.php3
 	$(PHP3) $< > $@
 
+%.xml: %.php3
+	$(PHP3) $< > $@
+
 #-----------------------------------------------------------------------------#
 #-----------------------------------------------------------------------------#
Index: rss.php3
===================================================================
RCS file: rss.php3
diff -N rss.php3
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ rss.php3	9 Feb 2009 04:44:10 -0000
@@ -0,0 +1,18 @@
+<? echo "<?xml version=\"1.0\"?>\n" ?>
+<rss version="2.0">
+<channel>
+  <title>The Mercury Project</title>
+  <link>http://www.mercury.csse.unimelb.edu.au/</link>
+  <description>News from the Mercury programming language project.</description>
+<? 
+
+include "include/functions.inc";
+include "news/newsdb.inc";
+
+while ( (list($date, $newsitem) = each($newsdb))) {
+	rssitem($date, $newsitem);
+}
+
+?>
+</channel>
+</rss>
Index: include/functions.inc
===================================================================
RCS file: /home/mercury1/repository/w3/include/functions.inc,v
retrieving revision 1.4
diff -u -r1.4 functions.inc
--- include/functions.inc	6 Oct 2000 03:27:15 -0000	1.4
+++ include/functions.inc	9 Feb 2009 05:16:43 -0000
@@ -17,6 +17,20 @@
 	echo "</td></tr>";
 }
 
+function rssitem($date, $item) {
+
+	list($title, $news) = $item;
+	list($day, $month, $year) = split(" ",$date);
+	$month = substr($month, 0, 3);
+	$news = htmlspecialchars($news);
+
+	echo "<item>\n";
+	echo "<title>$title</title>\n";
+	echo "<description>$news</description>\n";
+	echo "<pubDate>$day $month $year 00:00 +1000</pubDate>\n";
+	echo "</item>\n";
+}
+
 function reportitem($date, $item) {
 	global $root;
 
Index: include/index.inc
===================================================================
RCS file: /home/mercury1/repository/w3/include/index.inc,v
retrieving revision 1.5
diff -u -r1.5 index.inc
--- include/index.inc	13 Nov 1998 04:21:47 -0000	1.5
+++ include/index.inc	9 Feb 2009 05:58:50 -0000
@@ -15,3 +15,7 @@
 For older news items, see the
 (<a href="<? echo $root ?>/news.html">complete news archive</a>).
 
+<p>
+
+News is also available as an RSS feed at
+<a href=\"http://www.mercury.csse.unimelb.edu.au/rss.xml\">http://www.mercury.csse.unimelb.edu.au/rss.xml</a>.
Index: news/newsdb.inc
===================================================================
RCS file: /home/mercury1/repository/w3/news/newsdb.inc,v
retrieving revision 1.110
diff -u -r1.110 newsdb.inc
--- news/newsdb.inc	9 Feb 2009 03:51:49 -0000	1.110
+++ news/newsdb.inc	9 Feb 2009 05:58:21 -0000
@@ -22,6 +22,13 @@
 
 $newsdb = array(
 
+"9 February 2009" => array("RSS Feed",
+"You can now receive Mercury news items via an RSS feed by subscribing
+to the following URL: 
+<a href=\"http://www.mercury.csse.unimelb.edu.au/rss.xml\">http://www.mercury.csse.unimelb.edu.au/rss.xml</a>
+"
+),
+
 "5 February 2009" => array("New standard library modules",
 "We have added two new modules to the standard library: parsing_utils and
 calendar.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list