From 137bec8d16096f82416a31d6df9c82d6c10e1bd6 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Thu, 4 May 2017 01:40:53 +0200 Subject: [PATCH] jkqlfd --- content/assets/scripts/search.coffee | 15 +- content/assets/scripts/tipuesearch.js | 273 ++++++++++++------ .../assets/stylesheets/includes/general.scss | 3 +- .../14-15/git-de-stomme-content-tracker.md | 2 +- content/search.erb | 3 + 5 files changed, 192 insertions(+), 104 deletions(-) diff --git a/content/assets/scripts/search.coffee b/content/assets/scripts/search.coffee index c52c51f..12d6a4f 100644 --- a/content/assets/scripts/search.coffee +++ b/content/assets/scripts/search.coffee @@ -1,10 +1,9 @@ -$ -> - $('#tipue_search_input_field').focusin -> - $('#tipue_search_input').addClass("focused") +$('#tipue_search_input_field').on 'focusin', -> + $('#tipue_search_input').addClass("focused") - $('#tipue_search_input_field').focusout -> - $('#tipue_search_input').removeClass("focused") +$('#tipue_search_input_field').on 'focusout', -> + $('#tipue_search_input').removeClass("focused") - $('.nav-toggle').click -> - $('.nav-menu').toggleClass('is-active') - $('.nav-toggle').toggleClass('is-active') +$('.nav-toggle').on 'click', -> + $('.nav-menu').toggleClass('is-active') + $('.nav-toggle').toggleClass('is-active') diff --git a/content/assets/scripts/tipuesearch.js b/content/assets/scripts/tipuesearch.js index 29539fe..7a63b2a 100644 --- a/content/assets/scripts/tipuesearch.js +++ b/content/assets/scripts/tipuesearch.js @@ -1,7 +1,7 @@ /* -Tipue Search 5.0 -Copyright (c) 2015 Tipue +Tipue Search 6.0 +Copyright (c) 2017 Tipue Tipue Search is released under the MIT License http://www.tipue.com/search */ @@ -13,20 +13,26 @@ http://www.tipue.com/search var set = $.extend( { - 'show' : 7, - 'newWindow' : false, - 'showURL' : true, - 'showTitleCount' : true, - 'minimumLength' : 3, - 'descriptiveWords' : 25, - 'highlightTerms' : true, - 'highlightEveryTerm' : false, - 'mode' : 'static', - 'liveDescription' : '*', - 'liveContent' : '*', - 'contentLocation' : 'tipuesearch/tipuesearch_content.json', - 'debug' : false, - 'tipue_search_content' : '#tipue_search_content' + 'contentLocation' : 'tipuesearch/tipuesearch_content.json', + 'contextBuffer' : 60, + 'contextLength' : 60, + 'contextStart' : 90, + 'debug' : false, + 'descriptiveWords' : 25, + 'highlightTerms' : true, + 'liveContent' : '*', + 'liveDescription' : '*', + 'minimumLength' : 3, + 'mode' : 'static', + 'newWindow' : false, + 'show' : 9, + 'showContext' : true, + 'showRelated' : false, + 'showTime' : false, + 'showTitleCount' : true, + 'showURL' : true, + 'wholeWords' : true, + 'tipue_search_content' : '#tipue_search_content' }, options); @@ -40,47 +46,47 @@ http://www.tipue.com/search }); var tipuesearch_t_c = 0; + $(set.tipue_search_content).hide().html('
').show(); + if (set.mode == 'live') { for (var i = 0; i < tipuesearch_pages.length; i++) { - $.get(tipuesearch_pages[i]) - .done(function(html) + $.get(tipuesearch_pages[i]).done(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(''); + var t_2 = html.toLowerCase().indexOf('', t_1 + 7); + if (t_1 != -1 && t_2 != -1) { - var cont = $(set.liveContent, html).text(); - cont = cont.replace(/\s+/g, ' '); - var desc = $(set.liveDescription, html).text(); - desc = desc.replace(/\s+/g, ' '); + var tit = html.slice(t_1 + 7, t_2); + } + else + { + var tit = tipuesearch_string_1; + } - var t_1 = html.toLowerCase().indexOf(''); - var t_2 = html.toLowerCase().indexOf('', t_1 + 7); - if (t_1 != -1 && t_2 != -1) - { - var tit = html.slice(t_1 + 7, t_2); - } - else - { - var tit = tipuesearch_string_1; - } - - tipuesearch_in.pages.push( - { - "title": tit, - "text": desc, - "tags": cont, - "url": tipuesearch_pages[i] - }); + tipuesearch_in.pages.push( + { + "title": tit, + "text": desc, + "tags": cont, + "url": tipuesearch_pages[i] }); + }); } } if (set.mode == 'json') { - $.getJSON(set.contentLocation) - .done(function(json) - { - tipuesearch_in = $.extend({}, json); - }); + $.getJSON(set.contentLocation).done(function(json) + { + tipuesearch_in = $.extend({}, json); + }); } if (set.mode == 'static') @@ -96,8 +102,20 @@ http://www.tipue.com/search function getURLP(name) { - return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20')) || null; + 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')); @@ -115,10 +133,6 @@ http://www.tipue.com/search function getTipueSearch(start, replace) { - $(set.tipue_search_content).hide(); - $(set.tipue_search_content).html('
'); - $(set.tipue_search_content).show(); - var out = ''; var results = ''; var show_replace = false; @@ -127,7 +141,8 @@ http://www.tipue.com/search var c = 0; found = []; - var d = $('#tipue_search_input').val().toLowerCase(); + var d_o = $('#tipue_search_input').val(); + var d = d_o.toLowerCase(); d = $.trim(d); if ((d.match("^\"") && d.match("\"$")) || (d.match("^'") && d.match("'$"))) @@ -135,9 +150,10 @@ http://www.tipue.com/search standard = false; } + var d_w = d.split(' '); + if (standard) { - var d_w = d.split(' '); d = ''; for (var i = 0; i < d_w.length; i++) { @@ -203,7 +219,14 @@ http://www.tipue.com/search var s_t = tipuesearch_in.pages[i].text; for (var f = 0; f < d_w.length; f++) { - var pat = new RegExp(d_w[f], 'gi'); + if (set.wholeWords) + { + var pat = new RegExp('\\b' + d_w[f] + '\\b', 'gi'); + } + else + { + var pat = new RegExp(d_w[f], 'gi'); + } if (tipuesearch_in.pages[i].title.search(pat) != -1) { var m_c = tipuesearch_in.pages[i].title.match(pat).length; @@ -215,19 +238,6 @@ http://www.tipue.com/search score += (20 * m_c); } - 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, "$1"); - } - if (tipuesearch_in.pages[i].tags.search(pat) != -1) { var m_c = tipuesearch_in.pages[i].tags.match(pat).length; @@ -291,19 +301,6 @@ http://www.tipue.com/search score += (20 * m_c); } - 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, "$1"); - } - if (tipuesearch_in.pages[i].tags.search(pat) != -1) { var m_c = tipuesearch_in.pages[i].tags.match(pat).length; @@ -349,19 +346,27 @@ http://www.tipue.com/search tipuesearch_t_c++; } - if (show_replace == 1) + if (show_replace) { out += '
' + tipuesearch_string_2 + ' ' + d + '. ' + tipuesearch_string_3 + ' ' + d_r + '
'; } if (c == 1) { - out += '
' + tipuesearch_string_4 + '
'; + out += '
' + tipuesearch_string_4; } else { c_c = c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); - out += '
' + c_c + ' ' + tipuesearch_string_5 + '
'; + 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 += '
'; found.sort(function(a, b) { return b.score - a.score } ); @@ -380,7 +385,7 @@ http://www.tipue.com/search if (set.showURL) { var s_u = found[i].url.toLowerCase(); - if(s_u.indexOf('http://') == 0) + if (s_u.indexOf('http://') == 0) { s_u = s_u.slice(7); } @@ -390,6 +395,43 @@ http://www.tipue.com/search 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) @@ -408,21 +450,60 @@ http://www.tipue.com/search { t_d += ' ...'; } + + t_d = t_d.replace(/h0011/g, 'tipue_search_content_bold'); + out += '
' + t_d + '
'; } } l_o++; } + if (set.showRelated && standard) + { + f = 0; + for (var i = 0; i < tipuesearch_related.searches.length; i++) + { + if (d == tipuesearch_related.searches[i].search) + { + if (show_replace) + { + d_o = d; + } + if (!f) + { + out += ''; + } + } + if (c > set.show) { var pages = Math.ceil(c / set.show); var page = (start / set.show); - out += '
'; } } else @@ -497,15 +578,19 @@ http://www.tipue.com/search } } - $(set.tipue_search_content).hide(); - $(set.tipue_search_content).html(out); - $(set.tipue_search_content).slideDown(200); + $(set.tipue_search_content).hide().html(out).slideDown(200); $('#tipue_search_replaced').click(function() { getTipueSearch(0, false); }); + $('.tipue_search_related').click(function() + { + $('#tipue_search_input').val($(this).attr('id')); + getTipueSearch(0, true); + }); + $('.tipue_search_foot_box').click(function() { var id_v = $(this).attr('id'); diff --git a/content/assets/stylesheets/includes/general.scss b/content/assets/stylesheets/includes/general.scss index 44c3f25..b801f3c 100644 --- a/content/assets/stylesheets/includes/general.scss +++ b/content/assets/stylesheets/includes/general.scss @@ -154,7 +154,8 @@ footer.footer { .alignright { float: right; - margin: 15px; + padding: 15px; + background-color: $body-background; } // Bold definition types in
diff --git a/content/blog/14-15/git-de-stomme-content-tracker.md b/content/blog/14-15/git-de-stomme-content-tracker.md index 15383cb..b5f3a78 100644 --- a/content/blog/14-15/git-de-stomme-content-tracker.md +++ b/content/blog/14-15/git-de-stomme-content-tracker.md @@ -8,7 +8,7 @@ location: Zeus kelder poster-shaped -"I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'." +> "I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'."     -- Linus Torvalds Net zoals dat achter elk groot man een sterke vrouw staat, staat achter elk groot softwareproject een sterk versiecontrolesysteem. Dat geldt uiteraard ook voor de Linuxkernel, maar zo vanzelfsprekend was dat niet. Het bleek namelijk al snel dat er geen enkel zulk systeem bestond dat aan de noden van het grootste opensourceproject van de wereld kon voldoen: snelheid, een bijna onfeilbare data-integriteit, en een grote nadruk op parellel ontwikkelen waren broodnodig. Daarop sloegen Torvalds en kornuiten - ware hackers zijnde - zelf aan het werk, onder het motto ‘in geval van twijfel, kijk wat CVS doet, en doe het tegengestelde.’ diff --git a/content/search.erb b/content/search.erb index 0504678..32256f7 100644 --- a/content/search.erb +++ b/content/search.erb @@ -16,6 +16,8 @@ title: Search
+ +<% content_for :scripts do %> +<% end %>