Skip to content
Snippets Groups Projects
Commit e240e0ff authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

Merge branch 'move-lab-cards-ext' into 'develop'

Move lab cards external

See merge request !347
parents 0189e98c d6fdd63f
No related branches found
No related tags found
2 merge requests!354[release] Regular merge of develop,!347Move lab cards external
Pipeline #52821 passed with warnings
Showing
with 85 additions and 41 deletions
...@@ -29,13 +29,27 @@ def root_handbook(href): ...@@ -29,13 +29,27 @@ def root_handbook(href):
return href return href
def root_lab(href):
# remove sym link reference in href
if ('lab-software' in href):
href = href.replace('lab-software', 'lab').strip()
elif ('lab-equipment' in href):
href = href.replace('lab-equipment', 'lab').strip()
elif ('lab-hsa' in href):
href = href.replace('lab-hsa', 'lab').strip()
return href
def build_section_start(title, shortcut): def build_section_start(title, shortcut):
title = title.replace("Gdpr", "GDPR") title = title.replace("Gdpr", "GDPR")
title = title.replace("Handbook additional", "PI/Supervisor specifics") title = title.replace("Handbook additional", "Handbook: PI/Supervisor specifics")
title = title.replace("Handbook annexes", "Annexes") title = title.replace("Handbook annexes", "Handbook: Annexes")
title = title.replace("Covid 19", "COVID-19") title = title.replace("Covid 19", "COVID-19")
title = title.replace("Ppc", "PPC") title = title.replace("Ppc", "PPC")
title = title.replace("Lab software", "Lab: Software")
title = title.replace("Lab equipment", "Lab: Equipment")
title = title.replace("Lab hsa", "Lab: Health & Safety, Access")
return f'\n\t<div class="index-box noborderbox" id="{shortcut}-card">\n\t\t<h3>{title}</h3>\n\t\t<ul>\n' return f'\n\t<div class="index-box noborderbox" id="{shortcut}-card">\n\t\t<h3>{title}</h3>\n\t\t<ul>\n'
...@@ -133,6 +147,50 @@ def remove_header(localroot, root, filename): ...@@ -133,6 +147,50 @@ def remove_header(localroot, root, filename):
return n return n
def generate_header(folder, permalink, shortcut, order, legacy_from):
header = "---\n"
if len(order) > 0:
header += "order: " + str(order) + "\n"
header += "layout: page\n"
header += "permalink: " + permalink + "\n"
header += "shortcut: " + root_handbook(shortcut) + "\n"
header += "redirect_from:\n"
header += " - /cards/" + shortcut + "\n"
header += " - /" + folder + "/cards/" + shortcut + "\n"
# special case of handbook
if "handbook-annexes" in permalink or "handbook-additional" in permalink:
header += " - /cards/" + root_handbook(shortcut) + "\n"
header += " - /" + folder + "/cards/" + root_handbook(shortcut) + "\n"
# separate lab section
if "lab-software" in permalink or "lab-equipment" in permalink or "lab-hsa" in permalink:
header += " - /cards/" + root_lab(shortcut) + "\n"
header += " - /" + folder + "/cards/" + root_lab(shortcut) + "\n"
# include the legacy section
if len(legacy_from) > 0:
for item in legacy_from:
header += str(item)
else:
header += "---"
return header
def generate_whitelist_entry(folder, permalink, shortcut):
wl_entry = permalink + "\n"
wl_entry += "/?" + shortcut + "\n"
wl_entry += "/cards/" + shortcut + "\n"
wl_entry += "/" + folder + "/cards/" + shortcut + "\n"
if "handbook-annexes" in permalink or "handbook-additional" in permalink:
wl_entry += "/cards/" + root_handbook(shortcut) + "\n"
wl_entry += "/" + folder + "/cards/" + root_handbook(shortcut) + "\n"
# separate lab section
if "lab-software" in permalink or "lab-equipment" in permalink or "lab-hsa" in permalink:
wl_entry += "/cards/" + root_lab(shortcut) + "\n"
wl_entry += "/" + folder + "/cards/" + root_lab(shortcut) + "\n"
return wl_entry
# loop through the entire internal tree # loop through the entire internal tree
localroot = os.getcwd() localroot = os.getcwd()
...@@ -214,14 +272,8 @@ for folder in cardDirs: ...@@ -214,14 +272,8 @@ for folder in cardDirs:
# replace the / with a : # replace the / with a :
shortcut = re.sub('/', ':', shortcut) shortcut = re.sub('/', ':', shortcut)
# define the header for each card
header = "---\n"
if len(order) > 0: if len(order) > 0:
header += "order: " + str(order) + "\n" # find the maximum of existing orders
# append the order of the card
# find the maximum of existing orders
if folderFlag: if folderFlag:
if len(orderArr[indexS]) > 0: if len(orderArr[indexS]) > 0:
maxOrder = max(orderArr[indexS]) maxOrder = max(orderArr[indexS])
...@@ -236,33 +288,11 @@ for folder in cardDirs: ...@@ -236,33 +288,11 @@ for folder in cardDirs:
else: else:
orderArr[indexS] = [] orderArr[indexS] = []
header += "layout: page\n" # generate the header for each card
header += "permalink: " + permalink + "\n" header = generate_header(folder, permalink, shortcut, order, legacy_from)
header += "shortcut: " + root_handbook(shortcut) + "\n"
header += "redirect_from:\n"
header += " - /cards/" + shortcut + "\n"
header += " - /" + folder + "/cards/" + shortcut + "\n"
# special case of handbook
if "handbook-annexes" in permalink or "handbook-additional" in permalink:
header += " - /cards/" + root_handbook(shortcut) + "\n"
header += " - /" + folder + "/cards/" + root_handbook(shortcut) + "\n"
# include the legacy section
if len(legacy_from) > 0:
for item in legacy_from:
header += str(item)
else:
header += "---"
# add autogenerated links to whitelist # add autogenerated links to whitelist
whiteList += permalink + "\n" whiteList += generate_whitelist_entry(folder, permalink, shortcut)
whiteList += "/?" + shortcut + "\n"
whiteList += "/cards/" +shortcut + "\n"
whiteList += "/" + folder + "/cards/" + shortcut + "\n"
if "handbook-annexes" in permalink or "handbook-additional" in permalink:
whiteList += " - /cards/" + root_handbook(shortcut) + "\n"
whiteList += " - /" + folder + "/cards/" + root_handbook(shortcut) + "\n"
# add the header properly speaking # add the header properly speaking
line_prepender(fileName, header) line_prepender(fileName, header)
......
...@@ -23,13 +23,17 @@ window.boxHider = (function() { ...@@ -23,13 +23,17 @@ window.boxHider = (function() {
function GetSelectedBoxElement(id) { function GetSelectedBoxElement(id) {
var allBoxesArray = GetAllBoxElementsArray(); var allBoxesArray = GetAllBoxElementsArray();
var element = document.getElementById(id); // note: handbook and lab are actually grouped sections
if (id.startsWith('handbook') || id.startsWith('lab')) {
return true;
} else {
var element = document.getElementById(id);
if (allBoxesArray.includes(element)) { if (allBoxesArray.includes(element)) {
return element; return element;
}
return false;
} }
return false;
} }
function HideElement(element) { function HideElement(element) {
...@@ -84,6 +88,14 @@ window.boxHider = (function() { ...@@ -84,6 +88,14 @@ window.boxHider = (function() {
ShowElement(box); ShowElement(box);
} }
}); });
} else if (boxId.startsWith('lab')) {
allBoxes.map(function(box) {
if (!box.id.startsWith('lab')) {
HideElement(box);
} else {
ShowElement(box);
}
});
} else { } else {
allBoxes.map(function(box) { allBoxes.map(function(box) {
if (box != selectedBox) { if (box != selectedBox) {
......
--- ---
layout: page layout: page
permalink: /external/lab/dishwasher-utilization-and-maintenance/ permalink: /external/lab-equipment/dishwasher-utilization-and-maintenance/
shortcut: lab:dishwasher-utilization-and-maintenance shortcut: lab-equipment:dishwasher-utilization-and-maintenance
redirect_from: redirect_from:
- /cards/lab-equipment:dishwasher-utilization-and-maintenance
- /external/cards/lab-equipment:dishwasher-utilization-and-maintenance
- /cards/lab:dishwasher-utilization-and-maintenance - /cards/lab:dishwasher-utilization-and-maintenance
- /external/cards/lab:dishwasher-utilization-and-maintenance - /external/cards/lab:dishwasher-utilization-and-maintenance
--- ---
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment