Commit e267a396 authored by Laurent Heirendt's avatar Laurent Heirendt

Merge branch 'develop' into 'master'

Regular merge of develop

See merge request !148
parents c99993ed 3d5a3a15
Pipeline #28498 passed with stage
in 46 seconds
......@@ -77,8 +77,6 @@ sections.sort()
# Index contains the generated content, init it with an empty container
index = ''
index += '<script type="text/javascript" src="{{ "assets/js/jquery3.5.1.min.js" | relative_url }}"></script>\n'
index += '<script type="text/javascript" src="{{ "assets/js/router.js" | relative_url }}"></script>\n\n'
index += '\n<div class="index-box-container">\n'
localIndexArr = [[]] * len(sections)
......
# In case something goes horribly wrong, you can fall back to `image: ruby:2.5`
image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.5
image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.6
stages:
- build
......
......@@ -12,7 +12,7 @@ gem "jekyll", "~> 4.0"
gem "bundler", "> 2.0"
gem "minima", "~> 2.5"
gem 'jekyll-theme-lcsb-default', '~> 0.3.8'
gem 'jekyll-theme-lcsb-default', '~> 0.4.2'
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
......@@ -45,3 +45,4 @@ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1" if Gem.win_platform?
gem 'jekyll-spaceship', "0.6.0"
\ No newline at end of file
......@@ -57,6 +57,7 @@ plugins:
- jekyll-feed
- jekyll-paginate-v2
- jekyll-redirect-from
- jekyll-spaceship
# These settings are used to display share link to howto.lcsb.uni.lu
# The display logic itself is in the template
......@@ -70,13 +71,36 @@ defaults:
path: "external/*"
values:
include_link: true
searchable: 1.0
searchable: 1.0
- scope: # adding og:image to the SEO's metadata
path: ""
values:
image: /assets/favicon/apple-touch-icon.png
# GDPR banner settings
banner_title: >-
This website needs some cookies and similar means to function.
banner_text: >-
If you permit us, we will use those means to collect data on your visits for aggregated statistics to improve our service.
banner_accept_text: >-
Accept cookies for aggregated statistics
banner_refuse_text: >-
No thanks, only technically necessary cookies
banner_more_text: >-
More information
cookies_expire: 180 # days
analyticsurl: https://analytics.lcsb.uni.lu/hub/
lapurl: https://analytics.lcsb.uni.lu/lap/
siteID: 3 # you get this siteID by sending an email to lcsb-r3@uni.lu
cookieName: lap
accept_all_text: >-
Aggregate statistics cookies accepted
only_necessary_text: >-
Only necessary cookies accepted
path_policy: privacy-policy
logo_policy: https://analytics.lcsb.uni.lu/lap/static/logos/r3-logo.svg
timeout_hidebanner: 500 # milliseconds
cookieDomain: '*' # track visitors across all subdomains of a given domain; set to * to ignore
# Exclude from processing. (no need to touch these)
# The following items will not be processed, by default. Create a custom list
......
<script type="text/javascript" src="https://analytics.lcsb.uni.lu/lap/static/js/jquery.min.js"></script>
<script type="text/javascript" src="{{ "assets/js/router.js" | relative_url }}"></script>
\ No newline at end of file
<link rel="prefetch" href="index.js" />
<form>
<input class="search" placeholder="What are you looking for?" name="search_query" id="search_query" /><br />
<button class="search" type="submit">Find it</button>
</form>
<h1 id="search_header">Results of your query:</h1>
<table id="search_results_table">
<tbody id="search_results_tbody">
<tr id="search_results_placeholder" style="display: none">
<td id="search_results_placeholder_td"><h3>Please wait, search is in progress...</h3></td>
</tr>
</tbody>
</table>
<script src="{{ "assets/js/lunr.min.js" | relative_url }}" integrity="sha256-34Si1Y6llMBKM3G0jQILVeoQKEwuxjbk4zGWXXMT4ps=" crossorigin="anonymous"></script>
<script>
var el_table_body = document.getElementById('search_results_tbody');
var el_input_query = document.getElementById('search_query');
var el_tr_placeholder = document.getElementById('search_results_placeholder');
var el_header = document.getElementById('search_header');
var url_params = new URLSearchParams(window.location.search);
var search_term = url_params.get('search_query') || "";
if (!!search_term.length) {
el_input_query.value = search_term;
el_header.style.display = "block";
el_tr_placeholder.style.display = "block";
}
var construct_cell = function(title, content, link) {
if (link == '#') {
return '<td><h3 class="result">' + title + '</h3><p>' + content + '</p></td>';
} else {
return '<td><h3><a href="' + link + '">' + title + '</a></h3><p>' + content + '</p></td>';
}
}
var capitalize = function(text) {
return text.charAt(0).toUpperCase() + text.slice(1);
}
var prettify = function(text) {
return text.split(':').map(capitalize).join(' &raquo; ');
}
{% assign the_cards = site.pages | where_exp:"card","card.searchable >= 1.0" %}
window.content = { {% for card in the_cards %}
"{{ card.url | slugify }}": {
"title": "{{ card.shortcut | xml_escape }}",
"content": {{ card.content | strip_html | strip_newlines | jsonify }},
"url": "{{ card.url | xml_escape | relative_url }}"
} {% unless forloop.last %},{% endunless %} {% endfor %}
};
fetch('{{ "index.js" | relative_url }}').then(response => response.text()).then((data) => {
var the_index = JSON.parse(data);
window.search_index = lunr.Index.load(the_index);
if (search_term != "") {
var results = window.search_index.search(search_term);
for (var i = 0; i < results.length; i++) {
var node = document.createElement("tr");
node.innerHTML = construct_cell(prettify(window.content[results[i].ref].title),
window.content[results[i].ref].content.substring(0, 125) + '...',
window.content[results[i].ref].url);
el_table_body.appendChild(node);
}
if (results.length == 0) {
var node = document.createElement("tr");
node.innerHTML = construct_cell("No results",
'Sorry, we were unable to find anything that matches your query',
"#");
el_table_body.appendChild(node);
}
}
el_tr_placeholder.style.display = "none";
})
</script>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -44,8 +44,9 @@ if (sub.length > 0) {
if (status == 200) { // The sub-card is internal and accessible
RedirectTo(internalCardURL);
} else {
// No external, no internal - probably no access
RedirectTo('/404.html');
if (!sub.includes('search_query')) { // do not redirect when a search is performed
RedirectTo('/404.html'); // No external, no internal - probably no access
}
}
})
}
......
......@@ -4,9 +4,7 @@ title: Home
order: 1
---
<script type="text/javascript" src="{{ "assets/js/jquery3.5.1.min.js" | relative_url }}"></script>
<script type="text/javascript" src="{{ "assets/js/router.js" | relative_url }}"></script>
{% include scripts.html %}
# LCSB How-to Cards
......
This diff is collapsed.
......@@ -5,90 +5,4 @@ permalink: /search
order: 4
---
<link rel="prefetch" href="index.js" />
<form>
<input class="search" placeholder="What are you looking for?" name="search_query" id="search_query" /><br />
<button class="search" type="submit">Find it</button>
</form>
<h1 id="search_header">Results of your query:</h1>
<table id="search_results_table">
<tbody id="search_results_tbody">
<tr id="search_results_placeholder" style="display: none">
<td id="search_results_placeholder_td"><h3>Please wait, search is in progress...</h3></td>
</tr>
</tbody>
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.8/lunr.min.js" integrity="sha256-34Si1Y6llMBKM3G0jQILVeoQKEwuxjbk4zGWXXMT4ps=" crossorigin="anonymous"></script>
<script>
var el_table_body = document.getElementById('search_results_tbody');
var el_input_query = document.getElementById('search_query');
var el_tr_placeholder = document.getElementById('search_results_placeholder');
var el_header = document.getElementById('search_header');
var url_params = new URLSearchParams(window.location.search);
var search_term = url_params.get('search_query') || "";
if (!!search_term.length) {
el_input_query.value = search_term;
el_header.style.display = "block";
el_tr_placeholder.style.display = "block";
}
var construct_cell = function(title, content, link) {
if (link == '#') {
return '<td><h3 class="result">' + title + '</h3><p>' + content + '</p></td>';
} else {
return '<td><h3><a href="' + link + '">' + title + '</a></h3><p>' + content + '</p></td>';
}
}
var capitalize = function(text) {
return text.charAt(0).toUpperCase() + text.slice(1);
}
var prettify = function(text) {
return text.split(':').map(capitalize).join(' &raquo; ');
}
{% assign the_cards = site.pages | where_exp:"card","card.searchable >= 1.0" %}
window.content = { {% for card in the_cards %}
"{{ card.url | slugify }}": {
"title": "{{ card.shortcut | xml_escape }}",
"content": {{ card.content | strip_html | strip_newlines | jsonify }},
"url": "{{ card.url | xml_escape | relative_url }}"
} {% unless forloop.last %},{% endunless %} {% endfor %}
};
fetch('{{ "index.js" | relative_url }}').then(response => response.text()).then((data) => {
var the_index = JSON.parse(data);
window.search_index = lunr.Index.load(the_index);
if (search_term != "") {
var results = window.search_index.search(search_term);
for (var i = 0; i < results.length; i++) {
var node = document.createElement("tr");
node.innerHTML = construct_cell(prettify(window.content[results[i].ref].title),
window.content[results[i].ref].content.substring(0, 125) + '...',
window.content[results[i].ref].url);
el_table_body.appendChild(node);
}
if (results.length == 0) {
var node = document.createElement("tr");
node.innerHTML = construct_cell("No results",
'Sorry, we were unable to find anything that matches your query',
"#");
el_table_body.appendChild(node);
}
}
el_tr_placeholder.style.display = "none";
})
</script>
{% include search.html %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment