summaryrefslogtreecommitdiffhomepage
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rwxr-xr-xbuild311
1 files changed, 311 insertions, 0 deletions
diff --git a/build b/build
new file mode 100755
index 0000000..63b892e
--- /dev/null
+++ b/build
@@ -0,0 +1,311 @@
+#!/bin/sh
+# vi: ts=4 sw=4
+
+set -e
+
+require fsub gawk go pee sponge
+
+PATH="$PATH:scripts"
+
+rm -rf out
+mkdir out
+cp -r src/* out
+
+compile_for_lang() {
+ sd=src/$1
+ od=out/$1
+
+ case $lang in
+ en) hlang=en-US ;;
+ pt) hlang=pt-BR ;;
+ *) hlang=$1 ;;
+ esac
+
+ xfsub '<!-- LANG-SELECTOR -->' src/language-selector.html \
+ $od/nav-bar.html
+ sed -i "\\.<a href=/$1XYZ>.d" $od/nav-bar.html
+
+ find $od -name '*.html' \
+ | pee cat "xargs -- sed -i '
+ s|href=/XX|href=/$1|
+ s|<html lang=XX>|<html lang=$1>|
+ '" \
+ | while read file; do
+ xfsub '<!-- NAV-BAR -->' $od/nav-bar.html $file
+ xfsub '<!-- COIN-NAV -->' $od/euro/coin-nav.html $file
+ xfsub '<!-- NOTE-NAV -->' $od/euro/note-nav.html $file
+ xfsub '<!-- FOOTER -->' $od/footer.html $file
+ xfsub '<!-- TABLE-KEY -->' $od/table-key.html $file
+ done
+
+ for file in `find $od -name 'index.html'`; do
+ base=${file#out}
+ base=${base%/index.html}
+ sed -Ei "
+ /<nav>/,\\|</nav>|s|<a href=$base>([^<]*)</a>|<div class=selected>\1</div>|
+ " $file
+ done
+
+ sed -Ei '
+ /<!-- IF-COINS -->/,/<!-- FI-COINS -->/d
+ /<!-- (IF|FI)-NOTES -->/d
+ ' $od/euro/notes.template.html $od/euro/tnotes.template.html
+ sed -Ei '
+ /<!-- IF-NOTES -->/,/<!-- FI-NOTES -->/d
+ /<!-- (IF|FI)-COINS -->/d
+ ' $od/euro/coins.template.html
+
+ nod=$od/euro/tn
+ mkdir -p $nod
+ cp $od/euro/tnotes.template.html $nod/index.html
+ sed -Ei '
+ /<nav>/,\|</nav>|s|<a href=/../euro/tn>([^<]*)</a>|<div class=selected>\1</div>|
+ ' $nod/index.html
+ gawk -v denom=$denom '
+ @include "scripts/getcls.awk"
+
+ $1 == "TN" {
+ i++
+ col[i][0] = $2
+ col[i][1] = $3
+ col[i][2] = $4
+ }
+
+ END {
+ for (i = 1; i <= length(col); i++) {
+ printf \
+ "<tr><td class=missing>€%d</td><td class=%s>%s</td></tr>\n",\
+ col[i][0], getcls(col[i][2]), col[i][1]
+ }
+ }
+ ' data/notes | xfsub '<!-- TABLE-BODY -->' - $nod/index.html
+
+ for CC in `grep -Eo '^[A-Z]{2}' data/coins | uniq`; do
+ cc=`echo $CC | tr A-Z a-z`
+ nod=$od/euro/$cc
+ mkdir -p $nod
+ cp $od/euro/coins.template.html $nod/index.html
+ sed -i "
+ /<nav>/,\\|</nav>|s|<a href=/../euro/$cc>$CC</a>|<div class=selected>$CC</div>|
+ " $nod/index.html
+ grep -m1 "^$CC" data/country-info \
+ | cut -f2 \
+ | xfsub '<!-- DEMON -->' - $nod/index.html
+ sed -Ei "
+ /<!-- (IF|FI)-$CC -->/d
+ /<!-- IF-!$CC -->/,/<!-- FI-!$CC -->/d
+ /<!-- (IF|FI)-![A-Z]+ -->/d
+ /<!-- IF-[A-Z]+ -->/,/<!-- FI-[A-Z]+ -->/d
+ " $nod/index.html
+
+ gawk -v CC=$CC '
+ @include "scripts/getcls.awk"
+
+ $1 == CC && /.. start/ {
+ sub(/.. start/, "")
+ printf "<tr class=new-design><th colspan=8>%s</th></tr>\n", $0
+ next
+ }
+
+ $1 == CC {
+ y = $10
+ if ($11 != "")
+ y_ = $11
+ printf "<trX>"
+ for (i = 2; i <= 9; i++) {
+ # Greece 2002 needs special handling
+ if (CC == "GR" && $10 == 2002 && $11 == "MM") {
+ if (i <= 5)
+ y_ = "F"
+ else if (i <= 7)
+ y_ = "E"
+ else
+ y_ = "S"
+ }
+
+ if ($11 != "") {
+ printf "<td class=%s>%s <sup>%s</sup></td>",
+ getcls($i), y, y_
+ } else
+ printf "<td class=%s>%s</td>", getcls($i), y
+ }
+ print "</tr>"
+ }
+
+ END { print "MARKER LOL" }
+ ' data/coins \
+ | last-of-design.sed \
+ | xfsub '<!-- SCOIN-TABLE-BODY -->' - $nod/index.html
+
+ gawk -v CC=$CC '
+ @include "scripts/getcls.awk"
+
+ $1 == CC {
+ split($0, a, "\t")
+ $0 = a[1]
+
+ n = 2
+ y = $2
+
+ if (getcls($3) == "error") {
+ n = 3
+ printf "<tr><td class=missing>%s <sup>%s</sup></td>", y, $3
+ } else
+ printf "<tr><td class=missing>%s</td>", y
+
+ for (i = 1; i <= NF - n; i++) {
+ printf "<td colspan=Y class=%s>%s</td>",
+ getcls($(i + n)), a[i + 1]
+ }
+ print "</tr>"
+ }
+
+ END { print "MARKER LOL" }
+ ' data/ccs \
+ | colspan.sed \
+ | grep -Fv 'MARKER LOL' \
+ | xfsub '<!-- CCOIN-TABLE-BODY -->' - $nod/index.html
+ done
+
+ for denom in `grep -Eo '^[0-9]+' data/notes | uniq`; do
+ nod=$od/euro/$denom
+ mkdir -p $nod
+ cp $od/euro/notes.template.html $nod/index.html
+ sed -Ei "
+ /<nav>/,\\|</nav>|s|<a href=/../euro/$denom>([^<]*)</a>|<div class=selected>\\1</div>|
+ " $nod/index.html
+ sed -i "s/<!-- DENOM -->/$denom/" $nod/index.html
+
+ sed -Ei "
+ /<!-- (IF|FI)-$denom -->/d
+ /<!-- IF-!$denom -->/,/<!-- FI-!$denom -->/d
+ /<!-- (IF|FI)-![0-9]+ -->/d
+ /<!-- IF-[0-9]+ -->/,/<!-- FI-[0-9]+ -->/d
+ " $nod/index.html
+
+ gawk -v denom=$denom '
+ @include "scripts/getcls.awk"
+
+ BEGIN { FS = "\t" }
+
+ FILENAME == "data/country-info" { cc2name[$1] = $3 }
+
+ FILENAME == "data/note-info" && length == 0 { section++; next }
+ FILENAME == "data/note-info" && section == 0 { cc2c[$1] = $2 }
+ FILENAME == "data/note-info" && section == 1 { ab2l[$1] = $2 }
+
+ FILENAME == "data/notes" && $1 == denom && $2 == "2002" {
+ i++
+ col[i][0] = $3
+ col[i][1] = $4
+ }
+
+ END {
+ for (i = 1; i <= 3; i++) {
+ if (i == 3 && denom == 5) {
+ print "</tr>"
+ break
+ }
+ if (i == 1)
+ sig = "Wim Duisenberg"
+ else if (i == 2)
+ sig = "Jean-Claude Trichet"
+ else if (i == 3)
+ sig = "Mario Draghi"
+ print "<tr class=new-design><th colspan=12>"sig"</th></tr>"
+
+ c = 0
+ for (j = 1; j <= length(col); j++) {
+ split(col[j][1], s, " ")
+ if (s[i] == "/")
+ continue
+
+ if (c % 4 == 0)
+ printf "<trX>"
+
+ printf "<td colspan=X class=%s>", getcls(s[i])
+ printf "%s (%s)", cc2name[col[j][0]], cc2c[col[j][0]]
+ printf "</td>"
+
+ if (c % 4 == 3 && j < length(col))
+ print "</tr>"
+ c++
+ }
+ if ((c - 1) % 4 != 3)
+ print "</tr>"
+ }
+ print "MARKER LOL"
+ }
+ ' data/country-info data/note-info data/notes \
+ | colspan.sed \
+ | last-of-design.sed \
+ | xfsub '<!-- 2002-TABLE-BODY -->' - $nod/index.html
+
+ [ $denom -eq 500 ] && continue
+
+ gawk -v denom=$denom '
+ @include "scripts/getcls.awk"
+
+ BEGIN { FS = "\t" }
+
+ FILENAME == "data/country-info" { cc2name[$1] = $3 }
+
+ FILENAME == "data/note-info" && length == 0 { section++; next }
+ FILENAME == "data/note-info" && section == 0 { cc2c[$1] = $2 }
+ FILENAME == "data/note-info" && section == 1 { ab2l[$1] = $2 }
+
+ FILENAME == "data/notes" && $1 == denom && $2 == "Europa" {
+ i++
+ col[i][0] = $3
+ col[i][1] = $4
+ }
+
+ END {
+ for (i = 1; i <= 2; i++) {
+ if (i == 1)
+ sig = "Mario Draghi"
+ else if (i == 2)
+ sig = "Christine Lagarde"
+ print "<tr class=new-design><th colspan=12>"sig"</th></tr>"
+
+ c = 0
+ for (j = 1; j <= length(col); j++) {
+ split(col[j][1], s, " ")
+ if (s[i] == "/")
+ continue
+
+ if (c % 4 == 0)
+ printf "<trX>"
+
+ printf "<td colspan=X class=%s>", getcls(s[i])
+ printf "%s (%s)", cc2name[col[j][0]], cc2c[col[j][0]]
+ printf "</td>"
+
+ if (c % 4 == 3 && j < length(col))
+ print "</tr>"
+ c++
+ }
+ if ((c - 1) % 4 != 3)
+ print "</tr>"
+ }
+ print "MARKER LOL"
+ }
+ ' data/country-info data/note-info data/notes \
+ | colspan.sed \
+ | last-of-design.sed \
+ | xfsub '<!-- EUROPA-TABLE-BODY -->' - $nod/index.html
+ done
+
+ for file in `find $od -name '*.html'`; do
+ path=${file#out/??}
+ path=${path%/*.html}
+ sed -Ei "s|href=/(..)XYZ>|href=/\1$path>|" $file
+ done
+}
+
+for lang in `find out -mindepth 1 -maxdepth 1 -name '??' -printf '%f\n'`; do
+ compile_for_lang $lang &
+done
+wait
+
+find out -name '*.html' -and -not -name 'index.html' -delete