diff --git a/js/package.json b/js/package.json index 7f2bb5663..8598a0d92 100644 --- a/js/package.json +++ b/js/package.json @@ -4,7 +4,9 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build --modern", + "build:assets": "vue-cli-service build --modern", + "build:pictures": "scripty", + "build": "yarn run build:assets && yarn run build:pictures", "test:unit": "LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8 vue-cli-service test:unit", "test:e2e": "vue-cli-service test:e2e", "lint": "vue-cli-service lint" @@ -87,6 +89,7 @@ "prettier-eslint": "^12.0.0", "sass": "^1.29.0", "sass-loader": "^10.0.1", + "scripty": "^2.0.0", "typescript": "~4.1.2", "vue-cli-plugin-svg": "~0.1.3", "vue-i18n-extract": "^1.0.2", diff --git a/js/public/img/pics/2020-10-06-mobilizon-illustration-E_realisation.jpg b/js/public/img/pics/error.jpg similarity index 100% rename from js/public/img/pics/2020-10-06-mobilizon-illustration-E_realisation.jpg rename to js/public/img/pics/error.jpg diff --git a/js/public/img/pics/2020-10-06-mobilizon-illustration-B_creation-evenement.jpg b/js/public/img/pics/event_creation.jpg similarity index 100% rename from js/public/img/pics/2020-10-06-mobilizon-illustration-B_creation-evenement.jpg rename to js/public/img/pics/event_creation.jpg diff --git a/js/public/img/pics/2020-10-06-mobilizon-illustration-C_groupe.jpg b/js/public/img/pics/group.jpg similarity index 100% rename from js/public/img/pics/2020-10-06-mobilizon-illustration-C_groupe.jpg rename to js/public/img/pics/group.jpg diff --git a/js/public/img/pics/2020-10-06-mobilizon-illustration-A_homepage.jpg b/js/public/img/pics/homepage.jpg similarity index 100% rename from js/public/img/pics/2020-10-06-mobilizon-illustration-A_homepage.jpg rename to js/public/img/pics/homepage.jpg diff --git a/js/public/img/pics/2020-10-06-mobilizon-illustration-D_realisation.jpg b/js/public/img/pics/realisation.jpg similarity index 100% rename from js/public/img/pics/2020-10-06-mobilizon-illustration-D_realisation.jpg rename to js/public/img/pics/realisation.jpg diff --git a/js/public/img/pics/2020-10-06_Rose.jpg b/js/public/img/pics/rose.jpg similarity index 100% rename from js/public/img/pics/2020-10-06_Rose.jpg rename to js/public/img/pics/rose.jpg diff --git a/js/scripts/build/pictures.sh b/js/scripts/build/pictures.sh new file mode 100755 index 000000000..d19fec20a --- /dev/null +++ b/js/scripts/build/pictures.sh @@ -0,0 +1,90 @@ +#!/bin/bash + +set -eu + +output_dir="../priv/static/img/pics" +resolutions=( + 480 + 1024 + 1920 +) +ignore=( + homepage_background.png +) + +file_extension () { + filename=$(basename -- "$file") + echo "${filename##*.}" +} + +file_name () { + filename=$(basename -- "$file") + echo "${filename%.*}" +} + +convert_image () { + name=$(file_name) + extension=$(file_extension) + res="$1w" + output="$output_dir/$name-$res.$extension" + convert -geometry "$resolution"x $file $output +} + +produce_webp () { + name=$(file_name) + output="$output_dir/$name.webp" + cwebp $file -quiet -o $output +} + +progress() { + local w=80 p=$1; shift + # create a string of spaces, then change them to dots + printf -v dots "%*s" "$(( $p*$w/100 ))" ""; dots=${dots// /.}; + # print those dots on a fixed-width space plus the percentage etc. + printf "\r\e[K|%-*s| %3d %% %s" "$w" "$dots" "$p" "$*"; +} + + +echo "Generating responsive versions of the pictures…" + +if ! command -v convert &> /dev/null +then + echo "$(tput setaf 1)ERROR: The convert command could not be found. You need to install ImageMagick.$(tput sgr 0)" + exit 1 +fi + +nb_files=$( shopt -s nullglob ; set -- $output_dir/* ; echo $#) + +tasks=$((${#resolutions[@]}*$nb_files)) +i=1 +for file in $output_dir/* +do + if [[ -f $file ]]; then + for resolution in "${resolutions[@]}"; do + convert_image $resolution + progress $(($i*100/$tasks)) still working... + i=$((i+1)) + done + fi +done +echo -e "\nDone!" + +echo "Generating optimized versions of the pictures…" + +if ! command -v cwebp &> /dev/null +then + echo "$(tput setaf 1)ERROR: The cwebp command could not be found. You need to install webp.$(tput sgr 0)" + exit 1 +fi + +nb_files=$( shopt -s nullglob ; set -- $output_dir/* ; echo $#) +i=1 +for file in $output_dir/* +do + if [[ -f $file ]]; then + produce_webp + progress $(($i*100/$nb_files)) still working... + i=$((i+1)) + fi +done +echo -e "\nDone!" \ No newline at end of file diff --git a/js/src/components/Footer.vue b/js/src/components/Footer.vue index 50d4eaf7f..b82328f1f 100644 --- a/js/src/components/Footer.vue +++ b/js/src/components/Footer.vue @@ -1,6 +1,22 @@