From daf20dd652f9294273c1110f60ff4da6d99f67c5 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Tue, 26 May 2020 22:45:15 +0000 Subject: Commit preview bundle --- plugins/__init__.py | 1 + plugins/localsearch/MIT-LICENSE.txt | 20 + plugins/localsearch/README.md | 15 + plugins/localsearch/conf.py.sample | 17 + plugins/localsearch/conf.py.sample.alt | 53 ++ plugins/localsearch/localsearch.plugin | 12 + plugins/localsearch/localsearch/__init__.py | 106 ++++ .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 2073 bytes .../localsearch/files/assets/css/img/loader.gif | Bin 0 -> 4178 bytes .../localsearch/files/assets/css/img/search.png | Bin 0 -> 368 bytes .../localsearch/files/assets/css/tipuesearch.css | 271 +++++++++ .../localsearch/files/assets/js/tipuesearch.js | 611 +++++++++++++++++++++ .../localsearch/files/assets/js/tipuesearch.min.js | 181 ++++++ .../localsearch/files/assets/js/tipuesearch_set.js | 84 +++ .../localsearch/templates/jinja/localsearch.tmpl | 20 + .../localsearch/templates/mako/localsearch.tmpl | 20 + plugins/localsearch/search-EXAMPLE.html | 13 + 17 files changed, 1424 insertions(+) create mode 100644 plugins/__init__.py create mode 100644 plugins/localsearch/MIT-LICENSE.txt create mode 100644 plugins/localsearch/README.md create mode 100644 plugins/localsearch/conf.py.sample create mode 100644 plugins/localsearch/conf.py.sample.alt create mode 100644 plugins/localsearch/localsearch.plugin create mode 100644 plugins/localsearch/localsearch/__init__.py create mode 100644 plugins/localsearch/localsearch/__pycache__/__init__.cpython-37.pyc create mode 100644 plugins/localsearch/localsearch/files/assets/css/img/loader.gif create mode 100644 plugins/localsearch/localsearch/files/assets/css/img/search.png create mode 100644 plugins/localsearch/localsearch/files/assets/css/tipuesearch.css create mode 100644 plugins/localsearch/localsearch/files/assets/js/tipuesearch.js create mode 100644 plugins/localsearch/localsearch/files/assets/js/tipuesearch.min.js create mode 100644 plugins/localsearch/localsearch/files/assets/js/tipuesearch_set.js create mode 100644 plugins/localsearch/localsearch/templates/jinja/localsearch.tmpl create mode 100644 plugins/localsearch/localsearch/templates/mako/localsearch.tmpl create mode 100644 plugins/localsearch/search-EXAMPLE.html (limited to 'plugins') diff --git a/plugins/__init__.py b/plugins/__init__.py new file mode 100644 index 00000000..fd7e25d7 --- /dev/null +++ b/plugins/__init__.py @@ -0,0 +1 @@ +# Plugin modules go here. \ No newline at end of file diff --git a/plugins/localsearch/MIT-LICENSE.txt b/plugins/localsearch/MIT-LICENSE.txt new file mode 100644 index 00000000..f1310681 --- /dev/null +++ b/plugins/localsearch/MIT-LICENSE.txt @@ -0,0 +1,20 @@ +Tipue Search Copyright (c) 2012 Tipue + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/plugins/localsearch/README.md b/plugins/localsearch/README.md new file mode 100644 index 00000000..f7321da6 --- /dev/null +++ b/plugins/localsearch/README.md @@ -0,0 +1,15 @@ +If you don't want to depend on Google or DuckDuckGo to implement search for you, +or just want it to work even if you are offline, enable this plugin and the +search will be performed client side. It uses [Tipue Search](http://www.tipue.com/search/) as its engine. + +In ordrer to set up Tipue, you will need: + + * the sample config from `conf.py.sample` and a page set up to render `localsearch.tmpl` (which you may customize) — + an example is in `search-EXAMPLE.html` + * or the alternate sample config from `conf.py.sample.alt`, which uses a modal + and does not need another page + +For more information about how to customize it and use it, please refer to the Tipue +docs at http://www.tipue.com/search/ + +Tipue is under an MIT license (see MIT-LICENSE.txt) diff --git a/plugins/localsearch/conf.py.sample b/plugins/localsearch/conf.py.sample new file mode 100644 index 00000000..553abe65 --- /dev/null +++ b/plugins/localsearch/conf.py.sample @@ -0,0 +1,17 @@ +# This is an example that works well with Nikola's default Bootstrap3 theme. +# It displays the search field in the navigation bar, and the results +# on a separate page (which needs to be configured, see README.md). +# This snippet assumes the page ends up at /search/. + +SEARCH_FORM = """ + +""" + +EXTRA_HEAD_DATA = """ + +""" diff --git a/plugins/localsearch/conf.py.sample.alt b/plugins/localsearch/conf.py.sample.alt new file mode 100644 index 00000000..8c5c0285 --- /dev/null +++ b/plugins/localsearch/conf.py.sample.alt @@ -0,0 +1,53 @@ +# Alternate conf.py.sample -- for displaying in a modal dialog. +SEARCH_FORM = """ + + +""" + +EXTRA_HEAD_DATA = """ + +""" + +BODY_END = """ + + + +""" diff --git a/plugins/localsearch/localsearch.plugin b/plugins/localsearch/localsearch.plugin new file mode 100644 index 00000000..c7b91f6d --- /dev/null +++ b/plugins/localsearch/localsearch.plugin @@ -0,0 +1,12 @@ +[Core] +Name = localsearch +Module = localsearch + +[Nikola] +PluginCategory = LateTask + +[Documentation] +Author = Roberto Alsina, Chris Warrick, Kevin Sheppard +Version = 0.3.0 +Website = http://plugins.getnikola.com/#localsearch +Description = Create data files for local search via Tipue diff --git a/plugins/localsearch/localsearch/__init__.py b/plugins/localsearch/localsearch/__init__.py new file mode 100644 index 00000000..fdc8874d --- /dev/null +++ b/plugins/localsearch/localsearch/__init__.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- + +# Copyright © 2012-2014 Roberto Alsina and others. + +# Permission is hereby granted, free of charge, to any +# person obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the +# Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the +# Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice +# shall be included in all copies or substantial portions of +# the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +from __future__ import unicode_literals +import codecs +import json +import os + +from nikola.plugin_categories import LateTask +from nikola.utils import apply_filters, config_changed, copy_tree, makedirs + +# This is what we need to produce: +# var tipuesearch = {"pages": [ +# {"title": "Tipue Search, a jQuery site search engine", "text": "Tipue +# Search is a site search engine jQuery plugin. It's free for both commercial and +# non-commercial use and released under the MIT License. Tipue Search includes +# features such as word stemming and word replacement.", "tags": "JavaScript", +# "loc": "http://www.tipue.com/search"}, +# {"title": "Tipue Search demo", "text": "Tipue Search demo. Tipue Search is +# a site search engine jQuery plugin.", "tags": "JavaScript", "loc": +# "http://www.tipue.com/search/demo"}, +# {"title": "About Tipue", "text": "Tipue is a small web development/design +# studio based in North London. We've been around for over a decade.", "tags": "", +# "loc": "http://www.tipue.com/about"} +# ]}; + + +class Tipue(LateTask): + """Render the blog posts as JSON data.""" + + name = "localsearch" + + def gen_tasks(self): + self.site.scan_posts() + + kw = { + "translations": self.site.config['TRANSLATIONS'], + "output_folder": self.site.config['OUTPUT_FOLDER'], + "filters": self.site.config['FILTERS'], + "timeline": self.site.timeline, + } + + posts = self.site.timeline[:] + dst_path = os.path.join(kw["output_folder"], "assets", "js", + "tipuesearch_content.js") + + def save_data(): + pages = [] + for lang in kw["translations"]: + for post in posts: + # Don't index drafts (Issue #387) + if post.is_draft or post.is_private or post.publish_later: + continue + text = post.text(lang, strip_html=True) + text = text.replace('^', '') + + data = {} + data["title"] = post.title(lang) + data["text"] = text + data["tags"] = ",".join(post.tags) + data["url"] = post.permalink(lang, absolute=True) + pages.append(data) + output = json.dumps({"pages": pages}, indent=2) + output = 'var tipuesearch = ' + output + ';' + makedirs(os.path.dirname(dst_path)) + with codecs.open(dst_path, "wb+", "utf8") as fd: + fd.write(output) + + task = { + "basename": str(self.name), + "name": dst_path, + "targets": [dst_path], + "actions": [(save_data, [])], + 'uptodate': [config_changed(kw)], + 'calc_dep': ['_scan_locs:sitemap'] + } + yield apply_filters(task, kw['filters']) + + # Copy all the assets to the right places + asset_folder = os.path.join(os.path.dirname(__file__), "files") + for task in copy_tree(asset_folder, kw["output_folder"]): + task["basename"] = str(self.name) + yield apply_filters(task, kw['filters']) diff --git a/plugins/localsearch/localsearch/__pycache__/__init__.cpython-37.pyc b/plugins/localsearch/localsearch/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 00000000..7c4aaec0 Binary files /dev/null and b/plugins/localsearch/localsearch/__pycache__/__init__.cpython-37.pyc differ diff --git a/plugins/localsearch/localsearch/files/assets/css/img/loader.gif b/plugins/localsearch/localsearch/files/assets/css/img/loader.gif new file mode 100644 index 00000000..9c97738a Binary files /dev/null and b/plugins/localsearch/localsearch/files/assets/css/img/loader.gif differ diff --git a/plugins/localsearch/localsearch/files/assets/css/img/search.png b/plugins/localsearch/localsearch/files/assets/css/img/search.png new file mode 100644 index 00000000..8c6943d4 Binary files /dev/null and b/plugins/localsearch/localsearch/files/assets/css/img/search.png differ diff --git a/plugins/localsearch/localsearch/files/assets/css/tipuesearch.css b/plugins/localsearch/localsearch/files/assets/css/tipuesearch.css new file mode 100644 index 00000000..5793c6db --- /dev/null +++ b/plugins/localsearch/localsearch/files/assets/css/tipuesearch.css @@ -0,0 +1,271 @@ +/* +Tipue Search 7.1 +Copyright (c) 2019 Tipue +Tipue Search is released under the MIT License +http://www.tipue.com/search +*/ + + +/* search box */ + +/* +#tipue_search_input +{ + float: left; + font: 15px 'Open Sans', sans-serif; + color: #333; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + width: 230px; + background-color: #f3f3f3; + border: none; + padding: 9px 0 10px 18px; + height: 56px; + border-radius: 3px; + -moz-appearance: none; + -webkit-appearance: none; + box-sizing: border-box; + box-shadow: none; + outline: 0; + margin: 0; +} +#tipue_search_input:-webkit-autofill, +#tipue_search_input:-webkit-autofill:hover, +#tipue_search_input:-webkit-autofill:focus +{ + -webkit-box-shadow: 0 0 0px 1000px #f3f3f3 inset; +} +*/ +.tipue_search_button { + position: relative; + float: left; + width: 49px; + height: 56px; + margin-left: -3px; + background-color: #f3f3f3; + border: none; + border-top-right-radius: 3px; + border-bottom-right-radius: 3px; + box-sizing: border-box; + cursor: pointer; + outline: 0; +} + +.tipue_search_icon { + float: left; + font: 24px/1 'Open Sans', sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + color: #333; + transform: rotate(-45deg); + -moz-appearance: none; + -webkit-appearance: none; + box-sizing: border-box; + box-shadow: none; + outline: 0; + margin: -1px 0 0 16px; +} + +.tipue_search_group:after { + content: ""; + display: table; + clear: both; +} + + +/* search results */ + + +#tipue_search_content { + max-width: 100%; + margin: 0; +} + +.tipue_search_content_title { + font-weight: 300; + font-size: 2rem; + color: #111; +} + +.tipue_search_content_title a { + color: #111; + text-decoration: none; +} + +.tipue_search_result { + padding-top: 27px; +} + +#tipue_search_results_count, .tipue_search_content_debug { + font: 13px/1.5 'Source Code Pro', monospace; + text-transform: uppercase; + color: #999; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +#tipue_search_results_count { + padding-top: 9px; +} + +.tipue_search_content_url, .tipue_search_note, .tipue_search_related, #tipue_search_error, #tipue_search_replace { + font-weight: 300; + padding-top: 7px; + word-wrap: break-word; + hyphens: auto; +} + +#tipue_search_replace, .tipue_search_related { + margin-top: 7px; +} + +#tipue_search_error { + color: #333; + margin-top: 17px; +} + +.tipue_search_content_text { + font-weight: 300; + word-wrap: break-word; + hyphens: auto; + margin-top: 9px; +} + +.tipue_search_content_bold { + font-weight: 400; +} + +.tipue_search_content_debug { + margin: 7px 0 2px 0; +} + + +/* images */ + + +.tipue_search_image { + padding: 17px 0 6px 0; +} + +.tipue_search_img { + width: 100%; + max-width: 330px; + height: auto; + transition: 0.5s; + border-radius: 2px; +} + +.tipue_search_img:hover { + opacity: 0.9; +} + +#tipue_search_zoom_text { + font: 12px/1.7 'Source Code Pro', monospace; + color: #ccc; + text-transform: uppercase; + letter-spacing: 1px; + padding-top: 9px; +} + +#tipue_search_zoom_text a { + color: #ccc; + text-decoration: none; + border-bottom: 2px solid #f7f7f7; +} + +#tipue_search_zoom_text a:hover { + border: 0; +} + +.tipue_search_image_zoom { + cursor: pointer; +} + +#tipue_search_image_modal { + display: none; + position: fixed; + z-index: 1000; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgba(0, 0, 0, 0.9); +} + +.tipue_search_image_close { + position: absolute; + top: 0; + right: 0; + font: 22px/1 'Source Code Pro', monospace; + color: #ccc; + padding: 25px 30px; + cursor: pointer; +} + +.tipue_search_image_block { + margin: 0 auto; + max-width: 900px; + padding: 73px 30px 30px 30px; + box-sizing: border-box; + color: #fff; +} + +#tipue_search_zoom_img { + max-width: 100%; + height: auto; +} + +#tipue_search_zoom_text, .tipue_search_zoom_options { + padding-top: 9px; +} + + +/* footer */ + + +#tipue_search_foot { + margin: 51px 0 21px 0; +} + +#tipue_search_foot_boxes { + font: 14px 'Source Code Pro', sans-serif; + text-transform: uppercase; + color: #333; + padding: 0; + margin: 0; + cursor: pointer; +} + +#tipue_search_foot_boxes li { + display: inline; + list-style: none; + margin: 0; + padding: 0; +} + +#tipue_search_foot_boxes li a { + background-color: #f7f7f7; + color: #666; + padding: 10px 17px 11px 17px; + border-radius: 3px; + margin-right: 7px; + text-decoration: none; + text-align: center; + transition: 0.3s; +} + +#tipue_search_foot_boxes li.current { + background: #252525; + color: #ccc; + padding: 10px 17px 11px 17px; + border-radius: 3px; + margin-right: 7px; + text-align: center; +} + +#tipue_search_foot_boxes li a:hover { + background: #252525; + color: #ccc; +} + diff --git a/plugins/localsearch/localsearch/files/assets/js/tipuesearch.js b/plugins/localsearch/localsearch/files/assets/js/tipuesearch.js new file mode 100644 index 00000000..48245668 --- /dev/null +++ b/plugins/localsearch/localsearch/files/assets/js/tipuesearch.js @@ -0,0 +1,611 @@ + +/* +Tipue Search 7.1 +Copyright (c) 2019 Tipue +Tipue Search is released under the MIT License +http://www.tipue.com/search +*/ + + +(function($) { + + $.fn.tipuesearch = function(options) { + + var set = $.extend( { + + 'contextBuffer' : 60, + 'contextLength' : 60, + 'contextStart' : 90, + 'debug' : false, + 'descriptiveWords' : 25, + 'footerPages' : 3, + 'highlightTerms' : true, + 'imageZoom' : true, + 'minimumLength' : 3, + 'newWindow' : false, + 'show' : 10, + 'showContext' : true, + 'showRelated' : true, + 'showTime' : true, + 'showTitleCount' : true, + 'showURL' : true, + 'wholeWords' : true + }, options); + + return this.each(function() { + + var tipuesearch_t_c = 0; + + var tipue_search_w = ''; + if (set.newWindow) + { + tipue_search_w = ' target="_blank"'; + } + + function getURLP(name) + { + var locSearch = location.search; + var splitted = (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(locSearch)||[,""]); + var searchString = splitted[1].replace(/\+/g, '%20'); + try + { + searchString = decodeURIComponent(searchString); + } + catch(e) + { + searchString = unescape(searchString); + } + return searchString || null; + } + + if (getURLP('q')) + { + $('#tipue_search_input').val(getURLP('q')); + getTipueSearch(0, true); + } + + $(this).keyup(function(event) + { + if(event.keyCode == '13') + { + getTipueSearch(0, true); + } + }); + + + function getTipueSearch(start, replace) + { + window.scrollTo(0, 0); + + var out = ''; + var show_replace = false; + var show_stop = false; + var standard = true; + var c = 0; + var found = []; + + var d_o = $('#tipue_search_input').val(); + d_o = d_o.replace(/\+/g, ' ').replace(/\s\s+/g, ' '); + + d_o = $.trim(d_o); + var d = d_o.toLowerCase(); + + if ((d.match("^\"") && d.match("\"$")) || (d.match("^'") && d.match("'$"))) + { + standard = false; + } + + var d_w = d.split(' '); + + if (standard) + { + d = ''; + for (var i = 0; i < d_w.length; i++) + { + var a_w = true; + for (var f = 0; f < tipuesearch_stop_words.length; f++) + { + if (d_w[i] == tipuesearch_stop_words[f]) + { + a_w = false; + show_stop = true; + } + } + if (a_w) + { + d = d + ' ' + d_w[i]; + } + } + d = $.trim(d); + d_w = d.split(' '); + } + else + { + d = d.substring(1, d.length - 1); + } + + if (d.length >= set.minimumLength) + { + if (standard) + { + if (replace) + { + var d_r = d; + for (var i = 0; i < d_w.length; i++) + { + for (var f = 0; f < tipuesearch_replace.words.length; f++) + { + if (d_w[i] == tipuesearch_replace.words[f].word) + { + d = d.replace(d_w[i], tipuesearch_replace.words[f].replace_with); + show_replace = true; + } + } + } + d_w = d.split(' '); + } + + var d_t = d; + for (var i = 0; i < d_w.length; i++) + { + for (var f = 0; f < tipuesearch_stem.words.length; f++) + { + if (d_w[i] == tipuesearch_stem.words[f].word) + { + d_t = d_t + ' ' + tipuesearch_stem.words[f].stem; + } + } + } + d_w = d_t.split(' '); + + for (var i = 0; i < tipuesearch.pages.length; i++) + { + var score = 0; + var s_t = tipuesearch.pages[i].text; + for (var f = 0; f < d_w.length; f++) + { + if (set.wholeWords) + { + var pat = new RegExp('\\b' + d_w[f] + '\\b', 'gi'); + } + else + { + var pat = new RegExp(d_w[f], 'gi'); + } + if (tipuesearch.pages[i].title.search(pat) != -1) + { + var m_c = tipuesearch.pages[i].title.match(pat).length; + score += (20 * m_c); + } + if (tipuesearch.pages[i].text.search(pat) != -1) + { + var m_c = tipuesearch.pages[i].text.match(pat).length; + score += (20 * m_c); + } + if (tipuesearch.pages[i].tags) + { + if (tipuesearch.pages[i].tags.search(pat) != -1) + { + var m_c = tipuesearch.pages[i].tags.match(pat).length; + score += (10 * m_c); + } + } + if (tipuesearch.pages[i].url.search(pat) != -1) + { + score += 20; + } + + if (score != 0) + { + for (var e = 0; e < tipuesearch_weight.weight.length; e++) + { + if (tipuesearch.pages[i].url == tipuesearch_weight.weight[e].url) + { + score += tipuesearch_weight.weight[e].score; + } + } + } + + if (d_w[f].match('^-')) + { + pat = new RegExp(d_w[f].substring(1), 'i'); + if (tipuesearch.pages[i].title.search(pat) != -1 || tipuesearch.pages[i].text.search(pat) != -1 || tipuesearch.pages[i].tags.search(pat) != -1) + { + score = 0; + } + } + } + + if (score != 0) + { + found.push( + { + "score": score, + "title": tipuesearch.pages[i].title, + "desc": s_t, + "img": tipuesearch.pages[i].img, + "url": tipuesearch.pages[i].url, + "note": tipuesearch.pages[i].note + }); + c++; + } + } + } + else + { + for (var i = 0; i < tipuesearch.pages.length; i++) + { + var score = 0; + var s_t = tipuesearch.pages[i].text; + var pat = new RegExp(d, 'gi'); + if (tipuesearch.pages[i].title.search(pat) != -1) + { + var m_c = tipuesearch.pages[i].title.match(pat).length; + score += (20 * m_c); + } + if (tipuesearch.pages[i].text.search(pat) != -1) + { + var m_c = tipuesearch.pages[i].text.match(pat).length; + score += (20 * m_c); + } + if (tipuesearch.pages[i].tags) + { + if (tipuesearch.pages[i].tags.search(pat) != -1) + { + var m_c = tipuesearch.pages[i].tags.match(pat).length; + score += (10 * m_c); + } + } + if (tipuesearch.pages[i].url.search(pat) != -1) + { + score += 20; + } + + if (score != 0) + { + for (var e = 0; e < tipuesearch_weight.weight.length; e++) + { + if (tipuesearch.pages[i].url == tipuesearch_weight.weight[e].url) + { + score += tipuesearch_weight.weight[e].score; + } + } + } + + if (score != 0) + { + found.push( + { + "score": score, + "title": tipuesearch.pages[i].title, + "desc": s_t, + "img": tipuesearch.pages[i].img, + "url": tipuesearch.pages[i].url, + "note": tipuesearch.pages[i].note + }); + c++; + } + } + } + + if (c != 0) + { + if (set.showTitleCount && tipuesearch_t_c == 0) + { + var title = document.title; + document.title = '(' + c + ') ' + title; + tipuesearch_t_c++; + } + + if (c == 1) + { + out += '
' + tipuesearch_string_4; + } + else + { + var c_c = c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + out += '
' + c_c + ' ' + tipuesearch_string_5; + } + if (set.showTime) + { + var endTimer = new Date().getTime(); + var time = (endTimer - startTimer) / 1000; + out += ' (' + time.toFixed(2) + ' ' + tipuesearch_string_14 + ')'; + set.showTime = false; + } + out += '
'; + + if (set.showRelated && standard) + { + var ront = ''; + f = 0; + for (var i = 0; i < tipuesearch_related.Related.length; i++) + { + if (d == tipuesearch_related.Related[i].search) + { + if (!f) + { + out += ''; + out += ront; + } + } + + if (show_replace) + { + out += '
' + tipuesearch_string_2 + ' ' + d + '. ' + tipuesearch_string_3 + ' ' + d_r + '
'; + } + + found.sort(function(a, b) { return b.score - a.score } ); + + var l_o = 0; + + if (set.imageZoom) + { + out += '
'; + } + + for (var i = 0; i < found.length; i++) + { + if (l_o >= start && l_o < set.show + start) + { + out += '
'; + + out += ''; + + if (set.debug) + { + out += '
Score: ' + found[i].score + '
'; + } + + if (set.showURL) + { + var s_u = found[i].url.toLowerCase(); + if (s_u.indexOf('http://') == 0) + { + s_u = s_u.slice(7); + } + out += ''; + } + + if (found[i].img) + { + if (set.imageZoom) + { + out += '
' + found[i].title + '
'; + } + else + { + out += '
' + found[i].title + '
'; + } + } + + if (found[i].desc) + { + var t = found[i].desc; + + if (set.showContext) + { + d_w = d.split(' '); + var s_1 = found[i].desc.toLowerCase().indexOf(d_w[0]); + if (s_1 > set.contextStart) + { + var t_1 = t.substr(s_1 - set.contextBuffer); + var s_2 = t_1.indexOf(' '); + t_1 = t.substr(s_1 - set.contextBuffer + s_2); + t_1 = $.trim(t_1); + + if (t_1.length > set.contextLength) + { + t = '... ' + t_1; + } + } + } + + if (standard) + { + d_w = d.split(' '); + for (var f = 0; f < d_w.length; f++) + { + if (set.highlightTerms) + { + var patr = new RegExp('(' + d_w[f] + ')', 'gi'); + t = t.replace(patr, "$1"); + } + } + } + else if (set.highlightTerms) + { + var patr = new RegExp('(' + d + ')', 'gi'); + t = t.replace(patr, "$1"); + } + + var t_d = ''; + var t_w = t.split(' '); + if (t_w.length < set.descriptiveWords) + { + t_d = t; + } + else + { + for (var f = 0; f < set.descriptiveWords; f++) + { + t_d += t_w[f] + ' '; + } + } + t_d = $.trim(t_d); + if (t_d.charAt(t_d.length - 1) != '.') + { + t_d += ' ...'; + } + + t_d = t_d.replace(/h0011/g, 'span class=\"tipue_search_content_bold\"'); + t_d = t_d.replace(/h0012/g, '/span'); + + out += '
' + t_d + '
'; + } + + if (found[i].note) + { + out += '
' + found[i].note + '
'; + } + + out += '
'; + } + l_o++; + } + + if (c > set.show) + { + var pages = Math.ceil(c / set.show); + var page = (start / set.show); + if (set.footerPages < 3) + { + set.footerPages = 3; + } + + out += '
    '; + + if (start > 0) + { + out += '
  • ' + tipuesearch_string_6 + '
  • '; + } + + if (page <= 2) + { + var p_b = pages; + if (pages > set.footerPages) + { + p_b = set.footerPages; + } + for (var f = 0; f < p_b; f++) + { + if (f == page) + { + out += ''; + } + else + { + out += '
  • ' + (f + 1) + '
  • '; + } + } + } + else + { + var p_b = page + set.footerPages - 1; + if (p_b > pages) + { + p_b = pages; + } + for (var f = page - 1; f < p_b; f++) + { + if (f == page) + { + out += ''; + } + else + { + out += '
  • ' + (f + 1) + '
  • '; + } + } + } + + if (page + 1 != pages) + { + out += '
  • ' + tipuesearch_string_7 + '
  • '; + } + + out += '
