Bugzilla – Attachment 105138 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.18 KB, created by
David Roberts
on 2020-05-20 08:35:41 UTC
(
hide
)
Description:
Bug 25532: Add a wikipedia-style search suggestion feature to the OPAC
Filename:
MIME Type:
Creator:
David Roberts
Created:
2020-05-20 08:35:41 UTC
Size:
6.18 KB
patch
obsolete
>From ab76f832778e916c1bc9cd9ed5378b7f7dc5982b 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. >--- > .../bug_25532-add_OPACSearchAutoComplete_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 | 17 +++++++++++++++++ > 5 files changed, 36 insertions(+) > create mode 100644 installer/data/mysql/atomicupdate/bug_25532-add_OPACSearchAutoComplete_syspref.sql > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/wikipedia-search.js > >diff --git a/installer/data/mysql/atomicupdate/bug_25532-add_OPACSearchAutoComplete_syspref.sql b/installer/data/mysql/atomicupdate/bug_25532-add_OPACSearchAutoComplete_syspref.sql >new file mode 100644 >index 00000000000..3cc615da97b >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_25532-add_OPACSearchAutoComplete_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 ( "OPACSearchAutoComplete", 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..50db5c40136 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'), >+('OPACSearchAutoComplete','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..23a14afbe16 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: OPACSearchAutoComplete >+ 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..87cfd9414b5 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( 'OPACSearchAutoComplete' ) == 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..7590788a3b1 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/wikipedia-search.js >@@ -0,0 +1,17 @@ >+// 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]); >+ } >+ }); >+ } >+ }); >-- >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