mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
⚙️ Add academy builder script
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,6 +17,7 @@ slides/autopilot/state.yaml
|
||||
slides/index.html
|
||||
slides/past.html
|
||||
slides/slides.zip
|
||||
slides/_academy_*
|
||||
node_modules
|
||||
|
||||
### macOS ###
|
||||
|
||||
31
slides/academy-build.py
Executable file
31
slides/academy-build.py
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
html_file = sys.argv[1]
|
||||
output_file_template = "_academy_{}.html"
|
||||
title_regex = "name: toc-(.*)"
|
||||
redirects = open("_redirects", "w")
|
||||
|
||||
sections = re.split(title_regex, open(html_file).read())[1:]
|
||||
|
||||
while sections:
|
||||
link, markdown = sections[0], sections[1]
|
||||
sections = sections[2:]
|
||||
output_file_name = output_file_template.format(link)
|
||||
with open(output_file_name, "w") as f:
|
||||
html = open("workshop.html").read()
|
||||
html = html.replace("@@MARKDOWN@@", markdown)
|
||||
titles = re.findall("# (.*)", markdown) + [""]
|
||||
html = html.replace("@@TITLE@@", "{} — Kubernetes Academy".format(titles[0]))
|
||||
html = html.replace("@@SLIDENUMBERPREFIX@@", "")
|
||||
html = html.replace("@@EXCLUDE@@", "")
|
||||
html = html.replace(".nav[", ".hide[")
|
||||
f.write(html)
|
||||
redirects.write("/{} /{} 200!\n".format(link, output_file_name))
|
||||
|
||||
html = open(html_file).read()
|
||||
html = re.sub("#toc-([^)]*)", "_academy_\\1.html", html)
|
||||
sys.stdout.write(html)
|
||||
@@ -228,3 +228,6 @@ td {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user