'; + } + + } + else + { + out += '
' + tipuesearch_string_8 + '
'; + } + } + else + { + if (show_stop) + { + out += '
' + tipuesearch_string_8 + ' ' + tipuesearch_string_9 + '
'; + } + else + { + if (set.minimumLength == 1) + { + out += '
' + tipuesearch_string_11 + '
'; + } + else + { + out += '
' + tipuesearch_string_12 + ' ' + set.minimumLength + ' ' + tipuesearch_string_13 + '
'; + } + } + } + + $('#tipue_search_content').hide().html(out).slideDown(200); + + $('#tipue_search_replaced').click(function() + { + getTipueSearch(0, false); + }); + + $('.tipue_search_related_btn').click(function() + { + $('#tipue_search_input').val($(this).attr('id')); + getTipueSearch(0, true); + }); + + $('.tipue_search_image_zoom').click(function() + { + $('#tipue_search_image_modal').fadeIn(300); + $('#tipue_search_zoom_img').attr('src', this.src); + + var z_u = $(this).attr('data-url'); + $('#tipue_search_zoom_url').attr('href', z_u); + + var z_o = this.alt + ''; + + $('#tipue_search_zoom_text').html(z_o); + }); + + $('.tipue_search_image_close').click(function() + { + $('#tipue_search_image_modal').fadeOut(300); + }); + + $('.tipue_search_foot_box').click(function() + { + var id_v = $(this).attr('id'); + var id_a = id_v.split('_'); + + getTipueSearch(parseInt(id_a[0]), id_a[1]); + }); + } + + }); + }; + +})(jQuery); diff --git a/plugins/localsearch/localsearch/files/assets/js/tipuesearch.min.js b/plugins/localsearch/localsearch/files/assets/js/tipuesearch.min.js new file mode 100644 index 00000000..f50ef6ee --- /dev/null +++ b/plugins/localsearch/localsearch/files/assets/js/tipuesearch.min.js @@ -0,0 +1,181 @@ +(function($){$.fn.tipuesearch=function(options){var set=$.extend({'contextBuffer':60,'contextLength':60,'contextStart':90,'debug':false,'descriptiveWords':25,'footerPages':3,'highlightTerms':true,'imageZoom':true,'minimumLength':3,'newWindow':false,'show':10,'showContext':true,'showRelated':true,'showTime':true,'showTitleCount':true,'showURL':true,'wholeWords':true},options);return this.each(function(){var tipuesearch_t_c=0;var tipue_search_w='';if(set.newWindow) +{tipue_search_w=' target="_blank"';} +function getURLP(name) +{var locSearch=location.search;var splitted=(new RegExp('[?|&]'+name+'='+'([^&;]+?)(&|#|;|$)').exec(locSearch)||[,""]);var searchString=splitted[1].replace(/\+/g,'%20');try +{searchString=decodeURIComponent(searchString);} +catch(e) +{searchString=unescape(searchString);} +return searchString||null;} +if(getURLP('q')) +{$('#tipue_search_input').val(getURLP('q'));getTipueSearch(0,true);} +$(this).keyup(function(event) +{if(event.keyCode=='13') +{getTipueSearch(0,true);}});function getTipueSearch(start,replace) +{window.scrollTo(0,0);var out='';var show_replace=false;var show_stop=false;var standard=true;var c=0;var found=[];var d_o=$('#tipue_search_input').val();d_o=d_o.replace(/\+/g,' ').replace(/\s\s+/g,' ');d_o=$.trim(d_o);var d=d_o.toLowerCase();if((d.match("^\"")&&d.match("\"$"))||(d.match("^'")&&d.match("'$"))) +{standard=false;} +var d_w=d.split(' ');if(standard) +{d='';for(var i=0;i=set.minimumLength) +{if(standard) +{if(replace) +{var d_r=d;for(var i=0;i'+c_c+' '+tipuesearch_string_5;} +if(set.showTime) +{var endTimer=new Date().getTime();var time=(endTimer-startTimer)/ 1000;out+=' ('+time.toFixed(2)+' '+tipuesearch_string_14+')';set.showTime=false;} +out+='
';if(set.showRelated&&standard) +{var ront='';f=0;for(var i=0;i'+tipuesearch_related.Related[i].related+', ';f++;}} +if(f) +{ront=ront.slice(0,-2);ront+='.';out+=ront;}} +if(show_replace) +{out+='
'+tipuesearch_string_2+' '+d+'. '+tipuesearch_string_3+' '+d_r+'
';} +found.sort(function(a,b){return b.score-a.score});var l_o=0;if(set.imageZoom) +{out+='
';} +for(var i=0;i=start&&l_o'+found[i].title+'';if(set.debug) +{out+='
Score: '+found[i].score+'
';} +if(set.showURL) +{var s_u=found[i].url.toLowerCase();if(s_u.indexOf('http://')==0) +{s_u=s_u.slice(7);} +out+='';} +if(found[i].img) +{if(set.imageZoom) +{out+='
'+found[i].title+'
';} +else +{out+='
'+found[i].title+'
';}} +if(found[i].desc) +{var t=found[i].desc;if(set.showContext) +{d_w=d.split(' ');var s_1=found[i].desc.toLowerCase().indexOf(d_w[0]);if(s_1>set.contextStart) +{var t_1=t.substr(s_1-set.contextBuffer);var s_2=t_1.indexOf(' ');t_1=t.substr(s_1-set.contextBuffer+s_2);t_1=$.trim(t_1);if(t_1.length>set.contextLength) +{t='... '+t_1;}}} +if(standard) +{d_w=d.split(' ');for(var f=0;f$1");}}} +else if(set.highlightTerms) +{var patr=new RegExp('('+d+')','gi');t=t.replace(patr,"$1");} +var t_d='';var t_w=t.split(' ');if(t_w.length'+t_d+'';} +if(found[i].note) +{out+='
'+found[i].note+'
';} +out+='';} +l_o++;} +if(c>set.show) +{var pages=Math.ceil(c / set.show);var page=(start / set.show);if(set.footerPages<3) +{set.footerPages=3;} +out+='
    ';if(start>0) +{out+='
  • '+tipuesearch_string_6+'
  • ';} +if(page<=2) +{var p_b=pages;if(pages>set.footerPages) +{p_b=set.footerPages;} +for(var f=0;f';} +else +{out+='
  • '+(f+1)+'
  • ';}}} +else +{var p_b=page+set.footerPages-1;if(p_b>pages) +{p_b=pages;} +for(var f=page-1;f';} +else +{out+='
  • '+(f+1)+'
  • ';}}} +if(page+1!=pages) +{out+='
  • '+tipuesearch_string_7+'
  • ';} +out+='
';}} +else +{out+='
'+tipuesearch_string_8+'
';}} +else +{if(show_stop) +{out+='
'+tipuesearch_string_8+' '+tipuesearch_string_9+'
';} +else +{if(set.minimumLength==1) +{out+='
'+tipuesearch_string_11+'
';} +else +{out+='
'+tipuesearch_string_12+' '+set.minimumLength+' '+tipuesearch_string_13+'
';}}} +$('#tipue_search_content').hide().html(out).slideDown(200);$('#tipue_search_replaced').click(function() +{getTipueSearch(0,false);});$('.tipue_search_related_btn').click(function() +{$('#tipue_search_input').val($(this).attr('id'));getTipueSearch(0,true);});$('.tipue_search_image_zoom').click(function() +{$('#tipue_search_image_modal').fadeIn(300);$('#tipue_search_zoom_img').attr('src',this.src);var z_u=$(this).attr('data-url');$('#tipue_search_zoom_url').attr('href',z_u);var z_o=this.alt+'';$('#tipue_search_zoom_text').html(z_o);});$('.tipue_search_image_close').click(function() +{$('#tipue_search_image_modal').fadeOut(300);});$('.tipue_search_foot_box').click(function() +{var id_v=$(this).attr('id');var id_a=id_v.split('_');getTipueSearch(parseInt(id_a[0]),id_a[1]);});}});};})(jQuery); \ No newline at end of file diff --git a/plugins/localsearch/localsearch/files/assets/js/tipuesearch_set.js b/plugins/localsearch/localsearch/files/assets/js/tipuesearch_set.js new file mode 100644 index 00000000..8475b5c0 --- /dev/null +++ b/plugins/localsearch/localsearch/files/assets/js/tipuesearch_set.js @@ -0,0 +1,84 @@ + +/* +Tipue Search 7.1 +Copyright (c) 2019 Tipue +Tipue Search is released under the MIT License +http://www.tipue.com/search +*/ + + +/* +Stop words +Stop words list from http://www.ranks.nl/stopwords +*/ + +var tipuesearch_stop_words = ["a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "can't", "cannot", "could", "couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "don't", "down", "during", "each", "few", "for", "from", "further", "had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", "is", "isn't", "it", "it's", "its", "itself", "let's", "me", "more", "most", "mustn't", "my", "myself", "no", "nor", "not", "of", "off", "on", "once", "only", "or", "other", "ought", "our", "ours", "ourselves", "out", "over", "own", "same", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "so", "some", "such", "than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've", "this", "those", "through", "to", "too", "under", "until", "up", "very", "was", "wasn't", "we", "we'd", "we'll", "we're", "we've", "were", "weren't", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "who's", "whom", "why", "why's", "with", "won't", "would", "wouldn't", "you", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves"]; + + +// Word replace + +var tipuesearch_replace = {'words': [ + {'word': 'tipua', 'replace_with': 'tipue'}, + {'word': 'javscript', 'replace_with': 'javascript'}, + {'word': 'jqeury', 'replace_with': 'jquery'} +]}; + + +// Weighting + +var tipuesearch_weight = {'weight': [ + {'url': 'http://www.tipue.com', 'score': 60}, + {'url': 'http://www.tipue.com/search', 'score': 60}, + {'url': 'http://www.tipue.com/tipr', 'score': 30}, + {'url': 'http://www.tipue.com/support', 'score': 20} +]}; + + +// Illogical stemming + +var tipuesearch_stem = {'words': [ + {'word': 'e-mail', 'stem': 'email'}, + {'word': 'javascript', 'stem': 'jquery'}, + {'word': 'javascript', 'stem': 'js'} +]}; + + +// Related + +var tipuesearch_related = {'Related': [ + {'search': 'tipue', 'related': 'Search', 'include': 1}, + {'search': 'tipue', 'related': 'jQuery'}, + {'search': 'tipue', 'related': 'Blog'}, + {'search': 'tipue', 'related': 'Support'}, + {'search': 'tipue search', 'related': 'Demo', 'include': 1}, + {'search': 'tipue search', 'related': 'Support'} +]}; + + +// Internal strings + +var tipuesearch_string_1 = 'No title'; +var tipuesearch_string_2 = 'Showing results for'; +var tipuesearch_string_3 = 'Search instead for'; +var tipuesearch_string_4 = '1 result'; +var tipuesearch_string_5 = 'results'; +var tipuesearch_string_6 = 'Prev'; +var tipuesearch_string_7 = 'Next'; +var tipuesearch_string_8 = 'Nothing found'; +var tipuesearch_string_9 = 'Common words are largely ignored'; +var tipuesearch_string_10 = 'Related'; +var tipuesearch_string_11 = 'Search should be one character or more'; +var tipuesearch_string_12 = 'Search should be'; +var tipuesearch_string_13 = 'characters or more'; +var tipuesearch_string_14 = 'seconds'; +var tipuesearch_string_15 = 'Open Image'; +var tipuesearch_string_16 = 'Goto Page'; + + +// Internals + + +// Timer for showTime + +var startTimer = new Date().getTime(); + diff --git a/plugins/localsearch/localsearch/templates/jinja/localsearch.tmpl b/plugins/localsearch/localsearch/templates/jinja/localsearch.tmpl new file mode 100644 index 00000000..d392782e --- /dev/null +++ b/plugins/localsearch/localsearch/templates/jinja/localsearch.tmpl @@ -0,0 +1,20 @@ +{# -*- coding: utf-8 -*- #} +{% extends 'base.tmpl' %} +{% block content %} +

Search

+ +
Use the search box in the navigation bar to search.
+{% endblock %} + +{% block extra_js %} + + + + +{% endblock %} diff --git a/plugins/localsearch/localsearch/templates/mako/localsearch.tmpl b/plugins/localsearch/localsearch/templates/mako/localsearch.tmpl new file mode 100644 index 00000000..38441904 --- /dev/null +++ b/plugins/localsearch/localsearch/templates/mako/localsearch.tmpl @@ -0,0 +1,20 @@ +## -*- coding: utf-8 -*- +<%inherit file="base.tmpl"/> +<%block name="content"> +

Search

+ +
Use the search box in the navigation bar to search.
+ + +<%block name="extra_js"> + + + + + diff --git a/plugins/localsearch/search-EXAMPLE.html b/plugins/localsearch/search-EXAMPLE.html new file mode 100644 index 00000000..f8970bc5 --- /dev/null +++ b/plugins/localsearch/search-EXAMPLE.html @@ -0,0 +1,13 @@ + + +

Search results appear here.

-- cgit v1.2.3