fakestache-ssg

[Archived] A static site generator in Bash 4.
Log | Files | Refs | Submodules | README

commit bf95f3a5168bcacb75bd90d012a6a834796dce30
parent a42472e08b97bd5d9b47ff6f1b6e83991a50fcf3
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Mon, 16 Jan 2017 08:23:08 -0500

Merge branch 'master' of github.com:hs0ucy/fakestache-ssg

Diffstat:
Mfakestache | 10++++++----
Mfunctions/create-html-pages | 7+++----
Mfunctions/create-html-sections | 7+++++++
3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/fakestache b/fakestache @@ -39,11 +39,13 @@ case $1 in 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 + # Remove special chars and white spaces for the filename + archetype_title_nospecials=${archetype_title//[\'!,:;?]/} + archetype_filename=${archetype_title_nospecials// /-}.md - mo $ARCHETYPES_PATH/$1.md > $CONTENT_PATH/$1/"${NOW_DATE:0:4}"/"${NOW_DATE:5:2}"/"${archetype_filename,,}" + mkdir -p "$CONTENT_PATH/$1/${NOW_DATE:0:4}/${NOW_DATE:5:2}/" + + 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." diff --git a/functions/create-html-pages b/functions/create-html-pages @@ -12,12 +12,12 @@ create_html_pages () { case "$1" in true) - find_noindex_markdown=$(find "$CONTENT_PATH/" -mindepth 1 -type f \( -name "*.md" ! -name "index.md" \)) + find_noindex_markdown=$(find "$CONTENT_PATH/" -mindepth 2 -type f \( -name "*.md" ! -name "index.md" \)) rm -R "$PUBLICHTML_PATH/"* rm -R "$TMP_PATH/"* ;; false) - find_noindex_markdown=$(find "$CONTENT_PATH/" -mindepth 1 -type f \( -name "*.md" ! -name "index.md" \) -mtime -1) + find_noindex_markdown=$(find "$CONTENT_PATH/" -mindepth 2 -type f \( -name "*.md" ! -name "index.md" \) -mtime -100) ;; esac @@ -32,7 +32,6 @@ create_html_pages () { # Get the value of the template config templatename=$config_template - # page_path="$year"/"$month"/"${outputname%.*}" # Get the relative path of the markdown file page_path="$(realpath --relative-to=$CONTENT_PATH $markdown)" @@ -53,7 +52,7 @@ create_html_pages () { -o "$(dirname "$markdown")/${outputname%.*}.html" fi - echo "$config_date|$config_datetime|$BASE_URL/${page_path%.*}.html|$config_title" + echo "$config_date|$config_datetime|$BASE_URL/${page_path%.*}.html|$config_title" done | sort -nr -o "$FAKESTACHE_PATH"/"$DB" move_html_to_publichtml diff --git a/functions/create-html-sections b/functions/create-html-sections @@ -40,6 +40,13 @@ create_html_sections () { -o "$tmp_folder/$markdown_date-${outputname%.*}".inc.html done + # Create symlinks for images in section's landing page + for img in $(find "$indexsubdir/" -type f \( -name "*.jpg" -or -name "*.png" \)); do + rel_img_path=$(realpath --relative-to=$indexsubdir $img) + + $(ln -s -f "$rel_img_path" "$indexsubdir") + done + if test "$(ls -A "$tmp_folder/")"; then # Sort all the includes files # Create an HTML file with all the includes in descending order