You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "DomGarguilo (via GitHub)" <gi...@apache.org> on 2023/08/29 20:53:57 UTC
[GitHub] [accumulo-website] DomGarguilo opened a new pull request, #399: WIP - Update search page dependencies
DomGarguilo opened a new pull request, #399:
URL: https://github.com/apache/accumulo-website/pull/399
This PR aims to update the version of `lunr` and jquery that is imported in the search page.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo-website] ctubbsii commented on a diff in pull request #399: Update search page dependencies
Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #399:
URL: https://github.com/apache/accumulo-website/pull/399#discussion_r1309432172
##########
js/search.js:
##########
@@ -1,48 +1,49 @@
-jQuery(function() {
+jQuery(function () {
- window.idx = lunr(function () {
- this.field('id');
- this.field('title');
- this.field('content', { boost: 10 });
- this.field('categories');
- });
+ $.getJSON('/search_data.json').then(function (loaded_data) {
- window.data = $.getJSON('/search_data.json');
+ window.idx = lunr(function () {
+ this.field('id');
+ this.field('title');
+ this.field('content', { boost: 10 });
+ this.field('categories');
- window.data.then(function(loaded_data){
- $.each(loaded_data, function(index, value){
- window.idx.add($.extend({ "id": index }, value));
+ for (var index in loaded_data) {
+ this.add($.extend({ "id": index }, loaded_data[index]));
+ }
});
- });
- $("#site_search").submit(function(event){
+ $("#site_search").submit(function (event) {
event.preventDefault();
var query = $("#search_box").val();
var results = window.idx.search(query);
- display_search_results(query, results);
+ display_search_results(query, results, loaded_data);
+ });
+
});
- function display_search_results(query, results) {
+ function display_search_results(query, results, loaded_data) {
var $search_status = $("#search_status");
var $search_results = $("#search_results");
- window.data.then(function(loaded_data) {
-
- if (results.length) {
- $search_status.html('Found ' + results.length + ' results for "' + query + '"');
- $search_results.empty();
- results.forEach(function(result) {
- var item = loaded_data[result.ref];
- var n = item.content.search(query) - 50
- if (n < 0) {
- n = 0;
- }
- var appendString = '<tr><td><a href="' + item.url + '">' + item.title + '</a><td>' + item.content.substring(n, n+100) + '</tr>';
- $search_results.append(appendString);
- });
- } else {
- $search_status.html('No results found!');
+ if (!results.length) {
+ $search_status.html('No results found!');
+ return;
+ }
+
+ $search_status.html('Found ' + results.length + ' results for "' + query + '"');
+ $search_results.empty();
+ $search_results.append('<tbody>');
Review Comment:
The alternative to this, if you prefer, is to put the tbody in the page template, and use the jQuery selector to locate the tbody element, clear it, and add the rows to that, rather than locating the table and clearing it and appending a new tbody.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo-website] ctubbsii commented on a diff in pull request #399: WIP - Update search page dependencies
Posted by "ctubbsii (via GitHub)" <gi...@apache.org>.
ctubbsii commented on code in PR #399:
URL: https://github.com/apache/accumulo-website/pull/399#discussion_r1309421973
##########
js/search.js:
##########
@@ -1,48 +1,47 @@
-jQuery(function() {
+jQuery(function () {
- window.idx = lunr(function () {
- this.field('id');
- this.field('title');
- this.field('content', { boost: 10 });
- this.field('categories');
- });
+ $.getJSON('/search_data.json').then(function (loaded_data) {
- window.data = $.getJSON('/search_data.json');
+ window.idx = lunr(function () {
+ this.field('id');
+ this.field('title');
+ this.field('content', { boost: 10 });
+ this.field('categories');
- window.data.then(function(loaded_data){
- $.each(loaded_data, function(index, value){
- window.idx.add($.extend({ "id": index }, value));
+ for (var index in loaded_data) {
+ this.add($.extend({ "id": index }, loaded_data[index]));
+ }
});
- });
- $("#site_search").submit(function(event){
+ $("#site_search").submit(function (event) {
event.preventDefault();
var query = $("#search_box").val();
var results = window.idx.search(query);
- display_search_results(query, results);
+ display_search_results(query, results, loaded_data);
+ });
+
});
- function display_search_results(query, results) {
+ function display_search_results(query, results, loaded_data) {
var $search_status = $("#search_status");
var $search_results = $("#search_results");
- window.data.then(function(loaded_data) {
-
- if (results.length) {
- $search_status.html('Found ' + results.length + ' results for "' + query + '"');
- $search_results.empty();
- results.forEach(function(result) {
- var item = loaded_data[result.ref];
- var n = item.content.search(query) - 50
- if (n < 0) {
- n = 0;
- }
- var appendString = '<tr><td><a href="' + item.url + '">' + item.title + '</a><td>' + item.content.substring(n, n+100) + '</tr>';
- $search_results.append(appendString);
- });
- } else {
- $search_status.html('No results found!');
+ if (!results.length) {
+ $search_status.html('No results found!');
+ return;
+ }
+
+ $search_status.html('Found ' + results.length + ' results for "' + query + '"');
+ $search_results.empty();
Review Comment:
```suggestion
$search_results.empty();
$search_results.append('<tbody>');
```
##########
js/search.js:
##########
@@ -1,48 +1,47 @@
-jQuery(function() {
+jQuery(function () {
- window.idx = lunr(function () {
- this.field('id');
- this.field('title');
- this.field('content', { boost: 10 });
- this.field('categories');
- });
+ $.getJSON('/search_data.json').then(function (loaded_data) {
- window.data = $.getJSON('/search_data.json');
+ window.idx = lunr(function () {
+ this.field('id');
+ this.field('title');
+ this.field('content', { boost: 10 });
+ this.field('categories');
- window.data.then(function(loaded_data){
- $.each(loaded_data, function(index, value){
- window.idx.add($.extend({ "id": index }, value));
+ for (var index in loaded_data) {
+ this.add($.extend({ "id": index }, loaded_data[index]));
+ }
});
- });
- $("#site_search").submit(function(event){
+ $("#site_search").submit(function (event) {
event.preventDefault();
var query = $("#search_box").val();
var results = window.idx.search(query);
- display_search_results(query, results);
+ display_search_results(query, results, loaded_data);
+ });
+
});
- function display_search_results(query, results) {
+ function display_search_results(query, results, loaded_data) {
var $search_status = $("#search_status");
var $search_results = $("#search_results");
- window.data.then(function(loaded_data) {
-
- if (results.length) {
- $search_status.html('Found ' + results.length + ' results for "' + query + '"');
- $search_results.empty();
- results.forEach(function(result) {
- var item = loaded_data[result.ref];
- var n = item.content.search(query) - 50
- if (n < 0) {
- n = 0;
- }
- var appendString = '<tr><td><a href="' + item.url + '">' + item.title + '</a><td>' + item.content.substring(n, n+100) + '</tr>';
- $search_results.append(appendString);
- });
- } else {
- $search_status.html('No results found!');
+ if (!results.length) {
+ $search_status.html('No results found!');
+ return;
+ }
+
+ $search_status.html('Found ' + results.length + ' results for "' + query + '"');
+ $search_results.empty();
+ results.forEach(function (result) {
+ var item = loaded_data[result.ref];
+ var n = item.content.search(query) - 50
+ if (n < 0) {
+ n = 0;
}
+ var appendString = '<tr><td><a href="' + item.url + '">' + item.title + '</a><td>' + item.content.substring(n, n + 100) + '</tr>';
+ $search_results.append(appendString);
});
+
Review Comment:
```suggestion
$search_results.append('</tbody>');
```
##########
pages/search.md:
##########
@@ -24,6 +24,6 @@ Search results are limited to blog posts, release notes, and the 2.x documentati
<table class="table table-striped" id="search_results"></table>
-<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/1.0.0/lunr.min.js"></script>
+<script src="https://unpkg.com/lunr@2.3.9/lunr.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
Review Comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo-website] DomGarguilo merged pull request #399: Update search page dependencies
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo merged PR #399:
URL: https://github.com/apache/accumulo-website/pull/399
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo-website] DomGarguilo commented on pull request #399: WIP - Update search page dependencies
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on PR #399:
URL: https://github.com/apache/accumulo-website/pull/399#issuecomment-1698137281
I've marked this as WIP because I was hoping to remove the import of jquery on this page and just have it use the jquery that is already imported from the main page but when I remove it, for some reason it messes with the table styling and I am not sure why.
With jquery 1.11.3 import

With the jquery import removed (with jquery 3.7.0 present from the main page imports)

For some reason the alternating row shading does not happen in the second case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [accumulo-website] DomGarguilo commented on a diff in pull request #399: Update search page dependencies
Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on code in PR #399:
URL: https://github.com/apache/accumulo-website/pull/399#discussion_r1310223675
##########
js/search.js:
##########
@@ -1,48 +1,49 @@
-jQuery(function() {
+jQuery(function () {
- window.idx = lunr(function () {
- this.field('id');
- this.field('title');
- this.field('content', { boost: 10 });
- this.field('categories');
- });
+ $.getJSON('/search_data.json').then(function (loaded_data) {
- window.data = $.getJSON('/search_data.json');
+ window.idx = lunr(function () {
+ this.field('id');
+ this.field('title');
+ this.field('content', { boost: 10 });
+ this.field('categories');
- window.data.then(function(loaded_data){
- $.each(loaded_data, function(index, value){
- window.idx.add($.extend({ "id": index }, value));
+ for (var index in loaded_data) {
+ this.add($.extend({ "id": index }, loaded_data[index]));
+ }
});
- });
- $("#site_search").submit(function(event){
+ $("#site_search").submit(function (event) {
event.preventDefault();
var query = $("#search_box").val();
var results = window.idx.search(query);
- display_search_results(query, results);
+ display_search_results(query, results, loaded_data);
+ });
+
});
- function display_search_results(query, results) {
+ function display_search_results(query, results, loaded_data) {
var $search_status = $("#search_status");
var $search_results = $("#search_results");
- window.data.then(function(loaded_data) {
-
- if (results.length) {
- $search_status.html('Found ' + results.length + ' results for "' + query + '"');
- $search_results.empty();
- results.forEach(function(result) {
- var item = loaded_data[result.ref];
- var n = item.content.search(query) - 50
- if (n < 0) {
- n = 0;
- }
- var appendString = '<tr><td><a href="' + item.url + '">' + item.title + '</a><td>' + item.content.substring(n, n+100) + '</tr>';
- $search_results.append(appendString);
- });
- } else {
- $search_status.html('No results found!');
+ if (!results.length) {
+ $search_status.html('No results found!');
+ return;
+ }
+
+ $search_status.html('Found ' + results.length + ' results for "' + query + '"');
+ $search_results.empty();
+ $search_results.append('<tbody>');
Review Comment:
I think I like that idea. I made those changes in e3082c1 and everything looks good.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org