hugosoucycc

[ARCHIVED] Another old source code of <hugo.soucy.cc>.
Log | Files | Refs | Submodules

commit 2ce9890e8f4f3b68be48ba729a616ae839603a83
parent af1cadfca4918678a55c357ff875277b5ebab90a
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Mon, 27 Mar 2017 07:36:04 -0400

Split the frontend script into entities

Diffstat:
Aconfig/preprocessor.cfg | 35+++++++++++++++++++++++++++++++++++
Dfrontend | 30------------------------------
Mmanuelfile | 8++++----
Apreprocess_css | 38++++++++++++++++++++++++++++++++++++++
Apreprocess_javascript | 19+++++++++++++++++++
5 files changed, 96 insertions(+), 34 deletions(-)

diff --git a/config/preprocessor.cfg b/config/preprocessor.cfg @@ -0,0 +1,35 @@ +#!/bin/bash + +# Preprocessor Configuration File + +# Source ans destination paths +export SRC_PATH=static/dev +export DST_PATH=static/prod + +# Images destination path +export IMG_PATH=$DST_PATH/images + +# CSS source and destination paths +export CSS_SRC_PATH=$SRC_PATH/css +export CSS_DST_PATH=$DST_PATH/css + +# JavaScript source and destination paths +export JS_SRC_PATH=$SRC_PATH/js +export JS_DST_PATH=$DST_PATH/js + +# Associative array with breakpoints in EMs +declare -A BREAKPOINTS SIZES + +export BREAKPOINTS=( + [xxs]=$((360 / 16))em + [xs]=$((520 / 16))em + [sm]=$((768 / 16))em + [md]=$((992 / 16))em + [lg]=$((1140 / 16))em +) + +export SIZES=( + [36]=$((36 / 18))em + [27]=$((27 / 18))em + [21]=$((21 / 18))em +) diff --git a/frontend b/frontend @@ -1,30 +0,0 @@ -#!/bin/bash - -# You must install "Minify CLI" for running this script : -# <https://github.com/tdewolff/minify/tree/master/cmd/minify> -if hash minify 2>/dev/null; then - # CSS Concatenation - cat static/dev/css/global/fonts.css \ - static/dev/css/global/normalize.css \ - static/dev/css/global/abstractions.css \ - static/dev/css/global/base.css \ - static/dev/css/global/helpers.css \ - static/dev/css/global/grid.css \ - static/dev/css/modules/*.css \ - > static/prod/css/styles.css - - # CSS Minification - minify -v --mime=text/css < static/prod/css/styles.css > static/prod/css/styles.min.css - - # JavaScript Concatenation - cat static/dev/js/vendor/dom-utilities/dom-utilities.js \ - static/dev/js/custom/init.js \ - > static/prod/js/script.js - - # JavaScript Minification - minify -v --mime=text/javascript < static/prod/js/script.js > static/prod/js/script.min.js - -else - echo "- You must install Minify CLI for running this script" - echo "- <https://github.com/tdewolff/minify/tree/master/cmd/minify>" -fi diff --git a/manuelfile b/manuelfile @@ -38,19 +38,19 @@ function deploy () { echo "- ... and deployed!" } -# Concatenate and minify styles sheets (./frontend). +# Concatenate and minify stylesheets # Then export with rsync function update_css () { - ./frontend + ./preprocess_css rsync -avmh "./$ASSETS/css/" "$TMP_PATH/$PUBLICHTML/css/" rsync -avmh "./$ASSETS/css/" "./$PUBLICHTML/css/" } -# Concatenate and minify scripts (./frontend). +# Concatenate and minify scripts # Then export with rsync function update_js () { - ./frontend + ./preprocess_javascript rsync -avmh "./$ASSETS/js/" "$TMP_PATH/$PUBLICHTML/js/" rsync -avmh "./$ASSETS/js/" "./$PUBLICHTML/js/" diff --git a/preprocess_css b/preprocess_css @@ -0,0 +1,38 @@ +#!/bin/bash + +# CSS Preprocessing Script + +# Go to the script's directory +cd "$(dirname "$0")" + +# Include the preprocessor configuration file +. config/preprocessor.cfg + +# Include mustache for bash as library +. lib/mo/mo + + +# You must install "Minify CLI" for running this script : +# <https://github.com/tdewolff/minify/tree/master/cmd/minify> +if hash minify 2>/dev/null; then + # CSS Concatenation + cat $CSS_SRC_PATH/global/fonts.css \ + $CSS_SRC_PATH/global/normalize.css \ + $CSS_SRC_PATH/global/abstractions.css \ + $CSS_SRC_PATH/global/base.css \ + $CSS_SRC_PATH/global/helpers.css \ + $CSS_SRC_PATH/global/grid.css \ + $CSS_SRC_PATH/modules/*.css \ + > $CSS_DST_PATH/styles.tmp.css + + # Replace mustache tags with config/preprocessor.cfg parameters + mo $CSS_DST_PATH/styles.tmp.css > $CSS_DST_PATH/styles.css + + rm $CSS_DST_PATH/styles.tmp.css + + # CSS Minification + minify -v --mime=text/css < $CSS_DST_PATH/styles.css > $CSS_DST_PATH/styles.min.css +else + echo "- You must install Minify CLI for running this script" + echo "- <https://github.com/tdewolff/minify/tree/master/cmd/minify>" +fi diff --git a/preprocess_javascript b/preprocess_javascript @@ -0,0 +1,19 @@ +#!/bin/bash + +# JavaScript Preprocessing Script + +# You must install "Minify CLI" for running this script : +# <https://github.com/tdewolff/minify/tree/master/cmd/minify> +if hash minify 2>/dev/null; then + # JavaScript Concatenation + cat static/dev/js/vendor/dom-utilities/dom-utilities.js \ + static/dev/js/custom/init.js \ + > static/prod/js/script.js + + # JavaScript Minification + minify -v --mime=text/javascript < static/prod/js/script.js > static/prod/js/script.min.js + +else + echo "- You must install Minify CLI for running this script" + echo "- <https://github.com/tdewolff/minify/tree/master/cmd/minify>" +fi