1
0
Fork 0
mirror of https://git.ludikovsky.name/git/fugitive.git synced 2024-06-26 03:45:29 +02:00

added preprocessing possibilities for article (to enable use of Markdown, textile or whatever)

This commit is contained in:
p4bl0 2010-07-24 13:22:39 +02:00
parent 367a72ccb6
commit 5ff0da0a71
3 changed files with 32 additions and 17 deletions

39
README
View file

@ -14,7 +14,7 @@ fugitive README file
<br /> <br />
<code>git clone git://gitorious.org/fugitive/fugitive.git fugitive</code> <code>git clone git://gitorious.org/fugitive/fugitive.git fugitive</code>
<br /> <br />
Then simply go in the newly created directory: <code>cd fugitive</code>, and Then go in the newly created directory: <code>cd fugitive</code>, and
run the build script: <code>./build.sh</code>. run the build script: <code>./build.sh</code>.
<br /> <br />
This will generate an executable file &quot;fugitive&quot;. This will generate an executable file &quot;fugitive&quot;.
@ -35,7 +35,7 @@ fugitive README file
</p> </p>
<h3>Update</h3> <h3>Update</h3>
<p> <p>
Simply run <code>fugitive --install-hooks &lt;dir&gt;</code>.<br /> Run <code>fugitive --install-hooks &lt;dir&gt;</code>.<br />
This will only (re)install fugitive hooks scripts.<br /> This will only (re)install fugitive hooks scripts.<br />
If &lt;dir&gt; isn't specified then the current working directory is used. If &lt;dir&gt; isn't specified then the current working directory is used.
</p> </p>
@ -43,37 +43,44 @@ fugitive README file
<h2>Configuration</h2> <h2>Configuration</h2>
<p> <p>
There are three item in the "fugitive" section of the git config: There are three paths in the &quot;fugitive&quot; section of the git config:
</p> </p>
<ul> <ul>
<li> <li>
"public-dir" is the path to the directory that will contain the generated <em>public-dir</em> is the path to the directory that will contain the
html files. Defautlt value is ".", the root of the git repository. You generated html files. Defautlt value is &quot;.&quot;, the root of the git
could set it to "blog" for instance if you already have a static website repository. You could set it to &quot;blog&quot; for instance if you
under your git repos. already have a static website under your git repos.
</li> </li>
<li> <li>
"articles-dir" is the path where fugitive will look for published articles. <em>articles-dir</em> is the path where fugitive will look for published
Default value is "_articles". This path is relative to the root of the git articles. Default value is &quot;_articles&quot;. This path is relative to
repository, must be in it and must not start with ".". the root of the git repository, must be in it and must not start with
&quot;.&quot;.
</li> </li>
<li> <li>
"templates-dir" is the path where fugitive will look for templates files. <em>templates-dire</em> is the path where fugitive will look for templates
Default value is "_templates". This path is relative to the root of the git files. Default value is &quot;_templates&quot;. This path is relative to
repository, must be in it and must not start with ".". the root of the git repository, must be in it and must not start with
&quot;.&quot;.
</li> </li>
</ul> </ul>
<p> <p>
<strong>NOTE:</strong> You must NOT put a trailing '/' at the end of any of <strong>NOTE:</strong> You must NOT put a trailing '/' at the end of any of
those paths. those paths.
</p> </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 take
the file path as argument and write to stdout.
</p>
<h2>Usage</h2> <h2>Usage</h2>
<h3>General use</h3> <h3>General use</h3>
<p> <p>
Article you want to publish should be file without the .html extension in the Article you want to publish should be file without the .html extension in the
"articles-dir" directory (see CONFIGURATION). <em>articles-dir</em> directory (see CONFIGURATION).
</p> </p>
<p> <p>
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
@ -81,8 +88,8 @@ fugitive README file
</p> </p>
<p> <p>
<strong>/!\ WARNINGS:</strong><br /> <strong>/!\ WARNINGS:</strong><br />
DO NOT CREATE AN ARTICLE FILE NAMED "archives".<br /> DO NOT CREATE AN ARTICLE FILE NAMED &quot;archives&quot;.<br />
DO NOT CREATE AN ARTICLE FILE NAMED "index". DO NOT CREATE AN ARTICLE FILE NAMED &quot;index&quot;.
</p> </p>
<h3>Template system</h3> <h3>Template system</h3>
<p><em>*TODO*</em></p> <p><em>*TODO*</em></p>

View file

@ -34,10 +34,11 @@ fugitive_install() {
echo -n "Creating default directory tree... " echo -n "Creating default directory tree... "
mkdir -p _drafts _articles _templates mkdir -p _drafts _articles _templates
echo "done." echo "done."
echo -n "Adding default directory paths to git config... " echo -n "Adding default directory paths and settings to git config... "
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 "."
git config --add --path fugitive.preproc ""
echo "done." echo "done."
echo -n "Writing default template files... " echo -n "Writing default template files... "
fugitive_write_template > _templates/article.html <<EOF fugitive_write_template > _templates/article.html <<EOF

View file

@ -4,6 +4,7 @@ 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`
articles_dir=`git config --get fugitive.articles-dir` articles_dir=`git config --get fugitive.articles-dir`
preproc=`git config --get fugitive.preproc`
added_files=`git log -1 --name-status --pretty="format:" | grep -E '^A' | \ added_files=`git log -1 --name-status --pretty="format:" | grep -E '^A' | \
cut -f2` cut -f2`
@ -193,6 +194,11 @@ new=$RANDOM.$$
for f in $added_files $new $modified_files; do for f in $added_files $new $modified_files; do
if [ "$f" != "${f#$articles_dir}" ]; then if [ "$f" != "${f#$articles_dir}" ]; then
modification=$((modification + 1)) modification=$((modification + 1))
if [ "$preproc" != "" ]; then
preproc_bak=`tempfile -p "fugitive" -d "$articles_dir"`
mv "$f" "$preproc_bak"
$preproc "$preproc_bak" > "$f"
fi
art="${f#$articles_dir/}" art="${f#$articles_dir/}"
echo -n "[fugitive] Generating $public_dir/$art.html from $f... " echo -n "[fugitive] Generating $public_dir/$art.html from $f... "
cat "$templates_dir/article.html" | \ cat "$templates_dir/article.html" | \
@ -207,6 +213,7 @@ for f in $added_files $new $modified_files; do
echo "$art.html" >> .git/info/exclude echo "$art.html" >> .git/info/exclude
echo "done." echo "done."
fi fi
if [ "$preproc" != "" ]; then mv "$preproc_bak" "$f"; fi
fi fi
if [ "$f" = "$new" ]; then new=""; fi if [ "$f" = "$new" ]; then new=""; fi
done done