Skip to content

Commit 7a5f36c

Browse files
authored
Merge pull request #128 from iykdw/infrachanges
Add some pizzaz
2 parents 2df7217 + 8d2bddf commit 7a5f36c

File tree

10 files changed

+96
-62
lines changed

10 files changed

+96
-62
lines changed
191 KB
Loading
193 KB
Loading
199 KB
Loading
192 KB
Loading
217 KB
Loading
212 KB
Loading
4.72 MB
Loading
1.82 MB
Loading

generator/templates/training-site.j2.html

Lines changed: 86 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,103 @@
22
<head>
33
<title>Edinburgh Hacklab Training Docs</title>
44
<style>
5-
body {
6-
max-width: 70ch;
7-
margin: 1rem auto;
8-
font-family: system-ui;
9-
color: #212121;
10-
}
11-
footer { text-align: center; padding: 1rem; }
12-
summary {border-bottom: 1px solid black;}
13-
.h3 { font-size: 1.5rem; padding: 0.2rem; display: inline-block; font-weight: bold; margin-top: 20px;}
14-
.h4:nth-child(2) { margin-top: 10px; }
15-
.h4 { display: block; margin: 0.1rem; font-size: 1.3rem; font-weight: bold}
16-
.h4 a, .h4 a:visited, .h4 a:hover { color: inherit !important; text-decoration: none; font-size: 0.8rem; float: right; }
17-
li { margin: 0.5rem; }
18-
a { text-decoration: none; color: #0d47a1; }
19-
a:visited { color: #0d47a1; }
20-
a:hover { color: #1266e2; }
5+
body {
6+
max-width: 70ch;
7+
margin: 1rem auto;
8+
font-family: system-ui;
9+
color: #212121;
10+
background-size: cover;
11+
background-repeat: no-repeat;
12+
background-attachment: fixed;
13+
}
14+
footer { text-align: center; padding: 1rem; }
15+
summary {border-bottom: 1px solid black;}
16+
.h3 { font-size: 1.5rem; padding: 0.2rem; display: inline-block; font-weight: bold; margin-top: 20px;}
17+
.h4:nth-child(2) { margin-top: 10px; }
18+
.h4 { display: block; margin: 0.1rem; font-size: 1.3rem; font-weight: bold}
19+
.h4 a, .h4 a:visited, .h4 a:hover { color: inherit !important; text-decoration: none; font-size: 0.8rem; float: right; }
20+
li { margin: 0.5rem; }
21+
a { text-decoration: none; color: #0d47a1; }
22+
a:visited { color: #0d47a1; }
23+
a:hover { color: #1266e2; }
24+
.body {
25+
padding: 50px;
26+
height: auto;
27+
box-shadow: 0 0 25px 25px white;
28+
background-color: white;
29+
min-height: 100vh;
30+
}
2131
</style>
32+
33+
<script>
34+
function randomImage(){
35+
console.log({{images}})
36+
var images = {{images}}
37+
var size = images.length;
38+
var x = Math.floor(size * Math.random());
39+
var element = document.body
40+
element.style.backgroundImage = "linear-gradient(rgba(255, 255, 255, 0.75)), url("+ images[x] + ")";
41+
}
42+
43+
document.addEventListener("DOMContentLoaded", randomImage);
44+
</script>
2245
</head>
2346
<body>
24-
<h1>Edinburgh Hacklab Training Docs</h1>
47+
<div class="body">
48+
<h1>Edinburgh Hacklab Training Docs</h1>
2549

26-
<p>
27-
These are the documents we use for training people how to use our tools.
28-
</p>
50+
<p>
51+
These are the documents we use for training people how to use our tools.
52+
</p>
2953

3054

31-
<ul>
32-
<li><strong>Risk assessments</strong> outline the risks of each tool, and the steps we take to control them.</li>
33-
<li><strong>Training docs</strong> are summaries of what needs to be taught to use that tool safely, intended to help instructors deliver training.</li>
34-
<li><strong>Training cards</strong> are checklists for an instructor to fill out when training someone on that tool. Depending on the tool, we may require that a paper copy of this is filled out.</li>
35-
</ul>
55+
<ul>
56+
<li><strong>Risk assessments</strong> outline the risks of each tool, and the steps we take to control them.</li>
57+
<li><strong>Training docs</strong> are summaries of what needs to be taught to use that tool safely, intended to help instructors deliver training.</li>
58+
<li><strong>Training cards</strong> are checklists for an instructor to fill out when training someone on that tool. Depending on the tool, we may require that a paper copy of this is filled out.</li>
59+
</ul>
3660

37-
<p>
38-
To contribute to these training docs, see <a href="https://github.com/edinburghhacklab/hacklab-training">the github repository</a>. Non-vital information about a tool may belong better on <a href="https://wiki.ehlab.uk">the wiki</a>.
39-
</p>
61+
<p>
62+
To contribute to these training docs, see <a href="https://github.com/edinburghhacklab/hacklab-training">the github repository</a>. Non-vital information about a tool may belong better on <a href="https://wiki.ehlab.uk">the wiki</a>.
63+
</p>
4064

41-
{%- set idxs = [] %}
42-
{%- for key, value in syllabuses.items() recursive %}
43-
{%- set depth = idxs|length + 2 %}
44-
{% if depth == 3 %}
45-
</details>
46-
<details>
47-
{% endif %}
48-
{% if depth > 2 %}
65+
{%- set idxs = [] %}
66+
{%- for key, value in syllabuses.items() recursive %}
67+
{%- set depth = idxs|length + 2 %}
4968
{% if depth == 3 %}
50-
<summary>
69+
</details>
70+
<details>
5171
{% endif %}
52-
<div class="h{{depth}}">
53-
{{ key }}
54-
{% if value.files %}
55-
<a href="https://github.com/edinburghhacklab/hacklab-training/commit/{{ value.version }}">Version: {{ value.version }} - {{ value.commit_date }}</a>
72+
{% if depth > 2 %}
73+
{% if depth == 3 %}
74+
<summary>
75+
{% endif %}
76+
<div class="h{{depth}}">
77+
{{ key }}
78+
{% if value.files %}
79+
<a href="https://github.com/edinburghhacklab/hacklab-training/commit/{{ value.version }}">Version: {{ value.version }} - {{ value.commit_date }}</a>
80+
{% endif %}
81+
</div>
82+
{% if depth == 3 %}
83+
</summary>
5684
{% endif %}
57-
</div>
58-
{% if depth == 3 %}
59-
</summary>
60-
{% endif %}
6185

62-
{% endif %}
63-
{%- if value.files %}
64-
<ul>
65-
{%- for file, filename in value.files.items() %}
66-
<li><a href="{{ filename }}">{{ file }}</a></li>
67-
{%- endfor %}
68-
</ul>
69-
{%- else %}
70-
{%- do idxs.append(loop.index) %}
71-
{{ loop(value.items()) }}
72-
{%- do idxs.pop() %}
73-
{%- endif %}
74-
{%- endfor %}
75-
<footer>
76-
<p><small>Last updated: {{ timestr }}</small></p>
77-
</footer>
86+
{% endif %}
87+
{%- if value.files %}
88+
<ul>
89+
{%- for file, filename in value.files.items() %}
90+
<li><a href="{{ filename }}">{{ file }}</a></li>
91+
{%- endfor %}
92+
</ul>
93+
{%- else %}
94+
{%- do idxs.append(loop.index) %}
95+
{{ loop(value.items()) }}
96+
{%- do idxs.pop() %}
97+
{%- endif %}
98+
{%- endfor %}
99+
<footer>
100+
<p><small>Last updated: {{ timestr }}</small></p>
101+
</footer>
102+
</div>
78103
</body>
79104
</html>

generator/training_generator/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
from dataclasses import field
77
from datetime import datetime
88
from datetime import timezone
9+
from os import listdir
10+
from os.path import isfile
11+
from os.path import join
12+
from shutil import copytree
913
from tempfile import NamedTemporaryFile
1014

1115
import jinja2
12-
1316
from syllabus_processor import RISK_ASSESSMENT_FILENAME
1417
from syllabus_processor import SYLLABUS_FILENAME
1518
from syllabus_processor import SyllabusProcessor
@@ -121,13 +124,19 @@ def generate(syallabus_dir, output_dir, folder_filter):
121124
loader=jinja2.FileSystemLoader(os.path.abspath("./templates")),
122125
extensions=["jinja2.ext.do"],
123126
)
127+
128+
background_dir = "assets/backgrounds"
129+
copytree(background_dir, os.path.join(output_dir, "backgrounds"), dirs_exist_ok=True)
130+
onlyfiles = [f"./backgrounds/{f}" for f in listdir(background_dir) if isfile(join(background_dir, f))]
131+
124132
site_template = env.get_template("training-site.j2.html")
125133
with open(os.path.join(output_dir, "index.html"), "w", encoding="utf-8") as f:
126134
f.write(
127135
site_template.render(
128136
syllabuses=syllabuses,
129137
title=None,
130138
timestr=datetime.now(timezone.utc),
139+
images=onlyfiles
131140
)
132141
)
133142

0 commit comments

Comments
 (0)