fakestache-ssg

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

commit 5d1bafeeab64dbc5251d30df1c4999a8951a75a5
parent eb317b3397460db8c58bb4d59d353a3d77fe5067
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Fri,  4 Nov 2016 21:32:25 -0400

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

Diffstat:
Mconfig/config | 3+++
Mfakestache | 2++
Afakestache.db | 7+++++++
Afunctions/create-feed | 30++++++++++++++++++++++++++++++
Mfunctions/create-html-pages | 13+++----------
Mfunctions/create-html-sections | 23+++--------------------
Dtemplates/mustache/feed/feed-entry.mustache | 10----------
Mtemplates/mustache/partials/head.mustache | 4+++-
8 files changed, 51 insertions(+), 41 deletions(-)

diff --git a/config/config b/config/config @@ -4,6 +4,9 @@ export NOW_DATE="$(date +%Y-%m-%d)" export NOW_DATETIME="$(date +%H:%M:%S)" +# Flat Database Name +export DB=fakestache.db + # Site configuration file export SITE_DOMAINNAME="john.doe.tld" export SITE_URL="http://${SITE_DOMAINNAME}" diff --git a/fakestache b/fakestache @@ -22,6 +22,7 @@ . functions/move-html-to-publichtml . functions/create-html-pages . functions/create-html-sections +. functions/create-feed . functions/get-static-files . functions/clean-content-folder @@ -78,6 +79,7 @@ if hash pandoc 2>/dev/null; then build_pandoc_templates create_html_pages "$reset" create_html_sections + create_feed get_static_files clean_content_folder diff --git a/fakestache.db b/fakestache.db @@ -0,0 +1,7 @@ +2016-11-01|21:49:21|http://localhost:8181/note/2016/11/test-01.html|Test 01 +2016-11-01|17:06:47|http://localhost:8181/note/2016/11/j-aime-les-aaaaa.html|J'aime les aaaaa ! +2016-11-01|17:06:34|http://localhost:8181/note/2016/11/j-aime-les-aaaaa-.html|J'aime les aaaaa ?! +2016-11-01|15:29:41|http://localhost:8181/note/2016/11/j-aime-les-fruits.html|J'aime les fruits +2016-07-13|21:49:21|http://localhost:8181/note/emacs-sort-delete-matching-duplicate-lines.html|Emacs classer, effacer les doublons, effacer par patterns +2016-04-12|19:37:38|http://localhost:8181/note/encore-une-fois-je-viens-de-supprimer-mon-compte-facebook.html|Encore une fois je viens de supprimer mon compte facebook +null|21:49:21|http://localhost:8181/note/index.html|Notes diff --git a/functions/create-feed b/functions/create-feed @@ -0,0 +1,30 @@ +#!/bin/bash + +# Create the Atom feed from the flat database +create_feed () { + while read feed_entry; do + field_date=`echo $feed_entry | cut -d "|" -f 1` + field_datetime=`echo $feed_entry | cut -d "|" -f 2` + field_permalink=`echo $feed_entry | cut -d "|" -f 3` + field_title=`echo $feed_entry | cut -d "|" -f 4` + + echo "<entry>" + echo "<title>$field_title</title>" + echo "<link href=\"$field_permalink\" />" + echo "<updated>$field_date""T$field_datetime</updated>" + echo "<author>" + echo "<name>$SITE_AUTHOR</name>" + echo "<email>$SITE_AUTHOR_EMAIL</email>" + echo "</author>" + echo "</entry>" + + done < "$FAKESTACHE_PATH"/"$DB" > feed.atom.xhtml + + # This is for the feed + pandoc -t html "$FAKESTACHE_PATH/feed.atom.xhtml" -s \ + --template="$TPL_PANDOC_PATH/feed.txt" \ + -o "$PUBLICHTML/feed.atom.xml" \ + --parse-raw + + rm "$FAKESTACHE_PATH/feed.atom.xhtml" +} diff --git a/functions/create-html-pages b/functions/create-html-pages @@ -52,19 +52,12 @@ create_html_pages () { -o "$(dirname "$markdown")/${outputname%.*}.html" fi - echo "$config_date$config_datetime|$BASE_URL/${page_path%.*}|$config_title" + echo "$config_date|$config_datetime|$BASE_URL/${page_path%.*}.html|$config_title" done > fakestache.tmp.db - sort -nr fakestache.tmp.db > fakestache.db + sort -nr fakestache.tmp.db > "$FAKESTACHE_PATH"/"$DB" - # while read PAGEITEM; do - # ITEM1=`echo $PAGEITEM | cut -d "|" -f 1` - # ITEM2=`echo $PAGEITEM | cut -d "|" -f 2` - # ITEM3=`echo $PAGEITEM | cut -d "|" -f 3` - - # echo "$ITEM1" - - # done < fakestache.db + rm fakestache.tmp.db move_html_to_publichtml } diff --git a/functions/create-html-sections b/functions/create-html-sections @@ -37,13 +37,7 @@ create_html_sections () { --variable=url:"$BASE_URL/${url#*/}" \ --template="$TPL_PANDOC_PATH/${tplname}-index.inc.html" \ -t html5 \ - -o "$tmp_folder/$markdown_date-${outputname%.*}".inc.html - - pandoc "$markdown" -s \ - --variable=url:"$BASE_URL/${url#*/}" \ - --template="$TPL_PANDOC_PATH/feed-entry.txt" \ - -t plain \ - -o "$tmp_folder/$markdown_date-${outputname%.*}".entry.xhtml + -o "$tmp_folder/$markdown_date-${outputname%.*}".inc.html done if test "$(ls -A "$tmp_folder/")"; then @@ -51,24 +45,13 @@ create_html_sections () { # Create an HTML file with all the includes in descending order pandoc -t html5 $(find "$tmp_folder/" -type f -name \*.inc.html | sort -nr) \ -o "$tmp_folder/tmp.html" \ - --parse-raw - - # This is for the feed - pandoc -t html $(find "$tmp_folder/" -type f -name \*.entry.xhtml | sort -nr) \ - -o "$tmp_folder/tmp.feed.xhtml" \ - --parse-raw + --parse-raw # Merge the "includes.html" and "index.md" to create the section page list pandoc -t html5 "$indexsubdir/index.md" -s \ --template="$TPL_PANDOC_PATH/${tplname}-index.html" \ -A "$tmp_folder/tmp.html" \ - -o "$indexsubdir/index.html" - - # This is for the feed - pandoc -t html "$tmp_folder/tmp.feed.xhtml" -s \ - --template="$TPL_PANDOC_PATH/feed.txt" \ - -o "$PUBLICHTML/feed.$(basename "$indexsubdir").atom.xml" \ - --parse-raw + -o "$indexsubdir/index.html" fi done diff --git a/templates/mustache/feed/feed-entry.mustache b/templates/mustache/feed/feed-entry.mustache @@ -1,10 +0,0 @@ -<entry> - <title>$title$</title> - <link href="$url$" /> - <updated>$date$T$datetime$</updated> - - <author> - <name>{{ SITE_AUTHOR }}</name> - <email>{{ SITE_AUTHOR_EMAIL }}</email> - </author> -</entry> diff --git a/templates/mustache/partials/head.mustache b/templates/mustache/partials/head.mustache @@ -3,10 +3,12 @@ <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title>$pagetitle$ &mdash; {{ SITE_DOMAINNAME }}</title> - <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="{{ BASE_URL }}/css/styles.css" /> + <link href="{{ BASE_URL }}/feed.atom.xml" type="application/atom+xml" rel="alternate" title="Feed Atom" /> <meta name="description" content="{{ SITE_DESCRIPTION }}" /> <meta name="author" content="{{ SITE_AUTHOR }}" />