hugosoucycc

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

commit 8e132f991649e7064b71b96946cccacb891d242d
parent d8a6bbb67ad5fd6e324750bf87ff9bbf4d3637bc
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Thu,  4 Aug 2016 19:58:33 -0400

Merge branch 'master' of github.com:hs0ucy/hugosoucycc

Diffstat:
Marchetypes/note.md | 7++++---
Mconfig/config.sh | 8+++++++-
Acontent/note/m4-as-css-pre-processor.md | 7+++++++
Acontent/note/matane-budget-participatif.md | 11+++++++++++
Acontent/note/shipping-is-a-feature.md | 10++++++++++
Acontent/note/txti.md | 7+++++++
Dcreate.sh | 6------
Mfunctions/build-pandoc-templates.sh | 11-----------
Mfunctions/create-html-pages.sh | 4+++-
Mfunctions/create-html-sections.sh | 5++++-
Afunctions/get-archetypes.sh | 13+++++++++++++
Afunctions/get-pandoc-templates.sh | 14++++++++++++++
Mpanstash.sh | 51+++++++++++++++++++++++++++++++++++++--------------
Mtemplates/mustache/note.mustache | 5++++-
Awebmentions-test/README.md | 5+++++
Awebmentions-test/pingback.xml | 16++++++++++++++++
16 files changed, 142 insertions(+), 38 deletions(-)

