diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46485742d..d499c3a48 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -51,6 +51,7 @@ f-droid.org: - 'echo "baseurl: \"\"" >> userconfig.yml' - echo "Additional Jekyll config used for CI:" && cat userconfig.yml - bundle exec jekyll build -d $OUT_DIR --config _config.yml,userconfig.yml --verbose --trace + - ./tools/prepare-multi-lang.sh $OUT_DIR - cp -r $OUT_DIR $DEPLOY_DIR/ build: @@ -67,6 +68,7 @@ build: - 'echo baseurl: /$CI_PROJECT_NAME >> userconfig.yml' - echo "Additional Jekyll config used for CI:" && cat userconfig.yml - bundle exec jekyll build -d $OUT_DIR/$CI_PROJECT_NAME --config _config.yml,userconfig.yml --verbose --trace + - ./tools/prepare-multi-lang.sh $OUT_DIR/$CI_PROJECT_NAME --no-multi-views # This deploys feature branches to https://surge.sh, a free static site hosting service. @@ -93,6 +95,7 @@ preview: - 'echo fdroid-repo: https://guardianproject.info/fdroid/repo >> userconfig.yml' - echo "Additional Jekyll config used for CI:" && cat userconfig.yml - bundle exec jekyll build -d $OUT_DIR/$CI_PROJECT_NAME --config _config.yml,userconfig.yml --verbose --trace + - ./tools/prepare-multi-lang.sh $OUT_DIR/$CI_PROJECT_NAME --no-multi-views - apt-get install -y npm - npm install -g surge - update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10 @@ -144,3 +147,4 @@ pages: - echo "Additional Jekyll config used for CI:" && cat userconfig.yml - bundle exec jekyll build -d public --config _config.yml,userconfig.yml + - ./tools/prepare-multi-lang.sh public/$CI_PROJECT_NAME --no-multi-views diff --git a/tools/prepare-multi-lang.sh b/tools/prepare-multi-lang.sh index 62ab09fdf..92ddff0e6 100755 --- a/tools/prepare-multi-lang.sh +++ b/tools/prepare-multi-lang.sh @@ -65,9 +65,25 @@ function relative_symlink { ln -s ${SRC_RELATIVE_TO_DEST} ${DEST} } - LANGS="fr" -cd _site + +if [[ $# == 0 || ! -d $1/en ]]; then + echo "First argument must be the directory of the Jekyll website." + echo "This should take into account the baseurl as well. If the site" + echo "is output to 'build/' and the baseurl is 'fdroid-website/' then" + echo "the first argument should be 'build/fdroid-website/'" + exit 1 +fi + +cd $1 + +# For deploying to GitLab or surge.sh, we still want it to work, which requires leaving original English *.html files +# in the webroot rather than just MultiView compatible *.html.LANG files. +if [[ $# == 2 && $2 == "--no-multi-views" ]]; then + MULTI_VIEWS=false +else + MULTI_VIEWS=true +fi find en/ -type f -print0 | while IFS= read -r -d '' FILE_PATH do @@ -78,7 +94,7 @@ do mkdir -p ${DIR} - if [[ ${FILE} =~ ^(\.htaccess|.*\.css|.*\.js)$ ]]; then + if [[ ${MULTI_VIEWS} = false || ${FILE} =~ ^(\.htaccess|.*\.css|.*\.js)$ ]]; then echo "Not generating i18n version of ${DIR}/${FILE}" cp ${FILE_PATH} ${DIR}/${FILE} continue;