Verified Commit a125c9a0 authored by Laurent Heirendt's avatar Laurent Heirendt
Browse files

exceptions for subfolders of handbook

parent 886a10cc
Pipeline #48019 passed with stages
in 2 minutes and 28 seconds
......@@ -20,6 +20,15 @@ def build_link(title, href):
return f'\t\t\t<li><a href="{href}">{title}</a></li>\n'
def root_handbook(href):
# remove sym link reference in href
if ('handbook-additional' in href):
href = href.replace('handbook-additional', 'handbook').strip()
elif ('handbook-annexes' in href):
href = href.replace('handbook-annexes', 'handbook').strip()
return href
def build_section_start(title, shortcut):
title = title.replace("Gdpr", "GDPR")
......@@ -129,6 +138,9 @@ for folder in cardDirs:
print(" > Generating header for: " + fileName)
# remove the previous header
#if "handbook" in fileName:
# remove_header(localroot, root, file, 10)
#else:
remove_header(localroot, root, file, 8)
# generate a permalink
......@@ -147,10 +159,16 @@ for folder in cardDirs:
header = "---\n"
header += "layout: page\n"
header += "permalink: " + permalink + "\n"
header += "shortcut: " + shortcut + "\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"
header += "---"
# add autogenerated links to whitelist
......@@ -158,6 +176,9 @@ for folder in cardDirs:
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
line_prepender(fileName, header)
......@@ -165,7 +186,11 @@ for folder in cardDirs:
# open file and get the title after the header
count = 0
title = ""
bp = 9
if "handbook-annexes" in permalink or "handbook-additional" in permalink:
bp = 11
else:
bp = 9
with open(fileName, 'r') as f:
for line in f:
count += 1
......
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