summaryrefslogtreecommitdiffhomepage
path: root/lib.m4
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-10-29 22:39:48 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-10-29 22:39:48 +0100
commit9cad508b5c98ca1029460807249cafb712f28f1e (patch)
tree2ad62d1ca57b7dc691550865cb7fb0b55c26da34 /lib.m4
parentc88b4c2d0842dfbb32fa744dde781601b9e4e7cf (diff)
Migrate the site to GSP and a Makefile
Diffstat (limited to 'lib.m4')
-rw-r--r--lib.m454
1 files changed, 54 insertions, 0 deletions
diff --git a/lib.m4 b/lib.m4
new file mode 100644
index 0000000..a4cb49e
--- /dev/null
+++ b/lib.m4
@@ -0,0 +1,54 @@
+m4_changecom()
+m4_changequote([,])
+
+m4_dnl Output ‘$2’ if the country code matches ‘$1’
+m4_define(__ifcode, [m4_ifelse(__code, [$1], [$2])])
+
+m4_dnl Execute the script ‘$1’ in the ‘scripts/’ directory
+m4_define(__esyscmd, [m4_esyscmd([scripts/$1])])
+
+m4_dnl Include the file ‘$1’ in the ‘src/’ directory, while also keeping track
+m4_dnl of who called ‘__include’. This is required sometimes when expanding
+m4_dnl macros in included files.
+m4_define(__include, [
+ m4_define([__caller], m4___file__)
+ m4_include([src/$1])
+])
+
+m4_dnl A setup file for ‘src/euro/index.dcoins.gsp’. It converts ‘__denom’ from
+m4_dnl something unhelpful like ‘10c’ to something helpful like ‘0.10’.
+m4_define(__dcoins_denom, [m4_define([__denom], m4_ifelse(
+ [0], m4_regexp(__denom, [^\([0-9]\)c]),
+ m4_regexp(__denom, [^\([0-9]\)c], [0.0\1]),
+ [0], m4_regexp(__denom, [^\([0-9]+\)c]),
+ m4_regexp(__denom, [^\([0-9]+\)c], [0.\1]),
+ [0], m4_regexp(__denom, [^\([0-9]\)e]),
+ m4_regexp(__denom, [^\([0-9]\)e], [\1.00]),
+ [Something went wrong… check ‘init.m4’]
+))])
+
+m4_dnl Create a link to ‘$1’ with the text ‘$2’. This does some checks with the
+m4_dnl caller to mark some nav-bar buttons as ‘selected’. Dynamically generated
+m4_dnl pages can work with this API by hijacking ‘m4___file__’ via ‘__hijack’.
+m4_define(__link, [
+ m4_ifelse(
+ [$1], m4_regexp(__caller, [src\(/\)index\.gsp], [\1]),
+ [div .selected {-$2}],
+ [$1], m4_regexp(__caller, [src\(/.+\)/index\.gsp], [\1]),
+ [div .selected {-$2}],
+ [a href="$1" {-$2}]
+ )
+])
+
+m4_dnl Hijack ‘m4___file__’ by setting it to ‘src/$1/index.gsp’
+m4_define(__hijack, [m4_define([m4___file__], src/$1/index.gsp)])
+
+m4_dnl Add an entry in the site changelog for the date ‘$1’ with the body ‘$2’
+m4_define(__entry, [
+ section #$1 .cl-section .slant-down {
+ div {
+ h2 {=m4_esyscmd(echo $1 | scripts/changelog-dates.sed)}
+ $2
+ }
+ }
+])