From c2547e0b684e61539666ec6d130145fe1c59f341 Mon Sep 17 00:00:00 2001 From: Peter Ludikovsky Date: Mon, 15 Feb 2016 19:28:37 +0000 Subject: Added support for Atom feeds, improved validation for RSS feeds --- README.html | 20 +++++++++++--------- default-files/atom.xml | 22 ++++++++++++++++++++++ default-files/feed.xml | 23 ----------------------- default-files/rss.xml | 23 +++++++++++++++++++++++ default-files/top.html | 3 ++- html-gen.sh | 21 ++++++++++++++++++--- install.sh | 10 +++++++--- 7 files changed, 83 insertions(+), 39 deletions(-) create mode 100644 default-files/atom.xml delete mode 100644 default-files/feed.xml create mode 100644 default-files/rss.xml diff --git a/README.html b/README.html index 58d7435..309c2dd 100644 --- a/README.html +++ b/README.html @@ -128,7 +128,8 @@ fugitive: README
  • it regenerates static html files for articles that are just before and after newly added and deleted articles (this to maintain the "previous" and "next" links alive),
  • -
  • it regenerates the archives.html, tags.html, and feed.xml files,
  • +
  • it regenerates the archives.html, tags.html, atom.xml, and rss.xml + files,
  • and finally it copies the static html file of the last article to "index.html".
  • @@ -175,9 +176,9 @@ fugitive: README anything else.

    - The foreach loop construct is specific to the archives.html, tags.html, and - feed.xml templates and will therefore be described at the same time. Where - available, the loops are processed right after the includes. + The foreach loop construct is specific to the archives.html, tags.html, + atom.xml, and rss.xml templates and will therefore be described at the same + time. Where available, the loops are processed right after the includes.

    The syntax of the conditional construct is as follows: @@ -195,8 +196,8 @@ fugitive: README

    page_title
    Its value is "archives" in the archives.html template, - "feed" in the feed.xml template, or the article title in the - article.html template. + "feed" in the atom.xml and rss.xml template, or the article title + in the article.html template.
    blog_url
    @@ -373,7 +374,7 @@ fugitive: README Its value is the title of the next article ordered by publication date.
    -

    foreach loops in archives.html and feed.xml:

    +

    foreach loops in archives.html, atom.xml, and rss.xml:

    Two foreach loops are available: foreach:article and foreach:commit. The syntax is as follows: @@ -389,8 +390,9 @@ fugitive: README set in accordance with the commit each time. <?fugitive endforeach:commit ?>

    - The only difference between the archives.html and feed.xml templates is that - in feed.xml these constructs only loop on the five last articles and commits. + The only difference between the archives.html, atom.xml, and rss.xml + templates is that in atom.xml and rss.xml these constructs only loop on the + five last articles and commits.

    Hacking fugitive

    diff --git a/default-files/atom.xml b/default-files/atom.xml new file mode 100644 index 0000000..2cfc918 --- /dev/null +++ b/default-files/atom.xml @@ -0,0 +1,22 @@ + + + <?fugitive-install name ?>'s blog atom feed + + + atom.xml + + fugitive - http://gitorious.org/fugitive + + + <?fugitive article_title ?> + + .html + + + + + + ]]> + + + diff --git a/default-files/feed.xml b/default-files/feed.xml deleted file mode 100644 index b971b55..0000000 --- a/default-files/feed.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - <?fugitive-install name ?>'s blog rss feed - - 5 last published articles - fugitive - http://gitorious.org/fugitive - - - - - <![CDATA[<?fugitive article_title ?>]]> - .html - ]]> - - .html - - - - - - diff --git a/default-files/rss.xml b/default-files/rss.xml new file mode 100644 index 0000000..cc48d00 --- /dev/null +++ b/default-files/rss.xml @@ -0,0 +1,23 @@ + + + + + <?fugitive-install name ?>'s blog rss feed + + 5 last published articles + fugitive - http://gitorious.org/fugitive + + + + + <![CDATA[<?fugitive article_title ?>]]> + .html + ]]> + + .html + + + + + + diff --git a/default-files/top.html b/default-files/top.html index 5a2ea1b..6dc93a4 100644 --- a/default-files/top.html +++ b/default-files/top.html @@ -6,7 +6,8 @@ - + + diff --git a/html-gen.sh b/html-gen.sh index 6974d80..a98a1d7 100644 --- a/html-gen.sh +++ b/html-gen.sh @@ -377,12 +377,12 @@ if [ $modification -gt 0 ]; then sed "/^[[:space:]]*$/d" > "$temp" cp "$temp" "$public_dir/archives.html" echo "done." - echo -n "[fugitive] Generating $public_dir/feed.xml... " + echo -n "[fugitive] Generating $public_dir/rss.xml... " last_5_articles=`mktemp fugitiveXXXXXX` head -5 "$articles_sorted" > "$last_5_articles" last_5_commits=`mktemp fugitiveXXXXXX` head -5 "$commits" > "$last_5_commits" - cat "$templates_dir/feed.xml" | \ + cat "$templates_dir/rss.xml" | \ replace_includes | \ replace_foreach "article" "$last_5_articles" | \ replace_foreach "commit" "$last_5_commits" | \ @@ -390,7 +390,22 @@ if [ $modification -gt 0 ]; then replace_str "blog_url" "$blog_url" | \ replace_commit_info "-1" | \ sed "/^[[:space:]]*$/d" > "$temp" - cp "$temp" "$public_dir/feed.xml" + cp "$temp" "$public_dir/rss.xml" + echo "done." + echo -n "[fugitive] Generating $public_dir/atom.xml... " + last_5_articles=`mktemp fugitiveXXXXXX` + head -5 "$articles_sorted" > "$last_5_articles" + last_5_commits=`mktemp fugitiveXXXXXX` + head -5 "$commits" > "$last_5_commits" + cat "$templates_dir/atom.xml" | \ + replace_includes | \ + replace_foreach "article" "$last_5_articles" | \ + replace_foreach "commit" "$last_5_commits" | \ + replace_str "page_title" "feed" | \ + replace_str "blog_url" "$blog_url" | \ + replace_commit_info "-1" | \ + sed "/^[[:space:]]*$/d" > "$temp" + cp "$temp" "$public_dir/atom.xml" echo "done." rm "$last_5_articles" "$last_5_commits" "$temp" echo -n "[fugitive] Using last published article as index page... " diff --git a/install.sh b/install.sh index 9185665..20c84c2 100644 --- a/install.sh +++ b/install.sh @@ -69,7 +69,8 @@ fugitive_install() { *~ _public/index.html _public/archives.html -_public/feed.xml +_public/rss.xml +_public/atom.xml EOF echo "done." if [ "$1" = "local" ]; then @@ -89,8 +90,11 @@ EOF fugitive_write_template > _templates/bottom.html < _templates/feed.xml < _templates/rss.xml < _templates/atom.xml <