-
Notifications
You must be signed in to change notification settings - Fork 490
/
Copy pathlayout.jlhtml
183 lines (160 loc) · 7.96 KB
/
layout.jlhtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
$(begin
import Pluto
"The contents of `<head>` from a Pluto HTML export."
const pluto_head = let
default = Pluto.generate_html(;
pluto_cdn_root=Pluto.PLUTO_VERSION < v"0.19" ? "https://cdn.jsdelivr.net/gh/fonsp/Pluto.jl@9ca70c36/frontend/" : nothing)
m = match(r"<head.*?>(.*)</head>"s, default)
reduce([
# r"<script[^\n]data-pluto-file=[\"']?launch-parameters.*?/script>"s
r"<title.*?/title>"
r"<meta name=[\"']?description.*?>"
r"<meta name=[\"']?description.*?>"
r"<link rel=[\"']?icon.*?>"
]; init=m[1]) do s,r
replace(s, r => "")
end |> HTML
end
f(x,y) = get(page.output.frontmatter, x, y)
function section_number(frontmatter)
ch = get(frontmatter, "chapter", nothing)
se = get(frontmatter, "section", nothing)
isnothing(ch) || isnothing(se) ? nothing : "$(ch).$(se)"
end
nothing
end)<html lang="en">
<head>
<title>$(f("title", splitext(basename(page.input.relative_path))[1])) — Interactive Computational Thinking — MIT</title>
$(let d = f("description", nothing)
if d !== nothing
@htl("""<meta name="description" content=$(d) />""")
end
end)
<link rel="root" href="$(root_url)" />
<link rel="icon" href="$(root_url)/assets/favicon.ico" />
<link rel="icon" href="$(root_url)/assets/favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="$(root_url)/assets/styles/index.css" type="text/css" />
<link rel="stylesheet" href="$(root_url)/assets/styles/layout.css" type="text/css" />
<script src="$(root_url)/assets/scripts/sidebar.js" type="module"></script>
<link rel="pp-search-data" href="$(root_url)/pp_search_data.json" />
<script src="https://cdn.jsdelivr.net/npm/lunr@2.3.9/lunr.min.js" integrity="sha256-DFDZACuFeAqEKv/7Vnu1Tt5ALa58bcWZegGGFNgET8g=" crossorigin="anonymous" defer></script>
<script src="$(root_url)/assets/scripts/search.js" type="module" defer></script>
<script src="https://cdn.jsdelivr.net/npm/lite-youtube-embed@0.3.0/src/lite-yt-embed.js" integrity="sha256-sDRYYtDc+jNi2rrJPUS5kGxXXMlmnOSCq5ek5tYAk/M=" crossorigin="anonymous" defer></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lite-youtube-embed@0.3.0/src/lite-yt-embed.css" integrity="sha256-lv6SEl7Dhri7d86yiHCTuSWFb9CYROQFewxZ7Je0n5k=" crossorigin="anonymous">
<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "8572a580bead4b729ad55779ba3a1cd6"}'></script>
<script data-goatcounter="https://computationalthinking-stats.plutojl.org/count" async src="//computationalthinking-stats.plutojl.org/count.js"></script>
$(pluto_head)
</head>
<body>
<div id="pages-layout">
<button id="toggle-nav" title="Open navigation"></button>
<nav id="pages-sidebar">
<div>
<ul>
<li class="sidebar-about">
<div class="course-title">
<h1><a href="$(root_url)"><span>Introduction to</span> <span>Computational Thinking</span></a></h1>
<h2><span>Make mathematics your playground!</span></h2>
</div>
<div class="authors">
by <a href="http://math.mit.edu/~edelman">Alan Edelman</a>, <a href="http://sistemas.fciencias.unam.mx/~dsanders/">David P. Sanders</a> & <a href="https://people.csail.mit.edu/cel/">Charles E. Leiserson</a>
</div>
</li>
<li>
<div class="search-bar">
<form action="$(root_url)/search" method="GET">
<input type="search" name="q" placeholder="Search...">
<input type=submit value="🔎">
</form>
</div>
</li>
<li>
<div class="track-chooser">
<label>
<h2>Choose your track:</h2>
<select>
<option value="">Choose...</option>
<option value="julia">💻 Julia programming</option>
<option value="math">🎨 Mathematics</option>
<option value="climate">🌎 Climate science</option>
<option value="data">📊 Data science</option>
</select>
</label>
</div>
</li>
$(let
sidebar_data = Base.include(@__MODULE__, joinpath(@__DIR__, "..", "sidebar data.jl"))
sections = sidebar_data["main"]
[
@htl("""
<li>
<h3>$(section_name)</h3>
<ul>
$([
let
input = other_page.input
output = other_page.output
number = section_number(output.frontmatter)
name = get(output.frontmatter, "title", basename(input.relative_path))
desc = get(output.frontmatter, "description", nothing)
tags = get(output.frontmatter, "tags", String[])
active = page.url == other_page.url
homework_number = get(output.frontmatter, "homework_number", nothing)
href = root_url * "/" * other_page.url
class = [
active ? "active" : nothing,
homework_number === nothing ? "lecture" : "homework",
("tag_$(replace(x, " "=>"_"))" for x in tags)...,
]
if homework_number === nothing
@htl("""<li class=$(class)><a href=$(href) title=$(desc)><span class="entry-number">$(number)</span> $(name)</a></li>""")
else
@htl("""<li class=$(class)><a href=$(href) title=$(desc)><span class="entry-number">Homework $(homework_number):</span> $(name)</a></li>""")
end
end for other_page in pages
])
</ul>
</li>
""")
for (section_name, pages) in sections
]
end)
<li><hr></li>
<li class="sidebar-about">
<div class="semester-details">
<a href="$(root_url)/semesters/">Fall 2024</a>
<div class="course-numbers"><span>6.C25</span> / <span>18.C25</span> / <span style="opacity: .8;">etc</span></div>
</div>
<div class="logos">
<picture title="Massachusetts Institute of Technology">
<img src="$(root_url)/assets/MIT_logo.svg">
</picture>
<picture title="Julia Programming Language">
<source srcset="$(root_url)/assets/julia-logo-dark.svg" media="(prefers-color-scheme: dark)" />
<img src="$(root_url)/assets/julia-logo-color.svg">
</picture>
</div>
</li>
</ul>
</div>
</nav>
<div id="pages-content">
$(any(contains("lecture"), f("tags", String[])) ? @htl("""
<div class="lecture-header" >
<p class="number">Section $(f("chapter", "-")).$(f("section", "-"))</p>
<h1>$(
f("title", basename(page.input.relative_path))
)</h1>
<div class="video">
<h4>Lecture Video</h4>
<div>
<lite-youtube videoid=$(f("youtube_id", "notfound")) params="modestbranding=1&rel=0"></lite-youtube>
</div>
</div>
</div>
""") : nothing)
$(content)
</div>
</div>
</body>
</html>