Bugzilla – Attachment 49587 Details for
Bug 16111
RSS feed for OPAC search results has wrong content type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16111 [Revised] RSS feed for OPAC search results has wrong content type
Bug-16111-Revised-RSS-feed-for-OPAC-search-results.patch (text/plain), 11.71 KB, created by
Owen Leonard
on 2016-03-25 12:55:29 UTC
(
hide
)
Description:
Bug 16111 [Revised] RSS feed for OPAC search results has wrong content type
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2016-03-25 12:55:29 UTC
Size:
11.71 KB
patch
obsolete
>From 915a9c616dd678447d8ffb9c523ea36026c5d7df Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 21 Mar 2016 13:36:17 -0400 >Subject: [PATCH] Bug 16111 [Revised] RSS feed for OPAC search results has > wrong content type >Content-Type: text/plain; charset="utf-8" > >This patch fixing handling of OPAC search results feeds by correcting >parameters passed to the script and making format checks consistent in >the script. > >This patch also removes altogether references to a separate "atom" >formatted feed, because the template for that feed displays no content >(and never has). > >To test, apply the patch and perform a search in the OPAC. > >- Click the RSS link and confirm that the browser displays a feed with > no errors. In Chrome the feed should display a "document tree" view. >- Using the browser's developer console, verify that the content-type of > the document is defined as "text/xml." >- Validate the resulting feed at https://validator.w3.org/feed/ and > confirm that it is valid. > >Revision adds suggestion from QA to accept the old 'rss2' parameter and >treat it like an 'rss' parameter. Also changed: Corrected another place >where 'rss2' was used in the template. >--- > .../bootstrap/en/modules/opac-opensearch.tt | 49 ++-------------------- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 6 +-- > opac/opac-search.pl | 15 ++++--- > 3 files changed, 13 insertions(+), 57 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt >index 09f1a72..4253755 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt >@@ -7,20 +7,19 @@ > <Tags>koha opac [% LibraryName |html %]</Tags> > <Contact>[% KohaAdminEmailAddress |html %]</Contact> > <Url type="application/rss+xml" >- template="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?q={searchTerms}&pw={startPage?}&format=rss2"/> >+ template="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?q={searchTerms}&pw={startPage?}&format=rss"/> > </OpenSearchDescription> > > [% ELSE %] > >-[% IF ( rss2 ) %] > <rss version="2.0" > xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" > xmlns:dc="http://purl.org/dc/elements/1.1/" > xmlns:atom="http://www.w3.org/2005/Atom"> > <channel> > <title><![CDATA[[% LibraryName |html %] Search [% IF ( query_desc ) %]for '[% query_desc |html %]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc |html %]'[% END %]]]></title> >- <link>[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&format=rss2</link> >- <atom:link rel="self" type="application/rss+xml" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&sort_by=[% sort_by |html %]&format=rss2"/> >+ <link>[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&format=rss</link> >+ <atom:link rel="self" type="application/rss+xml" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&sort_by=[% sort_by |html %]&format=rss"/> > <description><![CDATA[ Search results [% IF ( query_desc ) %]for '[% query_desc |html %]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc |html %]'[% END %] at [% LibraryName |html %]]]></description> > <opensearch:totalResults>[% total %]</opensearch:totalResults> > <opensearch:startIndex>[% offset %]</opensearch:startIndex> >@@ -62,47 +61,5 @@ > [% END %] > </channel> > </rss> >-[% END %] >- >-[% IF ( atom ) %] >-<feed xmlns="http://www.w3.org/2005/Atom" >- xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"> >- <id>[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&format=atom</id> >- <title>[% LibraryName |html %] Search [% IF ( query_desc ) %]for '[% query_desc |html %]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc |html %]'[% END %]</title> >- <link href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %]&format=rss2"/> >- <updated>[% timestamp %]</updated> >- <author> >- <name>[% LibraryName |html %]</name> >- </author> >- <!-- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> --> >- <opensearch:totalResults>[% total %]</opensearch:totalResults> >- <opensearch:startIndex>[% page %]</opensearch:startIndex> >- [% IF ( results_per_page ) %] >- <opensearch:itemsPerPage>[% results_per_page %]</opensearch:itemsPerPage> >- [% ELSE %] >- <opensearch:itemsPerPage>20</opensearch:itemsPerPage> >- [% END %] >- <opensearch:Query role="request" searchTerms="[% query_desc |html %] [% limit_desc |html %]" startPage="[% page |html %]" /> >- <link rel="alternate" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi %][% limit_cgi %]pw=[% page %]&format=atom" type="application/atom+xml"/> >- <link rel="self" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi %][% limit_cgi %]&format=atom" type="application/atom+xml"/> >- <link rel="first" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi %][% limit_cgi %]pw=1&format=atom" type="application/atom+xml"/> >- <link rel="previous" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi %][% limit_cgi %]pw=2&format=atom" type="application/atom+xml"/> >- <link rel="next" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi %][% limit_cgi %]pw=4&format=atom" type="application/atom+xml"/> >- <link rel="last" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi %][% limit_cgi %]pw=42299&format=atom" type="application/atom+xml"/> >- <link rel="search" type="application/opensearchdescription+xml" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?format=opensearchdescription"/> >- >- [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] >- <entry> >- <title>[% SEARCH_RESULT.title |html %]</title> >- <link href="[% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]"/> >- <!-- <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> --> >- <updated>[% SEARCH_RESULT.timestamp %]</updated> >- <content type="text"><!-- put content here --> >- </content> >- <id>[% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]</id> >- </entry> >- [% END %] >- </feed> >-[% END %] > > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index 061ceed..e847c26 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -16,7 +16,7 @@ > [% END %] > [% END %] > >-<link rel="alternate" type="application/rss+xml" title="[% LibraryName |html %] Search RSS feed" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi |uri %]&count=[% countrss |uri %]&sort_by=acqdate_dsc&format=rss2" /> >+<link rel="alternate" type="application/rss+xml" title="[% LibraryName |html %] Search RSS feed" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi |uri %]&count=[% countrss |uri %]&sort_by=acqdate_dsc&format=rss" /> > </head> > > [% INCLUDE 'bodytag.inc' bodyid='results' bodyclass='scrollto' %] >@@ -41,7 +41,7 @@ > <strong>No results found!</strong> > <p> > [% IF ( searchdesc ) %] >- No results found for that in [% LibraryName %] catalog. <a href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi | html | url %]&format=rss2" class="rsssearchlink 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> >+ No results found for that in [% LibraryName %] catalog. <a href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi | html | url %]&format=rss" class="rsssearchlink 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> > [% ELSE %] > You did not specify any search criteria. > [% END %] >@@ -85,7 +85,7 @@ > [% END %] > ). > [% END %] >- <a href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi |html | url %]&count=[% countrss |html %]&sort_by=acqdate_dsc&format=rss2" class="rsssearchlink noprint"><img src="[% interface %]/[% theme %]/images/feed-icon-16x16.png" alt="Subscribe to this search" title="Subscribe to this search" class="rsssearchicon"/></a> >+ <a href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi |html | url %]&count=[% countrss |html %]&sort_by=acqdate_dsc&format=rss" class="rsssearchlink noprint"><img src="[% interface %]/[% theme %]/images/feed-icon-16x16.png" alt="Subscribe to this search" title="Subscribe to this search" class="rsssearchicon"/></a> > [% END # / IF total %] > </p> > [% END # / IF searchdesc %] >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 72d054f..d1a9993 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -89,8 +89,11 @@ my @params = $cgi->param("limit"); > my @searchCategories = $cgi->param('searchcat'); > > my $format = $cgi->param("format") || ''; >+# Accept "rss" or the older "rss2" parameter >+$format = 'rss' if $format =~ /rss/; >+ > my $build_grouped_results = C4::Context->preference('OPACGroupResults'); >-if ($format =~ /(rss|atom|opensearchdescription)/) { >+if ($format =~ /(rss|opensearchdescription)/) { > $template_name = 'opac-opensearch.tt'; > } > elsif (@params && $build_grouped_results) { >@@ -126,11 +129,8 @@ if($cgi->cookie("bib_list")){ > @cart_list = split(/\//, $cart_list); > } > >-if ($format eq 'rss2' or $format eq 'opensearchdescription' or $format eq 'atom') { >+if ($format eq 'rss' or $format eq 'opensearchdescription' ) { > $template->param($format => 1); >- $template->param(timestamp => strftime("%Y-%m-%dT%H:%M:%S-00:00", gmtime)) if ($format eq 'atom'); >- # FIXME - the timestamp is a hack - the biblio update timestamp should be used for each >- # entry, but not sure if that's worth an extra database query for each bib > } > if (C4::Context->preference("marcflavour") eq "UNIMARC" ) { > $template->param('UNIMARC' => 1); >@@ -736,8 +736,7 @@ for (my $i=0;$i<@servers;$i++) { > } > > ## If there's just one result, redirect to the detail page >- if ($total == 1 && $format ne 'rss2' >- && $format ne 'opensearchdescription' && $format ne 'atom') { >+ if ($total == 1 && $format ne 'rss' && $format ne 'opensearchdescription' ) { > my $biblionumber=$newresults[0]->{biblionumber}; > if (C4::Context->preference('BiblioDefaultView') eq 'isbd') { > print $cgi->redirect("/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=$biblionumber"); >@@ -970,7 +969,7 @@ $template->param( > add_to_some_public_shelves => $some_public_shelves, > ); > >-my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html'; >+my $content_type = ( $format eq 'rss' ) ? $format : 'html'; > > # If GoogleIndicTransliteration system preference is On Set parameter to load Google's javascript in OPAC search screens > if (C4::Context->preference('GoogleIndicTransliteration')) { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16111
:
49400
|
49587
|
49629
|
49837
|
76148
|
76160
|
76161
|
76162
|
77057
|
77058
|
77059
|
77060
|
78578
|
78579
|
78580
|
78581
|
78689
|
81285
|
81286
|
81287
|
81288
|
92050
|
92362
|
92363
|
92366
|
92435
|
92436
|
92437
|
92438
|
92439
|
92618
|
92619
|
92620
|
92621
|
92622
|
92623
|
92624