From 01bc12e920ac2d6bdc0a707a552dd93aab989be8 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Sat, 21 Mar 2020 17:48:30 -0400 Subject: [PATCH 01/35] maybe solved searching?? --- _includes/lesson-index.html | 2 ++ _includes/lesson_describe.html | 1 + css/style.css | 19 +++++++++++++++++++ js/lessonfilter.js | 8 +++++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index dc94f87d79..540cfaeee2 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -24,6 +24,7 @@ +
- +
- +
+ + +
+
- +
diff --git a/_includes/lesson_describe.html b/_includes/lesson_describe.html index 0a3766b05f..127be47a41 100755 --- a/_includes/lesson_describe.html +++ b/_includes/lesson_describe.html @@ -23,8 +23,7 @@

{{ include.authors }}

{{ lesson.title }}

- {{ lesson.abstract | markdownify | remove: '

' | remove: '

'}} -

+ {{ lesson.abstract | markdownify | remove: '

' | remove: '

'}}

{% comment %} Activity and topic are hidden via CSS as a hack to let JS sorting by activity and topic work. Note that the date sort is based on translation date first, falling back to publication date. diff --git a/css/style.css b/css/style.css index 6d8fdeeb32..3fcfbd53ea 100644 --- a/css/style.css +++ b/css/style.css @@ -347,6 +347,7 @@ Lessons Index display: inline-block; text-transform: uppercase; text-decoration: none; + } /***************** diff --git a/js/lessonfilter.js b/js/lessonfilter.js index ad2bb871af..1665c415a6 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -162,7 +162,6 @@ function wireButtons() { }); resetSearch(); } - } }); // Search lessons on enter press From 9f453ceb1268b2450fc28f65c2621922e1e32ae9 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Sun, 12 Apr 2020 19:26:06 -0400 Subject: [PATCH 11/35] fixed search bugs and got it working with filter logic --- _includes/lesson-index.html | 2 +- _includes/lesson_describe.html | 3 ++- css/style.css | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index 96ba225181..fab7fcd97c 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -25,7 +25,7 @@ this div ('lesson-list', referenced in lessonfilter.js) needs to contain the sort button/elements AND the actual list for the sort buttons to work -->
- +
diff --git a/_includes/lesson_describe.html b/_includes/lesson_describe.html index 127be47a41..0a3766b05f 100755 --- a/_includes/lesson_describe.html +++ b/_includes/lesson_describe.html @@ -23,7 +23,8 @@

{{ include.authors }}

{{ lesson.title }}

- {{ lesson.abstract | markdownify | remove: '

' | remove: '

'}}

+ {{ lesson.abstract | markdownify | remove: '

' | remove: '

'}} +

{% comment %} Activity and topic are hidden via CSS as a hack to let JS sorting by activity and topic work. Note that the date sort is based on translation date first, falling back to publication date. diff --git a/css/style.css b/css/style.css index 3fcfbd53ea..6d8fdeeb32 100644 --- a/css/style.css +++ b/css/style.css @@ -347,7 +347,6 @@ Lessons Index display: inline-block; text-transform: uppercase; text-decoration: none; - } /***************** From 76da59b6abebdf483ccdd332cba8a7b251513f0f Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Mon, 13 Apr 2020 11:45:31 -0400 Subject: [PATCH 12/35] added search enable button and more comments to code --- _includes/lesson-index.html | 5 +++- css/style.css | 3 ++- js/lessonfilter.js | 49 ++++++++++++++++++++++++++++--------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index fab7fcd97c..3e9aaf3112 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -24,10 +24,13 @@ -
+ +
+ +
diff --git a/css/style.css b/css/style.css index 6d8fdeeb32..d2bd0c9eb5 100644 --- a/css/style.css +++ b/css/style.css @@ -335,7 +335,8 @@ Lessons Index text-decoration: none; } - #search-button { + #search-button, + #enable-search-button { background-color: #efefef; color: #666; width: 39%; diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 1665c415a6..01a0a818b4 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -53,7 +53,10 @@ function applySortFromURI(uri,featureList) { } function lunrSearch(searchString, idx, corpus, featureList) { + // Create lunr search with initial search string const results = idx.search(searchString); + + // Get docs that contain the search string var docs = results.filter(result => corpus.some(doc => result.ref === doc.url)).map(result => { let doc = corpus.find(o => o.url === result.ref); return { @@ -64,6 +67,7 @@ function lunrSearch(searchString, idx, corpus, featureList) { const BUFFER = 30 // Number of characters to show for kwic-results const MAX_KWIC = 3 + // Create html to show search results using html mark docs.map((doc) => { let elementName = '/'+doc.url.split('/').slice(3, ).join('/') let search_keys = Object.keys(doc.matchData.metadata); @@ -81,19 +85,24 @@ function lunrSearch(searchString, idx, corpus, featureList) { $(`p[id="${elementName}-search_results"]`).css('display', ''); $(`p[id="${elementName}-search_results"]`).html(inner_results); }); + // Filter featureList to only show items from search results featureList.filter((item) => { if (item.visible()){ return docs.find((doc) => doc.title === item.values().title) } }); featureList.update() + // Hide original abstracts $('.abstract').css('display', 'none'); } function resetSearch() { + // Empty search input $('#search').val(''); + // Hide and empty search results $('.search_results').css('display', 'none'); $('.search_results').html(''); + // Show original abstract results $('.abstract').css('display', 'block'); }; @@ -114,14 +123,30 @@ function wireButtons() { // Get search indices and corpuses using URI to make a call to search-index for each language let idx; let corpus; - const language = uri.toString().split('/').slice(-3)[0]; - $.getJSON(`https://programminghistorian.github.io/search-index/indices/index${language.toUpperCase()}.json`).done(response => { - idx = lunr.Index.load(JSON.parse(JSON.stringify(response))); - }); - $.getJSON(`https://programminghistorian.org/${language}/search.json`).done(response => { - corpus = response; - $('#search').attr("placeholder", "Type search terms..."); - $('#search-button').prop('disabled', false); + + // Load search data + function loadSearchData() { + // Get language specific corpus and index + const language = uri.toString().split('/').slice(-3)[0]; + $.getJSON(`https://programminghistorian.github.io/search-index/indices/index${language.toUpperCase()}.json`).done(response => { + idx = lunr.Index.load(JSON.parse(JSON.stringify(response))); + }); + $.getJSON(`https://programminghistorian.org/${language}/search.json`).done(response => { + corpus = response; + // Enable search input and button once data loaded + $('#search').attr("placeholder", "Type search terms..."); + $('#search-button').prop('disabled', false); + }); + } + + // Enable search on button click + $("#enable-search-div").on("click", () => { + // Start loading search data + loadSearchData(); + + // Hide enable button and show search input + $("#enable-search-div").css("display", "none"); + $("#search-div").css("display", ""); }); // Example of an async version... not sure it works though @@ -145,14 +170,15 @@ function wireButtons() { // Check that's it's not empty if (searchString.length > 0) { + // Call lunr search lunrSearch(searchString, idx, corpus, featureList); } else { // If empty check if topic or activity selected if (document.querySelector('.current') === null) { - // Run reset + // If none selected, then run full reset $('#filter-none').click(); } else { - // Return filter lessons based on URI + // Otherwise return filter lessons based on URI var filterType = uri.toString().split('?').slice(-1).pop().split('=')[0]; var type = uri.toString().split('?').slice(-1).pop().split('=').splice(-1)[0]; featureList.filter(function (item) { @@ -160,6 +186,7 @@ function wireButtons() { var condition = filterType == 'topic' ? topicsArray.includes(type) : item.values().activity == type; return condition ? true : false; }); + // Call reset search to empty out search values resetSearch(); } } @@ -169,8 +196,6 @@ function wireButtons() { if (event.which == 13) { $("#search-button").click(); } - // featureList.search(searchString, ['content']); - // featureList.fuzzySearch(searchString, ['content']); // List.js has a fuzzy search method but I get fewer results with it than the regular search method. We could create are own fuzzy search function here and then use List.js filtering instead of search. }); // When a filter button is clicked From ea7577dcec95e9d489a1ae99433fd402769990f8 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Wed, 6 May 2020 18:44:41 -0400 Subject: [PATCH 13/35] fixed most of the bugs in full text search --- js/lessonfilter.js | 95 +++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 52 deletions(-) diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 01a0a818b4..142ccde850 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -8,7 +8,7 @@ function resetSort() { } -function applySortFromURI(uri,featureList) { +function applySortFromURI(uri,featureList, idx={}, corpus=[]) { console.log("applying sort from URI"); @@ -49,10 +49,10 @@ function applySortFromURI(uri,featureList) { } // Performm new sort - featureList.sort(sortType, { order: sortOrder }); + featureList.sort(sortType, {order: sortOrder}); } -function lunrSearch(searchString, idx, corpus, featureList) { +function lunrSearch(searchString, idx, corpus, featureList, uri) { // Create lunr search with initial search string const results = idx.search(searchString); @@ -68,6 +68,7 @@ function lunrSearch(searchString, idx, corpus, featureList) { const BUFFER = 30 // Number of characters to show for kwic-results const MAX_KWIC = 3 // Create html to show search results using html mark + let elements = [] docs.map((doc) => { let elementName = '/'+doc.url.split('/').slice(3, ).join('/') let search_keys = Object.keys(doc.matchData.metadata); @@ -81,19 +82,32 @@ function lunrSearch(searchString, idx, corpus, featureList) { }).join("") return grouped_kwic }).join("").replace(/(\r\n|\n|\r)/gm, ""); - - $(`p[id="${elementName}-search_results"]`).css('display', ''); - $(`p[id="${elementName}-search_results"]`).html(inner_results); + elements.push({'elementName': elementName, 'innerResults': inner_results}); + // $(`p[id="${elementName}-search_results"]`).css('display', ''); + // $(`p[id="${elementName}-search_results"]`).html(inner_results); }); - // Filter featureList to only show items from search results + // Filter featureList to only show items from search results and active filters + var filterType = uri.toString().split('?').slice(-1).pop().split('=')[0]; + var type = uri.toString().split('?').slice(-1).pop().split('=').splice(-1)[0]; + console.log('pre', featureList.matchingItems.length); featureList.filter((item) => { - if (item.visible()){ - return docs.find((doc) => doc.title === item.values().title) - } + var topicsArray = item.values().topics.split(/\s/); + var condition = filterType == 'topic' ? topicsArray.includes(type) : item.values().activity == type; + + return docs.find((doc) => { + return document.querySelector('.current') === null ? doc.title === item.values().title : (doc.title === item.values().title) && condition; + + }); }); - featureList.update() + featureList.update(); // Hide original abstracts $('.abstract').css('display', 'none'); + $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); + $('#results-value').css('textTransform', 'uppercase'); + elements.map( (elm) => { + $(`p[id="${elm.elementName}-search_results"]`).css('display', ''); + $(`p[id="${elm.elementName}-search_results"]`).html(elm.innerResults); + }) } function resetSearch() { @@ -149,34 +163,23 @@ function wireButtons() { $("#search-div").css("display", ""); }); - // Example of an async version... not sure it works though - // const request = async () => { - // const indexResponse = await fetch("https://raw.githubusercontent.com/programminghistorian/search-index/master/indices/indexEN.json"); - // const indexJSON = await indexResponse.json(); - // idx = lunr.Index.load(indexJSON); - // window.idx = idx; - // const corpusResponse = await fetch("https://raw.githubusercontent.com/programminghistorian/search-index/master/indices/indexEN.json"); - // const corpusJSON = await corpusResponse.json(); - // corpus = corpusJSON; - // window.corpus = corpus; - // } - // request(); // Search lessons on button click - $("#search-button").on("click", () => { - + $("#search-button").on("click", (event) => { // Get search string const searchString = $("#search").val(); // Check that's it's not empty if (searchString.length > 0) { // Call lunr search - lunrSearch(searchString, idx, corpus, featureList); + lunrSearch(searchString, idx, corpus, featureList, uri); } else { // If empty check if topic or activity selected if (document.querySelector('.current') === null) { // If none selected, then run full reset - $('#filter-none').click(); + $('#filter-none').triggerHandler('click'); + event.preventDefault(); + } else { // Otherwise return filter lessons based on URI var filterType = uri.toString().split('?').slice(-1).pop().split('=')[0]; @@ -190,6 +193,7 @@ function wireButtons() { resetSearch(); } } + }); // Search lessons on enter press $('#search').on('keyup', (event) => { @@ -203,12 +207,11 @@ function wireButtons() { // Set clicked button as current $('.filter').children().removeClass("current"); $(this).addClass("current"); - // Update the results header $('#results-value').text($(this).text() + " "); $('#results-value').css('textTransform', 'uppercase'); - - applySortFromURI(uri,featureList); + applySortFromURI(uri, featureList); + }); // When the reset button is clicked @@ -217,19 +220,20 @@ function wireButtons() { $('.filter').children().removeClass("current"); // Reset filter results header - $('#results-value').text($('#results-value').text()); - + $('#results-value').text(featureList.update().items.length); + $('#search').val(''); // Reset search results resetSearch(); + // Reset uri to remove query params uri.search(""); history.pushState(stateObj, "", uri.toString()); // Reset filtering and perform default sort featureList.filter(); + featureList.sort('date', { order: "desc" }); - // Reset sort buttons to defaults resetSort(); }); @@ -237,7 +241,7 @@ function wireButtons() { // When a sort button is clicked, update the results header to show current sorting status $('.sort').click(function() { - + // Get sort type from button (date or difficulty) var sortType = $(this).attr("data-sort"); @@ -281,20 +285,14 @@ function wireButtons() { $('.filter.activities').children().click(function() { var type = $(this).attr("id").substr(7); - - featureList.filter(function(item) { - if (item.values().activity == type) { - return true; - } else { - return false; - } - }); - + // reset url parameter uri.removeSearch("topic"); uri.setSearch("activity", type); // returns the URI instance for chaining history.pushState(stateObj, "", uri.toString()); console.log(uri.toString()); + // Use search to perform filtering + $("#search-button").click(); return false; }); @@ -305,20 +303,13 @@ function wireButtons() { var type = $(this).attr("id").substr(7); - featureList.filter(function(item) { - var topicsArray = item.values().topics.split(/\s/); - if (topicsArray.includes(type)) { - return true; - } else { - return false; - } - }); - // Reset url parameters uri.removeSearch("activity"); uri.setSearch("topic", type); // returns the URI instance for chaining history.pushState(stateObj, "", uri.toString()); console.log(uri.toString()); + // Use search to perform filtering + $("#search-button").click(); return false; }); From da7263f5fc1bc31abac9e5603e2af68f571b03ae Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Wed, 6 May 2020 19:34:39 -0400 Subject: [PATCH 14/35] added in support for multiple language stemmers --- _includes/lesson-index.html | 5 +- css/style.css | 6 + js/lessonfilter.js | 9 +- js/lunr.es.js | 599 ++++++++++++++++++++++++++++++ js/lunr.fr.js | 703 ++++++++++++++++++++++++++++++++++++ js/lunr.stemmer.support.js | 326 +++++++++++++++++ 6 files changed, 1646 insertions(+), 2 deletions(-) create mode 100644 js/lunr.es.js create mode 100644 js/lunr.fr.js create mode 100644 js/lunr.stemmer.support.js diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index 3e9aaf3112..e72a706433 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -29,7 +29,7 @@
- +
@@ -66,6 +66,9 @@

{{ site.data.snippets.filtering-results[page.lang] }}: + + + From ca4fd88a619a38a65c9cce9074e81584a0e95ab5 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Fri, 8 May 2020 17:49:49 -0400 Subject: [PATCH 16/35] updated search input to work with snippets --- _includes/lesson-index.html | 4 +++- css/style.css | 4 ++-- js/lessonfilter.js | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index e02017e9cf..f4569b5d96 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -27,7 +27,9 @@ this div ('lesson-list', referenced in lessonfilter.js) needs to contain the sort button/elements AND the actual list for the sort buttons to work -->
diff --git a/css/style.css b/css/style.css index acd768dc85..026cb8dfdd 100644 --- a/css/style.css +++ b/css/style.css @@ -319,7 +319,7 @@ Lessons Index SEARCH *****************/ - #search { + .search-input { width:60%; clear:both; margin-bottom:1rem; @@ -338,7 +338,7 @@ Lessons Index #search-button, #enable-search-button { background-color: #efefef; - color: #666; + color: rgb(153, 143, 143); width: 39%; font: .9rem/1.1rem 'Open Sans', sans-serif; diff --git a/js/lessonfilter.js b/js/lessonfilter.js index f68da20199..3c4543ea72 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -83,8 +83,7 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { return grouped_kwic }).join("").replace(/(\r\n|\n|\r)/gm, ""); elements.push({'elementName': elementName, 'innerResults': inner_results}); - // $(`p[id="${elementName}-search_results"]`).css('display', ''); - // $(`p[id="${elementName}-search_results"]`).html(inner_results); + }); // Filter featureList to only show items from search results and active filters var filterType = uri.toString().split('?').slice(-1).pop().split('=')[0]; @@ -148,7 +147,8 @@ function wireButtons() { $.getJSON(`https://programminghistorian.org/${language}/search.json`).done(response => { corpus = response; // Enable search input and button once data loaded - $('#search').attr("placeholder", "Type search terms..."); + $('#loading-search').css('display', 'none'); + $('#search').css('display', ''); $('#search-button').prop('disabled', false); }); } From e8372d73a9618e783b8949e4d6811f9104b0dbf6 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Fri, 8 May 2020 22:58:30 -0400 Subject: [PATCH 17/35] trying to comment and clean up code --- js/lessonfilter.js | 170 +++++++++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 77 deletions(-) diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 3c4543ea72..3c15b914a2 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -2,14 +2,17 @@ --- function resetSort() { + /* Function to reset sort buttons */ $('#current-sort').removeClass().addClass("sort-desc"); $("#sort-by-date").removeClass().addClass("sort desc my-asc"); $("#sort-by-difficulty").removeClass().addClass("sort my-desc"); } -function applySortFromURI(uri,featureList, idx={}, corpus=[]) { - +function applySortFromURI(uri,featureList) { + /* Function to update lesson-list using featureList and sort direction + - uses URI to generate sort directions + */ console.log("applying sort from URI"); var params = uri.search(true); @@ -50,13 +53,25 @@ function applySortFromURI(uri,featureList, idx={}, corpus=[]) { // Performm new sort featureList.sort(sortType, {order: sortOrder}); + + // Reset filter results header + $('#results-value').text(featureList.update().items.length); } -function lunrSearch(searchString, idx, corpus, featureList, uri) { - // Create lunr search with initial search string +function lunrSearch(searchString, idx, corpus, featureList, uri, stateObj) { + /* Function to generate search using lunr + - find search results using index + - load in original corpus and find relevant lessons + - generate new html to show search snippet + - use featureList to show lessons with search results (also relevant filters) + - display html + - update uri to include search string + */ + + // Get lessons that contain search string using lunr index const results = idx.search(searchString); - // Get docs that contain the search string + // Get lessons from corpus that contain the search string var docs = results.filter(result => corpus.some(doc => result.ref === doc.url)).map(result => { let doc = corpus.find(o => o.url === result.ref); return { @@ -86,27 +101,26 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { }); // Filter featureList to only show items from search results and active filters - var filterType = uri.toString().split('?').slice(-1).pop().split('=')[0]; - var type = uri.toString().split('?').slice(-1).pop().split('=').splice(-1)[0]; - console.log('pre', featureList.matchingItems.length); + var params = uri.search(true); + var type = params.activity ? params.activity : params.topic; featureList.filter((item) => { - var topicsArray = item.values().topics.split(/\s/); - var condition = filterType == 'topic' ? topicsArray.includes(type) : item.values().activity == type; - + let topicsArray = item.values().topics.split(/\s/); + let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; + // Could simply to just do Object.keys(params) > 1 here but in case we add more URI values this will explicitly check for filters along with search return docs.find((doc) => { - return document.querySelector('.current') === null ? doc.title === item.values().title : (doc.title === item.values().title) && condition; - + return ['topic', 'activity'].some(key => Object.keys(params).includes(key)) ? ((doc.title === item.values().title) && condition) : (doc.title === item.values().title); + }); }); - featureList.update(); // Hide original abstracts $('.abstract').css('display', 'none'); $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); $('#results-value').css('textTransform', 'uppercase'); + // Display updated search results elements.map( (elm) => { $(`p[id="${elm.elementName}-search_results"]`).css('display', ''); $(`p[id="${elm.elementName}-search_results"]`).html(elm.innerResults); - }) + }); } function resetSearch() { @@ -138,59 +152,63 @@ function wireButtons() { let corpus; // Load search data - function loadSearchData() { - // Get language specific corpus and index + const loadSearchData = async () => { const language = uri.toString().split('/').slice(-3)[0]; - $.getJSON(`https://programminghistorian.github.io/search-index/indices/index${language.toUpperCase()}.json`).done(response => { - idx = lunr.Index.load(JSON.parse(JSON.stringify(response))); - }); - $.getJSON(`https://programminghistorian.org/${language}/search.json`).done(response => { - corpus = response; - // Enable search input and button once data loaded - $('#loading-search').css('display', 'none'); - $('#search').css('display', ''); - $('#search-button').prop('disabled', false); - }); + const indexResponse = await fetch(`https://programminghistorian.github.io/search-index/indices/index${language.toUpperCase()}.json`); + const indexJSON = await indexResponse.json(); + idx = lunr.Index.load(indexJSON); + // window.idx = idx; + const corpusResponse = await fetch(`https://programminghistorian.org/${language}/search.json`); + const corpusJSON = await corpusResponse.json(); + corpus = corpusJSON; + $('#loading-search').css('display', 'none'); + $('#search').css('display', ''); + $('#search-button').prop('disabled', false); + // Hide enable button and show search input + $("#enable-search-div").css("display", "none"); + $("#search-div").css("display", ""); } // Enable search on button click $("#enable-search-div").on("click", () => { // Start loading search data loadSearchData(); - - // Hide enable button and show search input - $("#enable-search-div").css("display", "none"); - $("#search-div").css("display", ""); }); // Search lessons on button click - $("#search-button").on("click", (event) => { + $("#search-button").on("click", () => { // Get search string const searchString = $("#search").val(); + console.log(searchString); + searchString.length > 0 ? uri.setSearch("search", searchString) : uri.removeSearch('search'); + history.pushState(stateObj, "", uri.toString()); + console.log(uri.toString()); // Check that's it's not empty if (searchString.length > 0) { // Call lunr search - lunrSearch(searchString, idx, corpus, featureList, uri); + lunrSearch(searchString, idx, corpus, featureList, uri, stateObj); } else { // If empty check if topic or activity selected - if (document.querySelector('.current') === null) { - // If none selected, then run full reset - $('#filter-none').triggerHandler('click'); - event.preventDefault(); + // Call reset search to empty out search values + resetSearch(); - } else { + var params = uri.search(true); + var type = params.activity ? params.activity : params.topic; + if (type) { // Otherwise return filter lessons based on URI - var filterType = uri.toString().split('?').slice(-1).pop().split('=')[0]; - var type = uri.toString().split('?').slice(-1).pop().split('=').splice(-1)[0]; + featureList.filter(function (item) { var topicsArray = item.values().topics.split(/\s/); - var condition = filterType == 'topic' ? topicsArray.includes(type) : item.values().activity == type; - return condition ? true : false; + var condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; + return condition }); - // Call reset search to empty out search values - resetSearch(); + // Reset filter results header + $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); + $('#results-value').css('textTransform', 'uppercase'); + } else { + applySortFromURI(uri, featureList); } } @@ -204,45 +222,39 @@ function wireButtons() { // When a filter button is clicked $('.filter').children().click(function() { - // Set clicked button as current - $('.filter').children().removeClass("current"); - $(this).addClass("current"); - // Update the results header - $('#results-value').text($(this).text() + " "); - $('#results-value').css('textTransform', 'uppercase'); - applySortFromURI(uri, featureList); - + console.log('clicked children'); + // Set clicked button as current + $('.filter').children().removeClass("current"); + $(this).addClass("current"); + // Update the results header + $('#results-value').text($(this).text() + " "); + $('#results-value').css('textTransform', 'uppercase'); + applySortFromURI(uri, featureList); }); // When the reset button is clicked $('#filter-none').click(function() { - // Remove highlighting from filter buttons - $('.filter').children().removeClass("current"); + // Remove highlighting from filter buttons + $('.filter').children().removeClass("current"); - // Reset filter results header - $('#results-value').text(featureList.update().items.length); - - // Reset search results - resetSearch(); + // Reset filter results header + $('#results-value').text(featureList.update().items.length); + + // Reset search results + resetSearch(); - // Reset uri to remove query params - uri.search(""); - history.pushState(stateObj, "", uri.toString()); + // Reset uri to remove query params + uri.search(""); + history.pushState(stateObj, "", uri.toString()); - // Reset filtering and perform default sort - featureList.filter(); - - featureList.sort('date', { order: "desc" }); - // Reset sort buttons to defaults - resetSort(); - resetSearch(); - // $('#search').val(''); - // // Hide and empty search results - // $('.search_results').css('display', 'none'); - // $('.search_results').html(''); - // // Show original abstract results - // $('.abstract').css('display', 'block'); + // Reset filtering and perform default sort + featureList.filter(); + + featureList.sort('date', { order: "desc" }); + // Reset sort buttons to defaults + resetSort(); + resetSearch(uri, stateObj); }); @@ -333,10 +345,14 @@ function wireButtons() { // Look for URI query params var params = uri.search(true); var filter = params.activity ? params.activity : params.topic; - + var search = params.search; + // If a filter is present in the URI, simulate a click to run filter // Clicking a filter button checks for sort params in URI, so don't do it twice. - if (filter) { + if (search) { + $('#search').val(search); + loadSearchData().then(() => $('#search-button').click()).catch(e => console.log(e)); + } else if (filter) { console.log("FILTER:" + filter); $("#filter-" + filter).click(); } From 2340305715aa524a3de28e08aa9af784af762b9e Mon Sep 17 00:00:00 2001 From: spapastamkou Date: Sat, 9 May 2020 18:52:00 +0200 Subject: [PATCH 18/35] FR snippets --- _data/snippets.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_data/snippets.yml b/_data/snippets.yml index c7729431b8..9e01e318ad 100644 --- a/_data/snippets.yml +++ b/_data/snippets.yml @@ -355,22 +355,22 @@ filtering-results: loading-search: en: LOADING SEARCH... es: - fr: + fr: RECHERCHE EN COURS... pt: search-lessons: en: SEARCH LESSONS es: - fr: + fr: RECHERCHER LES LEÇONS pt: start-searching: en: START SEARCHING es: - fr: + fr: DÉMARRER LA RECHERCHE pt: type-search-terms: en: TYPE SEARCH TERMS... es: - fr: + fr: ENTRER UN OU PLUSIEURS TERMES DE RECHERCHE... pt: # lesson headers From a29e182f167eea029b5f779acd3f4de4af847fb2 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Sun, 10 May 2020 08:45:52 -0400 Subject: [PATCH 19/35] cleaned up code --- js/lessonfilter.js | 153 +++++++++++++++++++++------------------------ 1 file changed, 70 insertions(+), 83 deletions(-) diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 3c15b914a2..7a75059cbd 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -15,10 +15,10 @@ function applySortFromURI(uri,featureList) { */ console.log("applying sort from URI"); - var params = uri.search(true); - var sortOrder = params.sortOrder; - var sortType = params.sortType; - var nonSortOrder = (sortOrder == "desc" ? "asc" : "desc"); + const params = uri.search(true); + let sortOrder = params.sortOrder; + let sortType = params.sortType; + let nonSortOrder = (sortOrder == "desc" ? "asc" : "desc"); if (sortType) { console.log("SortType: " + sortType); @@ -65,14 +65,13 @@ function lunrSearch(searchString, idx, corpus, featureList, uri, stateObj) { - generate new html to show search snippet - use featureList to show lessons with search results (also relevant filters) - display html - - update uri to include search string */ // Get lessons that contain search string using lunr index const results = idx.search(searchString); // Get lessons from corpus that contain the search string - var docs = results.filter(result => corpus.some(doc => result.ref === doc.url)).map(result => { + let docs = results.filter(result => corpus.some(doc => result.ref === doc.url)).map(result => { let doc = corpus.find(o => o.url === result.ref); return { ...result, @@ -90,9 +89,9 @@ function lunrSearch(searchString, idx, corpus, featureList, uri, stateObj) { let inner_results = search_keys.map((token) => { let all_positions = doc.matchData.metadata[token].body.position; let grouped_kwic = all_positions.slice(0, MAX_KWIC).map(function (pos) { - var loc1 = pos[0] - var loc2 = loc1 + pos[1] - var rendered_text = `... ${doc.body.substring(loc1 - BUFFER, loc1)} ${doc.body.substring(loc1, loc2)} ${doc.body.substring(loc2, loc2 + BUFFER)} ...` + let loc1 = pos[0] + let loc2 = loc1 + pos[1] + let rendered_text = `... ${doc.body.substring(loc1 - BUFFER, loc1)} ${doc.body.substring(loc1, loc2)} ${doc.body.substring(loc2, loc2 + BUFFER)} ...` return rendered_text }).join("") return grouped_kwic @@ -101,8 +100,8 @@ function lunrSearch(searchString, idx, corpus, featureList, uri, stateObj) { }); // Filter featureList to only show items from search results and active filters - var params = uri.search(true); - var type = params.activity ? params.activity : params.topic; + const params = uri.search(true); + let type = params.activity ? params.activity : params.topic; featureList.filter((item) => { let topicsArray = item.values().topics.split(/\s/); let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; @@ -124,6 +123,7 @@ function lunrSearch(searchString, idx, corpus, featureList, uri, stateObj) { } function resetSearch() { + /* Function to reset search values and display to original settings */ // Empty search input $('#search').val(''); // Hide and empty search results @@ -134,54 +134,58 @@ function resetSearch() { }; function wireButtons() { + /* Main function for page load */ // set URI object to current Window location - var uri = new URI(location); + let uri = new URI(location); console.log(uri.toString()); - var options = { + let options = { valueNames: [ 'date', 'title', 'difficulty', 'activity', 'topics','abstract', 'content' ] }; - var featureList = new List('lesson-list', options); + let featureList = new List('lesson-list', options); // We need a stateObj for adjusting the URIs on button clicks, but the value is moot for now; could be useful for future functionality. - var stateObj = { foo: "bar" }; + let stateObj = { foo: "bar" }; // Get search indices and corpuses using URI to make a call to search-index for each language let idx; let corpus; - // Load search data - const loadSearchData = async () => { + async function loadSearchData() { + /*Function to load search data asynchronously*/ + + // Hide enable button and show search input + $("#enable-search-div").css("display", "none"); + $("#search-div").css("display", ""); + $('#loading-search').css('display', 'none'); + $('#search').css('display', ''); + $('#search-button').prop('disabled', false); + + // Get language and load idx and corpus const language = uri.toString().split('/').slice(-3)[0]; const indexResponse = await fetch(`https://programminghistorian.github.io/search-index/indices/index${language.toUpperCase()}.json`); const indexJSON = await indexResponse.json(); idx = lunr.Index.load(indexJSON); - // window.idx = idx; const corpusResponse = await fetch(`https://programminghistorian.org/${language}/search.json`); const corpusJSON = await corpusResponse.json(); corpus = corpusJSON; - $('#loading-search').css('display', 'none'); - $('#search').css('display', ''); - $('#search-button').prop('disabled', false); - // Hide enable button and show search input - $("#enable-search-div").css("display", "none"); - $("#search-div").css("display", ""); + } // Enable search on button click - $("#enable-search-div").on("click", () => { + $("#enable-search-div").on("click", function() { // Start loading search data loadSearchData(); }); // Search lessons on button click - $("#search-button").on("click", () => { + $("#search-button").on("click", function() { // Get search string const searchString = $("#search").val(); - console.log(searchString); + // Update URI to include search string searchString.length > 0 ? uri.setSearch("search", searchString) : uri.removeSearch('search'); history.pushState(stateObj, "", uri.toString()); console.log(uri.toString()); @@ -190,31 +194,33 @@ function wireButtons() { // Call lunr search lunrSearch(searchString, idx, corpus, featureList, uri, stateObj); } else { - // If empty check if topic or activity selected + // If empty check if topic or activity filter selected + // Call reset search to empty out search values resetSearch(); - var params = uri.search(true); - var type = params.activity ? params.activity : params.topic; + const params = uri.search(true); + let type = params.activity ? params.activity : params.topic; if (type) { - // Otherwise return filter lessons based on URI + // If filter selected, return filter lessons based on URI - featureList.filter(function (item) { - var topicsArray = item.values().topics.split(/\s/); - var condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; + featureList.filter((item) => { + let topicsArray = item.values().topics.split(/\s/); + let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; return condition }); // Reset filter results header $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); $('#results-value').css('textTransform', 'uppercase'); } else { + // Else applySortFromURI(uri, featureList); } } }); // Search lessons on enter press - $('#search').on('keyup', (event) => { + $('#search').on('keyup', function(event) { if (event.which == 13) { $("#search-button").click(); } @@ -222,14 +228,28 @@ function wireButtons() { // When a filter button is clicked $('.filter').children().click(function() { - console.log('clicked children'); // Set clicked button as current $('.filter').children().removeClass("current"); $(this).addClass("current"); - // Update the results header - $('#results-value').text($(this).text() + " "); - $('#results-value').css('textTransform', 'uppercase'); - applySortFromURI(uri, featureList); + + let type = $(this).attr("id").substr(7); + let filterType = $(this).parent().attr('class').split(' ')[1]; + // Reset url parameters + if (filterType === 'activities') { + uri.removeSearch("topic") + uri.setSearch("activity", type) + } else { + uri.removeSearch("activity") + uri.setSearch("topic", type) + } + + // returns the URI instance for chaining + history.pushState(stateObj, "", uri.toString()); + console.log(uri.toString()); + // Use search to perform filtering + $("#search-button").click(); + + return false; }); // When the reset button is clicked @@ -262,11 +282,11 @@ function wireButtons() { $('.sort').click(function() { // Get sort type from button (date or difficulty) - var sortType = $(this).attr("data-sort"); + let sortType = $(this).attr("data-sort"); // Get sort order info from button - var curSortOrder = $(this).hasClass("my-asc") ? "desc" : "asc"; - var newSortOrder = (curSortOrder == "asc" ? "desc" : "asc"); + let curSortOrder = $(this).hasClass("my-asc") ? "desc" : "asc"; + let newSortOrder = (curSortOrder == "asc" ? "desc" : "asc"); console.log("curSort:" + curSortOrder); console.log("newSort:" + newSortOrder); @@ -300,55 +320,22 @@ function wireButtons() { console.log(uri.toString()); }); - // Wire up each of the activity filter buttons. - $('.filter.activities').children().click(function() { - - var type = $(this).attr("id").substr(7); - - // reset url parameter - uri.removeSearch("topic"); - uri.setSearch("activity", type); // returns the URI instance for chaining - history.pushState(stateObj, "", uri.toString()); - console.log(uri.toString()); - // Use search to perform filtering - $("#search-button").click(); - - return false; - }); - - - // Wire up each of the topic filter buttons. - $('.filter.topics').children().click(function() { - - var type = $(this).attr("id").substr(7); - - // Reset url parameters - uri.removeSearch("activity"); - uri.setSearch("topic", type); // returns the URI instance for chaining - history.pushState(stateObj, "", uri.toString()); - console.log(uri.toString()); - // Use search to perform filtering - $("#search-button").click(); - - return false; - }); - /*************************************** All below code runs on each page load ****************************************/ // set labels based on the current language - var dateSort = $('#date-sort-text').attr('label'); - var difficultySort = $('#difficulty-sort-text').attr("label"); + const dateSort = $('#date-sort-text').attr('label'); + const difficultySort = $('#difficulty-sort-text').attr("label"); // Look for URI query params - var params = uri.search(true); - var filter = params.activity ? params.activity : params.topic; - var search = params.search; + const params = uri.search(true); + let filter = params.activity ? params.activity : params.topic; + let search = params.search; - // If a filter is present in the URI, simulate a click to run filter - // Clicking a filter button checks for sort params in URI, so don't do it twice. + // If a filter or search is present in the URI, simulate a click to run filter + // Clicking a filter button checks for sort params in URI, so don't do it twice OR load search data and simulate search click. if (search) { $('#search').val(search); loadSearchData().then(() => $('#search-button').click()).catch(e => console.log(e)); From e3f35a6fae6639ededea849166d23d63283ad576 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Sun, 10 May 2020 12:55:16 -0400 Subject: [PATCH 20/35] ordered lessons by search score --- _includes/lesson_describe.html | 3 ++ js/lessonfilter.js | 53 +++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/_includes/lesson_describe.html b/_includes/lesson_describe.html index 0a3766b05f..9b309aaf17 100755 --- a/_includes/lesson_describe.html +++ b/_includes/lesson_describe.html @@ -35,8 +35,11 @@

{{ include.authors }}

{{ lesson.difficulty }} + +
diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 7a75059cbd..9a86504815 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -55,10 +55,11 @@ function applySortFromURI(uri,featureList) { featureList.sort(sortType, {order: sortOrder}); // Reset filter results header - $('#results-value').text(featureList.update().items.length); + $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); + $('#results-value').css('textTransform', 'uppercase'); } -function lunrSearch(searchString, idx, corpus, featureList, uri, stateObj) { +function lunrSearch(searchString, idx, corpus, featureList, uri) { /* Function to generate search using lunr - find search results using index - load in original corpus and find relevant lessons @@ -97,20 +98,25 @@ function lunrSearch(searchString, idx, corpus, featureList, uri, stateObj) { return grouped_kwic }).join("").replace(/(\r\n|\n|\r)/gm, ""); elements.push({'elementName': elementName, 'innerResults': inner_results}); - + $(`span[id="${elementName}-score"]`).html(doc.score); }); // Filter featureList to only show items from search results and active filters const params = uri.search(true); let type = params.activity ? params.activity : params.topic; featureList.filter((item) => { + // console.log(item); let topicsArray = item.values().topics.split(/\s/); let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; // Could simply to just do Object.keys(params) > 1 here but in case we add more URI values this will explicitly check for filters along with search return docs.find((doc) => { - return ['topic', 'activity'].some(key => Object.keys(params).includes(key)) ? ((doc.title === item.values().title) && condition) : (doc.title === item.values().title); + if (doc.title === item.values().title) { + item.values().score = doc.score; + return ['topic', 'activity'].some(key => Object.keys(params).includes(key)) ? ((doc.title === item.values().title) && condition) : (doc.title === item.values().title); + } }); }); + featureList.sort('score', {order: "desc"}); // Hide original abstracts $('.abstract').css('display', 'none'); $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); @@ -131,6 +137,8 @@ function resetSearch() { $('.search_results').html(''); // Show original abstract results $('.abstract').css('display', 'block'); + // Reset score + $('.score').html(0); }; function wireButtons() { @@ -141,7 +149,7 @@ function wireButtons() { console.log(uri.toString()); let options = { - valueNames: [ 'date', 'title', 'difficulty', 'activity', 'topics','abstract', 'content' ] + valueNames: [ 'date', 'title', 'difficulty', 'activity', 'topics','abstract', 'content', 'score' ] }; let featureList = new List('lesson-list', options); @@ -180,8 +188,14 @@ function wireButtons() { }); - // Search lessons on button click + $("#search-button").on("click", function() { + /* Function that does ALL filtering and searching of list (whether search exists or not) + - checks if search string exists or not and updates URI + - if search string exists calls lunrSearch + - else performs filtering (if filter exists) or resets list + */ + // Get search string const searchString = $("#search").val(); @@ -198,23 +212,24 @@ function wireButtons() { // Call reset search to empty out search values resetSearch(); - const params = uri.search(true); let type = params.activity ? params.activity : params.topic; if (type) { + // If filter selected, return filter lessons based on URI featureList.filter((item) => { - let topicsArray = item.values().topics.split(/\s/); - let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; - return condition + item.values().score = 0; + + let topicsArray = item.values().topics.split(/\s/); + let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; + return condition + }); - // Reset filter results header - $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); - $('#results-value').css('textTransform', 'uppercase'); - } else { - // Else + applySortFromURI(uri, featureList); + } else { + $('#filter-none').click(); } } @@ -269,12 +284,16 @@ function wireButtons() { history.pushState(stateObj, "", uri.toString()); // Reset filtering and perform default sort - featureList.filter(); + featureList.filter( item => { + item.values().score = 0; + return true + }); featureList.sort('date', { order: "desc" }); // Reset sort buttons to defaults resetSort(); - resetSearch(uri, stateObj); + // Call reset search a second time seems to refresh html (very hacky solution) + resetSearch(); }); From 2a87ae0355472fb931d512b21f4a9659c914f097 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Tue, 12 May 2020 19:18:27 -0400 Subject: [PATCH 21/35] removed abstract styling from style.css --- css/style.css | 5 ----- 1 file changed, 5 deletions(-) diff --git a/css/style.css b/css/style.css index 026cb8dfdd..dde0f19dfb 100644 --- a/css/style.css +++ b/css/style.css @@ -465,11 +465,6 @@ Lessons Index clear:none; } - p.abstract { - font: .8rem/1.2rem 'Open Sans', sans-serif; - margin:0; - } - .list .date, .lesson-description .activity, .lesson-description .topics, From 18196ae005755f75d8cbc43f3341b994123dcf09 Mon Sep 17 00:00:00 2001 From: Jennifer Isasi Date: Wed, 13 May 2020 12:50:46 -0400 Subject: [PATCH 22/35] Update snippets.yml translated to ES search snippets --- _data/snippets.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_data/snippets.yml b/_data/snippets.yml index 9e01e318ad..3ffc319323 100644 --- a/_data/snippets.yml +++ b/_data/snippets.yml @@ -354,22 +354,22 @@ filtering-results: pt: loading-search: en: LOADING SEARCH... - es: + es: CARGANDO LA BÚSQUEDA... fr: RECHERCHE EN COURS... pt: search-lessons: en: SEARCH LESSONS - es: + es: BUSCAR LECCIONES fr: RECHERCHER LES LEÇONS pt: start-searching: en: START SEARCHING - es: + es: INICIAR BÚSQUEDA fr: DÉMARRER LA RECHERCHE pt: type-search-terms: en: TYPE SEARCH TERMS... - es: + es: ESCRIBE LOS TÉRMINOS DE BÚSQUEDA... fr: ENTRER UN OU PLUSIEURS TERMES DE RECHERCHE... pt: From 2bb695eba759a6f85dea666a32e082bca4de0783 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Wed, 13 May 2020 17:12:00 -0400 Subject: [PATCH 23/35] added search info and search indicator --- _includes/lesson-index.html | 6 ++++++ css/style.css | 29 +++++++++++++++++++++------ js/lessonfilter.js | 39 ++++++++++++++++++++++++++++--------- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index f4569b5d96..94035ede98 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -31,6 +31,12 @@ placeholder="{{ site.data.snippets.loading-search[page.lang] }}" style="background-color: #efefef" disabled> + +
+

To search for relevant terms, enter them into the search bar and either press the enter key or the search button. All searches are case insensitive. If multiple terms are entered, results will include lessons that have all terms, as well as lessons that contain either term. Results with more of the terms will be scored higher in the list. +

+

To only return results with more than one term, add the + symbol before the term. For example, +Twitter +Network. If you want to only return results that do not contain a term use the - symbol. For example, -Twitter +Network. For more information on how searching works, visit this website on searching with Lunr https://lunrjs.com/guides/searching.html

+

diff --git a/css/style.css b/css/style.css index 31f487c283..6a3c104a5c 100644 --- a/css/style.css +++ b/css/style.css @@ -321,7 +321,7 @@ Lessons Index *****************/ .search-input { - width:60%; + width:55%; clear:both; margin-bottom:1rem; background-color:#fefefe; @@ -340,7 +340,7 @@ Lessons Index #enable-search-button { background-color: #efefef; color: rgb(153, 143, 143); - width: 39%; + width: 35%; font: .9rem/1.1rem 'Open Sans', sans-serif; padding: .4rem .6rem; @@ -351,10 +351,27 @@ Lessons Index text-decoration: none; } - .search_results { - font: .8rem/1.2rem 'Open Sans', - sans-serif; - margin: 0; + #search-info-button { + padding: 0.5rem; + color: rgb(153, 143, 143); + } + + #search-info { + display: none; + height:0px; + background:#efefef; + overflow:hidden; + transition:0.5s; + -webkit-transition:0.5s; + width: 100%; + text-align: left; + box-sizing: border-box; + } + + #search-info.visible { + display: block; + height: fit-content; + padding: 10px; } /***************** diff --git a/js/lessonfilter.js b/js/lessonfilter.js index e6e864325e..5db0c14496 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -1,5 +1,6 @@ function resetSort() { /* Function to reset sort buttons */ + $('#current-sort').text('date'); $('#current-sort').removeClass().addClass("sort-desc"); $("#sort-by-date").removeClass().addClass("sort desc my-asc"); $("#sort-by-difficulty").removeClass().addClass("sort my-desc"); @@ -30,11 +31,11 @@ function applySortFromURI(uri, featureList) { // Update filter header and restore defaults to other button if (sortType == "date") { - $('#current-sort').text(dateSort); + $('#current-sort').text('date'); $('#sort-by-difficulty').removeClass().addClass("sort my-asc"); } else { - $('#current-sort').text(difficultySort); + $('#current-sort').text('difficulty'); $('#sort-by-date').removeClass().addClass("sort my-desc"); } } @@ -113,6 +114,12 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { }); }); + // remove existing sorts and indicate sorted by search results + $('#sort-by-difficulty').removeClass().addClass("sort my-asc"); + $('#sort-by-date').removeClass().addClass("sort my-desc"); + $('#current-sort').text('search'); + $('#current-sort').removeClass().addClass("sort-desc"); + featureList.sort('score', { order: "desc" }); // Hide original abstracts $('.abstract').css('display', 'none'); @@ -123,6 +130,7 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { $(`p[id="${elm.elementName}-search_results"]`).css('display', ''); $(`p[id="${elm.elementName}-search_results"]`).html(elm.innerResults); }); + } function resetSearch() { @@ -195,19 +203,25 @@ function wireButtons() { // Get search string const searchString = $("#search").val(); - - // Update URI to include search string - searchString.length > 0 ? uri.setSearch("search", searchString) : uri.removeSearch('search'); - history.pushState(stateObj, "", uri.toString()); - console.log(uri.toString()); + // Check that's it's not empty if (searchString.length > 0) { + // Update URI + uri.setSearch("search", searchString) + uri.removeSearch('sortOrder'); + uri.removeSearch('sortType'); + history.pushState(stateObj, "", uri.toString()); + console.log(uri.toString()); // Call lunr search lunrSearch(searchString, idx, corpus, featureList, uri, stateObj); + } else { // If empty check if topic or activity filter selected - // Call reset search to empty out search values + // Call reset search to empty out search values and update URI + uri.removeSearch('search'); + history.pushState(stateObj, "", uri.toString()); + console.log(uri.toString()); resetSearch(); const params = uri.search(true); let type = params.activity ? params.activity : params.topic; @@ -238,6 +252,14 @@ function wireButtons() { } }); + $('#search-info-button').click(function() { + if ($("#search-info").hasClass("visible")) { + $("#search-info").removeClass("visible"); + } else { + $("#search-info").addClass("visible"); + } + }); + // When a filter button is clicked $('.filter').children().click(function () { // Set clicked button as current @@ -309,7 +331,6 @@ function wireButtons() { // update class for clicked button $(this).removeClass("my-" + newSortOrder).addClass("my-" + curSortOrder); - // Update filter results header to show current sorting (date or difficulty) // Reset the other (non-pressed) button to its default sort arrow. if (sortType == "date") { From f0c0c830f0313aab88a743154df82c4e7497e078 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Wed, 13 May 2020 17:30:52 -0400 Subject: [PATCH 24/35] switched icon to question mark --- _includes/lesson-index.html | 4 ++-- css/style.css | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index 94035ede98..5721173eb3 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -31,11 +31,11 @@ placeholder="{{ site.data.snippets.loading-search[page.lang] }}" style="background-color: #efefef" disabled> - +

To search for relevant terms, enter them into the search bar and either press the enter key or the search button. All searches are case insensitive. If multiple terms are entered, results will include lessons that have all terms, as well as lessons that contain either term. Results with more of the terms will be scored higher in the list.

-

To only return results with more than one term, add the + symbol before the term. For example, +Twitter +Network. If you want to only return results that do not contain a term use the - symbol. For example, -Twitter +Network. For more information on how searching works, visit this website on searching with Lunr https://lunrjs.com/guides/searching.html

+

To only return results with multiple terms, add the + symbol before the term. For example, +Twitter +Network will return lessons that contain both "twitter" and "network". To only return results that do not contain a term use the - symbol. For example, -Twitter +Network will return lessons that contain "network" but not "twitter". For more detailed information, visit this guide on searching https://lunrjs.com/guides/searching.html

diff --git a/css/style.css b/css/style.css index 6a3c104a5c..435eddd00b 100644 --- a/css/style.css +++ b/css/style.css @@ -351,6 +351,15 @@ Lessons Index text-decoration: none; } + @media only screen and (max-width: 767px) { + /* phones */ + #search-button, + #enable-search-button { + width: 80%; + } + } + + #search-info-button { padding: 0.5rem; color: rgb(153, 143, 143); @@ -372,6 +381,7 @@ Lessons Index display: block; height: fit-content; padding: 10px; + margin-top: 10px; } /***************** From 81245d7adf8bbe1fca30648dd82341a2a5baac0f Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Thu, 14 May 2020 09:10:46 -0400 Subject: [PATCH 25/35] fixed search info for firefox and added loader --- _includes/lesson-index.html | 17 ++++++++++++++++- css/style.css | 16 +++++++++++++++- js/lessonfilter.js | 12 ++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index 5721173eb3..93d7519b6f 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -2,7 +2,22 @@ Core code for generating filterable lesson indexes on lessons.md and es/lecciones.md. This will repeatedly call lesson_describe.html in which individual lessons have their metadata formatted for display. {% endcomment %} - + +
+ + + + + + + + + + + +
+
    {% for activity in site.data.activities %} {% assign atype = activity.type %} diff --git a/css/style.css b/css/style.css index 435eddd00b..4dec597ec4 100644 --- a/css/style.css +++ b/css/style.css @@ -380,6 +380,7 @@ Lessons Index #search-info.visible { display: block; height: fit-content; + height: -moz-max-content; padding: 10px; margin-top: 10px; } @@ -500,7 +501,20 @@ Lessons Index display: none; } - + #pre-loader { + visibility: hidden; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + width: 100%; + position: fixed; + top: 0; + left: 0; + z-index: 9999; + transition: opacity 0.3s linear; + background: rgba(211, 211, 211, 0.8); + } /* ============================================================================= Top Navigation Bar ========================================================================== */ diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 5db0c14496..99ba0d9405 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -366,22 +366,30 @@ function wireButtons() { const dateSort = $('#date-sort-text').attr('label'); const difficultySort = $('#difficulty-sort-text').attr("label"); - // Look for URI query params + // // Look for URI query params const params = uri.search(true); let filter = params.activity ? params.activity : params.topic; let search = params.search; // If a filter or search is present in the URI, simulate a click to run filter // Clicking a filter button checks for sort params in URI, so don't do it twice OR load search data and simulate search click. + const preloader = $('#pre-loader'); + if (search) { + // preloader.css('display', 'flex'); + preloader.css('visibility', 'visible'); $('#search').val(search); - loadSearchData().then(() => $('#search-button').click()).catch(e => console.log(e)); + loadSearchData().then(() => { + preloader.fadeOut(1500); + $('#search-button').click(); + }).catch(e => console.log(e)); } else if (filter) { console.log("FILTER:" + filter); $("#filter-" + filter).click(); } else { // Apply sorting criteria from the URI if no filter + // preloader.css('display', 'none'); applySortFromURI(uri, featureList); } }; From 0a51f5a8d39058ac02ecf44c39792dd2f9b09638 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Thu, 14 May 2020 10:15:04 -0400 Subject: [PATCH 26/35] cleaning up code and adding comments --- _includes/lesson-index.html | 6 ++---- js/lessonfilter.js | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index 93d7519b6f..19e27a6d2d 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -2,9 +2,8 @@ Core code for generating filterable lesson indexes on lessons.md and es/lecciones.md. This will repeatedly call lesson_describe.html in which individual lessons have their metadata formatted for display. {% endcomment %} - +
    - @@ -16,8 +15,7 @@ -
    - +
    {% for activity in site.data.activities %} {% assign atype = activity.type %} diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 99ba0d9405..849b46f56a 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -252,6 +252,7 @@ function wireButtons() { } }); + // Search info button clicked show additional information $('#search-info-button').click(function() { if ($("#search-info").hasClass("visible")) { $("#search-info").removeClass("visible"); @@ -376,7 +377,7 @@ function wireButtons() { const preloader = $('#pre-loader'); if (search) { - // preloader.css('display', 'flex'); + // If search is true, load pre-loading graph to allow search results time to load preloader.css('visibility', 'visible'); $('#search').val(search); loadSearchData().then(() => { @@ -389,7 +390,6 @@ function wireButtons() { } else { // Apply sorting criteria from the URI if no filter - // preloader.css('display', 'none'); applySortFromURI(uri, featureList); } }; From 0a88cce34bf9eedceec03795d8b0e8be8b1f97a0 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Sat, 16 May 2020 11:42:07 -0400 Subject: [PATCH 27/35] cleaning code and changing url to slug --- _includes/lesson_describe.html | 6 +++--- _layouts/search.json | 1 + js/lessonfilter.js | 7 +++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/_includes/lesson_describe.html b/_includes/lesson_describe.html index 9b309aaf17..bf041d4ca8 100755 --- a/_includes/lesson_describe.html +++ b/_includes/lesson_describe.html @@ -33,11 +33,11 @@

    {{ include.authors }}

    {{ lesson.topics | join: ' '}} {% if lesson.translation_date %}{{ lesson.translation_date }}{% else %}{{ lesson.date }}{% endif %} {{ lesson.difficulty }} - - - diff --git a/_layouts/search.json b/_layouts/search.json index c14135cda4..b9c7a1bb03 100644 --- a/_layouts/search.json +++ b/_layouts/search.json @@ -13,6 +13,7 @@ { "id": {% increment counter %}, "url": {{ page.url | absolute_url | jsonify }}, + "slug": {{ page.slug | jsonify }}, "title": {{ page.title | jsonify }}, "body": {{ search_block | strip_html | jsonify }} }{% if forloop.last %}{% else %},{% endif %} diff --git a/js/lessonfilter.js b/js/lessonfilter.js index 849b46f56a..b0a9368ddf 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -11,7 +11,6 @@ function applySortFromURI(uri, featureList) { /* Function to update lesson-list using featureList and sort direction - uses URI to generate sort directions */ - console.log("applying sort from URI"); const params = uri.search(true); let sortOrder = params.sortOrder; @@ -49,7 +48,7 @@ function applySortFromURI(uri, featureList) { resetSort(); } - // Performm new sort + // Perform new sort featureList.sort(sortType, { order: sortOrder }); // Reset filter results header @@ -83,7 +82,8 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { // Create html to show search results using html mark let elements = [] docs.map((doc) => { - let elementName = '/' + doc.url.split('/').slice(3).join('/') + // let elementName = doc.slug; + let elementName = '/' + doc.url.split('/').slice(3).join('/'); let search_keys = Object.keys(doc.matchData.metadata); let inner_results = search_keys.map((token) => { let all_positions = doc.matchData.metadata[token].body.position; @@ -102,7 +102,6 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { const params = uri.search(true); let type = params.activity ? params.activity : params.topic; featureList.filter((item) => { - // console.log(item); let topicsArray = item.values().topics.split(/\s/); let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; // Could simply to just do Object.keys(params) > 1 here but in case we add more URI values this will explicitly check for filters along with search From 2654e91d9663d43ac95103eb6c3fff0fd0ce0ff6 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Sat, 16 May 2020 11:57:13 -0400 Subject: [PATCH 28/35] reverted back to url and added more comments --- _includes/lesson_describe.html | 6 +++--- _layouts/search.json | 1 - js/lessonfilter.js | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/_includes/lesson_describe.html b/_includes/lesson_describe.html index bf041d4ca8..9b309aaf17 100755 --- a/_includes/lesson_describe.html +++ b/_includes/lesson_describe.html @@ -33,11 +33,11 @@

    {{ include.authors }}

    {{ lesson.topics | join: ' '}} {% if lesson.translation_date %}{{ lesson.translation_date }}{% else %}{{ lesson.date }}{% endif %} {{ lesson.difficulty }} - - - diff --git a/_layouts/search.json b/_layouts/search.json index b9c7a1bb03..c14135cda4 100644 --- a/_layouts/search.json +++ b/_layouts/search.json @@ -13,7 +13,6 @@ { "id": {% increment counter %}, "url": {{ page.url | absolute_url | jsonify }}, - "slug": {{ page.slug | jsonify }}, "title": {{ page.title | jsonify }}, "body": {{ search_block | strip_html | jsonify }} }{% if forloop.last %}{% else %},{% endif %} diff --git a/js/lessonfilter.js b/js/lessonfilter.js index b0a9368ddf..ddab092784 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -82,9 +82,10 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { // Create html to show search results using html mark let elements = [] docs.map((doc) => { - // let elementName = doc.slug; + // Gets element name from absolute url that is generated by search.json. If URL syntax is changed, will need to double check that this code still works. Currently it gets /language/lessons/lesson-url. let elementName = '/' + doc.url.split('/').slice(3).join('/'); let search_keys = Object.keys(doc.matchData.metadata); + // Gets exact position of search results and highlights them using mark tags let inner_results = search_keys.map((token) => { let all_positions = doc.matchData.metadata[token].body.position; let grouped_kwic = all_positions.slice(0, MAX_KWIC).map(function (pos) { @@ -95,19 +96,24 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { }).join("") return grouped_kwic }).join("").replace(/(\r\n|\n|\r)/gm, ""); + // Saves element name and results to array to be displayed once featureList is updated. elements.push({ 'elementName': elementName, 'innerResults': inner_results }); + // Updates score element for search results $(`span[id="${elementName}-score"]`).html(doc.score); }); // Filter featureList to only show items from search results and active filters const params = uri.search(true); + // let type = params.activity ? params.activity : params.topic; featureList.filter((item) => { let topicsArray = item.values().topics.split(/\s/); let condition = params.topic ? topicsArray.includes(type) : item.values().activity == type; - // Could simply to just do Object.keys(params) > 1 here but in case we add more URI values this will explicitly check for filters along with search + // return items in list that are in search results and filter if clicked return docs.find((doc) => { if (doc.title === item.values().title) { + // update score values for item item.values().score = doc.score; + // Could simply to just do Object.keys(params) > 1 here but in case we add more URI values this will explicitly check for filters along with search return ['topic', 'activity'].some(key => Object.keys(params).includes(key)) ? ((doc.title === item.values().title) && condition) : (doc.title === item.values().title); } @@ -119,11 +125,14 @@ function lunrSearch(searchString, idx, corpus, featureList, uri) { $('#current-sort').text('search'); $('#current-sort').removeClass().addClass("sort-desc"); + // Sort featureList by score featureList.sort('score', { order: "desc" }); - // Hide original abstracts + + // Hide original abstracts and update Filtering to show number of results $('.abstract').css('display', 'none'); $('#results-value').text($(this).text().split(' ')[0] + '(' + featureList.update().matchingItems.length + ')' + " "); $('#results-value').css('textTransform', 'uppercase'); + // Display updated search results elements.map((elm) => { $(`p[id="${elm.elementName}-search_results"]`).css('display', ''); From 15c7c415eef25653ccfb808e2eb46f71a7f0d65c Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Sat, 16 May 2020 12:31:34 -0400 Subject: [PATCH 29/35] removed all console.logs and added snippet --- _data/snippets.yml | 11 +++++++++++ _includes/lesson-index.html | 4 +--- js/lessonfilter.js | 15 +-------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/_data/snippets.yml b/_data/snippets.yml index 3ffc319323..18e71e58d2 100644 --- a/_data/snippets.yml +++ b/_data/snippets.yml @@ -372,6 +372,17 @@ type-search-terms: es: ESCRIBE LOS TÉRMINOS DE BÚSQUEDA... fr: ENTRER UN OU PLUSIEURS TERMES DE RECHERCHE... pt: +search-info: + en: | + To search for relevant terms, enter them into the search bar and either press the enter key or the search button. All searches are case insensitive. If multiple terms are entered, results will include lessons that have all terms, as well as lessons that contain *either term*. Results with more of the terms will be scored higher in the list. + + To only return results with multiple terms, add the `+` symbol before the term. For example, `+Twitter +Network` will return lessons that contain *both* "twitter" and "network". To only return results that *do not* contain a term use the `-` symbol. For example, `-Twitter +Network` will return lessons that contain "network" but not "twitter". For more detailed information, visit this guide on searching[https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). + es: | + + fr: | + + pt: | + # lesson headers editor: diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index 19e27a6d2d..0c19b24527 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -46,9 +46,7 @@
    -

    To search for relevant terms, enter them into the search bar and either press the enter key or the search button. All searches are case insensitive. If multiple terms are entered, results will include lessons that have all terms, as well as lessons that contain either term. Results with more of the terms will be scored higher in the list. -

    -

    To only return results with multiple terms, add the + symbol before the term. For example, +Twitter +Network will return lessons that contain both "twitter" and "network". To only return results that do not contain a term use the - symbol. For example, -Twitter +Network will return lessons that contain "network" but not "twitter". For more detailed information, visit this guide on searching https://lunrjs.com/guides/searching.html

    + {{ site.data.snippets.search-info[page.lang] | markdownify }}
diff --git a/js/lessonfilter.js b/js/lessonfilter.js index ddab092784..ac2f849892 100644 --- a/js/lessonfilter.js +++ b/js/lessonfilter.js @@ -18,9 +18,6 @@ function applySortFromURI(uri, featureList) { let nonSortOrder = (sortOrder == "desc" ? "asc" : "desc"); if (sortType) { - console.log("SortType: " + sortType); - console.log("sortOrder: " + sortOrder); - console.log("nonSortOrder: " + nonSortOrder); // Update arrow of selected sort button $("#sort-by-" + sortType).removeClass().addClass("sort " + sortOrder + " my-" + nonSortOrder); @@ -40,7 +37,6 @@ function applySortFromURI(uri, featureList) { } else { // If no sort params, perform default sort - console.log("default sorting"); sortType = "date"; sortOrder = "desc"; @@ -159,7 +155,6 @@ function wireButtons() { // set URI object to current Window location let uri = new URI(location); - console.log(uri.toString()); let options = { valueNames: ['date', 'title', 'difficulty', 'activity', 'topics', 'abstract', 'content', 'score'] @@ -219,7 +214,6 @@ function wireButtons() { uri.removeSearch('sortOrder'); uri.removeSearch('sortType'); history.pushState(stateObj, "", uri.toString()); - console.log(uri.toString()); // Call lunr search lunrSearch(searchString, idx, corpus, featureList, uri, stateObj); @@ -229,7 +223,6 @@ function wireButtons() { // Call reset search to empty out search values and update URI uri.removeSearch('search'); history.pushState(stateObj, "", uri.toString()); - console.log(uri.toString()); resetSearch(); const params = uri.search(true); let type = params.activity ? params.activity : params.topic; @@ -288,7 +281,6 @@ function wireButtons() { // returns the URI instance for chaining history.pushState(stateObj, "", uri.toString()); - console.log(uri.toString()); // Use search to perform filtering $("#search-button").click(); @@ -335,9 +327,6 @@ function wireButtons() { let curSortOrder = $(this).hasClass("my-asc") ? "desc" : "asc"; let newSortOrder = (curSortOrder == "asc" ? "desc" : "asc"); - console.log("curSort:" + curSortOrder); - console.log("newSort:" + newSortOrder); - // update class for clicked button $(this).removeClass("my-" + newSortOrder).addClass("my-" + curSortOrder); // Update filter results header to show current sorting (date or difficulty) @@ -363,7 +352,6 @@ function wireButtons() { uri.setSearch("sortType", sortType); uri.setSearch("sortOrder", newSortOrder); history.pushState(stateObj, "", uri.toString()); - console.log(uri.toString()); }); /*************************************** @@ -391,9 +379,8 @@ function wireButtons() { loadSearchData().then(() => { preloader.fadeOut(1500); $('#search-button').click(); - }).catch(e => console.log(e)); + }); } else if (filter) { - console.log("FILTER:" + filter); $("#filter-" + filter).click(); } else { From 25071a8b89862ac9b4a204f278fe84764f8f4d46 Mon Sep 17 00:00:00 2001 From: Riva Quiroga <31421616+rivaquiroga@users.noreply.github.com> Date: Thu, 21 May 2020 10:05:41 -0400 Subject: [PATCH 30/35] ES translation of search documentation snippet --- _data/snippets.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_data/snippets.yml b/_data/snippets.yml index 18e71e58d2..23e705d9a4 100644 --- a/_data/snippets.yml +++ b/_data/snippets.yml @@ -378,7 +378,9 @@ search-info: To only return results with multiple terms, add the `+` symbol before the term. For example, `+Twitter +Network` will return lessons that contain *both* "twitter" and "network". To only return results that *do not* contain a term use the `-` symbol. For example, `-Twitter +Network` will return lessons that contain "network" but not "twitter". For more detailed information, visit this guide on searching[https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). es: | + Para buscar términos relevantes, escríbelos en la barra de búsqueda y aprieta la tecla "enter" o haz clic en el botón "buscar lecciones". Las búsquedas no distinguen mayúsculas y minúsculas. Si se ingresan múltiples términos, los resultados incluirán tanto lecciones que los contengan todos, como lecciones que contengan *solo alguno*. Los resultados que incluyan más de un término aparecerán primero en la lista. + Para obtener solo resultados con múltiples términos, agrega el símbolo `+` antes de cada uno. Por ejemplo, `+Twitter +Red` devolverá lecciones que contienen *tanto* "twitter" como "red". Para obtener solo resultados que *no* contengan cierto término, utiliza el símbolo `-`. Por ejemplo, `-Twitter +Red` devolverá lecciones que contienen "red" pero no "twitter". Para información más detallada, puedes revisar la guía sobre búsquedas (en inglés): [https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). fr: | pt: | From 819bf53e28dd9971e40dc8a753d0c09f86ee270f Mon Sep 17 00:00:00 2001 From: spapastamkou Date: Tue, 26 May 2020 17:28:36 +0200 Subject: [PATCH 31/35] FR translation search documentation snippet --- _data/snippets.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/_data/snippets.yml b/_data/snippets.yml index 23e705d9a4..60447bf605 100644 --- a/_data/snippets.yml +++ b/_data/snippets.yml @@ -382,6 +382,7 @@ search-info: Para obtener solo resultados con múltiples términos, agrega el símbolo `+` antes de cada uno. Por ejemplo, `+Twitter +Red` devolverá lecciones que contienen *tanto* "twitter" como "red". Para obtener solo resultados que *no* contengan cierto término, utiliza el símbolo `-`. Por ejemplo, `-Twitter +Red` devolverá lecciones que contienen "red" pero no "twitter". Para información más detallada, puedes revisar la guía sobre búsquedas (en inglés): [https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). fr: | + Pour obtenir des résultats en utilisant plusieurs termes de recherche, faites précéder chaque terme du symbole `+`. Par exemple, en insérant `+Twitter +réseau`, vous obtiendrez les tutoriels qui contiennent tous les deux termes. Pour *exclure* un terme des résultats obtenus, vous pouvez utiliser le symbole `-`. Par exemple, en insérant `-Twitter +réseau`, vous obtiendrez les tutoriels qui contiennent le terme "réseau", mais pas "Twitter". Pour en savoir plus sur les modalités de recherche, merci de consulter ce guide[https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). pt: | From 8f7230d1816395a56944cc4d7b2ce8c98a17ba48 Mon Sep 17 00:00:00 2001 From: Matthew Lincoln Date: Tue, 26 May 2020 13:05:27 -0400 Subject: [PATCH 32/35] use md shortcut for URLs --- _data/snippets.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_data/snippets.yml b/_data/snippets.yml index 60447bf605..34cafcfce2 100644 --- a/_data/snippets.yml +++ b/_data/snippets.yml @@ -376,13 +376,13 @@ search-info: en: | To search for relevant terms, enter them into the search bar and either press the enter key or the search button. All searches are case insensitive. If multiple terms are entered, results will include lessons that have all terms, as well as lessons that contain *either term*. Results with more of the terms will be scored higher in the list. - To only return results with multiple terms, add the `+` symbol before the term. For example, `+Twitter +Network` will return lessons that contain *both* "twitter" and "network". To only return results that *do not* contain a term use the `-` symbol. For example, `-Twitter +Network` will return lessons that contain "network" but not "twitter". For more detailed information, visit this guide on searching[https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). + To only return results with multiple terms, add the `+` symbol before the term. For example, `+Twitter +Network` will return lessons that contain *both* "twitter" and "network". To only return results that *do not* contain a term use the `-` symbol. For example, `-Twitter +Network` will return lessons that contain "network" but not "twitter". For more detailed information, visit this guide on searching: es: | Para buscar términos relevantes, escríbelos en la barra de búsqueda y aprieta la tecla "enter" o haz clic en el botón "buscar lecciones". Las búsquedas no distinguen mayúsculas y minúsculas. Si se ingresan múltiples términos, los resultados incluirán tanto lecciones que los contengan todos, como lecciones que contengan *solo alguno*. Los resultados que incluyan más de un término aparecerán primero en la lista. - Para obtener solo resultados con múltiples términos, agrega el símbolo `+` antes de cada uno. Por ejemplo, `+Twitter +Red` devolverá lecciones que contienen *tanto* "twitter" como "red". Para obtener solo resultados que *no* contengan cierto término, utiliza el símbolo `-`. Por ejemplo, `-Twitter +Red` devolverá lecciones que contienen "red" pero no "twitter". Para información más detallada, puedes revisar la guía sobre búsquedas (en inglés): [https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). + Para obtener solo resultados con múltiples términos, agrega el símbolo `+` antes de cada uno. Por ejemplo, `+Twitter +Red` devolverá lecciones que contienen *tanto* "twitter" como "red". Para obtener solo resultados que *no* contengan cierto término, utiliza el símbolo `-`. Por ejemplo, `-Twitter +Red` devolverá lecciones que contienen "red" pero no "twitter". Para información más detallada, puedes revisar la guía sobre búsquedas (en inglés): fr: | - Pour obtenir des résultats en utilisant plusieurs termes de recherche, faites précéder chaque terme du symbole `+`. Par exemple, en insérant `+Twitter +réseau`, vous obtiendrez les tutoriels qui contiennent tous les deux termes. Pour *exclure* un terme des résultats obtenus, vous pouvez utiliser le symbole `-`. Par exemple, en insérant `-Twitter +réseau`, vous obtiendrez les tutoriels qui contiennent le terme "réseau", mais pas "Twitter". Pour en savoir plus sur les modalités de recherche, merci de consulter ce guide[https://lunrjs.com/guides/searching.html](https://lunrjs.com/guides/searching.html). + Pour obtenir des résultats en utilisant plusieurs termes de recherche, faites précéder chaque terme du symbole `+`. Par exemple, en insérant `+Twitter +réseau`, vous obtiendrez les tutoriels qui contiennent tous les deux termes. Pour *exclure* un terme des résultats obtenus, vous pouvez utiliser le symbole `-`. Par exemple, en insérant `-Twitter +réseau`, vous obtiendrez les tutoriels qui contiennent le terme "réseau", mais pas "Twitter". Pour en savoir plus sur les modalités de recherche, merci de consulter ce guide pt: | From b5b05204676104a2c1a20e50108b225f03a3f1b4 Mon Sep 17 00:00:00 2001 From: ZoeLeBlanc Date: Tue, 26 May 2020 13:36:10 -0400 Subject: [PATCH 33/35] moved js files to vendor and only loaded file for language --- _includes/lesson-index.html | 7 +- js/lunr.es.js | 599 ------------------------------ js/lunr.fr.js | 703 ------------------------------------ js/lunr.stemmer.support.js | 326 ----------------- 4 files changed, 4 insertions(+), 1631 deletions(-) delete mode 100644 js/lunr.es.js delete mode 100644 js/lunr.fr.js delete mode 100644 js/lunr.stemmer.support.js diff --git a/_includes/lesson-index.html b/_includes/lesson-index.html index 0c19b24527..2eedd4b9d9 100644 --- a/_includes/lesson-index.html +++ b/_includes/lesson-index.html @@ -90,9 +90,10 @@

{{ site.data.snippets.filtering-results[page.lang] }}: - - - + +{% if page.lang != "en" %} + +{% endif %}