From d148eeb4a46cb647d13d451cb01cdc66835d2b03 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 10 Mar 2021 23:28:39 +0100 Subject: Add links from/to English pages --- "actualit\303\251s.sh" | 1 + build-member.sh | 8 ++++++-- build-programs.py | 22 ++++++++++++++++------ build.sh | 9 ++++++++- contact.sh | 1 + en/contact.sh | 1 + en/gallery.sh | 1 + en/index.sh | 1 + en/news.sh | 1 + en/programs.sh | 9 ++++++--- en/quartet.html | 8 ++++---- en/quartet.sh | 1 + en/template.html | 8 ++++---- galerie.sh | 1 + index.sh | 1 + programmes.sh | 9 ++++++--- quatuor.sh | 1 + template.html | 4 ++-- 18 files changed, 62 insertions(+), 25 deletions(-) diff --git "a/actualit\303\251s.sh" "b/actualit\303\251s.sh" index f18f1e1..a10cf40 100644 --- "a/actualit\303\251s.sh" +++ "b/actualit\303\251s.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 index d19c835..95e25b6 100755 --- a/build-member.sh +++ b/build-member.sh @@ -16,13 +16,15 @@ firstname () generate-parameters () { read fullname + local -r firstname=$(firstname "${fullname}") cat < - + EOF } diff --git a/build-programs.py b/build-programs.py index 69c7057..40398d8 100755 --- 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 = '''\
{name}
{composers}
- - + +
{description}
    @@ -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 index a9035f3..583bda0 100755 --- 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='\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 index 6a7a40c..82eba6c 100644 --- 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 index 6a7a40c..82eba6c 100644 --- 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 index 04b5a5e..6a46fae 100644 --- 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 index 934a371..d0bf618 100644 --- 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 index 08b6528..b52b3fa 100644 --- 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 index 3f90fb5..57f590d 100644 --- 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 index bc432f0..5d31b58 100644 --- a/en/quartet.html +++ b/en/quartet.html @@ -1,22 +1,22 @@
    - +

    Sophie Guille des Buttes

    violon

    - +

    David Forest

    violon

    - +

    Hervé Blandinières

    alto

    - +

    Enguerrand Bontoux

    violoncelle

    diff --git a/en/quartet.sh b/en/quartet.sh index 48d83b5..c0f7762 100644 --- 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 index 16d80e0..402b4fd 100644 --- a/en/template.html +++ b/en/template.html @@ -25,8 +25,8 @@

    Bellefeuille Quartet

    - - EN + + FR