3 # Replace the language picker site-wide, using a common source file:
4 # "lang-picker-source". The script is called from the root of enc-live.
5 # It doesn't take an argument.
10 head=$
(mktemp
-t rt.XXXXXX
) ||
exit 1
11 picker
=$
(mktemp
-t rt.XXXXXX
) ||
exit 1
12 tail=$
(mktemp
-t rt.XXXXXX
) ||
exit 1
13 trap 'rm -f "$head" "$picker" "$tail"' EXIT
15 # List all HTML files with a language picker and take them one by one.
16 # The regex will select index and workshops.
17 find .
-regex "\./.*/[iw][no][dr].*\.html" -not -path "./missing/*" |
18 sort |
sed 's,^\./,,' |
while read f
; do
19 # Extract the language from the file name.
21 # Make sure the page is correctly formatted.
22 if grep -q '<ul id="languages" class="os">' $f &&
23 grep -q '<li><strong><a href=.*Translation_Guide">' $f; then
24 # Add the 'current' class to the relevant item of lang-picker-source.
25 sed "s,<li><a href=\"/$lang\">,<li><a class=\"current\" href=\"/$lang\">," \
26 lang-picker-source
> $picker
27 # Extract what's before the language picker...
28 sed -n '1,/<ul id="languages" class="os">/p' $f > $head
29 # and what follows it.
30 sed -n '/<li><strong><a href=.*Translation_Guide">/,$p' $f > $tail
32 cat $head $picker $tail > $f
34 echo " !!! Unable to replace the language picker in $f."
40 git add
*/index.html
*/workshops.html
41 git commit
-m "index & workshops: update the language picker."