summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
Diffstat (limited to 'make')
-rwxr-xr-xmake125
1 files changed, 125 insertions, 0 deletions
diff --git a/make b/make
new file mode 100755
index 0000000..8125bd4
--- /dev/null
+++ b/make
@@ -0,0 +1,125 @@
+#!/usr/bin/env bash
+TITLE="Unorthodox Monolgues"
+AUTHOR="Abigail Kelley"
+EMAIL="UNMONO@MOHIT.UK"
+
+OUTFILE="unmono"
+LANG="en_GB"
+
+# Convert a markdown file to HTML and store it in the OUTFILE
+md2html() {
+ local file=$1
+
+ echo "Building $file..." >&2
+
+ filename_html=$OUTFILE/${file/%.md/.html}
+ filename_pdf=$OUTFILE/${file/%.md/.pdf}
+
+ local args=(
+ "--email-obfuscation=references"
+ "--from=markdown+emoji"
+ "--metadata=lang:$LANG"
+ "--shift-heading-level-by=-1"
+ "--toc-depth=4"
+ )
+
+ local args_html=(
+ "--css=static/style.css"
+ "--css=static/document.css"
+ "--include-before-body=header.html"
+ "--include-in-header=headerlinks.html"
+ "--table-of-contents"
+ )
+
+ local args_pdf=(
+ "--pdf-engine=xelatex"
+ )
+
+ # args+=("--citeproc") # Citations
+ # args+=("--mathjax") # Mathematical rendering
+
+ # args+=("--include-after-body=$goatcounter")
+ # args+=("--include-in-header=$favicon")
+
+ if [[ $file == ????-??-??-* ]]; then
+ args+=("--metadata=date:$(fmtdate ${file:0:10})")
+ fi
+
+ if [[ $file == 'index.md' ]]; then
+ args+=("--metadata=pagetitle:$TITLE")
+ fi
+
+ if [[ $file -nt $filename_html ]]; then
+ pandoc "${args[@]}" "${args_html[@]}" -t html \
+ --output=$OUTFILE/${file/%.md/.html} "$file" || echo "error while converting $file";
+ pandoc "${args[@]}" "${args_pdf[@]}" -t pdf \
+ --output=$OUTFILE/${file/%.md/.pdf} "$file" || echo "error while converting $file";
+ fi
+}
+
+extracttitle() {
+ local file=$1
+ sed -n '/^# /{s///p;q}' "$file"
+}
+
+extractauthor() {
+ grep "author" $f | sed 1q | cut -d":" -f 2
+}
+
+fmtdate() {
+ date --date="$1" "+%d %b %Y"
+}
+
+# Build all pages
+build() {
+
+ echo "./make --------------------------------------------------"
+ echo " Blog builder"
+ echo " Written by Mohit Agarwal"
+ echo " FOR INTERNAL USE ONLY"
+ echo "---------------------------------------------------------"
+
+ echo ""
+ echo "TITLE $TITLE"
+
+
+ # Build index file and convert posts
+ echo ""
+ echo "Building index.html and converting posts"
+ {
+ echo '<!DOCTYPE html>'
+ echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en_GB" xml:lang="en_GB">'
+ echo '<link rel="stylesheet" href="static/style.css">'
+ echo '<link rel="stylesheet" href="static/document.css">'
+ echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />'
+ echo "<title> $TITLE </title>"
+ echo '<head>'
+ echo '</head>'
+ echo '<body>'
+ echo "<h1 style='text-align:center;'> $TITLE </h1>"
+ local f
+ for f in ????-??-??-*.md; do
+ echo '</div>'
+ echo "$(fmtdate ${f:0:10}) - $(extractauthor "$f")"
+ echo "<a href=${f/%.md/.html}><h3 class='title'>$(extracttitle "$f")</h3></a>"
+ echo '<div class="article">'
+ md2html "$f"
+ done | tac
+ } > index.html
+
+ ./feed.sh
+
+ echo ""
+ echo "COPYING FILES"
+ cp -v index.html $OUTFILE/
+ cp -vr static $OUTFILE/
+ cp -vr images $OUTFILE/
+ cp -vr feed.xml $OUTFILE/
+
+ echo ""
+ echo "BLOG PUBLISHED"
+ echo "---------------------------------------------------------"
+ echo "---------------------------------------------------------"
+}
+
+build