hugosoucycc

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

commit df02646fb40518c1f8dc353f8e03ecf33c7738ec
parent 03755c43a7868636e7b6382425cbac4619f29e65
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Sun,  6 Nov 2016 19:22:04 -0500

Replace PanStash with FakeStache

It is the new name of the SSG.

Diffstat:
Afakestache | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+), 0 deletions(-)

diff --git a/fakestache b/fakestache @@ -0,0 +1,93 @@ +#!/bin/bash +# +# FAKESTACHE SSG - Yep! An Other Static Website Generator! +# (Pandoc + Mustache + Bash) +# + +# Dependencies : +# * Pandoc - Make sure it's installed on your machine : `$ pandoc -v`. +# * Mustache - Is already includes in pantash : `lib/mo/`. + +# Include the main configuration file +. config/config + +# Include mustache for bash +. lib/mo/mo + +# Include all the main functions +. functions/parse_yaml +. functions/get-archetypes +. functions/build-pandoc-templates +. functions/get-pandoc-templates +. functions/move-html-to-publichtml +. functions/create-html-pages +. functions/create-html-sections +. functions/create-feed +. functions/get-static-files +. functions/clean-content-folder + +get_archetypes + +# Reset all variables that might be set +reset=false + +case $1 in + "${archetypes[*]}") + if [ -n "$2" ]; then + archetype_title="$2" + archetype_date=$NOW_DATE + archetype_datetime=$NOW_DATETIME + archetype_template="$1" + + # Remove special chars for the filename + archetype_title_nospecials=${archetype_title//[^A-Za-z0-9]/-} + archetype_filename=${archetype_title_nospecials//--/}.md + + mo $ARCHETYPES_PATH/$1.md > $CONTENT_PATH/$1/"${NOW_DATE:0:4}"/"${NOW_DATE:5:2}"/"${archetype_filename,,}" + + echo "- The file '$CONTENT_PATH/$1/${NOW_DATE:0:4}/${NOW_DATE:5:2}/${archetype_filename,,}' hab been created." + + exit 0 + else + echo "- ERROR: Requires a second argument! You need a title to create a $1." >&2 + exit 1 + fi + ;; + -d|--dev) + BASE_URL=$SITE_URL_DEV + + case $2 in + -r|--reset) + reset=true + ;; + esac + ;; + -r|--reset) + reset=true + + case $2 in + -d|--dev) + BASE_URL=$SITE_URL_DEV + ;; + esac + ;; +esac + +if hash pandoc 2>/dev/null; then + # Ok Pandoc is here. + # Then execute main functions + build_pandoc_templates + create_html_pages "$reset" + create_html_sections + create_feed + get_static_files + clean_content_folder + + echo "- Your New Website Is Ready Here : $PUBLICHTML_PATH/ . Thanks Pandoc!!" + exit 0 +else + echo "- Sorry But You must Install *Pandoc* For Using *FakeStache SSG*." + echo "- Please Visit <http://pandoc.org/installing.html>." + + exit 1 +fi