diff --git a/archetypes/note.md b/archetypes/note.md @@ -1,7 +1,8 @@ --- -title: -date: {{ NOW_DATE }} -datetime: {{ NOW_DATETIME }} +title: {{ archetype_title }} +date: {{ archetype_date }} +datetime: {{ archetype_datetime }} +bridgy: true --- ... diff --git a/config/config.sh b/config/config.sh @@ -12,6 +12,9 @@ export SITE_LANGUAGE="fr" export MUSTACHE=templates/mustache export PANDOC=templates/pandoc +# Archetypes folder (markdown files) +export ARCHETYPES=archetypes + # Content folder (markdown files) export CONTENT=content @@ -21,7 +24,7 @@ export ASSETS=static/prod # Public HTML folder export PUBLICHTML=public_html -# Paths +# PATHS # To the current absolute path export PANSTASH_PATH=$(pwd) @@ -31,6 +34,9 @@ export TPL_MUSTACHE_PATH=$PANSTASH_PATH/$MUSTACHE # To the pandoc templates export TPL_PANDOC_PATH=$PANSTASH_PATH/$PANDOC +# To the archetypes files +export ARCHETYPES_PATH=$PANSTASH_PATH/$ARCHETYPES + # To the content files export CONTENT_PATH=$PANSTASH_PATH/$CONTENT diff --git a/content/note/m4-as-css-pre-processor.md b/content/note/m4-as-css-pre-processor.md @@ -0,0 +1,7 @@ +--- +title: M4 as CSS pre-processor +date: 2016-08-03 +datetime: 12:15:45 +--- + +«Use the Unix: m4 as a CSS pre-processor» ~ <http://x.soucy.cc/ca>. diff --git a/content/note/matane-budget-participatif.md b/content/note/matane-budget-participatif.md @@ -0,0 +1,11 @@ +--- +title: Matane budget participatif +date: 2016-08-03 +datetime: 12:25:29 +--- + +Bien sûr mon vote va à la «statue de 100 pieds de haut à l'effigie de +Pincette la Crevette» ^^ + +<blockquote class="twitter-tweet" data-partner="tweetdeck"><p lang="fr" dir="ltr">Bravo à la ville de <a href="https://twitter.com/hashtag/Matane?src=hash">#Matane</a> pour cette initiative en matière de <a href="https://twitter.com/hashtag/budgetparticipatif?src=hash">#budgetparticipatif</a>! On a hâte de voir la suite ;) <a href="https://t.co/7svB9nhznh">https://t.co/7svB9nhznh</a></p>&mdash; Écologie Urbaine (@EcologieUrbaine) <a href="https://twitter.com/EcologieUrbaine/status/755462339218976768">July 19, 2016</a></blockquote> +<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> diff --git a/content/note/shipping-is-a-feature.md b/content/note/shipping-is-a-feature.md @@ -0,0 +1,10 @@ +--- +title: Shipping is a feature +date: 2016-08-04 +datetime: 16:18:47 +cite: Joel on Software +citeurl: http://www.joelonsoftware.com/items/2009/09/23.html +bridgy: true +--- + +«Shipping is a feature. A really important feature. Your product must have it.» diff --git a/content/note/txti.md b/content/note/txti.md @@ -0,0 +1,7 @@ +--- +title: Txti +date: 2016-08-03 +datetime: 11:47:44 +--- + +**Txti**: Fast web pages for everybody ~ <http://txti.es/>. diff --git a/create.sh b/create.sh @@ -1,6 +0,0 @@ -#!/bin/bash - -# Include the main configuration file -. config/config.sh - -lib/mo/mo archetypes/note.md > archetypes/la-nouvelle-note.md diff --git a/functions/build-pandoc-templates.sh b/functions/build-pandoc-templates.sh @@ -14,15 +14,4 @@ build_pandoc_templates () { mo $mustache > $TPL_PANDOC_PATH/${mustachename%.*}.html done # End - - # Create an array with templates names - templates=() - - for template in $TPL_PANDOC_PATH/*; do - # Template name without path - templatename=$(basename "$template") - # Push templates names in the array - templates+=(${templatename%.*}) - done - # End } diff --git a/functions/create-html-pages.sh b/functions/create-html-pages.sh @@ -7,6 +7,8 @@ create_html_pages () { echo "Create all the HTML pages with pandoc" + get_pandoc_templates + # Create the homepage pandoc --template=$TPL_PANDOC_PATH/index.html -o $CONTENT_PATH/index.html $CONTENT_PATH/index.md @@ -28,7 +30,7 @@ create_html_pages () { # First create year and month folders mkdir -p $(dirname "$markdown")/$year/$month - fi + fi # Check if a section have a specific template or use the default template if [[ " ${templates[*]} " == *" $section "* ]]; then diff --git a/functions/create-html-sections.sh b/functions/create-html-sections.sh @@ -4,6 +4,8 @@ create_html_sections () { echo "Create section page list" + get_pandoc_templates + for indexsubdir in $(find $CONTENT_PATH/ -mindepth 2 -name index.md -exec dirname {} \;); do # For each section page create a temporary "includes" folder mkdir $indexsubdir/includes @@ -24,12 +26,13 @@ create_html_sections () { # Set the variable for the date markdown_date=$config_date + markdown_datetime=$config_datetime # Set the variable for the URL url=$(find $PUBLICHTML/ -type f -name ${outputname%.*}.html;) # Create all the includes files that make up section page and put them into the "includes" folder - pandoc $markdown -s --variable=url:$BASE_URL/${url#*/} --template=$TPL_PANDOC_PATH/"$tplname"-index.inc.html -t html5 -o $indexsubdir/includes/$markdown_date-${outputname%.*}.inc.html + pandoc $markdown -s --variable=url:$BASE_URL/${url#*/} --template=$TPL_PANDOC_PATH/"$tplname"-index.inc.html -t html5 -o $indexsubdir/includes/$markdown_date-$markdown_datetime-${outputname%.*}.inc.html done if test "$(ls -A "$indexsubdir/includes/")"; then diff --git a/functions/get-archetypes.sh b/functions/get-archetypes.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Create an array with archtypes names +get_archetypes () { + archetypes=() + + for archetype in $ARCHETYPES_PATH/*; do + # Template name without path + archetypename=$(basename "$archetype") + # Push templates names in the array + archetypes+=(${archetypename%.*}) + done +} diff --git a/functions/get-pandoc-templates.sh b/functions/get-pandoc-templates.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Create an array with templates names +get_pandoc_templates () { + templates=() + + for template in $TPL_PANDOC_PATH/*; do + # Template name without path + templatename=$(basename "$template") + # Push templates names in the array + templates+=(${templatename%.*}) + done + # End +} diff --git a/panstash.sh b/panstash.sh @@ -8,6 +8,8 @@ # * Pandoc - Make sure it's installed on your machine : `$ pandoc -v`. # * Mustache - Is already includes in pantash : `lib/mo/`. +# Maybe i should call it «FAKESTASH» !? «FAKESTASH SSG». + # Include the main configuration file . config/config.sh @@ -18,29 +20,50 @@ . lib/parse_yaml.sh # Include all the main functions +. functions/get-archetypes.sh . functions/build-pandoc-templates.sh +. functions/get-pandoc-templates.sh . functions/move-html-to-publichtml.sh . functions/create-html-pages.sh . functions/create-html-sections.sh . functions/get-static-files.sh . functions/clean-content-folder.sh -# Check if Pandoc is installed. -if hash pandoc 2>/dev/null; then - # Ok Pandoc is here. - # Execute main functions - build_pandoc_templates - create_html_pages - create_html_sections - get_static_files - clean_content_folder +get_archetypes + +if [[ -n "$1" ]] && [[ " ${archetypes[*]} " == *" $1 "* ]] && [[ -n "$2" ]]; then + # Should be more dynamic with regex. + # Don't suppose of the file format. + + # Build the archetype's title from 2nd argument + # It'll work if the format is "this-is-my-new-conten.md" + dynamictitle=$(echo "$2" | tr '-' ' ' | sed -r 's/.md//g') - echo "Your New Website Is Ready Here : $PUBLICHTML_PATH/ . Thanks Pandoc!!" + archetype_title=${dynamictitle^} + archetype_date=$NOW_DATE + archetype_datetime=$NOW_DATETIME - exit 0 + mo $ARCHETYPES_PATH/$1.md > $CONTENT_PATH/$1/$2 + + echo "- The file '$CONTENT_PATH/$1/$2' hab been created." else - echo "Sorry But You must Install *Pandoc* For Using *Panstash*." - echo "Please Visit <http://pandoc.org/installing.html>." + # Check if Pandoc is installed. + if hash pandoc 2>/dev/null; then + # Ok Pandoc is here. + # Execute main functions + build_pandoc_templates + create_html_pages + create_html_sections + 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 *Panstash*." + echo "- Please Visit <http://pandoc.org/installing.html>." - exit 1 + exit 1 + fi fi diff --git a/templates/mustache/note.mustache b/templates/mustache/note.mustache @@ -5,7 +5,7 @@ <article class="layout h-entry hentry as-note"> <div class="layout__vcenter"> <h1 class="visuallyhidden">$title$</h1> - + $if(citeurl)$ <blockquote class="note__blockquote p-name e-content"> <div class="note__blockquote__quote">$body$</div> @@ -34,6 +34,9 @@ $if(modified)$Modifié le <time class="dt-updated">$modified$</time>.$endif$ </footer> </div> + $if(bridgy)$ + <a class="visuallyhidden" href="https://brid.gy/publish/twitter"></a> + $endif$ </article> </main> diff --git a/webmentions-test/README.md b/webmentions-test/README.md @@ -0,0 +1,5 @@ +Swap out the two URLs (first is source, second is target) then run with curl: + +``` +curl -X POST -d @pingback.xml https://webmention.io/hugo.soucy.cc/xmlrpc +``` diff --git a/webmentions-test/pingback.xml b/webmentions-test/pingback.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<methodCall> +<methodName>pingback.ping</methodName> +<params> + <param> + <value> + <string>http://hugo.soucy.cc/note</string> + </value> + </param> + <param> + <value> + <string>http://hugo.soucy.cc/note/2016/07/emacs-sort-delete-matching-duplicate-lines</string> + </value> + </param> +</params> +</methodCall>