Bugzilla – Attachment 92050 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: Fix content type for RSS feed
Bug-16111-Fix-content-type-for-RSS-feed.patch (text/plain), 17.17 KB, created by
Jonathan Druart
on 2019-08-07 15:09:22 UTC
(
hide
)
Description:
Bug 16111: Fix content type for RSS feed
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-08-07 15:09:22 UTC
Size:
17.17 KB
patch
obsolete
>From 6a2af9433a0ae62605e326dd1a07a62f0a6a4979 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 18 Jun 2018 17:31:27 -0300 >Subject: [PATCH] Bug 16111: Fix content type for RSS feed > >Test plan: >GET http://catalogue/cgi-bin/koha/opac-search.pl?idx=kw&q=perl&count=50&sort_by=acqdate_dsc&format=rss2 > >=> Without this patch it returns content type text/html >=> With this patch it returns text/xml > >GET http://catalogue/cgi-bin/koha/opac-search.pl?idx=kw&q=perl&count=50&sort_by=acqdate_dsc&format=rss >=> Without this patch it does not work >=> With this patch it returns text/xml > >Bug 16111: Fix atom support > >Bug 16111: Remove 'rss2' which should be 'rss' or 'atom' > >Bug 16111: Replace <link> with <link href... >--- > .../bootstrap/en/modules/opac-opensearch.tt | 47 +++++++++++++--------- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 6 +-- > .../bootstrap/en/modules/opac-search-history.tt | 4 +- > opac/opac-search.pl | 7 +++- > 4 files changed, 37 insertions(+), 27 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 52d5dd8df7..1d4280b880 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-opensearch.tt >@@ -11,20 +11,20 @@ > <Tags>koha opac [% LibraryName | html %]</Tags> > <Contact>[% KohaAdminEmailAddress | html %]</Contact> > <Url type="application/rss+xml" >- template="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?q={searchTerms}&pw={startPage?}&format=rss2"/> >+ template="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?q={searchTerms}&pw={startPage?}&format=rss"/> > </OpenSearchDescription> > > [% ELSE %] > >-[% IF ( rss2 ) %] >+[% IF ( rss ) %] > <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 | html %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]&format=rss2</link> >- <atom:link rel="self" type="application/rss+xml" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]&sort_by=[% sort_by | uri %]&format=rss2"/> >+ <link href=[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&format=rss</link> >+ <atom:link rel="self" type="application/rss+xml" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&sort_by=[% sort_by | uri %]&format=atom"/> > <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 | html %]</opensearch:totalResults> > <opensearch:startIndex>[% offset | html %]</opensearch:startIndex> >@@ -34,12 +34,18 @@ > <opensearch:itemsPerPage>20</opensearch:itemsPerPage> > [% END %] > [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] >- <atom:link rel="search" type="application/opensearchdescription+xml" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | url %]&sort_by=[% SEARCH_RESULT.sort_by |uri %]&format=opensearchdescription"/> >+ <atom:link rel="search" type="application/opensearchdescription+xml" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | $raw %]&sort_by=[% SEARCH_RESULT.sort_by |uri %]&format=opensearchdescription"/> > <opensearch:Query role="request" searchTerms="[% SEARCH_RESULT.query_desc |uri %][% SEARCH_RESULT.limit_desc |uri %]" startPage="[% SEARCH_RESULT.page | html %]" /> > <item> > <title>[% INCLUDE 'biblio-title-head.inc' biblio=SEARCH_RESULT %]</title> > <dc:identifier>ISBN [% SEARCH_RESULT.isbn | html %]</dc:identifier> >- <link>[% IF ( SEARCH_RESULT.BiblioDefaultViewmarc ) %][% OPACBaseURL | html %]/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %][% ELSE %][% IF ( SEARCH_RESULT.BiblioDefaultViewisbd ) %][% OPACBaseURL | html %]/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %][% ELSE %][% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %][% END %][% END %]</link> >+ [% IF ( SEARCH_RESULT.BiblioDefaultViewmarc ) %] >+ <link href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]" /> >+ [% ELSIF ( SEARCH_RESULT.BiblioDefaultViewisbd ) %] >+ <link href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]" /> >+ [% ELSE %] >+ <link href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]" /> >+ [% END %] > <description><![CDATA[ > [% IF ( AdlibrisEnabled && SEARCH_RESULT.normalized_isbn ) %] > <img src="[% AdlibrisURL | html %]?isbn=[% SEARCH_RESULT.normalized_isbn | html %]" alt="Adlibris cover image" /> >@@ -75,9 +81,9 @@ > [% IF ( atom ) %] > <feed xmlns="http://www.w3.org/2005/Atom" > xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"> >- <id>[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | html %]&format=atom</id> >+ <id>[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&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 | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]&format=rss2"/> >+ <link href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&format=rss2"/> > <updated>[% timestamp | html %]</updated> > <author> > <name>[% LibraryName | html %]</name> >@@ -90,24 +96,25 @@ > [% 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 | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]pw=[% page | uri %]&format=atom" type="application/atom+xml"/> >- <link rel="self" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]&format=atom" type="application/atom+xml"/> >- <link rel="first" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]pw=1&format=atom" type="application/atom+xml"/> >- <link rel="previous" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]pw=2&format=atom" type="application/atom+xml"/> >- <link rel="next" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]pw=4&format=atom" type="application/atom+xml"/> >- <link rel="last" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | url %]pw=42299&format=atom" type="application/atom+xml"/> >- <link rel="search" type="application/opensearchdescription+xml" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?format=opensearchdescription"/> >+ <opensearch:Query role="request" searchTerms="[% SEARCH_RESULT.query_desc | html %] [% SEARCH_RESULT.limit_desc | html %]" startPage="[% page | html %]" /> >+ <link rel="alternate" href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | $raw %]pw=[% page %]&format=atom" type="application/atom+xml"/> >+ <link rel="self" href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | $raw %]&format=atom" type="application/atom+xml"/> >+ <link rel="first" href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | $raw %]pw=1&format=atom" type="application/atom+xml"/> >+ <link rel="previous" href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | $raw %]pw=2&format=atom" type="application/atom+xml"/> >+ <link rel="next" href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | $raw %]pw=4&format=atom" type="application/atom+xml"/> >+ <link rel="last" href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?[% SEARCH_RESULT.query_cgi | $raw %][% SEARCH_RESULT.limit_cgi | $raw %]pw=42299&format=atom" type="application/atom+xml"/> >+ <link rel="search" type="application/opensearchdescription+xml" href="[% OPACBaseURL | html %]/cgi-bin/koha/opac-search.pl?format=opensearchdescription"/> > > [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] > <entry> >- <title>[% SEARCH_RESULT.title | html %]</title> >- <link href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]"/> >+ <title>[% SEARCH_RESULT.title | html %] [% FOREACH subtitl IN SEARCH_RESULT.subtitle %], [% subtitl.subfield | html %][% END %]</title> >+ <link>[% IF ( SEARCH_RESULT.BiblioDefaultViewmarc ) %][% OPACBaseURL | html %]/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %][% ELSE %][% IF ( SEARCH_RESULT.BiblioDefaultViewisbd ) %][% OPACBaseURL | html %]/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %][% ELSE %][% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %][% END %][% END %]</link> > <!-- <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> --> > <updated>[% SEARCH_RESULT.timestamp | html %]</updated> >- <content type="text"><!-- put content here --> >- </content> > <id>[% OPACBaseURL | html %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | html %]</id> >+ <content type="text"> >+ >+ </content> > </entry> > [% END %] > </feed> >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 12c9a2d1c6..967af422bb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -24,7 +24,7 @@ > [% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > >-<link rel="alternate" type="application/rss+xml" title="[% LibraryName | html %] Search RSS feed" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&count=[% countrss |uri %]&sort_by=acqdate_dsc&format=rss2" /> >+<link rel="alternate" type="application/rss+xml" title="[% LibraryName | html %] Search RSS feed" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&count=[% countrss |uri %]&sort_by=acqdate_dsc&format=rss" /> > </head> > [% BLOCK cssinclude %][% END %] > [% INCLUDE 'bodytag.inc' bodyid='results' bodyclass='scrollto' %] >@@ -61,7 +61,7 @@ > <p> > [% IF ( searchdesc ) %] > No results found for that in [% LibraryName | html %] catalog. >- <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&format=rss2" class="rsssearchlink noprint"> >+ <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&format=rss" class="rsssearchlink noprint"> > <i class="fa fa-rss rsssearchicon" title="Subscribe to this search"></i> > </a> > [% ELSE %] >@@ -107,7 +107,7 @@ > [% END %] > ). > [% END %] >- <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&format=rss2" class="rsssearchlink noprint"> >+ <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&format=rss" class="rsssearchlink noprint"> > <i class="fa fa-rss rsssearchicon" title="Subscribe to this search"></i> > </a> > [% END # / IF total %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt >index 098f532a2a..7191092024 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-search-history.tt >@@ -72,7 +72,7 @@ > <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td> > <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td> > <td> >- <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&[% s.query_cgi | $raw %]&count=[% countrss | uri %]&sort_by=acqdate_dsc&format=rss2" class="rsssearchlink"> >+ <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&[% s.query_cgi | $raw %]&count=[% countrss | uri %]&sort_by=acqdate_dsc&format=rss" class="rsssearchlink"> > <i class="fa fa-rss rsssearchicon" title="Subscribe to this search"></i> > </a> > <a href="/cgi-bin/koha/opac-search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a> >@@ -117,7 +117,7 @@ > <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td> > <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td> > <td> >- <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&[% s.query_cgi | $raw %]&count=[% countrss | uri %]&sort_by=acqdate_dsc&format=rss2" class="rsssearchlink"> >+ <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&[% s.query_cgi | $raw %]&count=[% countrss | uri %]&sort_by=acqdate_dsc&format=rss" class="rsssearchlink"> > <i class="fa fa-rss rsssearchicon" title="Subscribe to this search"></i> > </a> > <a href="/cgi-bin/koha/opac-search.pl?[% s.query_cgi | $raw %]"> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 27d1f2ce5c..55fe17f006 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -118,6 +118,9 @@ else { > $template_name = 'opac-advsearch.tt'; > $template_type = 'advsearch'; > } >+ >+$format = 'rss' if $format =~ /rss/; >+ > # load the template > ($template, $borrowernumber, $cookie) = get_template_and_user({ > template_name => $template_name, >@@ -142,7 +145,7 @@ 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' or $format eq 'atom') { > $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 >@@ -769,7 +772,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' >+ if ($total == 1 && $format ne 'rss' > && $format ne 'opensearchdescription' && $format ne 'atom') { > my $biblionumber=$newresults[0]->{biblionumber}; > if (C4::Context->preference('BiblioDefaultView') eq 'isbd') { >-- >2.11.0
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