diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-12-30 20:57:15 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-12-30 20:57:15 +0100 |
| commit | 8c1256185ee44b1c4abbccfd8b0bfc92e119e688 (patch) | |
| tree | 5eed92b74b0e5f6433873cbb745869c378748a27 | |
| parent | 2013d68dad67988ae62e21c4921c2910e9bdff40 (diff) | |
| download | quatuorbellefeuille.com-8c1256185ee44b1c4abbccfd8b0bfc92e119e688.tar.xz | |
Refactor "current" class addition
Will make it easier to add them up for individual members.
| -rw-r--r-- | actualités.sh | 5 | ||||
| -rwxr-xr-x | build.sh | 24 | ||||
| -rw-r--r-- | contact.sh | 2 | ||||
| -rw-r--r-- | gallerie.sh | 5 | ||||
| -rw-r--r-- | programmes.sh | 5 | ||||
| -rw-r--r-- | quatuor.sh | 5 |
6 files changed, 25 insertions, 21 deletions
diff --git a/actualités.sh b/actualités.sh index 6e037f3..f18f1e1 100644 --- a/actualités.sh +++ b/actualités.sh @@ -1,6 +1,3 @@ title=Actualités stylesheets=actualités - -old='<li><a href="actualités.html">' -new='<li class="current"><a href="actualités.html">' -current_div=",${old},${new}," +transforms=("$(transform-li-current-a actualités)") @@ -14,6 +14,22 @@ then fi cp template.html ${output} + +transform-li-current-a () +{ + local old="<li><a href=\"$1.html\">" + local new="<li class=\"current\"><a href=\"$1.html\">" + echo "s/${old}/${new}/" +} + +transform-li-dropdown-current-a () +{ + local old="<li class=\"dropdown\"><a href=\"$1.html\">" + local new="<li class=\"dropdown current\"><a href=\"$1.html\">" + echo "s/${old}/${new}/" +} + +transforms=() . ${parameters} sed -i s/'{TITLE}'/"${title}"/ ${output} @@ -26,9 +42,9 @@ done sed -i /'{STYLESHEETS}'/'c\'"${link_stylesheets}" ${output} -if test "${current_div:-}" -then - sed -i s"${current_div}" ${output} -fi +for transform in "${transforms[@]}" +do + sed -i "${transform}" ${output} +done sed -i -e /'{MAIN}'/"r ${input}" -e /'{MAIN}'/'c\' ${output} @@ -1,3 +1,3 @@ title=Contact stylesheets=(contact) -current_div='/class="contact"/class="contact current"/' +transforms=('s/class="contact"/class="contact current"/') diff --git a/gallerie.sh b/gallerie.sh index 5c39199..b52ee27 100644 --- a/gallerie.sh +++ b/gallerie.sh @@ -1,6 +1,3 @@ title=Gallerie stylesheets=gallerie - -old='<li><a href="gallerie.html">' -new='<li class="current"><a href="gallerie.html">' -current_div=",${old},${new}," +transforms=("$(transform-li-current-a gallerie)") diff --git a/programmes.sh b/programmes.sh index 2a3486d..9c8d9e7 100644 --- a/programmes.sh +++ b/programmes.sh @@ -1,6 +1,3 @@ title=Programmes stylesheets=programmes - -old='<li><a href="programmes.html">' -new='<li class="current"><a href="programmes.html">' -current_div=",${old},${new}," +transforms=("$(transform-li-current-a programmes)") @@ -1,6 +1,3 @@ title=Biographie stylesheets=quatuor - -old='<li class="dropdown"><a href="quatuor.html">' -new='<li class="dropdown current"><a href="quatuor.html">' -current_div=",${old},${new}," +transforms=("$(transform-li-dropdown-current-a quatuor)") |
