Bugzilla – Attachment 105220 Details for
Bug 25532
Add a wikipedia-style search suggestion feature to the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25532: Add a wikipedia-style search suggestion feature to the OPAC
Bug-25532-Add-a-wikipedia-style-search-suggestion-.patch (text/plain), 6.43 KB, created by
David Roberts
on 2020-05-21 15:23:53 UTC
(
hide
)
Description:
Bug 25532: Add a wikipedia-style search suggestion feature to the OPAC
Filename:
MIME Type:
Creator:
David Roberts
Created:
2020-05-21 15:23:53 UTC
Size:
6.43 KB
patch
obsolete
>From 5423abdd57f6b6a43e8cc65b19b5007e5848f96e Mon Sep 17 00:00:00 2001 >From: David Roberts <david@koha-ptfs.co.uk> >Date: Tue, 19 May 2020 20:12:57 +0000 >Subject: [PATCH] Bug 25532: Add a wikipedia-style search suggestion feature to > the OPAC > >This patch adds an auto-complete function to the OPAC search and a new >system preference 'OPACSearchAutoComplete' > >To test: > >1) Install the patch >2) Go to the OPAC and start typing a search term, e.g. Harry Potter >3) You should see a drop down will appear suggesting likely search terms >which can be selected >4) Repeat the search, but mis-spell your search term, e.g. Hrry Potter. >5) You should still see the correctly spelled search term being offered >for selection >6) Check that the search is unaffected, and still works correctly, both >when logged in and not logged in. >--- > ...32-add_OPACWikipediaSearchSuggestions_syspref.sql | 7 +++++++ > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/opac.pref | 7 +++++++ > .../opac-tmpl/bootstrap/en/includes/opac-bottom.inc | 4 ++++ > koha-tmpl/opac-tmpl/bootstrap/js/wikipedia-search.js | 20 ++++++++++++++++++++ > 5 files changed, 39 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/bug_25532-add_OPACWikipediaSearchSuggestions_syspref.sql > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/wikipedia-search.js > >diff --git a/installer/data/mysql/atomicupdate/bug_25532-add_OPACWikipediaSearchSuggestions_syspref.sql b/installer/data/mysql/atomicupdate/bug_25532-add_OPACWikipediaSearchSuggestions_syspref.sql >new file mode 100644 >index 00000000000..2630177398f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_25532-add_OPACWikipediaSearchSuggestions_syspref.sql >@@ -0,0 +1,7 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ $dbh->do(q{ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ( "OPACWikipediaSearchSuggestions", 0, NULL, "Enable a search suggestion to the OPAC Search box.","YesNo" ) }); >+ >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 25532 - Add a wikipedia-style search suggestion feature to the OPAC)\n"; >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 4ad73ef827e..c796bb47c64 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -433,6 +433,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OpacResetPassword','0','','Shows the ''Forgot your password?'' link in the OPAC','YesNo'), > ('OPACResultsLibrary', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'), > ('OPACResultsSidebar','','70|10','Define HTML to be included on the search results page, underneath the facets sidebar','Textarea'), >+('OPACWikipediaSearchSuggestions','0','NULL','Enable search suggestions based on data entered into the search box','YesNo'), > ('OPACSearchForTitleIn','<li><a href=\"https://worldcat.org/search?q={TITLE}\" target=\"_blank\">Other Libraries (WorldCat)</a></li>\n<li><a href=\"https://scholar.google.com/scholar?q={TITLE}\" target=\"_blank\">Other Databases (Google Scholar)</a></li>\n<li><a href=\"https://www.bookfinder.com/search/?author={AUTHOR}&title={TITLE}&st=xl&ac=qr\" target=\"_blank\">Online Stores (Bookfinder.com)</a></li>\n<li><a href=\"https://openlibrary.org/search?author=({AUTHOR})&title=({TITLE})\" target=\"_blank\">Open Library (openlibrary.org)</a></li>','70|10','Enter the HTML that will appear in the \'Search for this title in\' box on the detail page in the OPAC. Enter {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the URL. Leave blank to disable \'More Searches\' menu.','Textarea'), > ('OpacSeparateHoldings','0',NULL,'Separate current branch holdings from other holdings (OPAC)','YesNo'), > ('OpacSeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings (OPAC)','Choice'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 7169962c840..02f9b9b65b4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -563,6 +563,13 @@ OPAC: > syntax: text/html > class: code > - >+ - pref: OPACWikipediaSearchSuggestions >+ default: 0 >+ choices: >+ yes: Enable >+ no: Disable >+ - "search suggestions based on data entered into the search box" >+ - > - pref: OpacBrowseSearch > default: 0 > choices: >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index a32e7a56ee6..677d830e4f2 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -121,6 +121,10 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > [% Asset.js("js/amazonimages.js") | $raw %] > [% END %] > >+[% IF Koha.Preference( 'OPACWikipediaSearchSuggestions' ) == 1 %] >+[% Asset.js("js/wikipedia-search.js") | $raw %] >+[% END %] >+ > <script> > //<![CDATA[ > var MSG_CONFIRM_AGAIN = _("Warning: Cannot be undone. Please confirm once again") >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/wikipedia-search.js b/koha-tmpl/opac-tmpl/bootstrap/js/wikipedia-search.js >new file mode 100644 >index 00000000000..2a3ed3bf0b7 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/wikipedia-search.js >@@ -0,0 +1,20 @@ >+// Wikipedia search auto-complete help >+ $("#translControl1").autocomplete({ >+ source: function(request, response) { >+ $.ajax({ >+ url: "https://en.wikipedia.org/w/api.php", >+ dataType: "jsonp", >+ data: { >+ 'action': "opensearch", >+ 'format': "json", >+ 'search': request.term >+ }, >+ success: function(data) { >+ response(data[1]); >+ } >+ }); >+ }, >+ open: function() { >+ $('.ui-autocomplete').append('<li style="text-align:right;font-size:80%;padding: 5px 10px;background:rgba(0,0,0,0.1)">Powered by Wikipedia</li>'); >+ } >+ }); >-- >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 25532
:
105138
|
105220
|
105488