1
0
Fork 0
mirror of https://git.ludikovsky.name/git/fugitive.git synced 2024-06-16 08:35:34 +02:00

now generating rss feed too

This commit is contained in:
p4bl0 2010-07-25 18:52:35 +02:00
parent dbae9472bd
commit 81fa7bd8b6
9 changed files with 142 additions and 96 deletions

90
README
View file

@ -1,12 +1,12 @@
fugitive README file
<h2>Info</h2>
<h2 id="info">Info</h2>
<p>
fugitive is a blog engine running on top of git using hooks to generate
static html pages and thus having only git as dependency.
</p>
<h2>Install</h2>
<h2 id="install">Install</h2>
<h3>Build</h3>
<p>
@ -28,9 +28,14 @@ fugitive README file
&lt;dir&gt;.
<br />
If &lt;dir&gt; isn't specified then the current working directory is used.
<p>
<p>
<strong>NOTE:</strong> You need to use the same process to install any remote
</p>
<p class="important">
Once you have installed your blog you need to set the <em>blog-url</em>
parameter in your git configuration. See <a href="#config">configuration</a>
for details.
</p>
<p class="note">
You need to use the same process to install any remote
repository where you'd like to push your blog.
</p>
<h3>Update</h3>
@ -40,42 +45,52 @@ fugitive README file
If &lt;dir&gt; isn't specified then the current working directory is used.
</p>
<h2>Configuration</h2>
<h2 id="config">Configuration</h2>
<p>
There are three paths in the &quot;fugitive&quot; section of the git config:
All this settings are in the &quot;fugitive&quot; section of the git config.
You can change them with the command <code>git config
fugitive.<em>parameter</em> <em>value</em></code>, where <em>parameter</em>
is one of the following:
</p>
<ul>
<li>
<em>public-dir</em> is the path to the directory that will contain the
generated html files. Defautlt value is &quot;.&quot;, the root of the git
repository. You could set it to &quot;blog&quot; for instance if you
already have a static website under your git repos.
</li>
<li>
<em>articles-dir</em> is the path where fugitive will look for published
articles. Default value is &quot;_articles&quot;. This path is relative to
the root of the git repository, must be in it and must not start with
&quot;.&quot;.
</li>
<li>
<em>templates-dire</em> is the path where fugitive will look for templates
files. Default value is &quot;_templates&quot;. This path is relative to
the root of the git repository, must be in it and must not start with
&quot;.&quot;.
</li>
</ul>
<p>
<strong>NOTE:</strong> You must NOT put a trailing '/' at the end of any of
those paths.
</p>
<p>
If you want your article to be preprocessed by an external tool (markdown,
textile...) you need to set <em>preproc</em> to a command line that will read
on stdin and write to stdout.
<dl>
<dt>blog-url</dt>
<dd>
This is the public url of the generated blog. <strong>You need to set
it</strong> as soon as possible since it's required for the RSS feed (and
used in the default template's footer).
</dd>
<dt>public-dir</dt>
<dd>
This is the path to the directory that will contain the generated html
files. Defautlt value is &quot;.&quot;, the root of the git repository. You
could set it to &quot;blog&quot; for instance if you already have a static
website under your git repos.
</dd>
<dt>articles-dir</dt>
<dd>
This is the path where fugitive will look for published articles. Default
value is &quot;_articles&quot;. This path is relative to the root of the
git repository, must be in it and must not start with &quot;.&quot;.
</dd>
<dt>templates-dire</dt>
<dd>
This is the path where fugitive will look for templates files. Default
value is &quot;_templates&quot;. This path is relative to the root of the
git repository, must be in it and must not start with &quot;.&quot;.
</dd>
<dt>preproc</dt>
<dd>
If you want your article to be preprocessed by an external tool (markdown,
textile...) you need to set <em>preproc</em> to a command line that will
read on stdin and write to stdout.
</dd>
</dl>
<p class="note">
You must NOT put a trailing '/' at the end of any of the path.
</p>
<h2>Usage</h2>
<h2 id="usage">Usage</h2>
<h3>General use</h3>
<p>
@ -86,8 +101,7 @@ fugitive README file
The first line of the file will be used as title and the rest of the file as
the content.
</p>
<p>
<strong>/!\ WARNINGS:</strong><br />
<p class="warning">
DO NOT CREATE AN ARTICLE FILE NAMED &quot;archives&quot;.<br />
DO NOT CREATE AN ARTICLE FILE NAMED &quot;index&quot;.
</p>

View file

