From 44376fadba6dd208206a7c60d10c4b39981b5441 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Fri, 17 Apr 2015 14:02:15 -0400
Subject: [PATCH] Bug 1917 - Add RSS Feeds for Lists

Test Plan:
1) Apply this patch
2) Create one or more public lists
3) View the list in the opac
4) Note the new RSS icon next to the list name
5) Open the link in FireFox or an RSS reader
6) You should see an RSS feed of your list with the title
   and author of each item as a hyperlink to the record details
---
 .../bootstrap/en/modules/opac-shelves-rss.tt       |   18 ++++++++++++++++++
 .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt |    8 +++++++-
 opac/opac-shelves.pl                               |    4 +++-
 3 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt
new file mode 100644
index 0000000..fe97142
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<rss version="2.0">
+
+<channel>
+ <title>[% shelfname %]</title>
+ <link>[% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&amp;viewshelf=[% shelfnumber | html %]</link>
+ <description>RSS feed for public list [% shelfname | html %]</description>
+
+[% FOREACH i IN itemsloop %]
+ <item>
+  <title>[% i.title %] by [% i.author %]</title>
+  <link>[% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% i.biblionumber %]</link>
+ </item>
+[% END %]
+
+</channel>
+</rss>
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
index da28e97..ef2a32b 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
@@ -151,7 +151,13 @@
                     [% END # / IF paramsloop %]
 
                     [% IF ( viewshelf ) %]<!--  Viewing a particular shelf -->
-                        <h3>[% shelfname |html %]</h3>
+                        <h3>
+                            [% shelfname |html %]
+                            <a href="[% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&amp;viewshelf=[% shelfnumber | html %]" class="rss-list-link noprint">
+                                <img src="[% interface %]/[% theme %]/images/feed-icon-16x16.png" alt="Subscribe to this search" title="Subscribe to this search" border="0" class="rsssearchicon"/>
+                            </a>
+                        </h3>
+
                         [% IF ( itemsloop ) %]
                             <div id="toolbar" class="toolbar clearfix">
                                 <div class="list-actions">
diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl
index fe13b7d..e3410e2 100755
--- a/opac/opac-shelves.pl
+++ b/opac/opac-shelves.pl
@@ -25,8 +25,10 @@ use C4::Auth;
 
 my $query = CGI->new();
 
+my $template_name = $query->param('rss') ? "opac-shelves-rss.tt" : "opac-shelves.tt";
+
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user({
-        template_name   => "opac-shelves.tt",
+        template_name   => $template_name,
         query           => $query,
         type            => "opac",
         authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
-- 
1.7.2.5