hugosoucycc

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

commit 2f20d717e5a01f151540c5fde9893afb8425ceb3
parent ba9f4d3534f031dbd5b3d35ac0571ad85468dfcb
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Fri, 16 Sep 2016 21:03:02 -0400

Add the feed atom creation.

Diffstat:
Mfunctions/build-pandoc-templates | 9+++++++++
Mfunctions/create-html-sections | 17++++++++++++++++-
Dtemplates/mustache/feed-entry.mustache | 12------------
Dtemplates/mustache/feed.mustache | 13-------------
Atemplates/mustache/feed/feed-entry.mustache | 10++++++++++
Mtemplates/mustache/feed/feed.mustache | 24++++--------------------
Mtemplates/mustache/partials/head.mustache | 3+++
7 files changed, 42 insertions(+), 46 deletions(-)

diff --git a/functions/build-pandoc-templates b/functions/build-pandoc-templates @@ -7,6 +7,7 @@ build_pandoc_templates () { # Purge the $TPL_PANDOC_PATH/ folder before the conversion rm -Rf "$TPL_PANDOC_PATH/"*.html + # HTML Templates for mustache in "$TPL_MUSTACHE_PATH/"*.mustache; do # Remove files path mustachename=$(basename "$mustache") @@ -14,4 +15,12 @@ build_pandoc_templates () { mo "$mustache" > "$TPL_PANDOC_PATH/${mustachename%.*}".html done # End + + # Feed Templates + for mustachefeed in "$TPL_MUSTACHE_PATH/feed/"*.mustache; do + # Remove files path + mustachefeedname=$(basename "$mustachefeed") + # And then the convertion without the mustache extension + mo "$mustachefeed" > "$TPL_PANDOC_PATH/${mustachefeedname%.*}".txt + done } diff --git a/functions/create-html-sections b/functions/create-html-sections @@ -16,7 +16,7 @@ create_html_sections () { # For each section page create a temporary "includes" folder mkdir -p "$TMP_PATH/panstash/$(basename "$indexsubdir")" - tmp_folder="$TMP_PATH/panstash/$(basename "$indexsubdir")" + tmp_folder="$TMP_PATH/panstash/$(basename "$indexsubdir")" # For all markdown files that are not "index.md" for markdown in $(find "$indexsubdir/" -type f \( -name "*.md" ! -name "index.md" \)); do @@ -38,6 +38,12 @@ create_html_sections () { --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 done if test "$(ls -A "$tmp_folder/")"; then @@ -47,11 +53,20 @@ create_html_sections () { -o "$tmp_folder/tmp.html" \ --parse-raw + pandoc -t html $(find "$tmp_folder/" -type f -name \*.entry.xhtml | sort -nr) \ + -o "$tmp_folder/tmp.feed.xhtml" \ + --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" + + pandoc -t html "$tmp_folder/tmp.feed.xhtml" -s \ + --template="$TPL_PANDOC_PATH/feed.txt" \ + -o "$PUBLICHTML/feed.$(basename "$indexsubdir").atom.xml" \ + --parse-raw fi done diff --git a/templates/mustache/feed-entry.mustache b/templates/mustache/feed-entry.mustache @@ -1,12 +0,0 @@ -<entry> - <title>$title$</title> - <link href="$url$" /> - <link rel="alternate" type="text/html" href="$url$"/> - <updated>{{ config_date }}</updated> - - <author> - <name>{{ SITE_AUTHOR }}</name> - <email>{{ SITE_AUTHOR_EMAIL }}</email> - </author> -</entry> -<!-- ! --> diff --git a/templates/mustache/feed.mustache b/templates/mustache/feed.mustache @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<feed xmlns="http://www.w3.org/2005/Atom"> - <title>Flux Atom de {{ SITE_DOMAINNAME }}</title> - <subtitle>A subtitle.</subtitle> - <link href="{{ SITE_URL }}/feed.atom.xml" rel="self" /> - <link href="{{ SITE_URL }}" /> - <updated>2003-12-13T18:30:02Z</updated> - - $for(include-after)$ - $include-after$ - $endfor$$ - <!-- End of the feed --> -</feed> diff --git a/templates/mustache/feed/feed-entry.mustache b/templates/mustache/feed/feed-entry.mustache @@ -0,0 +1,10 @@ +<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/feed/feed.mustache b/templates/mustache/feed/feed.mustache @@ -1,27 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Flux Atom de {{ SITE_DOMAINNAME }}</title> - <subtitle>A subtitle.</subtitle> + <subtitle>{{ SITE_DESCRIPTION }}</subtitle> <link href="{{ SITE_URL }}/feed.atom.xml" rel="self" /> <link href="{{ SITE_URL }}" /> - <updated>2003-12-13T18:30:02Z</updated> - - {{# get_every_feed_entry }} - <entry> - <title>{{ __ENTRYTITLE__ }}</title> - <link href="{{ __ENTRYURL__ }}" /> - <link rel="alternate" type="text/html" href="{{ __ENTRYURLALTERNATE__ }}"/> - <updated>{{ config_date }}</updated> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - {{ __ENTRYCONTENT__ }} - </div> - </content> - <author> - <name>{{ SITE_AUTHOR }}</name> - <email>{{ SITE_AUTHOR_EMAIL }}</email> - </author> - </entry> - {{/ get_every_feed_entry }} + <updated>{{ NOW_DATE }}T{{ NOW_DATETIME }}</updated> + + $body$ <!-- End of the feed --> </feed> diff --git a/templates/mustache/partials/head.mustache b/templates/mustache/partials/head.mustache @@ -20,6 +20,9 @@ <link rel="me" href="https://github.com/hs0ucy" /> <link rel="me" href="sms:+15819966481" /> + <link href="{{ BASE_URL }}/feed.note.atom.xml" type="application/atom+xml" rel="alternate" title="Feed des notes" /> + <link href="{{ BASE_URL }}/feed.txt.atom.xml" type="application/atom+xml" rel="alternate" title="Feed des textes" /> + <meta name="robots" content="noindex, nofollow" /> <meta name="description" content="{{ SITE_DESCRIPTION }}" /> <meta name="author" content="{{ SITE_AUTHOR }}" />