@ -1,7 +1,8 @@
<footer>
<p>
<a href="http://www.gnu.org/copyleft/copyleft.html">copyleft</a>
<?fugitive-install name ?> <?fugitive-install year ?>
<a href="<?fugitive blog_url ?>"><?fugitive-install name ?></a>
<?fugitive-install year ?>
&mdash;
powered by <a href="http://gitorious.org/fugitive">fugitive</a>
</p>

23
default-files/feed.xml Normal file
View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title><?fugitive-install name ?>'s blog rss feed</title>
<link><?fugitive blog_url ?></link>
<description>5 last published articles</description>
<generator>fugitive - http://gitorious.org/fugitive</generator>
<lastBuildDate><?fugitive commit_date ?></lastBuildDate>
<?fugitive foreach:article ?>
<item>
<title><![CDATA[<?fugitive article_title ?>]]></title>
<link><?fugitive blog_url ?><?fugitive article_file ?>.html</link>
<description><![CDATA[<?fugitive article_content ?>]]></description>
<author><?fugitive article_cauthor ?></author>
<guid><?fugitive blog_url ?><?fugitive article_file ?>.html</guid>
<pubDate><?fugitive article_cdatetime ?></pubDate>
</item>
<?fugitive endforeach:article ?>
</channel>
</rss>

View file

@ -1,13 +0,0 @@
<footer>
<p>
<a href="http://www.gnu.org/copyleft/copyleft.html">copyleft</a>
<?fugitive-install name ?> <?fugitive-install year ?>
&mdash;
powered by <a href="http://gitorious.org/fugitive">fugitive</a>
</p>
<p>
last build was <?fugitive commit_hash ?>
at <time><?fugitive commit_datetime ?></time>,<br />
subject was <q><?fugitive commit_subject ?></q>
</p>
</footer>

View file

