← Back to team overview

brainstorm-dev team mailing list archive

Patch: RSS feed for idea pages

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I've attached a bzr bundle that generates an rss feed for an idea and
its comments.

It also makes the dates in the other rss feeds valid RFC 822 which
feedvalidator was complaining about.

Feedback welcome :)

Dean
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIXSV7eedO8dcp9nYRAjCpAKCNwly7+BCWNF1/fd1MrmE65b0+hACfasa4
qa8obq7iUkwARcTQFfRtWu4=
=CHbI
-----END PGP SIGNATURE-----
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: dean@xxxxxxxxxxx-20080621153723-ua5fwatxewnr1e5h
# target_branch: file:///home/dean/code/ubuntu-qa.main/
# testament_sha1: b3f9971d0da58adab752f7a7e466b9c79fa7900c
# timestamp: 2008-06-21 16:39:14 +0100
# base_revision_id: ndeschildre@xxxxxxxxx-20080619184503-\
#   2hik8r7g453mow94
# 
# Begin patch
=== modified file 'code/modules/qapoll/controller.php'
--- code/modules/qapoll/controller.php	2008-06-16 17:33:36 +0000
+++ code/modules/qapoll/controller.php	2008-06-21 15:24:40 +0000
@@ -49,6 +49,7 @@
 require_once "views/view.php";
 require_once "views/pagination.php";
 require_once "views/choice/choice.html.php";
+require_once "views/choice/choice.rss2.php";
 require_once "views/choicelist/choicelist.html.php";
 require_once "views/choicelist/choicelist.rss2.php";
 require_once "views/choicelist/choicelist.json.php";
@@ -912,6 +913,14 @@
 					drupal_set_message("You need to login first!", 'error_msg');
 					drupal_set_header("Location: " . $GLOBALS['basemodule_url'] . "/item/" . $this->_param1 . "/");
 				}
+				else if($this->_param2 == "rss2")
+				{
+					// Display RSS feed of choice and comments
+					$model = new ChoiceModel();
+					$model->setId($this->_param1);
+					$view = new ChoiceRSS2View();
+					$template ="rss2";
+				}
 				else if($this->_param2 == null)
 				{
 					//A comment was submitted. Save it.

=== modified file 'code/modules/qapoll/views/choice/choice.html.php'
--- code/modules/qapoll/views/choice/choice.html.php	2008-05-25 16:17:45 +0000
+++ code/modules/qapoll/views/choice/choice.html.php	2008-06-21 15:24:40 +0000
@@ -43,6 +43,11 @@
 		if($template == "default")
 			drupal_add_js('modules/qapoll/js/qapoll_choice_page.js');
 
+		//Add RSS feed
+		$basemodulepath = $GLOBALS['basemodule_path'];
+		drupal_add_feed($GLOBALS['basemodule_url'] . "/" . $basemodulepath .'/'. $this->_data->id."/rss2" ,
+		 "RSS feed for this choice");
+		
 		//Load the category list corresponding to this poll.
 		$this->_categoryList = $this->_model->_pollModel->getCategoryList();
 

=== added file 'code/modules/qapoll/views/choice/choice.rss2.php'
--- code/modules/qapoll/views/choice/choice.rss2.php	1970-01-01 00:00:00 +0000
+++ code/modules/qapoll/views/choice/choice.rss2.php	2008-06-21 15:24:40 +0000
@@ -0,0 +1,46 @@
+<?php
+
+/*
+Copyright (C) 2007 Nicolas Deschildre <ndeschildre@xxxxxxxxx>
+
+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 2
+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, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+
+class ChoiceRSS2View extends View
+{
+
+
+	/**
+	 * Prepare and display the page.
+	 */
+	function display($template = "rss2")
+	{
+		global $site;
+		//Indicate the content type.
+		drupal_set_header("Content-type: text/rss");
+		//Execute default template
+		$content .= $this->loadTemplate("choice/", $template);
+		//Don't return the content, otherwise drupal will add some HTML in the way.
+		echo $content;
+
+		return null;
+	}
+
+
+}
+
+?>

