quatuorbellefeuille.com

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

build-member.sh (1870B)


      1 #!/bin/bash
      2 
      3 set -eu
      4 
      5 input=$1
      6 template=$2
      7 outdir=$3
      8 uri=$4
      9 output="${outdir}/${uri}"
     10 
     11 . settings.sh
     12 
     13 firstname ()
     14 {
     15     local -r fullname=$1
     16     local name=${fullname%% *}
     17     echo ${name,}
     18 }
     19 
     20 generate-parameters ()
     21 {
     22     read fullname
     23     local -r firstname=$(firstname "${fullname}")
     24 
     25     cat <<EOF
     26 title='${fullname}'
     27 stylesheets=(membre)
     28 transforms=("\$(transform-li-dropdown-current-a quatuor)"
     29             "\$(transform-li-current-a quatuor)"
     30             "\$(transform-li-current-a ${firstname})")
     31 translation=${firstname}
     32 EOF
     33 }
     34 
     35 pandoc-inline ()
     36 {
     37     ${pandoc} | sed -r 's,^<p>(.+)</p>$,\1,'
     38 }
     39 
     40 generate-main ()
     41 {
     42     read fullname
     43     read instrument
     44     read emph1
     45     read emph2
     46     local -r name=$(firstname "${fullname}")
     47 
     48     cat <<EOF
     49 <main style="--emph1-color: ${emph1}; --emph2-color: ${emph2}">
     50   <div class="bio-title">
     51     <h1 class="name">${fullname}</h1>
     52     <h2 class="instrument">${instrument}</h2>
     53   </div>
     54   <div class="bio">
     55 EOF
     56 
     57     while read line
     58     do
     59         # Ignore empty lines.
     60         if [[ ${line} =~ ^[[:space:]]*$ ]]
     61         then
     62             continue
     63         fi
     64 
     65         # Pasting from GDoc yields trailing spaces; remove those.
     66         if ! [[ ${line} =~ ([^?]+\?)\ (.+[^ ])\ * ]]
     67         then
     68             >&2 echo "Invalid line: ${line}"
     69             continue
     70         fi
     71 
     72         cat <<EOF
     73     <dl>
     74       <dt>$(pandoc-inline <<< "${BASH_REMATCH[1]}") </dt>
     75       <dd>$(pandoc-inline <<< ${BASH_REMATCH[2]})</dd>
     76     </dl>
     77 EOF
     78     done
     79 
     80     imgdir=$(realpath --relative-to $(dirname "${template}") images)
     81 
     82     cat <<EOF
     83   </div>
     84   <img src="${imgdir}/${name}/portrait.png" style="background-image: url(${imgdir}/${name}/bg.jpg)">
     85 </main>
     86 EOF
     87 }
     88 
     89 ./build.sh <(generate-main < "${input}")        \
     90            <(generate-parameters < "${input}")  \
     91            "${template}"                        \
     92            "${outdir}" "${uri}"