From 07ae048ae71387ad39e07841d1c3eb76ce0736ee Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 18 Jul 2024 22:01:30 +0200 Subject: Add completion percentages to each page --- GNUmakefile | 3 +++ scripts/gen-stats | 34 ++++++++++++++++++++++++++++++++++ src/euro/index.ccoins.gsp | 1 + src/style.css | 4 ++++ 4 files changed, 42 insertions(+) create mode 100755 scripts/gen-stats diff --git a/GNUmakefile b/GNUmakefile index c5cb884..31ff619 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -46,6 +46,8 @@ eurotndeps := src/euro/index.tnotes.gsp src/euro/nav.dnotes.gsp data/notes # Macro to get a countries demonym from their country code demonym = $(shell awk '$$1 == toupper("$1") { print $$2 }' data/country-info) +percentage = $(shell ./scripts/gen-stats $1) + # Macros to handle dependencies for world pages wpath = $(if $(filter $2,o),\ out/world/$(if $(filter $2,c),coins,notes)/$1/index.html,\ @@ -66,6 +68,7 @@ out/%.html: src/%.gsp $(gspdeps) $(eurocc): out/euro/%/index.html: $(gspdeps) $(euroccdeps) m4 -P -D__coins -D__code=$* -D__demonym=$(call demonym,$*) \ + -D__percentage="$(call percentage,$*)" \ lib.m4 src/euro/index.ccoins.gsp | gsp >$@ $(eurocd): out/euro/%/index.html: $(eurocddeps) $(gspdeps) diff --git a/scripts/gen-stats b/scripts/gen-stats new file mode 100755 index 0000000..46148d4 --- /dev/null +++ b/scripts/gen-stats @@ -0,0 +1,34 @@ +#!/bin/sh + +gawk -v CC=$1 ' +@include "scripts/getcls.awk" + +function hndl(x) { + if (x == "/") + return + if (x ~ /[XO@]/) + have++ + cnt++ +} + +BEGIN { + CC = toupper(CC) +} + +FILENAME == "data/coins" && $1 == CC && $2 != "start" { + split($0, xs) + for (i = 2; i < length(xs); i++) + hndl(xs[i]) +} + +FILENAME == "data/ccs" && $1 == CC { + gsub(/([A-Z]{2} [0-9]{4}( [A-Za-z]+)?|\t.*)/, " ") + split($0, xs) + for (i = 1; i <= length(xs); i++) + hndl(xs[i]) +} + +END { + printf "%d/%d (%d%%)\n", have, cnt, have / cnt * 100 +} +' data/coins data/ccs diff --git a/src/euro/index.ccoins.gsp b/src/euro/index.ccoins.gsp index 18b5ef4..3e0bbe3 100644 --- a/src/euro/index.ccoins.gsp +++ b/src/euro/index.ccoins.gsp @@ -16,6 +16,7 @@ html lang="en" { section { header { h1 {-__demonym Euro Coins} + p {-__percentage} } } diff --git a/src/style.css b/src/style.css index e2e5f20..26db499 100644 --- a/src/style.css +++ b/src/style.css @@ -222,6 +222,10 @@ header h1 { margin-bottom: 0; } +header p { + color: lightgrey; +} + @media only screen and (min-width: 1000px) { header h1 { font-size: 2.5rem; -- cgit v1.2.3