Replacing tipue search by duckduckgo iframe

This commit is contained in:
Lucas Cimon 2017-12-20 21:55:08 +01:00
parent 6dfec32172
commit d6d9329d30
No known key found for this signature in database
GPG Key ID: 6AF36E0DE97FE852
21 changed files with 66 additions and 3789 deletions

View File

@ -39,7 +39,7 @@ Features
* [Open Graph](http://ogp.me) support. * [Open Graph](http://ogp.me) support.
* [Twitter Summary Card](https://dev.twitter.com/cards/types/summary) support. * [Twitter Summary Card](https://dev.twitter.com/cards/types/summary) support.
* [Schema.org](http://schema.org) support. * [Schema.org](http://schema.org) support.
* Search with [Tipue Search](http://www.tipue.com/search). * Search with [DuckDuckGo](https://duckduckgo.com/search_box).
* Responsive design. * Responsive design.
* Comment with DISQUS or inno * Comment with DISQUS or inno
* SCSS style sheets. * SCSS style sheets.
@ -66,8 +66,7 @@ If you want to use the theme with search enabled (and probably you want it).
```python ```python
TAG_SAVE_AS = '' TAG_SAVE_AS = ''
AUTHOR_SAVE_AS = '' AUTHOR_SAVE_AS = ''
DIRECT_TEMPLATES = ('index', 'categories', 'archives', 'search', 'tipue_search') DIRECT_TEMPLATES = ('index', 'categories', 'archives')
TIPUE_SEARCH_SAVE_AS = 'tipue_search.json'
``` ```
If you want to use mg with search disabled. If you want to use mg with search disabled.
@ -200,8 +199,7 @@ This is the settings file for Dev's Bytes.
TAG_SAVE_AS = '' TAG_SAVE_AS = ''
AUTHOR_SAVE_AS = '' AUTHOR_SAVE_AS = ''
PLUGINS = ['representative_image'] PLUGINS = ['representative_image']
DIRECT_TEMPLATES = ('index', 'categories', 'archives', 'search', 'tipue_search') DIRECT_TEMPLATES = ('index', 'categories', 'archives')
TIPUE_SEARCH_SAVE_AS = 'tipue_search.json'
RELATIVE_URLS = False RELATIVE_URLS = False

View File

@ -18,33 +18,24 @@ def sed(filepath, pattern, value):
# Generating CSS bundle # Generating CSS bundle
short_hash = sha1(cat('static/main.css')).hexdigest()[:7] short_hash = sha1(cat('static/main.css')).hexdigest()[:7]
sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.css', '-SHORTSHA1-{}.css'.format(short_hash)) sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.css', '-SHORTSHA1-{}.css'.format(short_hash))
for DISABLE_SEARCH in range(2): bundle_filename = 'bundle-SHORTSHA1-{}.css'.format(short_hash)
bundle_filename = 'bundle-DISABLE_SEARCH-{}-SHORTSHA1-{}.css'.format(DISABLE_SEARCH, short_hash) with open('static/' + bundle_filename, 'wb') as bundle:
with open('static/' + bundle_filename, 'wb') as bundle: bundle.write(cat('static/csslibs/uikit-2.27.4.min.css'))
bundle.write(cat('static/csslibs/uikit-2.27.4.min.css')) bundle.write(cat('static/csslibs/solarized-highlight.css'))
if not DISABLE_SEARCH: bundle.write(cat('static/main.css'))
bundle.write(cat('static/csslibs/uikit-2.27.4-search.min.css'))
bundle.write(cat('static/csslibs/tipuesearch.css'))
bundle.write(cat('static/csslibs/solarized-highlight.css'))
bundle.write(cat('static/main.css'))
# Generating JS bundle # Generating JS bundle
short_hash = sha1(cat('static/js/enable-search.js') + cat('static/js/social.js') + cat('static/js/filter-tags.js')).hexdigest()[:7] short_hash = sha1(cat('static/js/social.js') + cat('static/js/filter-tags.js')).hexdigest()[:7]
sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.js', '-SHORTSHA1-{}.js'.format(short_hash)) sed('templates/base.html', '-SHORTSHA1-[a-z0-9]+.js', '-SHORTSHA1-{}.js'.format(short_hash))
for DISABLE_SEARCH, SHARE, MG_FILTER_TAGS in itertools.product(range(2), repeat=3): for SHARE, MG_FILTER_TAGS in itertools.product(range(2), repeat=2):
bundle_filename = 'bundle-DISABLE_SEARCH-{}-SHARE-{}-MG_FILTER_TAGS-{}-SHORTSHA1-{}.js'.format( bundle_filename = 'bundle-SHARE-{}-MG_FILTER_TAGS-{}-SHORTSHA1-{}.js'.format(
DISABLE_SEARCH, SHARE, MG_FILTER_TAGS, short_hash) SHARE, MG_FILTER_TAGS, short_hash)
with open('static/' + bundle_filename, 'wb') as bundle: with open('static/' + bundle_filename, 'wb') as bundle:
bundle.write(cat('static/jslibs/html5shiv-3.7.2.min.js')) bundle.write(cat('static/jslibs/html5shiv-3.7.2.min.js'))
bundle.write(cat('static/jslibs/jquery-1.10.2.min.js')) bundle.write(cat('static/jslibs/jquery-1.10.2.min.js'))
bundle.write(cat('static/jslibs/uikit-2.27.4.min.js')) bundle.write(cat('static/jslibs/uikit-2.27.4.min.js'))
bundle.write(cat('static/jslibs/lazysizes-4.0.0-rc3.min.js')) bundle.write(cat('static/jslibs/lazysizes-4.0.0-rc3.min.js'))
bundle.write(cat('static/jslibs/lazysizes-4.0.0-rc3.noscript.min.js')) bundle.write(cat('static/jslibs/lazysizes-4.0.0-rc3.noscript.min.js'))
if not DISABLE_SEARCH:
bundle.write(cat('static/jslibs/uikit-2.27.4-search.min.js'))
bundle.write(cat('static/jslibs/tipuesearch_set.js'))
bundle.write(cat('static/jslibs/tipuesearch.js'))
bundle.write(cat('static/js/enable-search.js'))
if SHARE: if SHARE:
bundle.write(cat('static/jslibs/jquery.sticky-kit.js')) bundle.write(cat('static/jslibs/jquery.sticky-kit.js'))
bundle.write(cat('static/js/social.js')) bundle.write(cat('static/js/social.js'))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -83,12 +83,14 @@ html{font:400 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;-webkit-text
.highlight .vg { color: #268bd2 } /* Name.Variable.Global */ .highlight .vg { color: #268bd2 } /* Name.Variable.Global */
.highlight .vi { color: #268bd2 } /* Name.Variable.Instance */ .highlight .vi { color: #268bd2 } /* Name.Variable.Instance */
.highlight .il { color: #2aa198 } /* Literal.Number.Integer.Long */ .highlight .il { color: #2aa198 } /* Literal.Number.Integer.Long */
/* csslint warned: Too many font-size declarations (10), abstraction needed. */
@font-face { @font-face {
font-family: 'Open Sans'; font-family: 'Open Sans';
font-style: italic; font-style: italic;
font-weight: 800; font-weight: 800;
src: local('Open Sans ExtraBold Italic'), local('OpenSans-ExtraBoldItalic'), url(fonts/PRmiXeptR36kaC0GEAetxlDMrAYtoOisqqMDW9M_Mqc.ttf) format('truetype'); src: local('Open Sans ExtraBold Italic'), local('OpenSans-ExtraBoldItalic'), url(fonts/PRmiXeptR36kaC0GEAetxlDMrAYtoOisqqMDW9M_Mqc.ttf) format('truetype');
} }
@font-face { @font-face {
font-family: 'Oswald'; font-family: 'Oswald';
font-style: normal; font-style: normal;
@ -97,7 +99,7 @@ html{font:400 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif;-webkit-text
} }
html, h1, h2, h3 { html, h1, h2, h3 {
font-family: "Oswald", "Helvetica Neue",Helvetica,Arial,sans-serif; } font-family: "Oswald", "Helvetica Neue", Helvetica, Arial, sans-serif; }
html { html {
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;
@ -122,22 +124,22 @@ a {
color: #444; } color: #444; }
.uk-article-content { .uk-article-content {
font: 400 14px / 20px "Helvetica Neue",Helvetica,Arial,sans-serif; } font: 400 14px / 20px "Helvetica Neue", Helvetica, Arial, sans-serif; }
.uk-icon-twitter { .uk-icon-twitter {
color: #00B0ED; } color: #00b0ed; }
.uk-icon-facebook, .uk-icon-facebook-square { .uk-icon-facebook, .uk-icon-facebook-square {
color: #3B5999; } color: #3b5999; }
.uk-icon-google-plus, .uk-icon-google-plus-square { .uk-icon-google-plus, .uk-icon-google-plus-square {
color: #D34836; } color: #d34836; }
.uk-nav-side > li.uk-active > a { .uk-nav-side > li.uk-active > a {
background: #28D1B2; } background: #28d1b2; }
.uk-pagination > .uk-active > span { .uk-pagination > .uk-active > span {
background: #28D1B2; } background: #28d1b2; }
.uk-icon-medium { .uk-icon-medium {
margin-right: 0.3em; } margin-right: 0.3em; }
@ -179,7 +181,7 @@ a {
.mg-brand, .mg-brand > h1 { .mg-brand, .mg-brand > h1 {
display: block; display: block;
margin: .5rem 0; margin: 0.5rem 0;
font-style: italic; font-style: italic;
font-size: 2.5rem; font-size: 2.5rem;
line-height: 2.5rem; line-height: 2.5rem;
@ -194,7 +196,7 @@ a {
} }
.mg-tagline { .mg-tagline {
padding: .5rem 2rem; padding: 0.5rem 2rem;
font-size: 1.4rem; font-size: 1.4rem;
color: white; } color: white; }
@ -214,8 +216,8 @@ a {
overflow: visible; overflow: visible;
color: #444; color: #444;
font: inherit; font: inherit;
padding: .5rem 1.5rem; padding: 0.5rem 1.5rem;
margin: .5rem 1rem; margin: 0.5rem 1rem;
text-transform: uppercase; text-transform: uppercase;
cursor: pointer; } cursor: pointer; }
.mg-tag-filter:hover { .mg-tag-filter:hover {
@ -223,11 +225,11 @@ a {
.mg-tag-filter-include { .mg-tag-filter-include {
background-color: #33b5e5; } background-color: #33b5e5; }
.mg-tag-filter-exclude { .mg-tag-filter-exclude {
background-color: #FF9148; } background-color: #ff9148; }
.mg-nav-small { .mg-nav-small {
display: flex; display: flex;
width: 100% } width: 100%; }
.mg-nav-menu-toggle-small { .mg-nav-menu-toggle-small {
flex: 1; } flex: 1; }
@ -254,7 +256,7 @@ a {
min-width: 0; /* required for flexbox shrink to work properly - Chrome 60 */ min-width: 0; /* required for flexbox shrink to work properly - Chrome 60 */
max-height: 50%; max-height: 50%;
max-width: 50%; max-width: 50%;
padding: 1rem; /* csslint allow: box-model */ padding: 1rem; /* csslint warned here on box model */
margin: 0 auto; margin: 0 auto;
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -265,19 +267,19 @@ a {
.mg-feed { .mg-feed {
color: #bf4d00; } color: #bf4d00; }
.mg-feed:hover { .mg-feed:hover {
color: #D14905; } color: #d14905; }
.mg-tags { .mg-tags {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: right; } text-align: right; }
.mg-tag { .mg-tag {
margin: 0 .5rem; margin: 0 0.5rem;
color: #D14905; } color: #d14905; }
.mg-tag:hover { .mg-tag:hover {
color: #D14905; } color: #d14905; }
.mg-tag > .uk-icon-tag { .mg-tag > .uk-icon-tag {
display: inline; /* so that the icon stick with the tag label */ display: inline; /* so that the icon stick with the tag label */
margin-right: .2rem; } margin-right: 0.2rem; }
.mg-list-title { .mg-list-title {
font-size: 2em; font-size: 2em;
@ -293,7 +295,7 @@ a {
margin-top: 1em; } margin-top: 1em; }
.mg-icon-link { .mg-icon-link {
padding: .3rem; } padding: 0.3rem; }
.mg-icon-link:hover { .mg-icon-link:hover {
text-decoration: none; } text-decoration: none; }
@ -302,17 +304,17 @@ a {
.mg-icons-small .uk-icon-rss { .mg-icons-small .uk-icon-rss {
color: white; color: white;
background-color: #D14905; } background-color: #d14905; }
.mg-icons-small .uk-icon-twitter { .mg-icons-small .uk-icon-twitter {
background-color: #00B0ED; } background-color: #00b0ed; }
.mg-icons-small .uk-icon-facebook { .mg-icons-small .uk-icon-facebook {
background-color: #3B5999; } background-color: #3b5999; }
.mg-icons-small .uk-icon-google-plus { .mg-icons-small .uk-icon-google-plus {
background-color: #D34836; } background-color: #d34836; }
.mg-icons-small .uk-icon-envelope { .mg-icons-small .uk-icon-envelope {
background-color: #059; } background-color: #059; }
.uk-icon-shaarli:before { .uk-icon-shaarli::before {
content: ' '; content: ' ';
display: inline-block; display: inline-block;
height: 28px; height: 28px;
@ -320,7 +322,7 @@ a {
background-image: url(shaarli-icon.png); background-image: url(shaarli-icon.png);
background-size: contain; background-size: contain;
vertical-align: middle; } vertical-align: middle; }
.uk-icon-stackoverflow:before { .uk-icon-stackoverflow::before {
content: ' '; content: ' ';
display: inline-block; display: inline-block;
height: 28px; height: 28px;
@ -328,7 +330,7 @@ a {
background-image: url(stackoverflow-icon.png); background-image: url(stackoverflow-icon.png);
background-size: contain; background-size: contain;
vertical-align: middle; } vertical-align: middle; }
.uk-icon-travis-ci:before { .uk-icon-travis-ci::before {
content: ' '; content: ' ';
display: inline-block; display: inline-block;
height: 28px; height: 28px;
@ -338,7 +340,7 @@ a {
vertical-align: middle; } vertical-align: middle; }
.mg-support-logo { .mg-support-logo {
margin: .5rem;} margin: 0.5rem;}
.mg-badges li { .mg-badges li {
float: left; float: left;
@ -354,7 +356,7 @@ a {
.mg-search { .mg-search {
display: flex; } display: flex; }
.mg-search-button { .mg-search-button {
font-family: FontAwesome; font-family: FontAwesome, serif;
background-color: transparent; background-color: transparent;
border: none; border: none;
cursor: pointer; } cursor: pointer; }
@ -370,7 +372,7 @@ a {
.mg-cloud-tag { .mg-cloud-tag {
display: inline-block; display: inline-block;
padding: .2rem; padding: 0.2rem;
line-height: 110%; } line-height: 110%; }
.mg-cloud-tag-size-5 { .mg-cloud-tag-size-5 {
@ -385,7 +387,7 @@ a {
font-size: 300%; } font-size: 300%; }
.mg-cloud-tag-badge { .mg-cloud-tag-badge {
color: #D14905; } color: #d14905; }
.mg-fadeable { .mg-fadeable {
@ -413,3 +415,10 @@ a:focus, .uk-link:focus {
.mg-skiplinks a:focus { .mg-skiplinks a:focus {
color: white; color: white;
} }
.duckduckgo {
height: 40px;
width: 90%;
padding: 5%;
background: #f5f5f5;
}

View File

@ -1,103 +0,0 @@
/*!
* Tipue Search 4.0
* Copyright (c) 2014 Tipue
* Tipue Search is released under the MIT License
* http://www.tipue.com/search
*
* This is a modified version of the Tipue Search plugin style sheet,
* edited for the pelican mg theme.
* If you are looking for the original Tipue Search plugin style sheet
* check the project home at http://www.tipue.com/search.
*/
#tipue_search_content {
max-width: 650px;
padding-top: 15px;
margin: 0; }
#tipue_search_loading:before {
padding-top: 60px;
font-family: FontAwesome;
content: "\f013";
background: #fff no-repeat left;
-webkit-animation: fa-spin 2s infinite linear;
-moz-animation: fa-spin 2s infinite linear;
-o-animation: fa-spin 2s infinite linear;
animation: fa-spin 2s infinite linear; }
#tipue_search_warning_head {
font: 300 15px/1.6;
color: #555; }
#tipue_search_warning {
font: 300 13px/1.6;
color: #333;
margin: 7px 0; }
#tipue_search_warning a {
color: #36c;
font-weight: 300;
text-decoration: none; }
#tipue_search_warning a:hover {
color: #333; }
.tipue_search_content_title {
font-size: 2em;
line-height: 42px;
font-weight: 400;
text-transform: none;
margin-top: 0.5em; }
.tipue_search_content_title a {
color: #444;
text-decoration: none; }
.tipue_search_content_title a:hover {
color: #444;
text-decoration: underline; }
.tipue_search_content_url {
display: none; }
.tipue_search_content_text {
margin-top: 3px; }
.h01 {
font-weight: bold; }
#tipue_search_foot {
margin: 51px 0 21px 0; }
#tipue_search_foot_boxes {
font-size: 0.75em;
padding: 0;
margin: 0; }
#tipue_search_foot_boxes li {
list-style: none;
margin: 0;
padding: 0;
display: inline; }
#tipue_search_foot_boxes li a {
padding: 9px 15px 10px 15px;
background-color: #f1f1f1;
border: 1px solid #dcdcdc;
border-radius: 1px;
color: #333;
margin-right: 7px;
text-decoration: none;
text-align: center; }
#tipue_search_foot_boxes li.current {
padding: 9px 15px 10px 15px;
background: #fff;
border: 1px solid #dcdcdc;
border-radius: 1px;
color: #333;
margin-right: 7px;
text-align: center; }
#tipue_search_foot_boxes li a:hover {
border: 1px solid #ccc;
background-color: #f3f3f3; }

View File

@ -1,2 +0,0 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
.uk-search{display:inline-block;position:relative;margin:0}.uk-search:before{content:"\f002";position:absolute;top:0;left:0;width:30px;line-height:30px;text-align:center;font-family:FontAwesome;font-size:14px;color:rgba(0,0,0,.2)}.uk-search-field::-moz-focus-inner{border:0;padding:0}.uk-search-field::-webkit-search-cancel-button,.uk-search-field::-webkit-search-decoration{-webkit-appearance:none}.uk-search-field::-ms-clear{display:none}.uk-search-field::-moz-placeholder{opacity:1}.uk-search-field{box-sizing:border-box;margin:0;border-radius:0;font:inherit;color:#444;-webkit-appearance:none;width:120px;height:30px;padding:0 0 0 30px;border:1px solid transparent;background:rgba(0,0,0,0);-webkit-transition:all .2s linear;transition:all .2s linear;vertical-align:middle}.uk-search-field:-ms-input-placeholder{color:#999!important}.uk-search-field::-moz-placeholder{color:#999}.uk-search-field::-webkit-input-placeholder{color:#999}.uk-search-field:focus{outline:0}.uk-search-field:focus,.uk-search.uk-active .uk-search-field{width:180px}.uk-dropdown-search{width:300px;margin-top:0;background:#f5f5f5;color:#444}.uk-open>.uk-dropdown-search{-webkit-animation:uk-slide-top-fixed .2s ease-in-out;animation:uk-slide-top-fixed .2s ease-in-out}.uk-navbar-flip .uk-dropdown-search{margin-top:5px;margin-right:-15px}.uk-nav-search>li>a{color:#444}.uk-nav-search>li.uk-active>a{background:#00a8e6;color:#fff;outline:0}.uk-nav-search .uk-nav-header{color:#999}.uk-nav-search .uk-nav-divider{border-top:1px solid #ddd}.uk-nav-search ul a{color:#07D}.uk-nav-search ul a:hover{color:#059}.uk-offcanvas .uk-search{display:block;margin:20px 15px}.uk-offcanvas .uk-search:before{color:#777}.uk-offcanvas .uk-search-field{width:100%;border-color:transparent;background:#1a1a1a;color:#ccc}.uk-offcanvas .uk-search-field:-ms-input-placeholder{color:#777!important}.uk-offcanvas .uk-search-field::-moz-placeholder{color:#777}.uk-offcanvas .uk-search-field::-webkit-input-placeholder{color:#777}

View File

@ -1,10 +0,0 @@
$(document).ready(() => {
$('.tipue_search').tipuesearch({
show: 10,
mode: 'json',
showURL: false,
descriptiveWords: 75,
highlightEveryTerm: true,
contentLocation: './tipue_search.json',
});
});

View File

@ -1,444 +0,0 @@
/*
Tipue Search 4.0
Copyright (c) 2014 Tipue
Tipue Search is released under the MIT License
http://www.tipue.com/search
*/
(function($) {
$.fn.tipuesearch = function(options) {
var set = $.extend( {
'show' : 7,
'newWindow' : false,
'showURL' : true,
'minimumLength' : 3,
'descriptiveWords' : 25,
'highlightTerms' : true,
'highlightEveryTerm' : false,
'mode' : 'static',
'liveDescription' : '*',
'liveContent' : '*',
'contentLocation' : 'tipuesearch/tipuesearch_content.json'
}, options);
return this.each(function() {
var tipuesearch_in = {
pages: []
};
$.ajaxSetup({
async: false
});
if (set.mode == 'live')
{
for (var i = 0; i < tipuesearch_pages.length; i++)
{
$.get(tipuesearch_pages[i], '',
function (html)
{
var cont = $(set.liveContent, html).text();
cont = cont.replace(/\s+/g, ' ');
var desc = $(set.liveDescription, html).text();
desc = desc.replace(/\s+/g, ' ');
var t_1 = html.toLowerCase().indexOf('<title>');
var t_2 = html.toLowerCase().indexOf('</title>', t_1 + 7);
if (t_1 != -1 && t_2 != -1)
{
var tit = html.slice(t_1 + 7, t_2);
}
else
{
var tit = 'No title';
}
tipuesearch_in.pages.push({
"title": tit,
"text": desc,
"tags": cont,
"loc": tipuesearch_pages[i]
});
}
);
}
}
if (set.mode == 'json')
{
$.getJSON(set.contentLocation,
function(json)
{
tipuesearch_in = $.extend({}, json);
}
);
}
if (set.mode == 'static')
{
tipuesearch_in = $.extend({}, tipuesearch);
}
var tipue_search_w = '';
if (set.newWindow)
{
tipue_search_w = ' target="_blank"';
}
function getURLP(name)
{
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20')) || null;
}
if (getURLP('q'))
{
$('main .tipue_search').val(getURLP('q'));
getTipueSearch(0, true);
}
$(this).keyup(function(event)
{
if(event.keyCode == '13')
{
getTipueSearch(0, true);
}
});
function getTipueSearch(start, replace)
{
$('#tipue_search_content').hide();
var out = '';
var results = '';
var show_replace = false;
var show_stop = false;
var standard = true;
var c = 0;
found = new Array();
var d = $('main .tipue_search').val().toLowerCase();
d = $.trim(d);
if ((d.match("^\"") && d.match("\"$")) || (d.match("^'") && d.match("'$")))
{
standard = false;
}
if (standard)
{
var d_w = d.split(' ');
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_in.pages.length; i++)
{
var score = 1000000000;
var s_t = tipuesearch_in.pages[i].text;
for (var f = 0; f < d_w.length; f++)
{
var pat = new RegExp(d_w[f], 'i');
if (tipuesearch_in.pages[i].title.search(pat) != -1)
{
score -= (200000 - i);
}
if (tipuesearch_in.pages[i].text.search(pat) != -1)
{
score -= (150000 - i);
}
if (set.highlightTerms)
{
if (set.highlightEveryTerm)
{
var patr = new RegExp('(' + d_w[f] + ')', 'gi');
}
else
{
var patr = new RegExp('(' + d_w[f] + ')', 'i');
}
s_t = s_t.replace(patr, "<span class=\"h01\">$1</span>");
}
if (tipuesearch_in.pages[i].tags.search(pat) != -1)
{
score -= (100000 - i);
}
if (d_w[f].match("^-"))
{
pat = new RegExp(d_w[f].substring(1), 'i');
if (tipuesearch_in.pages[i].title.search(pat) != -1 || tipuesearch_in.pages[i].text.search(pat) != -1 || tipuesearch_in.pages[i].tags.search(pat) != -1)
{
score = 1000000000;
}
}
}
if (score < 1000000000)
{
found[c++] = score + '^' + tipuesearch_in.pages[i].title + '^' + s_t + '^' + tipuesearch_in.pages[i].loc;
}
}
}
else
{
for (var i = 0; i < tipuesearch_in.pages.length; i++)
{
var score = 1000000000;
var s_t = tipuesearch_in.pages[i].text;
var pat = new RegExp(d, 'i');
if (tipuesearch_in.pages[i].title.search(pat) != -1)
{
score -= (200000 - i);
}
if (tipuesearch_in.pages[i].text.search(pat) != -1)
{
score -= (150000 - i);
}
if (set.highlightTerms)
{
if (set.highlightEveryTerm)
{
var patr = new RegExp('(' + d + ')', 'gi');
}
else
{
var patr = new RegExp('(' + d + ')', 'i');
}
s_t = s_t.replace(patr, "<span class=\"h01\">$1</span>");
}
if (tipuesearch_in.pages[i].tags.search(pat) != -1)
{
score -= (100000 - i);
}
if (score < 1000000000)
{
found[c++] = score + '^' + tipuesearch_in.pages[i].title + '^' + s_t + '^' + tipuesearch_in.pages[i].loc;
}
}
}
if (c != 0)
{
if (show_replace == 1)
{
out += '<div id="tipue_search_warning_head">Showing results for ' + d + '</div>';
out += '<div id="tipue_search_warning">Search instead for <a href="javascript:void(0)" id="tipue_search_replaced">' + d_r + '</a></div>';
}
if (c == 1)
{
out += '<div id="tipue_search_results_count">1 result</div>';
}
else
{
c_c = c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
out += '<div id="tipue_search_results_count">' + c_c + ' results</div>';
}
found.sort();
var l_o = 0;
for (var i = 0; i < found.length; i++)
{
var fo = found[i].split('^');
if (l_o >= start && l_o < set.show + start)
{
out += '<div class="tipue_search_content_title"><a href="' + fo[3] + '"' + tipue_search_w + '>' + fo[1] + '</a></div>';
if (set.showURL)
{
out += '<div class="tipue_search_content_url"><a href="' + fo[3] + '"' + tipue_search_w + '>' + fo[3] + '</a></div>';
}
var t = fo[2];
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 += ' ...';
}
out += '<div class="tipue_search_content_text">' + t_d + '</div>';
}
l_o++;
}
if (c > set.show)
{
var pages = Math.ceil(c / set.show);
var page = (start / set.show);
out += '<div id="tipue_search_foot"><ul id="tipue_search_foot_boxes">';
if (start > 0)
{
out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (start - set.show) + '_' + replace + '">Prev</a></li>';
}
if (page <= 2)
{
var p_b = pages;
if (pages > 3)
{
p_b = 3;
}
for (var f = 0; f < p_b; f++)
{
if (f == page)
{
out += '<li class="current">' + (f + 1) + '</li>';
}
else
{
out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';
}
}
}
else
{
var p_b = page + 2;
if (p_b > pages)
{
p_b = pages;
}
for (var f = page - 1; f < p_b; f++)
{
if (f == page)
{
out += '<li class="current">' + (f + 1) + '</li>';
}
else
{
out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (f * set.show) + '_' + replace + '">' + (f + 1) + '</a></li>';
}
}
}
if (page + 1 != pages)
{
out += '<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="' + (start + set.show) + '_' + replace + '">Next</a></li>';
}
out += '</ul></div>';
}
}
else
{
out += '<div id="tipue_search_warning_head">Nothing found</div>';
}
}
else
{
if (show_stop)
{
out += '<div id="tipue_search_warning_head">Nothing found</div><div id="tipue_search_warning">Common words are largely ignored</div>';
}
else
{
out += '<div id="tipue_search_warning_head">Search too short</div>';
if (set.minimumLength == 1)
{
out += '<div id="tipue_search_warning">Should be one character or more</div>';
}
else
{
out += '<div id="tipue_search_warning">Should be ' + set.minimumLength + ' characters or more</div>';
}
}
}
$('#tipue_search_content').html(out);
$('#tipue_search_content').slideDown(200);
$('#tipue_search_replaced').click(function()
{
getTipueSearch(0, false);
});
$('.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);

View File

@ -1,22 +0,0 @@
/*
Tipue Search 4.0
Copyright (c) 2014 Tipue
Tipue Search is released under the MIT License
http://www.tipue.com/search
*/
var tipuesearch_stop_words = ["and", "be", "by", "do", "for", "he", "how", "if", "is", "it", "my", "not", "of", "or", "the", "to", "up", "what", "when"];
var tipuesearch_replace = {"words": [
{"word": "tipua", "replace_with": "tipue"},
{"word": "javscript", "replace_with": "javascript"}
]};
var tipuesearch_stem = {"words": [
{"word": "e-mail", "stem": "email"},
{"word": "javascript", "stem": "js"},
{"word": "nightmare.js", "stem": "nightmarejs"}
]};

View File

@ -1,2 +0,0 @@
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(e){var s;window.UIkit2&&(s=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-search",["uikit"],function(){return s||e(UIkit2)})}(function(e){"use strict";e.component("search",{defaults:{msgResultsHeader:"Search Results",msgMoreResults:"More Results",msgNoResults:"No results found",template:'<ul class="uk-nav uk-nav-search uk-autocomplete-results"> {{#msgResultsHeader}}<li class="uk-nav-header uk-skip">{{msgResultsHeader}}</li>{{/msgResultsHeader}} {{#items && items.length}} {{~items}} <li data-url="{{!$item.url}}"> <a href="{{!$item.url}}"> {{{$item.title}}} {{#$item.text}}<div>{{{$item.text}}}</div>{{/$item.text}} </a> </li> {{/items}} {{#msgMoreResults}} <li class="uk-nav-divider uk-skip"></li> <li class="uk-search-moreresults" data-moreresults="true"><a href="#" onclick="jQuery(this).closest(\'form\').submit();">{{msgMoreResults}}</a></li> {{/msgMoreResults}} {{/end}} {{^items.length}} {{#msgNoResults}}<li class="uk-skip"><a>{{msgNoResults}}</a></li>{{/msgNoResults}} {{/end}} </ul>',renderer:function(e){var s=this.options;this.dropdown.append(this.template({items:e.results||[],msgResultsHeader:s.msgResultsHeader,msgMoreResults:s.msgMoreResults,msgNoResults:s.msgNoResults})),this.show()}},boot:function(){e.$html.on("focus.search.uikit","[data-uk-search]",function(){var s=e.$(this);s.data("search")||e.search(s,e.Utils.options(s.attr("data-uk-search")))})},init:function(){var s=this;this.autocomplete=e.autocomplete(this.element,this.options),this.autocomplete.dropdown.addClass("uk-dropdown-search"),this.autocomplete.input.on("keyup",function(){s.element[s.autocomplete.input.val()?"addClass":"removeClass"]("uk-active")}).closest("form").on("reset",function(){s.value="",s.element.removeClass("uk-active")}),this.on("selectitem.uk.autocomplete",function(e,t){t.url?location.href=t.url:t.moreresults&&s.autocomplete.input.closest("form").submit()}),this.element.data("search",this)}})});

View File

@ -330,3 +330,10 @@ a:focus, .uk-link:focus {
.mg-skiplinks a:focus { .mg-skiplinks a:focus {
color: white; color: white;
} }
.duckduckgo {
height: 40px;
width: 90%;
padding: 5%;
background: #f5f5f5;
}

View File

@ -52,7 +52,7 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
<link rel="stylesheet" type="text/css" href="{{SITEURL}}/theme/bundle-DISABLE_SEARCH-{{DISABLE_SEARCH|string|first|length|string|first}}-SHORTSHA1-39aab30.css"> <link rel="stylesheet" type="text/css" href="{{SITEURL}}/theme/bundle-SHORTSHA1-b785cd8.css">
</head> </head>
<body> <body>
<!--[if lt IE 7]> <!--[if lt IE 7]>
@ -69,7 +69,9 @@
</div> </div>
<ul class="uk-hidden-small mg-skiplinks"> <ul class="uk-hidden-small mg-skiplinks">
{% if not DISABLE_SEARCH %}
<li><a href="#search-form">Search form</a></li> <li><a href="#search-form">Search form</a></li>
{% endif %}
</ul> </ul>
<div class="mg-header-extra uk-hidden-small"> <div class="mg-header-extra uk-hidden-small">
@ -146,12 +148,7 @@
</div> </div>
{% if not DISABLE_SEARCH %} {% if not DISABLE_SEARCH %}
<div class="uk-panel uk-panel-box"> <iframe src="https://duckduckgo.com/search.html?site={{ SITEURL }}&prefill=Search" class="duckduckgo" frameborder="0"></iframe>
<form id="search-form" role="search" title="Search form" class="mg-search" action="{{ SITEURL }}/search.html" data-uk-search>
<input type="submit" title="Submit search terms" class="mg-search-button" value="&#xf002;">
<input type="search" title="words" placeholder="words" name="q" class="mg-search-query uk-search-field tipue_search" autocomplete="off">
</form>
</div>
{% endif %} {% endif %}
{% if LINKS %} {% if LINKS %}
@ -211,10 +208,7 @@
<div class="uk-offcanvas-bar"> <div class="uk-offcanvas-bar">
{% if not DISABLE_SEARCH %} {% if not DISABLE_SEARCH %}
<form role="search" title="Search form" class="mg-search" action="{{ SITEURL }}/search.html" data-uk-search> <iframe src="https://duckduckgo.com/search.html?site={{ SITEURL }}&prefill=Search" class="duckduckgo" frameborder="0"></iframe>
<input type="submit" title="Submit search terms" class="mg-search-button" value="&#xf002;">
<input type="search" title="words" placeholder="words" name="content" class="mg-search-query uk-search-field tipue_search" autocomplete="off">
</form>
{% endif %} {% endif %}
<ul class="uk-nav uk-nav-offcanvas" data-uk-nav> <ul class="uk-nav uk-nav-offcanvas" data-uk-nav>
@ -259,10 +253,9 @@
</div> </div>
</aside> </aside>
<script src="{{SITEURL}}/theme/bundle-DISABLE_SEARCH-{{DISABLE_SEARCH|string|first|length|string|first}}-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-9eba27f.js"></script> <script src="{{SITEURL}}/theme/bundle-SHARE-{{SHARE|string|first|length|string|first}}-MG_FILTER_TAGS-{{MG_FILTER_TAGS|string|first|length|string|first}}-SHORTSHA1-004a392.js"></script>
{% include 'disqus_count.html' %} {% include 'disqus_count.html' %}
{% include 'analytics.html' %} {% include 'analytics.html' %}
</body> </body>
</html> </html>

View File

@ -1,15 +0,0 @@
{% extends "base.html" %}
{% block title %}Search results{% endblock %}
{% block description %}{% endblock %}
{% block content %}
<div class="uk-width-medium-4-5">
<h1 class="uk-heading-large">Search results</h1>
<div id="tipue_search_content"></div>
</div>
{% endblock %}