mirror of
https://git.ludikovsky.name/git/fugitive.git
synced 2024-10-05 15:35:29 +02:00
started to write the template system doc in the README
This commit is contained in:
parent
f71626c7ec
commit
4cd15fad3c
202
README
202
README
|
@ -152,4 +152,206 @@ fugitive: README
|
||||||
Do not create an article file named "index".
|
Do not create an article file named "index".
|
||||||
</p>
|
</p>
|
||||||
<h3 id="templating">Template system</h3>
|
<h3 id="templating">Template system</h3>
|
||||||
|
<p>
|
||||||
|
The better explaination about the templates system is to see what the default
|
||||||
|
templates looks like. But since they do not use all the offered
|
||||||
|
possibilities, here are some more explainations...
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The fugitive template system uses xml preprocessor
|
||||||
|
syntax: <code><?fugitive <em>var</em> ?></code> is rendered as the
|
||||||
|
value of <em>var</em>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
In addition to that, there are a conditional and a foreach loop constructs,
|
||||||
|
plus an include directive.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The syntax of the include directive is <code><?fugitive
|
||||||
|
include:<em>file</em> ?></code> where <em>file</em> is relative to
|
||||||
|
the <em>templates-dir</em> directory
|
||||||
|
(see <a href="#config">configuration</a>). The includes are processed before
|
||||||
|
anything else.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The foreach loop construct is specific to the "archives.html" and
|
||||||
|
"feed.xml" templates and will therefore be described at the same
|
||||||
|
time. Where available, the loops are processed right after the includes.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The syntax of the conditional construct is as follow:
|
||||||
|
</p>
|
||||||
|
<pre><<span class="keyword">?fugitive</span> ifset:<em>var</em> ?>
|
||||||
|
Template code which is ignored if var value is empty, and
|
||||||
|
which typically includes <<span class="function-name">code</span>><<span class="keyword">?fugitive</span> <em>var</em> ?></<span class="function-name">code</span>>.
|
||||||
|
<<span class="keyword">?fugitive</span> endifset:<em>var</em> ?></pre>
|
||||||
|
<p class="note">
|
||||||
|
Not every variables can be used in the conditional construct, it is indicated
|
||||||
|
in the description od those which can't.
|
||||||
|
</p>
|
||||||
|
<p>The following variables are available everywhere:</p>
|
||||||
|
<dl>
|
||||||
|
<dt>page_title</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is "archives" in the archives.html template,
|
||||||
|
"feed" in the feed.xml template, or the article title in the
|
||||||
|
article.html template.
|
||||||
|
</dd>
|
||||||
|
<dt>blog_url</dt>
|
||||||
|
<dd>
|
||||||
|
the <em>blog-url</em> value in the "fugitive" section of the git
|
||||||
|
configuration (see <a href="#config">configuration</a>).
|
||||||
|
</dd>
|
||||||
|
<dt>commit_Hash</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the hash corresponding to the last commit that provoked the
|
||||||
|
(re)generation of the file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_hash</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the short hash (the seven first digit of the hash)
|
||||||
|
corresponding to the last commit that provoked the (re)generation of the
|
||||||
|
file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_author</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the name of the author of the last commit that provoked the
|
||||||
|
(re)generation of the file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_author_email</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the email of the author of the last commit that provoked the
|
||||||
|
(re)generation of the file (with '@' replaced by "[at]" and '.'
|
||||||
|
replaced by "(dot)").
|
||||||
|
</dd>
|
||||||
|
<dt>commit_datetime</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the date and time of the last commit that provoked the
|
||||||
|
(re)generation of the file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_date</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the date of the last commit that provoked the (re)generation
|
||||||
|
of the file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_time</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the time of the last commit that provoked the (re)generation
|
||||||
|
of the file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_timestamp</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the unix timestamp of the last commit that provoked the
|
||||||
|
(re)generation of the file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_subject</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the subject (first line of the commit message) of the last
|
||||||
|
commit that provoked the (re)generation of the file.
|
||||||
|
</dd>
|
||||||
|
<dt>commit_body</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the body (the rest of the commit message) of the last commit
|
||||||
|
that provoked the (re)generation of the file. <strong>This variable can't
|
||||||
|
be used in the conditional construct.</strong>
|
||||||
|
</dd>
|
||||||
|
<dt>commit_slug</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the subject of the last commit that provoked the
|
||||||
|
(re)generation of the file but formatted to be file name friendly.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<h4>Variables specific to the article.html templates:</h4>
|
||||||
|
<dl>
|
||||||
|
<dt>article_title</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the title of the article (the first line of the file).
|
||||||
|
</dd>
|
||||||
|
<dt>article_content</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the content of the article (the rest of the
|
||||||
|
file). <strong>This variable can't be used in the conditional
|
||||||
|
construct.</strong>
|
||||||
|
</dd>
|
||||||
|
<dt>article_file</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the file name of the article (without the .html extension).
|
||||||
|
</dd>
|
||||||
|
<dt>article_cdatetime</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the date and time of the publication of the article (the date
|
||||||
|
of the commit which added the article to the repository in
|
||||||
|
the <em>articles-dir</em> directory
|
||||||
|
(see <a href="#config">configuration</a>)).
|
||||||
|
</dd>
|
||||||
|
<dt>article_cdate</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the date of the publication of the article.
|
||||||
|
</dd>
|
||||||
|
<dt>article_ctime</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the time of the publication of the article.
|
||||||
|
</dd>
|
||||||
|
<dt>article_ctimestamp</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the timestamp of the publication of the article.
|
||||||
|
</dd>
|
||||||
|
<dt>article_mdatetime</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the date and time of the last modification of the article
|
||||||
|
(the date of the last commit which changed the article file).
|
||||||
|
</dd>
|
||||||
|
<dt>article_mdate</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the date of the last modification of the article.
|
||||||
|
</dd>
|
||||||
|
<dt>article_mtime</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the time of the last modification of the article.
|
||||||
|
</dd>
|
||||||
|
<dt>article_mtimestamp</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the timestamp of the last modification of the article.
|
||||||
|
</dd>
|
||||||
|
<dt>article_cauthor</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the author of the commit which added the article to the
|
||||||
|
repository.
|
||||||
|
</dd>
|
||||||
|
<dt>article_cauthor_email</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the email of the author of the commit which added the article
|
||||||
|
to the repository (with '@' replaced by "[at]" and '.' replaced
|
||||||
|
by "(dot)").
|
||||||
|
</dd>
|
||||||
|
<dt>article_mauthor</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the author of the last commit which changed the article file.
|
||||||
|
</dd>
|
||||||
|
<dt>article_mauthor_email</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the email of the author of the last commit which changed the
|
||||||
|
article file (with '@' replaced by "[at]" and '.' replaced by
|
||||||
|
"(dot)").
|
||||||
|
</dd>
|
||||||
|
<dt>article_previous_file</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the file name (without .html extension) of the previous
|
||||||
|
article ordered by publication date.
|
||||||
|
</dd>
|
||||||
|
<dt>article_previous_title</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the title of the previous article ordered by publication date.
|
||||||
|
</dd>
|
||||||
|
<dt>article_next_file</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the file name (without .html extension) of the next article
|
||||||
|
ordered by publication date.
|
||||||
|
</dd>
|
||||||
|
<dt>article_next_title</dt>
|
||||||
|
<dd>
|
||||||
|
Its value is the title of the next article ordered by publication date.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
<h4>foreach loops in archives.html and feed.xml:</h4>
|
||||||
<p><em>*TODO*</em></p>
|
<p><em>*TODO*</em></p>
|
||||||
|
|
|
@ -369,8 +369,10 @@ if [ $modification -gt 0 ]; then
|
||||||
last_5_commits=`mktemp --suffix "-fugitive"`
|
last_5_commits=`mktemp --suffix "-fugitive"`
|
||||||
head -5 "$commits" > "$last_5_commits"
|
head -5 "$commits" > "$last_5_commits"
|
||||||
cat "$templates_dir/feed.xml" | \
|
cat "$templates_dir/feed.xml" | \
|
||||||
|
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" | \
|
||||||
|
replace_str "page_title" "feed" | \
|
||||||
replace_str "blog_url" "$blog_url" | \
|
replace_str "blog_url" "$blog_url" | \
|
||||||
replace_commit_info "-1" | \
|
replace_commit_info "-1" | \
|
||||||
sed "/^\s*$/d" > "$public_dir/feed.xml"
|
sed "/^\s*$/d" > "$public_dir/feed.xml"
|
||||||
|
|
Loading…
Reference in a new issue