@ -124,6 +124,29 @@ article > div p {
margin: 1em 0;
text-indent: 2em;
}
article > div p.important:before {
content: "important: ";
color: #f00;
font-weight: bold;
font-variant: small-caps;
}
article > div p.warning:before {
content: "warning: ";
color: #fa0;
font-weight: bold;
font-variant: small-caps;
}
article > div p.info:before {
content: "info: ";
color: #080;
font-weight: bold;
font-variant: small-caps;
}
article > div p.note:before {
content: "note: ";
font-weight: bold;
font-variant: small-caps;
}
article > div ul {
margin: 1em 0;
padding: 0 0 0 3em;

View file

@ -1,24 +0,0 @@
<nav>
<?fugitive ifset:article_file ?>
<ul class="nav">
<?fugitive ifset:article_previous_file ?>
<li>
<a href="<?fugitive article_previous_file ?>.html">« previous</a>
</li>
<?fugitive endifset:article_previous_file ?>
<?fugitive ifset:article_next_file ?>
<li>
<a href="<?fugitive article_next_file ?>.html">next »</a>
</li>
<?fugitive endifset:article_next_file ?>
</ul>
<?fugitive endifset:article_file ?>
<ul>
<li><a href="index.html">home</a></li>
<li><a href="archives.html">archives</a></li>
</ul>
</nav>
<header>
<h1><?fugitive-install name ?>'s blog</h1>
<q>fugitive: a blog engine for hackers.</q>
</header>

View file

@ -6,6 +6,7 @@
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=utf-8" />
<meta name="author" content="<?fugitive-install name ?>" />
<meta name="description" content="<?fugitive-install name ?>'s blog" />
<link rel="alternate" type="application/rss+xml" href="<?fugitive blog_url ?>feed.xml" title="5 last articles RSS feed" />
<link rel="stylesheet" href="fugitive.css" type="text/css" media="screen" />
<link rel="stylesheet" href="print.css" type="text/css" media="print" />
<link rel="contents" href="archives.html" />

View file

@ -39,6 +39,7 @@ fugitive_install() {
mkdir -p _drafts _articles _templates
echo "done."
echo -n "Adding default directory paths and settings to git config... "
git config --add --path fugitive.blog-url "http://localhost/fugitive/"
git config --add --path fugitive.templates-dir "_templates"
git config --add --path fugitive.articles-dir "_articles"
git config --add --path fugitive.public-dir "."
@ -51,16 +52,14 @@ EOF
fugitive_write_template > _templates/archives.html <<EOF
#INCLUDE:default-files/archives.html#
EOF
fugitive_write_template > _templates/nav-header.html <<EOF
#INCLUDE:default-files/nav-header.html#
fugitive_write_template > _templates/top.html <<EOF
#INCLUDE:default-files/top.html#
EOF
fugitive_write_template > _templates/footer.html <<EOF
#INCLUDE:default-files/footer.html#
fugitive_write_template > _templates/bottom.html <<EOF
#INCLUDE:default-files/bottom.html#
EOF
echo "done."
echo -n "Writing dummy article (README)... "
(base64 -d | gunzip) > _articles/README <<EOF
#INCLUDE:README#
fugitive_write_template > _templates/feed.xml <<EOF
#INCLUDE:default-files/feed.xml#
EOF
echo "done."
echo -n "Writing default css files... "
@ -72,15 +71,22 @@ EOF
EOF
echo "done."
fugitive_install_hooks
echo -n "Importing files into git repository... "
git add _templates/* fugitive.css print.css >/dev/null
git commit -m "fugitive inital import" >/dev/null
echo "done."
echo -n "Preventing git to track temporary and generated files... "
echo "*~\nindex.html\narchives.html" > .git/info/exclude
echo "done."
echo "Importing files into git repository... "
git add _templates/* fugitive.css print.css >/dev/null
git commit -m "fugitive inital import" >/dev/null
echo "First import finished."
echo "Writing dummy article (README) and adding it to the repos... "
(base64 -d | gunzip) > _articles/README <<EOF
#INCLUDE:README#
EOF
git add _articles/README
git ci -m "fugitive fresh install" >/dev/null
echo "done."
cd - >/dev/null
echo 'Installation complete!'
echo 'Installation almost complete, please visit your blog :-).'
}
case "$1" in

View file

@ -1,5 +1,6 @@
#!/bin/sh
blog_url=`git config --get fugitive.blog-url`
public_dir=`git config --get fugitive.public-dir`
if [ ! -d "$public_dir" ]; then mkdir -p "$public_dir"; fi
templates_dir=`git config --get fugitive.templates-dir`
@ -14,10 +15,6 @@ deleted_files=`git log -1 --name-status --pretty="format:" | grep -E '^D' | \
cut -f2`
generated_files=`tempfile -p "fugitive"`
sanit_mail() {
sed "s/@/[at]/;s/\./(dot)/"
}
articles_sorted=`tempfile -p "fugitive"`
for f in $articles_dir/*; do
ts=`git log --format="%at" -- "$f" | tail -1`
@ -86,6 +83,10 @@ get_commit_body() {
fi
}
sanit_mail() {
sed "s/@/[at]/;s/\./(dot)/"
}
replace_condition() {
if [ "$2" = "" ]; then
sed "s/<?fugitive\s\+\(end\)\?ifset:$1\s*?>/\n\0\n/g" | \
@ -190,7 +191,8 @@ replace_article_info() {
article_next_file=`get_article_next_file "$1"`
article_next_title=`get_article_title "$article_next_file"`
replace_str "article_file" "$1" | \
replace_file "article_content" "`get_article_content \"$1\"`" | \
replace_str "article_file" "$1" | \
replace_str "article_title" "$article_title" | \
replace_str "article_cdatetime" "$article_cdatetime" | \
replace_str "article_cdate" "$article_cdate" | \
@ -264,9 +266,9 @@ generate_article() {
fi
art="${1#$articles_dir/}"
cat "$templates_dir/article.html" | \
replace_file "article_content" "`get_article_content \"$art\"`" | \
replace_includes | \
replace_str "page_title" "`get_article_title \"$art\"`" | \
replace_str "blog_url" "$blog_url" | \
replace_commit_info "-1" | \
replace_article_info "$art" | \
sed "/^\s*$/d" > "$public_dir/$art.html"
@ -341,10 +343,23 @@ if [ $modification -gt 0 ]; then
replace_foreach "commit" "$commits" | \
replace_empty_article_info | \
replace_str "page_title" "archives" | \
replace_str "blog_url" "$blog_url" | \
replace_commit_info "-1" | \
sed "/^\s*$/d" > "$public_dir/archives.html"
echo "done."
echo -n "[fugitive] Generating $public_dir/feed.xml... "
last_5_articles=`tempfile -p "fugitive"`
head -5 "$articles_sorted" > "$last_5_articles"
last_5_commits=`tempfile -p "fugitive"`
head -5 "$commits" > "$last_5_commits"
cat "$templates_dir/feed.xml" | \
replace_foreach "article" "$last_5_articles" | \
replace_foreach "commit" "$last_5_commits" | \
replace_str "blog_url" "$blog_url" | \
replace_commit_info "-1" | \
sed "/^\s*$/d" > "$public_dir/feed.xml"
echo "done."
rm "$last_5_articles" "$last_5_commits"
echo -n "[fugitive] Using last published article as index page... "
cp "$public_dir/`head -1 $articles_sorted`.html" "$public_dir/index.html"
echo "done".