Switch to a template-based build

This commit is contained in:
~lucidiot 2021-10-24 17:52:45 +02:00
parent 75d903cf03
commit e6f3bdbfb5
5 changed files with 88 additions and 27 deletions

View File

@ -1,24 +1,24 @@
#!/bin/bash -e
shopt -s globstar
include_after=$(mktemp "/tmp/$USER.XXXXXXXXXX")
tree_output=$(mktemp "/tmp/$USER.XXXXXXXXXX")
tree_file=$(mktemp "/tmp/$USER.XXXXXXXXXX")
trap "rm \"$include_after\" \"$tree_output\" \"$tree_file\"" EXIT
trap "rm \"$tree_output\" \"$tree_file\"" EXIT
# Preprocess include-after.html
sed "s/{{ now }}/$(date -Iseconds)/g;s/{{ generator }}/$(pandoc --version | head -n1)/g" include-after.html > "$include_after"
# Variables included in the pandoc template
now="$(date -Iseconds)"
generator="$(pandoc --version | head -n1)"
function convert {
pandoc \
--read markdown \
--write html \
--standalone \
--include-in-header include-header.html \
--include-before-body include-before.html \
--include-after-body "$include_after" \
--template template.html \
--highlight-style zenburn \
--css "/~$USER/theme.css" \
--variable generator="$generator" \
--variable now="$now" \
-o "$2" \
"$1"
chmod 644 "$2"

View File

@ -1,8 +0,0 @@
<hr />
<p>
<a href="https://creativecommons.org/licenses/by/4.0/" target="_blank">
<img src="/~lucidiot/img/cc.gif" style="float: right" alt="Licensed under Creative Commons Attribution 4.0 International" title="Licensed under Creative Commons Attribution 4.0 International" />
</a>
<em>Generated on {{ now }} using {{ generator }}</em>
</p>
</div>

View File

@ -1,10 +0,0 @@
<div id="meta-header">
<div id="meta-header-links">
<a href="https://tilde.town/~lucidiot/"><img src="/~lucidiot/img/town.gif" alt="" /> town</a>
<a href="https://breadpunk.club/~lucitoast/"><img src="/~lucidiot/img/bread.gif" alt="" /> breadpunk</a>
<a href="https://envs.net/~lucidiot/"><img src="/~lucidiot/img/envs.gif" alt="" /> <strong>envs</strong></a>
<a href="https://brainshit.fr/"><img src="/~lucidiot/img/brainshit.gif" alt="" /> brainshit</a>
</div>
<p>lucidiot's cybrecluster</p>
</div>
<div id="main">

View File

@ -1,2 +0,0 @@
<link rel="shortcut icon" type="image/x-icon" href="/~lucidiot/img/favicon.ico" />
<link rel="alternate" type="application/rss+xml" href="/~lucidiot/rss.xml" title="latest articles" />

81
template.html Normal file
View File

@ -0,0 +1,81 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>
<head>
<meta charset="utf-8" />
<meta name="generator" content="$generator$" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
$for(author-meta)$
<meta name="author" content="$author-meta$" />
$endfor$
$if(date-meta)$
<meta name="dcterms.date" content="$date-meta$" />
$endif$
$if(keywords)$
<meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
$endif$
<title>$if(title-prefix)$$title-prefix$ $endif$$pagetitle$</title>
<style>
$styles.html()$
</style>
$for(css)$
<link rel="stylesheet" href="$css$" />
$endfor$
$if(math)$
$math$
$endif$
<link rel="shortcut icon" type="image/x-icon" href="/~lucidiot/img/favicon.ico" />
<link rel="alternate" type="application/rss+xml" href="/~lucidiot/rss.xml" title="latest articles" />
$for(header-includes)$
$header-includes$
$endfor$
</head>
<body>
<div id="meta-header">
<div id="meta-header-links">
<a href="https://tilde.town/~lucidiot/"><img src="/~lucidiot/img/town.gif" alt="" /> town</a>
<a href="https://breadpunk.club/~lucitoast/"><img src="/~lucidiot/img/bread.gif" alt="" /> breadpunk</a>
<a href="https://envs.net/~lucidiot/"><img src="/~lucidiot/img/envs.gif" alt="" /> <strong>envs</strong></a>
<a href="https://brainshit.fr/"><img src="/~lucidiot/img/brainshit.gif" alt="" /> brainshit</a>
</div>
<p>lucidiot's cybrecluster</p>
</div>
<div id="main">
$for(include-before)$
$include-before$
$endfor$
$if(title)$
<header id="title-block-header">
<h1 class="title">$title$</h1>
$if(subtitle)$
<p class="subtitle">$subtitle$</p>
$endif$
$for(author)$
<p class="author">$author$</p>
$endfor$
$if(date)$
<p class="date">$date$</p>
$endif$
</header>
$endif$
$if(toc)$
<nav id="$idprefix$TOC" role="doc-toc">
$if(toc-title)$
<h2 id="$idprefix$toc-title">$toc-title$</h2>
$endif$
$table-of-contents$
</nav>
$endif$
$body$
$for(include-after)$
$include-after$
$endfor$
<hr />
<p>
<a href="https://creativecommons.org/licenses/by/4.0/" target="_blank">
<img src="/~lucidiot/img/cc.gif" style="float: right" alt="Licensed under Creative Commons Attribution 4.0 International" title="Licensed under Creative Commons Attribution 4.0 International" />
</a>
<em>Generated on $now$ using $generator$</em>
</p>
</div>
</body>
</html>