Commit 5973054b authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

feat: add router to index.html

parent 29ce8dda
Pipeline #26368 passed with stages
in 4 minutes and 32 seconds
......@@ -76,7 +76,10 @@ sections = list(set(sections))
sections.sort()
# Index contains the generated content, init it with an empty container
index = '\n<div class="index-box-container">\n'
index = '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>\n'
index += '<script type="text/javascript" src="router.js"></script>\n\n'
index += '\n<div class="index-box-container">\n'
localIndexArr = [[]] * len(sections)
for folder in cardDirs:
......
......@@ -4,6 +4,10 @@ title: Home
order: 1
---
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="router.js"></script>
# LCSB How-to Cards
The Bioinformatics Core and Lab Support teams assist researchers from the Luxembourg Centre for Systems Biomedicine ([LCSB](https://www.uni.lu/lcsb)) with the organization, management, and curation of research data through its R3 initiative.
......
---
---
function UrlExists(url, cb) {
jQuery.ajax({
url: url,
dataType: 'text',
type: 'GET',
cache: false,
complete: function(xhr){
if(typeof cb === 'function')
cb.apply(this, [xhr.status]);
}
});
}
function GetShortcutDestination() {
var s = window.location.href;
var pathArray = s.split('?');
// Cut the query if it exists
if (pathArray.length > 1) {
return pathArray[1];
} else {
return '';
}
}
function RedirectTo(newLocation) {
document.location.replace(newLocation);
}
// Pick the shortcut link destination from URL, like: `category:subcategory:card-name`
var sub = GetShortcutDestination();
// If there's a shortcut to handle
if (sub.length > 0) {
var externalCardURL = '/external/cards/' + sub;
var internalCardURL = '/internal/cards/' + sub;
UrlExists(externalCardURL, function(status){
if (status == 200) { // The sub-card is external and accessible
RedirectTo(externalCardURL);
} else {
UrlExists(internalCardURL, function(status){
if (status == 200) { // The sub-card is internal and accessible
RedirectTo(internalCardURL);
} else {
// No external, no internal - probably no access
RedirectTo('/404.html');
}
})
}
});
}
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