1
0
Fork 0
mirror of https://git.ludikovsky.name/git/fugitive.git synced 2024-05-18 14:35:32 +02:00

Added support for Atom feeds, improved validation for RSS feeds

This commit is contained in:
Peter 2016-02-15 19:28:37 +00:00
parent cd10c52edb
commit c2547e0b68
6 changed files with 62 additions and 18 deletions

View file

@ -128,7 +128,8 @@ fugitive: README
<li>it regenerates static html files for articles that are just before and <li>it regenerates static html files for articles that are just before and
after newly added and deleted articles (this to maintain the after newly added and deleted articles (this to maintain the
&quot;previous&quot; and &quot;next&quot; links alive),</li> &quot;previous&quot; and &quot;next&quot; links alive),</li>
<li>it regenerates the archives.html, tags.html, and feed.xml files,</li> <li>it regenerates the archives.html, tags.html, atom.xml, and rss.xml
files,</li>
<li>and finally it copies the static html file of the last article to <li>and finally it copies the static html file of the last article to
&quot;index.html&quot;.</li> &quot;index.html&quot;.</li>
</ul> </ul>
@ -175,9 +176,9 @@ fugitive: README
anything else. anything else.
</p> </p>
<p> <p>
The foreach loop construct is specific to the archives.html, tags.html, and The foreach loop construct is specific to the archives.html, tags.html,
feed.xml templates and will therefore be described at the same time. Where atom.xml, and rss.xml templates and will therefore be described at the same
available, the loops are processed right after the includes. time. Where available, the loops are processed right after the includes.
</p> </p>
<p> <p>
The syntax of the conditional construct is as follows: The syntax of the conditional construct is as follows:
@ -195,8 +196,8 @@ fugitive: README
<dt>page_title</dt> <dt>page_title</dt>
<dd> <dd>
Its value is &quot;archives&quot; in the archives.html template, Its value is &quot;archives&quot; in the archives.html template,
&quot;feed&quot; in the feed.xml template, or the article title in the &quot;feed&quot; in the atom.xml and rss.xml template, or the article title
article.html template. in the article.html template.
</dd> </dd>
<dt>blog_url</dt> <dt>blog_url</dt>
<dd> <dd>
@ -373,7 +374,7 @@ fugitive: README
Its value is the title of the next article ordered by publication date. Its value is the title of the next article ordered by publication date.
</dd> </dd>
</dl> </dl>
<h4>foreach loops in archives.html and feed.xml:</h4> <h4>foreach loops in archives.html, atom.xml, and rss.xml:</h4>
<p> <p>
Two foreach loops are available: <code>foreach:article</code> Two foreach loops are available: <code>foreach:article</code>
and <code>foreach:commit</code>. The syntax is as follows: and <code>foreach:commit</code>. The syntax is as follows:
@ -389,8 +390,9 @@ fugitive: README
set in accordance with the commit each time. set in accordance with the commit each time.
&lt;<span class="keyword">?fugitive</span> endforeach:commit ?&gt;</pre> &lt;<span class="keyword">?fugitive</span> endforeach:commit ?&gt;</pre>
<p> <p>
The only difference between the archives.html and feed.xml templates is that The only difference between the archives.html, atom.xml, and rss.xml
in feed.xml these constructs only loop on the five last articles and commits. templates is that in atom.xml and rss.xml these constructs only loop on the
five last articles and commits.
</p> </p>
<h2 id="hacking">Hacking fugitive</h2> <h2 id="hacking">Hacking fugitive</h2>

22
default-files/atom.xml Normal file
View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
<title><?fugitive-install name ?>'s blog atom feed</title>
<link rel="self" href="<?fugitive blog_url ?>atom.xml" />
<link href="<?fugitive blog_url ?>" />
<id><?fugitive blog_url ?>atom.xml</id>
<updated><?fugitive commit_datetime_html5 ?></updated>
<generator>fugitive - http://gitorious.org/fugitive</generator>
<?fugitive foreach:article ?>
<entry>
<title><?fugitive article_title ?></title>
<link href="<?fugitive blog_url ?><?fugitive article_file ?>.html" />
<id><?fugitive blog_url ?><?fugitive article_file ?>.html</id>
<updated><?fugitive article_mdatetime_html5 ?></updated>
<published><?fugitive article_cdatetime_html5 ?></published>
<author>
<name><?fugitive article_cauthor ?></name>
</author>
<content type="html"><![CDATA[ <?fugitive article_content ?> ]]></content>
</entry>
<?fugitive endforeach:article ?>
</feed>

View file