=== added file 'code/modules/qapoll/views/choice/tmpl/rss2.php'
--- code/modules/qapoll/views/choice/tmpl/rss2.php	1970-01-01 00:00:00 +0000
+++ code/modules/qapoll/views/choice/tmpl/rss2.php	2008-06-21 15:24:40 +0000
@@ -0,0 +1,41 @@
+<?php
+
+/*
+Copyright (C) 2007 Nicolas Deschildre <ndeschildre@xxxxxxxxx>
+
+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 2
+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, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+echo "<?xml version=\"1.0\"?>"; ?>
+
+<rss version="2.0">
+  <channel>
+    <title><![CDATA[<?php echo strip_tags_and_evil_attributes($this->_data->title); ?>]]></title>
+    <link><?php echo $GLOBALS['basemodule_url'] . "/item/" . $this->_data->id . "/"; ?></link>
+    <description><![CDATA[<?php echo str_replace("\n", "<br />", strip_tags_and_evil_attributes($this->_data->description, $GLOBALS['site']->getSetting("item_description_auth_tags"))) ?>]]></description>
+
+    <language>en-us</language>
+    <pubDate><?php echo date("r", strtotime($this->_data->date))?></pubDate>
+    <lastBuildDate><?php echo date("r", strtotime($this->_data->date))?></lastBuildDate>
+    <generator>QAPoll module</generator>
+    <guid isPermaLink="true"><?php echo $GLOBALS['basemodule_url'] . "/item/" . $this->_data->id . "/"; ?></guid>
+    <?php foreach($this->_data->comment_items as $comment): ?>
+    <?php 
+     $this->comment =& $comment;
+     echo $this->loadTemplate("choice/", "rss2", "comment");
+    ?>
+    <?php endforeach; ?>
+  </channel>
+</rss>

=== added file 'code/modules/qapoll/views/choice/tmpl/rss2_comment.php'
--- code/modules/qapoll/views/choice/tmpl/rss2_comment.php	1970-01-01 00:00:00 +0000
+++ code/modules/qapoll/views/choice/tmpl/rss2_comment.php	2008-06-21 15:24:40 +0000
@@ -0,0 +1,25 @@
+<?php
+
+/*
+ * Copyright (C) 2008 Dean Sas <dean@xxxxxxxxxxx>
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * */
+?>
+<item>
+  <title>Comment from <?php echo $this->comment->username ?></title>
+  <description><![CDATA[<?php echo str_replace("\n", "<br />", strip_tags_and_evil_attributes($this->comment->comment, $GLOBALS['site']->getSetting("item_description_auth_tags"))) ?>]]></description>
+  <pubDate><?php echo date("r", strtotime($this->comment->date))?></pubDate>
+</item>

=== modified file 'code/modules/qapoll/views/choicelist/tmpl/rss2.php'
--- code/modules/qapoll/views/choicelist/tmpl/rss2.php	2008-03-01 13:28:19 +0000
+++ code/modules/qapoll/views/choicelist/tmpl/rss2.php	2008-06-21 15:37:23 +0000
@@ -35,8 +35,8 @@
     <link><?php echo $GLOBALS['basemodule_url']; ?></link>
     <description><![CDATA[<?php if($GLOBALS['entrypoint']->getData()->description != null) echo str_replace("\n", "<br />",$GLOBALS['entrypoint']->getData()->description); else echo str_replace("\n", "<br />", $this->_data->description); ?>]]></description>
     <language>en-us</language>
-    <pubDate><?php echo date("D, d-M-Y"); ?> 00:00:00 UTC</pubDate>
-    <lastBuildDate><?php echo date("D, d-M-Y"); ?> 00:00:00 UTC</lastBuildDate>
+    <pubDate><?php echo date("r"); ?></pubDate>
+    <lastBuildDate><?php echo date("r"); ?></lastBuildDate>
     <generator>QAPoll module</generator>
  
 <?php for ($i = 0; $i < count($this->_data->items); $i++) : ?>

=== modified file 'code/modules/qapoll/views/choicelist/tmpl/rss2_item.php'
--- code/modules/qapoll/views/choicelist/tmpl/rss2_item.php	2008-05-10 18:04:49 +0000
+++ code/modules/qapoll/views/choicelist/tmpl/rss2_item.php	2008-06-21 15:37:23 +0000
@@ -51,6 +51,6 @@
 <?php endif; ?>
 ]]>
 </description>
-      <pubDate><?php echo date("D, d-M-Y"); ?> 00:00:00 UTC</pubDate>
+      <pubDate><?php echo date("r"); ?></pubDate>
       <guid><?php echo $GLOBALS['basemodule_url'] . "/item/" . $this->item->id . "/"; ?></guid>
     </item>

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWVepa3EACG9fgHAwdff////n
/66////6YBAd8Ptu4HU5ooAAAGNXbCdhsmoaaaUyaA0Nso0FLEaVPUANAaANAANAAAADQAABzCaM
jQ0MhhGhkNNGgAxGTIBhAMBzCaMjQ0MhhGhkNNGgAxGTIBhAMAkSEU2IlPFPxSfpPI9Ux6pP1T9E
9UP0p6jDKHqaabUNGmgAikECaCYTTTICaTMibRpMKYTCGmg9J5RggkiBAGkGgkZGNCoeakNlD0jQ
GQ9QNAH6pQSpQUMYwFCEMYxtJsa0Y9P7tf6+Hv/DTEOBO7WD8b5wZicfTp9y6/ZCLK4YY7ZGyItu
DlPu+Z22bH9DveNWlhKGy8TMnYw5NbBFWY36nzdOcv83TL1Z1UdLPxwsi7jjjJUGGNKnGB1eNkKW
VHwDQkJw0HBKeTMN5YtEh1XlYqlGnHaTIVt/7bqgPWwgSQO9hNoHDQc8fORqlQmV5fLT41qzLLD9
HU8NwFzAejX4YDIXPihBiPcHKDQ2222v5zL3opIyOzqh6mIt2UtZSc7lKLUZ2GJucVY9jRtjOEUF
ekIZJeTgnGIyNNSSh61n2zIL0yXbAsHwaJGoqglYoWDJ4m3K7WAZfkhKrzoSZNPMdroZ8aHif463
lcBk2GDp/272l7hK4o7m2lWLH9nvuspx4lD5PnWQVpYz7wedjM828K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