quatuorbellefeuille.com

Content, build scripts and admin scripts for the Bellefeuille Quartet website.
git clone https://git.kevinlegouguec.net/quatuorbellefeuille.com
Log | Files | Refs

commit d148eeb4a46cb647d13d451cb01cdc66835d2b03
parent 9f74233ffedb0609d43d54b6169dc47dd6337803
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Wed, 10 Mar 2021 23:28:39 +0100

Add links from/to English pages

Diffstat:
Mactualités.sh | 1+
Mbuild-member.sh | 8++++++--
Mbuild-programs.py | 22++++++++++++++++------
Mbuild.sh | 9++++++++-
Mcontact.sh | 1+
Men/contact.sh | 1+
Men/gallery.sh | 1+
Men/index.sh | 1+
Men/news.sh | 1+
Men/programs.sh | 9++++++---
Men/quartet.html | 8++++----
Men/quartet.sh | 1+
Men/template.html | 8++++----
Mgalerie.sh | 1+
Mindex.sh | 1+
Mprogrammes.sh | 9++++++---
Mquatuor.sh | 1+
Mtemplate.html | 4++--
18 files changed, 62 insertions(+), 25 deletions(-)

diff --git a/actualités.sh b/actualités.sh @@ -1,3 +1,4 @@ title=Actualités stylesheets=actualités transforms=("$(transform-li-current-a actualités)") +translation=news diff --git a/build-member.sh b/build-member.sh @@ -16,13 +16,15 @@ firstname () generate-parameters () { read fullname + local -r firstname=$(firstname "${fullname}") cat <<EOF title='${fullname}' stylesheets=(membre) transforms=("\$(transform-li-dropdown-current-a quatuor)" "\$(transform-li-current-a quatuor)" - "\$(transform-li-current-a $(firstname "${fullname}"))") + "\$(transform-li-current-a ${firstname})") +translation=${firstname} EOF } @@ -64,9 +66,11 @@ EOF EOF done + imgdir=$(realpath --relative-to $(dirname "${template}") images) + cat <<EOF </div> - <img src="images/${name}/portrait.png" style="background-image: url(images/${name}/bg.jpg)"> + <img src="${imgdir}/${name}/portrait.png" style="background-image: url(${imgdir}/${name}/bg.jpg)"> </main> EOF } diff --git a/build-programs.py b/build-programs.py @@ -1,8 +1,11 @@ #!/usr/bin/env python3 import html +from os import path +from pathlib import Path import re from subprocess import run +from sys import argv PROGRAM_RE = re.compile('\n'.join(( @@ -24,8 +27,8 @@ BLOCK_TEMPLATE = '''\ <summary> <div class="name">{name}</div> <div class="composers">{composers}</div> - <img class="button open" src="images/chevron-down.svg"> - <img class="button close" src="images/chevron-up.svg"> + <img class="button open" src="{imgdir}/chevron-down.svg"> + <img class="button close" src="{imgdir}/chevron-up.svg"> </summary> {description} <ol class="pieces"> @@ -53,10 +56,17 @@ def print_program(info): print(BLOCK_TEMPLATE.format_map(info)) -def main(): - for p in read_programs('programs.in'): - print_program(p.groupdict()) +def main(programs_src): + # pathlib.Path(x).relative_to(y) cannot handle y not being under x, + # os.path.relpath('x') yields '' rather than '.'. + # 😮‍💨 + imgdir = path.relpath('images', Path(programs_src).parent) + + for p in read_programs(programs_src): + info = p.groupdict() + info['imgdir'] = imgdir + print_program(info) if __name__ == '__main__': - main() + main(argv[1]) diff --git a/build.sh b/build.sh @@ -32,13 +32,20 @@ sed -i s/'{TITLE}'/"${title}"/ ${output} link_stylesheets='' for s in "${stylesheets[@]}" do - spath=$(realpath --relative-to $(dirname "${input}") stylesheets/"${s}".css) + # Prefer relative paths so that drafts under /admin/drafts find + # the correct stylesheets. + # ${input} might be a temporary file; assume ${template} is a + # bona-fide node in our directory hierarchy, and use that to + # compute the path to the stylesheets folder. + spath=$(realpath --relative-to $(dirname "${template}") stylesheets/"${s}".css) link_template='<link rel="stylesheet" href="%s">\n' link_stylesheets+=$(printf "${link_template}" "${spath}") done sed -i /'{STYLESHEETS}'/'c\'"${link_stylesheets}" ${output} +sed -i s/'{TRANSLATION}'/"${translation}"/ ${output} + for transform in "${transforms[@]}" do sed -i "${transform}" ${output} diff --git a/contact.sh b/contact.sh @@ -2,3 +2,4 @@ title=Contact stylesheets=(contact) transforms=('s/class="contact"/class="contact current"/' # Desktop. "$(transform-li-current-a contact)") # Mobile. +translation=contact diff --git a/en/contact.sh b/en/contact.sh @@ -2,3 +2,4 @@ title=Contact stylesheets=(contact) transforms=('s/class="contact"/class="contact current"/' # Desktop. "$(transform-li-current-a contact)") # Mobile. +translation=contact diff --git a/en/gallery.sh b/en/gallery.sh @@ -1,3 +1,4 @@ title=Gallery stylesheets=galerie transforms=("$(transform-li-current-a gallery)") +translation=galerie diff --git a/en/index.sh b/en/index.sh @@ -1,2 +1,3 @@ title=Welcome stylesheets=(index dark) +translation=index diff --git a/en/news.sh b/en/news.sh @@ -1,3 +1,4 @@ title=News stylesheets=actualités transforms=("$(transform-li-current-a news)") +translation=actualités diff --git a/en/programs.sh b/en/programs.sh @@ -1,8 +1,10 @@ add-programs () { - sed -i \ - -e /'{PROGRAMS}'/'r '<(./build-programs.py) \ - -e /'{PROGRAMS}'/'c\' \ + local programs_src=$(dirname "${input}")/programs.in + + sed -i \ + -e /'{PROGRAMS}'/'r '<(./build-programs.py "${programs_src}") \ + -e /'{PROGRAMS}'/'c\' \ $1 } @@ -10,3 +12,4 @@ title=Programs stylesheets=programmes transforms=("$(transform-li-current-a programs)") postprocess=add-programs +translation=programmes diff --git a/en/quartet.html b/en/quartet.html @@ -1,22 +1,22 @@ <main> <div id="photos"> <a class="member" href="sophie.html"> - <img class="portrait" src="images/sophie/full.png"> + <img class="portrait" src="../images/sophie/full.png"> <p class="name">Sophie Guille des Buttes</p> <p class="instrument">violon</p> </a> <a class="member" href="david.html"> - <img class="portrait" src="images/david/full.png"> + <img class="portrait" src="../images/david/full.png"> <p class="name">David Forest</p> <p class="instrument">violon</p> </a> <a class="member" href="hervé.html"> - <img class="portrait" src="images/hervé/full.png"> + <img class="portrait" src="../images/hervé/full.png"> <p class="name">Hervé Blandinières</p> <p class="instrument">alto</p> </a> <a class="member" href="enguerrand.html"> - <img class="portrait" src="images/enguerrand/full.png"> + <img class="portrait" src="../images/enguerrand/full.png"> <p class="name">Enguerrand Bontoux</p> <p class="instrument">violoncelle</p> </a> diff --git a/en/quartet.sh b/en/quartet.sh @@ -11,3 +11,4 @@ stylesheets=quatuor transforms=("$(transform-li-dropdown-current-a quartet)" # Desktop. "$(transform-li-current-a quartet)") # Mobile. postprocess=add-bio +translation=quatuor diff --git a/en/template.html b/en/template.html @@ -25,8 +25,8 @@ <h1>Bellefeuille Quartet</h1> </a> </header> - <a class="lang" href="{FR}"> - EN + <a class="lang" href="../{TRANSLATION}.html"> + FR </a> <nav class="menu"> <ol> @@ -98,8 +98,8 @@ {MAIN} <footer class="social"> - <a class="lang" href=""> - EN + <a class="lang" href="../{TRANSLATION}.html"> + FR </a> <a href="https://www.facebook.com/quatuorbellefeuille/" target="_blank" rel="noreferrer noopener"> diff --git a/galerie.sh b/galerie.sh @@ -1,3 +1,4 @@ title=Galerie stylesheets=galerie transforms=("$(transform-li-current-a galerie)") +translation=gallery diff --git a/index.sh b/index.sh @@ -1,2 +1,3 @@ title=Bienvenue stylesheets=(index dark) +translation=index diff --git a/programmes.sh b/programmes.sh @@ -1,8 +1,10 @@ add-programs () { - sed -i \ - -e /'{PROGRAMS}'/'r '<(./build-programs.py) \ - -e /'{PROGRAMS}'/'c\' \ + local programs_src=$(dirname "${input}")/programs.in + + sed -i \ + -e /'{PROGRAMS}'/'r '<(./build-programs.py "${programs_src}") \ + -e /'{PROGRAMS}'/'c\' \ $1 } @@ -10,3 +12,4 @@ title=Programmes stylesheets=programmes transforms=("$(transform-li-current-a programmes)") postprocess=add-programs +translation=programs diff --git a/quatuor.sh b/quatuor.sh @@ -11,3 +11,4 @@ stylesheets=quatuor transforms=("$(transform-li-dropdown-current-a quatuor)" # Desktop. "$(transform-li-current-a quatuor)") # Mobile. postprocess=add-bio +translation=quartet diff --git a/template.html b/template.html @@ -25,7 +25,7 @@ <h1>Quatuor Bellefeuille</h1> </a> </header> - <a class="lang" href="{EN}"> + <a class="lang" href="en/{TRANSLATION}.html"> EN </a> <nav class="menu"> @@ -98,7 +98,7 @@ {MAIN} <footer class="social"> - <a class="lang" href=""> + <a class="lang" href="en/{TRANSLATION}.html"> EN </a> <a href="https://www.facebook.com/quatuorbellefeuille/"