hugosoucycc

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

commit ba3433af0e86c4611050796a5bf4019364df9536
parent a85a8aedc27bee128fe476c5352d6c15318a046b
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Mon,  7 Nov 2016 16:08:57 -0500

Add the new way to create feed.

Diffstat:
Mfunctions/create-feed | 27++++++++++-----------------
Atemplates/mustache/feed/feed-entry.mustache | 9+++++++++
2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/functions/create-feed b/functions/create-feed @@ -2,29 +2,22 @@ # 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` + while read -r 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) + + mo "$TPL_MUSTACHE_PATH/feed/feed-entry.mustache" - 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 + # Build the feed with Pandoc from the `feed.atom.xhtml` file 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" + # Then remove it when the feed is created + rm "$FAKESTACHE_PATH/feed.atom.xhtml" } diff --git a/templates/mustache/feed/feed-entry.mustache b/templates/mustache/feed/feed-entry.mustache @@ -0,0 +1,9 @@ +<entry> + <title>{{ field_title }}</title> + <link href="{{ field_permalink }}" /> + <updated>{{ field_date}}T{{ field_datetime }}</updated> + <author> + <name>{{ SITE_AUTHOR }}</name> + <email>{{ SITE_AUTHOR_EMAIL }}</email> + </author> +</entry>