-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.nw
183 lines (147 loc) · 3.85 KB
/
index.nw
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
<<url>>=
https://github.com/ctarbide
@
<<body>>=
<h1><<TITLE>></h1>
<p> Hi, you are very much welcome!
<h2>Pages</h2>
<<pages listing>>
<h2>About</h2>
<p> The intent of this is to document some of the stuff I do at <a href="<<url>>"><<url>></a>.
<p> <a href="pages/2024/2024-01-06_15h38m06_meta/index.html">More information</a>.
@
<<PRIMARY SOURCES>>=
<<TOP>>/assets.nw index.nw
@
<<URL_PREFIX>>=
https://ctarbide.github.io/
@
<<TOP>>=
.
@
<<CANONICAL_URL>>=
<<URL_PREFIX>>index.html
@
<<TITLE>>=
ctarbi.de - Main Page
@
<<sh preamble>>=
#!/bin/sh
set -eu
@
<<print LAST MODIFIED>>=
if [ -f .draft ]; then
last-modified.sh index.nw pages.nw | perl -MPOSIX=strftime \
-lne'print(strftime(qq{@<<LAST MODIFIED@>>=\n%B %e, %Y (DRAFT)\n@\n}, gmtime($_)))'
else
FORMAT='format:%B %e, %Y at %T UTC' git-last-modified.sh index.nw | perl \
-lne'print(qq{@<<LAST MODIFIED@>>=\n${_}\n@\n})'
fi
@
<<generate>>=
<<sh preamble>>
<<print LAST MODIFIED>>
cat <<PRIMARY SOURCES>> pages.nw
@
<<render>>=
<<sh preamble>>
nofake -Rgenerate index.nw | sh | CHMOD='chmod 0444' nofake.sh --error -Rindex.html -oindex.html
@
<<index.html>>=
<!DOCTYPE html>
<html lang="en">
<title><<TITLE>></title>
<<metas and links>>
<<style>>
<<body>>
<<footer>>
@
<<metas and links>>=
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.6">
<link rel="canonical" href="<<CANONICAL_URL>>">
<link rel="icon" href="<<assets - favicon.ico for top level>>" type="image/x-icon">
@
<<footer>>=
<p> This <a href="index.nw">page</a> was last modified on <<LAST MODIFIED>>.<br>
@
<<*>>=
<<sh preamble>>
if git-file-is-pristine.sh index.nw pages.nw Makefile; then
rm -f .draft
else
date '+%Y-%m-%d_%Hh%Mm%S' > .draft
git reset --quiet -- index.html
fi
nofake -R'generate pages.nw' index.nw | sh
nofake --error -Rrender <<PRIMARY SOURCES>> pages.nw | sh
@
<<find pages - Makefile>>=
find pages/ -mindepth 3 -maxdepth 3 -name Makefile -type f
@
<<find pages - .draft>>=
find pages/ -mindepth 3 -maxdepth 3 -name .draft -type f
@
<<generate pages listing>>=
<<find pages - Makefile>> | LC_ALL=C sort -r | perl -MURI::Escape -le'
printf(qq{@<<pages listing>>=\n});
printf(qq{<ul>\n});
while (<STDIN>) {
chomp;
next unless m{^(.*/)(.*?)/Makefile$};
$_ = $1 . $2;
next if -f qq{${_}/.hidden};
next unless m{^( pages/ [12]\d{3} / ) (.*)$}xi;
my ($date, $item) = ($1, $2);
my $url = $date . uri_escape($item);
print(qq{<li><p><a href="${url}/">${item}</a></p></li>});
}
printf(qq{</ul>\n});
printf(qq{@\n});'
@
<<generate pages.nw>>=
<<sh preamble>>
rm -f pages.nw
(
echo 'generated from index.nw'
echo
<<generate pages listing>>
)>pages.nw
chmod 0444 pages.nw
@
<<generate Makefile>>=
<<sh preamble>>
( <<find pages - Makefile>> | LC_ALL=C sort | perl -le'
printf(qq{@<<make pages>>=\n});
while (<STDIN>) {
chomp;
next unless m{^(.*)/Makefile$};
print(qq{\t\$(MAKE) -C \047${1}\047});
}
printf(qq{@\n});'
) | CHMOD='chmod 0444' nofake.sh --error -RMakefile -oMakefile index.nw -
@
<<Makefile>>=
# generated from index.nw
index.html: .installation-ok update-Makefile unlink-draft-pages pages index.nw
@nofake --error index.nw | sh
.installation-ok: bin/check-installation.sh
@./bin/check-installation.sh
@date '+%Y-%m-%d_%Hh%Mm%S' > .installation-ok
.PHONY: update-Makefile
update-Makefile:
@nofake -R'generate Makefile' index.nw | sh
.PHONY: unlink-draft-pages
unlink-draft-pages:
@nofake -R'unlink draft pages' index.nw | sh
.PHONY: pages
pages: unlink-draft-pages
<<make pages>>
@
This is useful to force index.html regeneration if their primary sources have
become pristine (committed in repository).
<<unlink draft pages>>=
<<sh preamble>>
<<find pages - .draft>> | LC_ALL=C sort |
perl -lne's,/.draft$,,; unlink qq{${_}/index.html}'
@