hugo.soucy.cc

The personnal website source code of Hugo Soucy. Creates from an homebrewed static website generator (Ferron).
Log | Files | Refs

commit ead4aedb123f0dad57431cdc9519ce6bedf5c1c7
parent 78fc36a4a249b65ff703fb53a071d8f07c7f88bf
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Sun, 19 Nov 2017 12:46:21 -0500

Adapt the bash scripts for the ferron environnment

Diffstat:
Mhttpd | 8++------
Mmanuelfile | 29+++++++++++++++++------------
Mpreprocess_css | 19+++++++++----------
Mpreprocess_javascript | 3---
Drwd | 26--------------------------
5 files changed, 28 insertions(+), 57 deletions(-)

diff --git a/httpd b/httpd @@ -6,15 +6,11 @@ # Dependency : # - https://unix4lyfe.org/darkhttpd -# Include fakestache configuration files -. config/site.cfg -. config/app.cfg - if hash darkhttpd 2>/dev/null; then # "$BROWSER" "$SITE_URL_DEV" && - xdg-open "$SITE_URL_DEV" && + xdg-open "http://localhost:8181" && - darkhttpd "$TMP_PATH/$PUBLICHTML/" --port "$SITE_PORT_DEV" + darkhttpd ./public_html --port 8181 else echo "- Sorry But You must Install *darkhttpd*." diff --git a/manuelfile b/manuelfile @@ -7,6 +7,9 @@ # $HOME/.manuel.d/plugins/manuel-contrib-watch load_plugin manuel-contrib-watch +FERRON_PATH=/home/hs0ucy/_01_http/ferron + +SITE_PATH=/home/hs0ucy/_01_http/ferron/sites/hugo.soucy.cc SITE_DOMAINNAME="hugo.soucy.cc" SITE_PUBLIC_HTML=public_html SITE_STATIC_DST=static/dst @@ -16,23 +19,25 @@ SITE_TEMPLATES=templates # Update partials/cv.mustache function updatecv () { # from git@github.com:hs0ucy/Curriculum-vitae.git repository - curl https://raw.githubusercontent.com/hs0ucy/Curriculum-vitae/master/curriculum-vitae.html > "./$SITE_TEMPLATES/partials/cv.mustache" + curl https://raw.githubusercontent.com/hs0ucy/Curriculum-vitae/master/curriculum-vitae.html > "$SITE_TEMPLATES/partials/cv.mustache" } # Concatenate and minify assets # Then build the static site function build () { - updatecv - + updatecv && + ./preprocess_css ./preprocess_javascript - + case $1 in -d|--dev) - lua53 ./ferron.lua --dev + cd $FERRON_PATH && + lua53 "$FERRON_PATH"/ferron.lua --dev ;; *) - lua53 ./ferron.lua + cd $FERRON_PATH && + lua53 "$FERRON_PATH"/ferron.lua ;; esac @@ -42,7 +47,7 @@ function build () { # Build the static site # Then deploy it to the web server function deploy () { - build + build && ./deploy @@ -52,17 +57,17 @@ function deploy () { # Concatenate and minify stylesheets # Then export with rsync function update_css () { - ./preprocess_css + ./preprocess_css && - rsync -avmh "./$$SITE_STATIC_DST/css/" "./$SITE_PUBLICHTML/css/" + rsync -avmh "$SITE_STATIC_DST/css/" "$SITE_PUBLIC_HTML/css/" } # Concatenate and minify scripts # Then export with rsync function update_js () { - ./preprocess_javascript + ./preprocess_javascript && - rsync -avmh "./$SITE_STATIC_DST/js/" "./$SITE_PUBLICHTML/js/" + rsync -avmh "$SITE_STATIC_DST/js/" "$SITE_PUBLIC_HTML/js/" } # Watch CSS and JS files @@ -74,5 +79,5 @@ function watch_assets_change () { ["*?js"]="update_js" ) - manuel_watch "./$SITE_STATIC_SRC/" + manuel_watch "$SITE_STATIC_SRC/" } diff --git a/preprocess_css b/preprocess_css @@ -2,11 +2,11 @@ # CSS Preprocessing Script -# Go to the script's directory -cd "$(dirname "$0")" +# Include mustache for bash as library +. ~/bin/mo -CSS_SRC_PATH=static/src/css CSS_DST_PATH=static/dst/css +CSS_SRC_PATH=static/src/css # Convert pixels to EMs px_to_em () { @@ -21,7 +21,7 @@ px_to_em () { } # Associative array with breakpoints and sizes in EMs -declare -A BREAKPOINTS SIZES +declare -A BREAKPOINTS BREAKPOINTS=( [xxs]=$(px_to_em 360) @@ -31,8 +31,6 @@ BREAKPOINTS=( [lg]=$(px_to_em 1140) ) -echo "${BREAKPOINTS[xxs]}" - # 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 @@ -45,11 +43,12 @@ if hash minify 2>/dev/null; then "$CSS_SRC_PATH/global/grid.css" \ "$CSS_SRC_PATH/modules/"*.css \ > "$CSS_DST_PATH/styles.tmp.css" + + # Replace mustache tags with associative array and co. + mo "$CSS_DST_PATH"/styles.tmp.css > "$CSS_DST_PATH"/styles.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 + # Remove the temporary stylesheet + 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 diff --git a/preprocess_javascript b/preprocess_javascript @@ -2,9 +2,6 @@ # JavaScript Preprocessing Script -# Go to the script's directory -cd "$(dirname "$0")" - JS_SRC_PATH=static/src/js JS_DST_PATH=static/dst/js diff --git a/rwd b/rwd @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -# Preprocessor Configuration File - -# Convert pixels to EMs -px_to_em () { - pixel_size=$1 - pixel_context=16 - - if [ -n "$2" ]; then - pixel_context=$2 - fi - - echo "$(bc <<< "scale=4;$pixel_size/$pixel_context")em" -} - -# Associative array with breakpoints and sizes in EMs -declare -A BREAKPOINTS - -export BREAKPOINTS=( - [xxs]=$(px_to_em 360) - [xs]=$(px_to_em 520) - [sm]=$(px_to_em 768) - [md]=$(px_to_em 992) - [lg]=$(px_to_em 1140) -)