blob: 631aa1374f07b365497f53d68a37ef7669a51a92 (
about) (
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
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
|
#!/bin/sh
set -eu
usage() {
cat <<-'EOF' | sed "s|@NAME@|$0|g"
Usage:
@NAME@ FILENAME
@NAME@ -h
EOF
}
help() {
cat <<-'EOF'
Options:
-h, --help show this message
FILENAME the input markdown file
EOF
}
for f in "$@"; do
case "$f" in
--)
break
;;
--help)
usage
help
exit
;;
*)
;;
esac
done
while getopts 'h' flag; do
case "$flag" in
h)
usage
help
exit
;;
*)
usage >&2
exit 2
;;
esac
done
shift $((OPTIND - 1))
F="${1:-}"
assert_arg() {
if [ -z "$1" ]; then
printf 'Missing %s.\n\n' "$2" >&2
usage >&2
exit 2
fi
}
assert_arg "$F" 'FILENAME'
HTML="$(dirname "$F")/$(basename "$F" .md).html"
escape() {
sed 's/a/a/'
}
url_for() {
printf '%s%s' "$BASE_URL" "$1"
}
absolute() {
printf 'https://%s%s' "$FQDN" "$(cat)"
}
_() {
printf '%s' "$1" | escape
}
# FIXME
langs='en pt fr eo es'
# langs=''
. src/development/config.env
. "${F%.md}.env"
# src/development/md snippets "$F"
cat <<-EOF
<!DOCTYPE html>
<html lang="$lang">
<head>
<meta charset="UTF-8" />
<meta viewport content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="$(url_for 'styles.css')" />
<link rel="icon" type="image/svg+xml" href="$(url_for 'static/lord-favicon.svg')" />
<link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.articles.en.atom')" title="$(_ "EuAndreh's blog")" />
<link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.tils.en.atom')" title="$(_ "EuAndreh's TIL")" />
<link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.podcasts.en.atom')" title="$(_ "EuAndreh's podcasts")" />
<link rel="alternate" type="application/atom+xml" hreflang="$lang" href="$(url_for 'feed.screencasts.en.atom')" title="$(_ "EuAndreh's screencasts")" />
<title>EuAndreh</title>
<meta name="author" content="EuAndreh" />
<meta property="og:site_name" content="$(_ 'FIXME 1')" />
<meta property="og:locale" content="$lang" />
<meta property="og:title" content="$(_ 'FIXME 2')" />
<link rel="canonical" href="$(url_for '' | absolute)" />
<meta property="og:url" content="$(url_for '' | absolute)" />
<!-- FIXME: link to next and prev -->
</head>
<body>
<header>
<nav>
<ul>
<a href="$(url_for "$lang/")">$(_ 'FIXME homepage link name')</a>
<a href="$(url_for "$(_ 'about.html')")">$(_ 'About')</a>
</ul>
EOF
if [ -n "$langs" ]; then
printf ' <ul>\n'
for l in $langs; do
cat <<-EOF
<li>
<a href="FIXME 3">$l</a>
</li>
EOF
done
printf ' </ul>\n'
fi
cat <<-EOF
</nav>
</header>
<main>
<article>
EOF
awk '
BEGIN {
separator = 0
should_print = 0
}
/^---$/ {
separator++
}
should_print {print}
separator == 2 && !should_print { should_print = !should_print }
' "$F" |
md2html
# src/development/md render
cat <<-EOF
</article>
</main>
<footer>
<ul>
<li>
<img class="FIXME" src="$(url_for 'static/envelope.svg' alt="FIXME")" />
<a href="mailto:eu@euandre.org">eu@euandre.org</a>
</li>
<li>
<img class="FIXME" src="$(url_for 'static/lock.svg' alt="FIXME")" />
<a href="$(url_for 'static/public.asc')">81F90EC3CD356060</a>
</li>
</ul>
<p>
$(_ 'The content for this site is licensed under <a rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>. The <a href="https://euandreh.xyz/website.git">code</a> is <a rel="license" href="https://euandreh.xyz/website.git/tree/COPYING">AGPLv3 or later</a>. Patches welcome.')
</p>
</footer>
</body>
</html>
EOF
|