@ -6,7 +6,7 @@
<link><?fugitive blog_url ?></link> <link><?fugitive blog_url ?></link>
<description>5 last published articles</description> <description>5 last published articles</description>
<generator>fugitive - http://gitorious.org/fugitive</generator> <generator>fugitive - http://gitorious.org/fugitive</generator>
<lastBuildDate><?fugitive commit_date ?></lastBuildDate> <lastBuildDate><?fugitive commit_date_html5 ?></lastBuildDate>
<?fugitive foreach:article ?> <?fugitive foreach:article ?>
<item> <item>
@ -15,7 +15,7 @@
<description><![CDATA[<?fugitive article_content ?>]]></description> <description><![CDATA[<?fugitive article_content ?>]]></description>
<author><?fugitive article_cauthor ?></author> <author><?fugitive article_cauthor ?></author>
<guid><?fugitive blog_url ?><?fugitive article_file ?>.html</guid> <guid><?fugitive blog_url ?><?fugitive article_file ?>.html</guid>
<pubDate><?fugitive article_cdatetime ?></pubDate> <pubDate><?fugitive article_cdatetime_html5 ?></pubDate>
</item> </item>
<?fugitive endforeach:article ?> <?fugitive endforeach:article ?>

View file

@ -6,7 +6,8 @@
<meta name="author" content="<?fugitive-install name ?>" /> <meta name="author" content="<?fugitive-install name ?>" />
<meta name="description" content="<?fugitive-install name ?>'s blog" /> <meta name="description" content="<?fugitive-install name ?>'s blog" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<link rel="alternate" type="application/rss+xml" href="<?fugitive blog_url ?>feed.xml" title="5 last articles RSS feed" /> <link rel="alternate" type="application/rss+xml" href="<?fugitive blog_url ?>rss.xml" title="5 last articles RSS feed" />
<link rel="alternate" type="application/atom+xml" href="<?fugitive blog_url ?>atom.xml" title="5 last articl es Atom feed">
<link rel="stylesheet" href="fugitive.css" type="text/css" media="screen" /> <link rel="stylesheet" href="fugitive.css" type="text/css" media="screen" />
<link rel="stylesheet" href="print.css" type="text/css" media="print" /> <link rel="stylesheet" href="print.css" type="text/css" media="print" />
<link rel="contents" href="archives.html" /> <link rel="contents" href="archives.html" />

View file

@ -377,12 +377,12 @@ if [ $modification -gt 0 ]; then
sed "/^[[:space:]]*$/d" > "$temp" sed "/^[[:space:]]*$/d" > "$temp"
cp "$temp" "$public_dir/archives.html" cp "$temp" "$public_dir/archives.html"
echo "done." echo "done."
echo -n "[fugitive] Generating $public_dir/feed.xml... " echo -n "[fugitive] Generating $public_dir/rss.xml... "
last_5_articles=`mktemp fugitiveXXXXXX` last_5_articles=`mktemp fugitiveXXXXXX`
head -5 "$articles_sorted" > "$last_5_articles" head -5 "$articles_sorted" > "$last_5_articles"
last_5_commits=`mktemp fugitiveXXXXXX` last_5_commits=`mktemp fugitiveXXXXXX`
head -5 "$commits" > "$last_5_commits" head -5 "$commits" > "$last_5_commits"
cat "$templates_dir/feed.xml" | \ cat "$templates_dir/rss.xml" | \
replace_includes | \ replace_includes | \
replace_foreach "article" "$last_5_articles" | \ replace_foreach "article" "$last_5_articles" | \
replace_foreach "commit" "$last_5_commits" | \ replace_foreach "commit" "$last_5_commits" | \
@ -390,7 +390,22 @@ if [ $modification -gt 0 ]; then
replace_str "blog_url" "$blog_url" | \ replace_str "blog_url" "$blog_url" | \
replace_commit_info "-1" | \ replace_commit_info "-1" | \
sed "/^[[:space:]]*$/d" > "$temp" 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." echo "done."
rm "$last_5_articles" "$last_5_commits" "$temp" rm "$last_5_articles" "$last_5_commits" "$temp"
echo -n "[fugitive] Using last published article as index page... " echo -n "[fugitive] Using last published article as index page... "

View file

@ -69,7 +69,8 @@ fugitive_install() {
*~ *~
_public/index.html _public/index.html
_public/archives.html _public/archives.html
_public/feed.xml _public/rss.xml
_public/atom.xml
EOF EOF
echo "done." echo "done."
if [ "$1" = "local" ]; then if [ "$1" = "local" ]; then
@ -89,8 +90,11 @@ EOF
fugitive_write_template > _templates/bottom.html <<EOF fugitive_write_template > _templates/bottom.html <<EOF
#INCLUDE:default-files/bottom.html# #INCLUDE:default-files/bottom.html#
EOF EOF
fugitive_write_template > _templates/feed.xml <<EOF fugitive_write_template > _templates/rss.xml <<EOF
#INCLUDE:default-files/feed.xml# #INCLUDE:default-files/rss.xml#
EOF
fugitive_write_template > _templates/atom.xml <<EOF
#INCLUDE:default-files/atom.xml#
EOF EOF
echo "done." echo "done."
echo -n "Writing default css files... " echo -n "Writing default css files... "