forked from loopbackio/loopback.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: discovery powered search and sitemap gen
- Loading branch information
Showing
17 changed files
with
609 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ dist | |
.jekyll-metadata | ||
vendor | ||
.bundle | ||
pages/en/lb4/ | ||
pages/**/*/readmes/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ gem 'github-pages' | |
gem 'jekyll' | ||
gem 'jekyll-redirect-from' | ||
gem 'jekyll-relative-links' | ||
gem 'jekyll-sitemap' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,6 +248,7 @@ DEPENDENCIES | |
jekyll | ||
jekyll-redirect-from | ||
jekyll-relative-links | ||
jekyll-sitemap | ||
rouge | ||
|
||
BUNDLED WITH | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
{% include head.html %} | ||
|
||
<script> | ||
$(function () { | ||
$('[data-toggle="tooltip"]').tooltip() | ||
}) | ||
</script> | ||
{% if page.datatable == true %} | ||
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css"> | ||
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.5/js/jquery.dataTables.js"></script> | ||
<script> | ||
$(document).ready(function(){ | ||
|
||
$('table.datatable').DataTable( { | ||
paging: false, | ||
stateSave: true | ||
} | ||
); | ||
</script> | ||
{% endif %} | ||
|
||
</head> | ||
<body> | ||
{% include topnav.html %} | ||
<!-- Page Content --> | ||
<div class="container"> | ||
<!-- Content Row --> | ||
<div class="row"> | ||
<!-- Content Column --> | ||
<div class="col-md-8 col-md-offset-2 col-sm-12"> | ||
<h1>Search Results</h1> | ||
<div class="results"> | ||
<img src="/images/LB_Preloader.gif" alt="Loading"> | ||
</div> | ||
</div> | ||
<!-- /.row --> | ||
</div> | ||
<!-- /.container --> | ||
</div> | ||
|
||
<script> | ||
// List of HTML entities for escaping. | ||
var htmlEscapes = { | ||
'&': '&', | ||
'<': '<', | ||
'>': '>', | ||
'"': '"', | ||
"'": ''', | ||
'/': '/' | ||
}; | ||
|
||
// Regex containing the keys listed immediately above. | ||
var htmlEscaper = /[&<>"'\/]/g; | ||
|
||
// Escape a string for HTML interpolation. | ||
|
||
function escapeHTML(string) { | ||
string = ('' + string).replace(htmlEscaper, function(match) { | ||
return htmlEscapes[match]; | ||
}); | ||
// Undo <em></em> -- used to highlight matches | ||
string = string.replace(/<em>/g, '<em>'); | ||
return string.replace(/</em>/g, '</em>'); | ||
}; | ||
|
||
$(document).ready(function() { | ||
var query = window.location.href.slice(window.location.href.indexOf('?') + 1); | ||
|
||
if (query && query.length > 0) { | ||
var split = query.split('&'); | ||
var queryObj = {}; | ||
split.forEach(function(s) { | ||
queryObj[s.split('=')[0]] = s.split('=')[1]; | ||
}); | ||
} | ||
|
||
$('.search-bar').val(queryObj.q.replace('+', ' ')); | ||
|
||
var urlBase = "https://openwhisk.ng.bluemix.net/api/v1/web/slbld%40ca.ibm.com_loopback/default/search.json"; | ||
var url = urlBase + query; | ||
|
||
$.get(url).done(function(data) { | ||
if (!data.status) { | ||
$('.results').html('<h3>' + escapeHTML(data.msg) + '</h3>'); | ||
} else { | ||
var html = '<ul class="resultList">' | ||
data.results.forEach(function(res) { | ||
if (!res.highlight.text) { | ||
res.highlight.text = [] | ||
} | ||
res.highlight.text.forEach(function(t) { | ||
t = escapeHTML(t); | ||
}); | ||
|
||
html += '<li><a class="title" href="' + escapeHTML(res.metadata.url) + '">' + escapeHTML(res.metadata.title) + '</a><br/>'; | ||
html += '<a class="link" href="' + escapeHTML(res.metadata.url) + '">' + window.location.protocol + '//' + window.location.host + escapeHTML(res.metadata.url) + '</a>'; | ||
html += '<p>' + res.highlight.text.splice(0, 3).join('<br/>') + '</p></li>'; | ||
}); | ||
html += '</ul>'; | ||
|
||
// Page Index | ||
var pages = Math.floor(data.matching_results / 10); | ||
var offset = 0; | ||
if (queryObj.offset) { | ||
offset = Number(queryObj.offset); | ||
} | ||
|
||
html += '<ul class="pagination">' | ||
|
||
for (var i=0; i<pages; i++) { | ||
queryObj.offset = i*10; | ||
var page = i + 1; | ||
var active = Math.floor(offset / 10) == i ? 'active' : ''; | ||
|
||
html += '<li class="' + active + '"><a href="/search?' + $.param(queryObj) + '">' + page + '</a></li>'; | ||
} | ||
|
||
$('.results').html(html); | ||
} | ||
}); | ||
}) | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.