Summary Files Commits Branches @commit @diff @stats
path: root / ext / pagenav.awk
blob: 0f2a2978f8ee89898d3e68627b62bc6b67fb3717 (plain) (blame)
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
FNR == 1 {
	STD_FILENAME = FILENAME
	sub(/^\.\/website\//, "", STD_FILENAME)

	substitutions["dbarsep"] = " || "

	# Stats element
	stats = \
"	<div id=\"pagenav-stats\">" ORS \
"		<strong>Reading: [$expected-reading]</strong> " substitutions["dbarsep"] " <strong>Created: [$created]</strong> " substitutions["dbarsep"] " <strong>Edited: [$edited]</strong>" ORS \
"		" substitutions["dbarsep"] " <a href=\"https://gitlab.com/Syndamia/syndamiadotcom/-/blob/master/src/" STD_FILENAME "\"><strong>GitLab source</strong></a>" ORS \
"	</div>"

	# Breadcrumbs element
	match(FILEDIR, /(blog|slides|teaching|misc)/)
	foldersLen = split(substr(FILEDIR, RSTART), folders, "/")

	href = ".."
	breadcrumb = " &raquo; <em>" folders[foldersLen] "</em>"
	for (i = foldersLen-1; i > 0; i--) {
		breadcrumb = " &raquo; " "<a href=\"" href "\">" folders[i] "</a>" breadcrumb
		href = "../" href
	}
	breadcrumb = \
"	<div id=\"pagenav-breadcrumb\">" ORS \
"		" breadcrumb ORS \
"	</div>"

	substitutions["pagenav"] = \
".text <div id=\"pagenav\">" ORS \
	stats ORS \
	breadcrumb ORS \
"</div>"
}