mirror of
https://git.ludikovsky.name/git/fugitive.git
synced 2024-09-28 22:25:27 +02:00
now generating rss feed too
This commit is contained in:
parent
dbae9472bd
commit
81fa7bd8b6
88
README
88
README
|
@ -1,12 +1,12 @@
|
||||||
fugitive README file
|
fugitive README file
|
||||||
|
|
||||||
<h2>Info</h2>
|
<h2 id="info">Info</h2>
|
||||||
<p>
|
<p>
|
||||||
fugitive is a blog engine running on top of git using hooks to generate
|
fugitive is a blog engine running on top of git using hooks to generate
|
||||||
static html pages and thus having only git as dependency.
|
static html pages and thus having only git as dependency.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2>Install</h2>
|
<h2 id="install">Install</h2>
|
||||||
|
|
||||||
<h3>Build</h3>
|
<h3>Build</h3>
|
||||||
<p>
|
<p>
|
||||||
|
@ -28,9 +28,14 @@ fugitive README file
|
||||||
<dir>.
|
<dir>.
|
||||||
<br />
|
<br />
|
||||||
If <dir> isn't specified then the current working directory is used.
|
If <dir> isn't specified then the current working directory is used.
|
||||||
<p>
|
</p>
|
||||||
<p>
|
<p class="important">
|
||||||
<strong>NOTE:</strong> You need to use the same process to install any remote
|
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.
|
repository where you'd like to push your blog.
|
||||||
</p>
|
</p>
|
||||||
<h3>Update</h3>
|
<h3>Update</h3>
|
||||||
|
@ -40,42 +45,52 @@ fugitive README file
|
||||||
If <dir> isn't specified then the current working directory is used.
|
If <dir> isn't specified then the current working directory is used.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2>Configuration</h2>
|
<h2 id="config">Configuration</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
There are three paths in the "fugitive" section of the git config:
|
All this settings are in the "fugitive" 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>
|
</p>
|
||||||
<ul>
|
<dl>
|
||||||
<li>
|
<dt>blog-url</dt>
|
||||||
<em>public-dir</em> is the path to the directory that will contain the
|
<dd>
|
||||||
generated html files. Defautlt value is ".", the root of the git
|
This is the public url of the generated blog. <strong>You need to set
|
||||||
repository. You could set it to "blog" for instance if you
|
it</strong> as soon as possible since it's required for the RSS feed (and
|
||||||
already have a static website under your git repos.
|
used in the default template's footer).
|
||||||
</li>
|
</dd>
|
||||||
<li>
|
<dt>public-dir</dt>
|
||||||
<em>articles-dir</em> is the path where fugitive will look for published
|
<dd>
|
||||||
articles. Default value is "_articles". This path is relative to
|
This is the path to the directory that will contain the generated html
|
||||||
the root of the git repository, must be in it and must not start with
|
files. Defautlt value is ".", the root of the git repository. You
|
||||||
".".
|
could set it to "blog" for instance if you already have a static
|
||||||
</li>
|
website under your git repos.
|
||||||
<li>
|
</dd>
|
||||||
<em>templates-dire</em> is the path where fugitive will look for templates
|
<dt>articles-dir</dt>
|
||||||
files. Default value is "_templates". This path is relative to
|
<dd>
|
||||||
the root of the git repository, must be in it and must not start with
|
This is the path where fugitive will look for published articles. Default
|
||||||
".".
|
value is "_articles". This path is relative to the root of the
|
||||||
</li>
|
git repository, must be in it and must not start with ".".
|
||||||
</ul>
|
</dd>
|
||||||
<p>
|
<dt>templates-dire</dt>
|
||||||
<strong>NOTE:</strong> You must NOT put a trailing '/' at the end of any of
|
<dd>
|
||||||
those paths.
|
This is the path where fugitive will look for templates files. Default
|
||||||
</p>
|
value is "_templates". This path is relative to the root of the
|
||||||
<p>
|
git repository, must be in it and must not start with ".".
|
||||||
|
</dd>
|
||||||
|
<dt>preproc</dt>
|
||||||
|
<dd>
|
||||||
If you want your article to be preprocessed by an external tool (markdown,
|
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
|
textile...) you need to set <em>preproc</em> to a command line that will
|
||||||
on stdin and write to stdout.
|
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>
|
</p>
|
||||||
|
|
||||||
<h2>Usage</h2>
|
<h2 id="usage">Usage</h2>
|
||||||
|
|
||||||
<h3>General use</h3>
|
<h3>General use</h3>
|
||||||
<p>
|
<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 first line of the file will be used as title and the rest of the file as
|
||||||
the content.
|
the content.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p class="warning">
|
||||||
<strong>/!\ WARNINGS:</strong><br />
|
|
||||||
DO NOT CREATE AN ARTICLE FILE NAMED "archives".<br />
|
DO NOT CREATE AN ARTICLE FILE NAMED "archives".<br />
|
||||||
DO NOT CREATE AN ARTICLE FILE NAMED "index".
|
DO NOT CREATE AN ARTICLE FILE NAMED "index".
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<footer>
|
<footer>
|
||||||
<p>
|
<p>
|
||||||
<a href="http://www.gnu.org/copyleft/copyleft.html">copyleft</a>
|
<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 ?>
|
||||||
—
|
—
|
||||||
powered by <a href="http://gitorious.org/fugitive">fugitive</a>
|
powered by <a href="http://gitorious.org/fugitive">fugitive</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
23
default-files/feed.xml
Normal file
23
default-files/feed.xml
Normal 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>
|
|
@ -1,13 +0,0 @@
|
||||||
<footer>
|
|
||||||
<p>
|
|
||||||
<a href="http://www.gnu.org/copyleft/copyleft.html">copyleft</a>
|
|
||||||
<?fugitive-install name ?> <?fugitive-install year ?>
|
|
||||||
—
|
|
||||||
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>
|
|
|
@ -124,6 +124,29 @@ article > div p {
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
text-indent: 2em;
|
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 {
|
article > div ul {
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
padding: 0 0 0 3em;
|
padding: 0 0 0 3em;
|
||||||
|
|
|
@ -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>
|
|
|
@ -6,6 +6,7 @@
|
||||||
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=utf-8" />
|
<meta http-equiv="Content-type" content="application/xhtml+xml; charset=utf-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" />
|
||||||
|
<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="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" />
|
||||||
|
|
32
install.sh
32
install.sh
|
@ -39,6 +39,7 @@ fugitive_install() {
|
||||||
mkdir -p _drafts _articles _templates
|
mkdir -p _drafts _articles _templates
|
||||||
echo "done."
|
echo "done."
|
||||||
echo -n "Adding default directory paths and settings to git config... "
|
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.templates-dir "_templates"
|
||||||
git config --add --path fugitive.articles-dir "_articles"
|
git config --add --path fugitive.articles-dir "_articles"
|
||||||
git config --add --path fugitive.public-dir "."
|
git config --add --path fugitive.public-dir "."
|
||||||
|
@ -51,16 +52,14 @@ EOF
|
||||||
fugitive_write_template > _templates/archives.html <<EOF
|
fugitive_write_template > _templates/archives.html <<EOF
|
||||||
#INCLUDE:default-files/archives.html#
|
#INCLUDE:default-files/archives.html#
|
||||||
EOF
|
EOF
|
||||||
fugitive_write_template > _templates/nav-header.html <<EOF
|
fugitive_write_template > _templates/top.html <<EOF
|
||||||
#INCLUDE:default-files/nav-header.html#
|
#INCLUDE:default-files/top.html#
|
||||||
EOF
|
EOF
|
||||||
fugitive_write_template > _templates/footer.html <<EOF
|
fugitive_write_template > _templates/bottom.html <<EOF
|
||||||
#INCLUDE:default-files/footer.html#
|
#INCLUDE:default-files/bottom.html#
|
||||||
EOF
|
EOF
|
||||||
echo "done."
|
fugitive_write_template > _templates/feed.xml <<EOF
|
||||||
echo -n "Writing dummy article (README)... "
|
#INCLUDE:default-files/feed.xml#
|
||||||
(base64 -d | gunzip) > _articles/README <<EOF
|
|
||||||
#INCLUDE:README#
|
|
||||||
EOF
|
EOF
|
||||||
echo "done."
|
echo "done."
|
||||||
echo -n "Writing default css files... "
|
echo -n "Writing default css files... "
|
||||||
|
@ -72,15 +71,22 @@ EOF
|
||||||
EOF
|
EOF
|
||||||
echo "done."
|
echo "done."
|
||||||
fugitive_install_hooks
|
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 -n "Preventing git to track temporary and generated files... "
|
||||||
echo "*~\nindex.html\narchives.html" > .git/info/exclude
|
echo "*~\nindex.html\narchives.html" > .git/info/exclude
|
||||||
echo "done."
|
echo "done."
|
||||||
echo "Importing files into git repository... "
|
echo "Writing dummy article (README) and adding it to the repos... "
|
||||||
git add _templates/* fugitive.css print.css >/dev/null
|
(base64 -d | gunzip) > _articles/README <<EOF
|
||||||
git commit -m "fugitive inital import" >/dev/null
|
#INCLUDE:README#
|
||||||
echo "First import finished."
|
EOF
|
||||||
|
git add _articles/README
|
||||||
|
git ci -m "fugitive fresh install" >/dev/null
|
||||||
|
echo "done."
|
||||||
cd - >/dev/null
|
cd - >/dev/null
|
||||||
echo 'Installation complete!'
|
echo 'Installation almost complete, please visit your blog :-).'
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
blog_url=`git config --get fugitive.blog-url`
|
||||||
public_dir=`git config --get fugitive.public-dir`
|
public_dir=`git config --get fugitive.public-dir`
|
||||||
if [ ! -d "$public_dir" ]; then mkdir -p "$public_dir"; fi
|
if [ ! -d "$public_dir" ]; then mkdir -p "$public_dir"; fi
|
||||||
templates_dir=`git config --get fugitive.templates-dir`
|
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`
|
cut -f2`
|
||||||
generated_files=`tempfile -p "fugitive"`
|
generated_files=`tempfile -p "fugitive"`
|
||||||
|
|
||||||
sanit_mail() {
|
|
||||||
sed "s/@/[at]/;s/\./(dot)/"
|
|
||||||
}
|
|
||||||
|
|
||||||
articles_sorted=`tempfile -p "fugitive"`
|
articles_sorted=`tempfile -p "fugitive"`
|
||||||
for f in $articles_dir/*; do
|
for f in $articles_dir/*; do
|
||||||
ts=`git log --format="%at" -- "$f" | tail -1`
|
ts=`git log --format="%at" -- "$f" | tail -1`
|
||||||
|
@ -86,6 +83,10 @@ get_commit_body() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sanit_mail() {
|
||||||
|
sed "s/@/[at]/;s/\./(dot)/"
|
||||||
|
}
|
||||||
|
|
||||||
replace_condition() {
|
replace_condition() {
|
||||||
if [ "$2" = "" ]; then
|
if [ "$2" = "" ]; then
|
||||||
sed "s/<?fugitive\s\+\(end\)\?ifset:$1\s*?>/\n\0\n/g" | \
|
sed "s/<?fugitive\s\+\(end\)\?ifset:$1\s*?>/\n\0\n/g" | \
|
||||||
|
@ -190,6 +191,7 @@ replace_article_info() {
|
||||||
article_next_file=`get_article_next_file "$1"`
|
article_next_file=`get_article_next_file "$1"`
|
||||||
article_next_title=`get_article_title "$article_next_file"`
|
article_next_title=`get_article_title "$article_next_file"`
|
||||||
|
|
||||||
|
replace_file "article_content" "`get_article_content \"$1\"`" | \
|
||||||
replace_str "article_file" "$1" | \
|
replace_str "article_file" "$1" | \
|
||||||
replace_str "article_title" "$article_title" | \
|
replace_str "article_title" "$article_title" | \
|
||||||
replace_str "article_cdatetime" "$article_cdatetime" | \
|
replace_str "article_cdatetime" "$article_cdatetime" | \
|
||||||
|
@ -264,9 +266,9 @@ generate_article() {
|
||||||
fi
|
fi
|
||||||
art="${1#$articles_dir/}"
|
art="${1#$articles_dir/}"
|
||||||
cat "$templates_dir/article.html" | \
|
cat "$templates_dir/article.html" | \
|
||||||
replace_file "article_content" "`get_article_content \"$art\"`" | \
|
|
||||||
replace_includes | \
|
replace_includes | \
|
||||||
replace_str "page_title" "`get_article_title \"$art\"`" | \
|
replace_str "page_title" "`get_article_title \"$art\"`" | \
|
||||||
|
replace_str "blog_url" "$blog_url" | \
|
||||||
replace_commit_info "-1" | \
|
replace_commit_info "-1" | \
|
||||||
replace_article_info "$art" | \
|
replace_article_info "$art" | \
|
||||||
sed "/^\s*$/d" > "$public_dir/$art.html"
|
sed "/^\s*$/d" > "$public_dir/$art.html"
|
||||||
|
@ -341,10 +343,23 @@ if [ $modification -gt 0 ]; then
|
||||||
replace_foreach "commit" "$commits" | \
|
replace_foreach "commit" "$commits" | \
|
||||||
replace_empty_article_info | \
|
replace_empty_article_info | \
|
||||||
replace_str "page_title" "archives" | \
|
replace_str "page_title" "archives" | \
|
||||||
|
replace_str "blog_url" "$blog_url" | \
|
||||||
replace_commit_info "-1" | \
|
replace_commit_info "-1" | \
|
||||||
sed "/^\s*$/d" > "$public_dir/archives.html"
|
sed "/^\s*$/d" > "$public_dir/archives.html"
|
||||||
echo "done."
|
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... "
|
echo -n "[fugitive] Using last published article as index page... "
|
||||||
cp "$public_dir/`head -1 $articles_sorted`.html" "$public_dir/index.html"
|
cp "$public_dir/`head -1 $articles_sorted`.html" "$public_dir/index.html"
|
||||||
echo "done".
|
echo "done".
|
||||||
|
|
Loading…
Reference in a new issue