mirror of
https://git.ludikovsky.name/git/fugitive.git
synced 2024-09-28 22:25:27 +02:00
design + added article metadata template tags
This commit is contained in:
parent
dc6e418184
commit
1a0583755b
|
@ -21,25 +21,28 @@
|
|||
</nav>
|
||||
<header>
|
||||
<h1>p4bl0's blog</h1>
|
||||
<q>the blog where every number is written in base 10.</q>
|
||||
<q>the blog where every number is written in base 10</q>
|
||||
</header>
|
||||
<div id="content">
|
||||
<article>
|
||||
<header>
|
||||
<h2><?fugitive article_title ?></h2>
|
||||
</header>
|
||||
<footer>
|
||||
by <?fugitive commit_author ?>, on
|
||||
<time datetime="<?fugitive commit_datetime ?>">
|
||||
<?fugitive commit_date ?> at
|
||||
<?fugitive commit_time ?></time>.
|
||||
by <?fugitive article_cauthor ?>, on
|
||||
<time datetime="<?fugitive article_cdatetime ?>">
|
||||
<?fugitive article_cdate ?> at <?fugitive article_ctime ?>
|
||||
</time><br />
|
||||
<small>
|
||||
last update by <?fugitive article_mauthor ?>, on
|
||||
<time datetime="<?fugitive article_mdatetime ?>">
|
||||
<?fugitive article_mdate ?> at <?fugitive article_mtime ?>
|
||||
</time>
|
||||
</small>
|
||||
</footer>
|
||||
</header>
|
||||
<div>
|
||||
<?fugitive article_content ?>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<p>
|
||||
<a href="http://www.gnu.org/copyleft/copyleft.html">copyleft</a>
|
||||
|
@ -51,9 +54,9 @@
|
|||
hosted at <a href="http://berthold.shebang.ws/">berthold</a>'s
|
||||
</p>
|
||||
<p>
|
||||
last commit was <?fugitive commit_hash ?>,
|
||||
at <time><?fugitive commit_datetime ?></time>,
|
||||
<q><?fugitive commit_subject ?></q>.
|
||||
last build was <?fugitive commit_hash ?>,
|
||||
<time><?fugitive commit_datetime ?></time>,
|
||||
<q><?fugitive commit_subject ?></q>
|
||||
</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
|
235
src/fugitive.css
Normal file
235
src/fugitive.css
Normal file
|
@ -0,0 +1,235 @@
|
|||
* { margin: 0; padding: 0; }
|
||||
html, body {
|
||||
background-color: #fff;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: monospace;
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
color: #333;
|
||||
}
|
||||
#container {
|
||||
padding: 0 1em;
|
||||
margin: 0 auto;
|
||||
width: 51%;
|
||||
min-width: 480px;
|
||||
}
|
||||
nav {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0.3em 1em;
|
||||
border: 1px solid #ccc;
|
||||
border-top: 0;
|
||||
background: #f2f2f2;
|
||||
color: #aaa;
|
||||
font-size: 1.3em;
|
||||
text-align: left;
|
||||
}
|
||||
nav ul { padding: 0; margin: 0; }
|
||||
nav ul li { display: inline; }
|
||||
nav ul li:before { content: " — "; }
|
||||
nav ul li:first-child:before { content: ""; }
|
||||
nav ul li a {
|
||||
color: #aaa;
|
||||
text-decoration: none;
|
||||
}
|
||||
nav ul li a:hover { color: #888; }
|
||||
header {
|
||||
display: block;
|
||||
margin: 1em 0;
|
||||
padding: 1em;
|
||||
border: 4px double #ccc;
|
||||
}
|
||||
header h1 {
|
||||
margin: 0 0 0.3em 0;
|
||||
madding: 0;
|
||||
color:
|
||||
font-size: 2em;
|
||||
font-weight: normal;
|
||||
}
|
||||
header q {
|
||||
font-size: 1.2em;
|
||||
font-style: italic;
|
||||
}
|
||||
article {
|
||||
display: block;
|
||||
text-align: left;
|
||||
counter-reset: code;
|
||||
counter-reset: figure;
|
||||
}
|
||||
article header {
|
||||
display: block;
|
||||
margin: 2em 0 0 0;
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
border-bottom: 1px dashed #ccc;
|
||||
}
|
||||
article header h2 {
|
||||
margin: 0;
|
||||
padding: 0 0 0.2em 0;
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
article footer {
|
||||
display: block;
|
||||
margin: 0.3em 0 2em 0;
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
color: #888;
|
||||
font-size: 1em;
|
||||
text-align: right;
|
||||
}
|
||||
article > div {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 1.5em;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
article > div p:first-child:first-letter {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
article > div p {
|
||||
margin: 1em 0;
|
||||
text-indent: 2em;
|
||||
}
|
||||
article > div ul {
|
||||
margin: 1em 0;
|
||||
padding: 0 0 0 3em;
|
||||
}
|
||||
article > div ul li {
|
||||
margin: 0 0 0.2em 0;
|
||||
padding: 0 0 0 0.5em;
|
||||
list-style-position: outside;
|
||||
list-style-type: circle;
|
||||
}
|
||||
article > div dl {
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
}
|
||||
article > div dl dt {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
article > div dl dd {
|
||||
margin: 0 0 0.3em 0;
|
||||
padding: 0 0 0 2em;
|
||||
}
|
||||
article > div blockquote {
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
padding-left: 2em;
|
||||
background: #f2f2f2;
|
||||
border-left: 0.1em solid #ccc;
|
||||
}
|
||||
article > div blockquote p {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
article > div a:hover { text-decoration: underline; }
|
||||
article > div a:visited { color: #048; }
|
||||
article > div code {
|
||||
color: #ccc;
|
||||
background-color: #333;
|
||||
padding: 0 0.2em;
|
||||
}
|
||||
article > div pre:before {
|
||||
display: block;
|
||||
padding: 0 0.5em;
|
||||
font-size: 0.8em;
|
||||
line-height: 1em;
|
||||
background-color: #444;
|
||||
content: "code " counter(code) ":";
|
||||
counter-increment: code;
|
||||
}
|
||||
article > div pre {
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
overflow: auto;
|
||||
color: #ccc;
|
||||
background-color: #333;
|
||||
max-height: 420px;
|
||||
}
|
||||
article > div pre .comment {
|
||||
color: #888;
|
||||
}
|
||||
article > div pre .comment-delimiter {
|
||||
color: #888;
|
||||
}
|
||||
article > div pre .constant {
|
||||
color: #d0d;
|
||||
}
|
||||
article > div pre .function-name {
|
||||
color: #27d;
|
||||
}
|
||||
article > div pre .keyword {
|
||||
color: #dd0;
|
||||
}
|
||||
article > div pre .preprocessor {
|
||||
color: #9c3;
|
||||
}
|
||||
article > div pre .string {
|
||||
color: #3af;
|
||||
}
|
||||
article > div pre .type {
|
||||
color: #fa0;
|
||||
}
|
||||
article > div pre .variable-name {
|
||||
color: #0b0;
|
||||
}
|
||||
article > div a {
|
||||
color: #08f;
|
||||
text-decoration: none;
|
||||
}
|
||||
article > div figure {
|
||||
display: block;
|
||||
margin: 1em 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
article > div figure figcaption {
|
||||
display: block;
|
||||
}
|
||||
article > div figure figcaption:before {
|
||||
display: inline;
|
||||
content: "figure " counter(figure) ":";
|
||||
counter-increment: figure;
|
||||
}
|
||||
article > div .left {
|
||||
float: left;
|
||||
margin: 0 1em 0.5em 0;
|
||||
}
|
||||
article > div .right {
|
||||
float: right;
|
||||
margin: 0 0 0.5em 1em;
|
||||
}
|
||||
article > div .center {
|
||||
text-align: center;
|
||||
}
|
||||
article > div hr {
|
||||
margin: 1.5em auto;
|
||||
padding: 0;
|
||||
height: 1px;
|
||||
width: 80%;
|
||||
border: none;
|
||||
background-color: #aaa;
|
||||
}
|
||||
footer {
|
||||
display: block;
|
||||
margin: 3em 0 0 0;
|
||||
padding: 1em;
|
||||
border-top: 1px dotted #aaa;
|
||||
color: #888;
|
||||
font-size: 0.9em;
|
||||
clear: both;
|
||||
}
|
||||
footer p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
footer p a {
|
||||
color: #666;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
|
@ -15,10 +15,14 @@ deleted_files=`git log -1 --name-status --pretty="format:" | grep -E '^D' | \
|
|||
last_published_article=`git log --name-status --pretty="format:" | \
|
||||
grep -E '^A' | cut -f2 | grep -E '^$articles_dir' | head -1`
|
||||
|
||||
sanit_mail() {
|
||||
sed "s/@/[at]/;s/\./(dot)/"
|
||||
}
|
||||
|
||||
commit_Hash=`git log -1 --format="%H"`
|
||||
commit_hash=`git log -1 --format="%h"`
|
||||
commit_author=`git log -1 --format="%an"`
|
||||
commit_author_email=`git log -1 --format="%ae" | sed "s/@/[at]/;s/\./(dot)/"`
|
||||
commit_author_email=`git log -1 --format="%ae" | sanit_mail`
|
||||
commit_datetime=`git log -1 --format="%ai"`
|
||||
commit_date=`git log -1 --format="%ad" --date="short"`
|
||||
commit_time=`git log -1 --format="%ai" | cut -d' ' -f2`
|
||||
|
@ -32,10 +36,13 @@ commit_body() {
|
|||
echo "$tmp"
|
||||
}
|
||||
|
||||
article_get_title() {
|
||||
article_info() {
|
||||
git log --format="$1" -- "$2"
|
||||
}
|
||||
article_title() {
|
||||
head -1 "$1"
|
||||
}
|
||||
article_get_content() {
|
||||
article_content() {
|
||||
tmp=`tempfile -p "fugitive"`
|
||||
tail -n+2 "$1" > "$tmp"
|
||||
(sleep 5 && rm -f "$tmp") & # this message will self-destruct in 5s
|
||||
|
@ -55,11 +62,38 @@ replace_commit_info() {
|
|||
replace_var_by_string "commit_hash" "$commit_hash" | \
|
||||
replace_var_by_string "commit_author" "$commit_author" | \
|
||||
replace_var_by_string "commit_author_email" "$commit_author_email" | \
|
||||
replace_var_by_string "commit_datetime" "$commit_datetime" | \
|
||||
replace_var_by_string "commit_date" "$commit_date" | \
|
||||
replace_var_by_string "commit_time" "$commit_time" | \
|
||||
replace_var_by_string "commit_timestamp" "$commit_timestamp" | \
|
||||
replace_var_by_string "commit_subject" "$commit_subject" | \
|
||||
replace_var_by_string "commit_slug" "$commit_slug" | \
|
||||
replace_var_by_file "commit_body" "`commit_body`"
|
||||
}
|
||||
replace_article_info() {
|
||||
cdt=`article_info "%ai" "$1" | tail -1`
|
||||
mdt=`article_info "%ai" "$1" | head -1`
|
||||
replace_var_by_file "article_content" "`article_content \"$1\"`" | \
|
||||
replace_var_by_string "article_title" "`article_title \"$1\"`" | \
|
||||
replace_var_by_string "article_cdatetime" "$cdt" | \
|
||||
replace_var_by_string "article_cdate" "`echo $cdt | cut -d' ' -f1`" | \
|
||||
replace_var_by_string "article_ctime" "`echo $cdt | cut -d' ' -f2`" | \
|
||||
replace_var_by_string "article_ctimestamp" \
|
||||
"`article_info \"%at\" \"$1\" | tail -1`" | \
|
||||
replace_var_by_string "article_mdatetime" "$mdt" | \
|
||||
replace_var_by_string "article_mdate" "`echo $mdt | cut -d' ' -f1`" | \
|
||||
replace_var_by_string "article_mtime" "`echo $mdt | cut -d' ' -f2`" | \
|
||||
replace_var_by_string "article_mtimestamp" \
|
||||
"`article_info \"%at\" \"$1\" | head -1`" | \
|
||||
replace_var_by_string "article_cauthor" \
|
||||
"`article_info \"%an\" \"$1\" | tail -1`" | \
|
||||
replace_var_by_string "article_cauthor_email" \
|
||||
"`article_info \"%ae\" \"$1\" | tail -1 | sanit_mail`" | \
|
||||
replace_var_by_string "article_mauthor" \
|
||||
"`article_info \"%an\" \"$1\" | head -1`" | \
|
||||
replace_var_by_string "article_mauthor_email" \
|
||||
"`article_info \"%ae\" \"$1\" | head -1 | sanit_mail`"
|
||||
}
|
||||
|
||||
for f in $deleted_files; do
|
||||
if [ "$f" != "${f#$articles_dir}" ]; then
|
||||
|
@ -74,8 +108,7 @@ for f in $added_files $modified_files; do
|
|||
echo -n "Generating $public_dir/${f#$articles_dir/}.html from $f... "
|
||||
cat $templates_dir/article.html | \
|
||||
replace_commit_info | \
|
||||
replace_var_by_string "article_title" "`article_get_title \"$f\"`" | \
|
||||
replace_var_by_file "article_content" "`article_get_content \"$f\"`" | \
|
||||
replace_article_info "$f" | \
|
||||
cat > $public_dir/${f#$articles_dir/}.html
|
||||
echo "done."
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue