summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreudoxia <uplink@distress.network>2020-12-13 21:49:05 -0500
committereudoxia <uplink@distress.network>2020-12-13 21:49:05 -0500
commit10b3951776a80d1f73676f87eade25c1c28d0cb7 (patch)
tree667d70d678633dfeba22fb9df3538c14ad412315
parent0f3293ce2a9d9563087bb00b29db31aa1f06f961 (diff)
modified log formatting; slight usage instruction stylistic change
-rwxr-xr-xmd.sh56
-rwxr-xr-xplain.sh12
-rwxr-xr-xreload.sh10
-rwxr-xr-xsvgtex.sh15
4 files changed, 44 insertions, 49 deletions
diff --git a/md.sh b/md.sh
index afdce35..86de05b 100755
--- a/md.sh
+++ b/md.sh
@@ -1,10 +1,10 @@
#!/bin/sh
set -e
-# usage:
-# ./md.sh <target dir>
-# ./md.sh <input md> <output html>
-#
+usage="usage:
+ ./md.sh <target dir>
+ ./md.sh <input md> <output html>"
+
# input: <target dir>/src.md ./md-header ./md-footer <site root>/nav.html
# output: <target dir>/index.html
# dependencies: lowdown fzf ./urlencode
@@ -30,21 +30,17 @@ OUT="$1/index.html"
[ "$2" ] && { IN="$1" ; OUT="$2" ; }
-[ "$1" ] || {
-echo "usage:
- ./md.sh <target dir>
- ./md.sh <input md> <output html>" ; exit 1 ;
-}
+[ "$1" ] || { echo "$usage" ; exit 1 ; }
-[ -f $IN ] || { echo "---- [FATAL] $IN not found ----" ; exit 1 ; }
-[ -f md-header ] || { echo "---- [FATAL] md-header not found ----" ; exit 1 ; }
-[ -f md-footer ] || { echo "---- [FATAL] md-footer not found ----" ; exit 1 ; }
-[ $(which lowdown) ] || { echo "---- [FATAL] lowdown not found ----" ; exit 1 ; }
+[ -f $IN ] || { printf "%s \tFATAL: %s not found\n" "[->]" "$IN"; exit 1 ; }
+[ -f md-header ] || { printf "%s \tFATAL: md-header not found\n" "[->]" ; exit 1 ; }
+[ -f md-footer ] || { printf "%s \tFATAL: md-footer not found\n" "[->]" ; exit 1 ; }
+[ $(which lowdown) ] || { printf "%s \tFATAL: lowdown not found\n" "[->]" ; exit 1 ; }
cat md-header > $OUT
lowdown -Thtml $IN >> $OUT
cat md-footer >> $OUT
-echo '[ok] initial assembly'
+printf "[ok] \tinitial assembly\n"
sedesc() {
@@ -66,30 +62,30 @@ decode() {
TITLE=$(grep -e '^title: ' -m 1 $IN | cut -f 2- -d ' ' | sedesc)
sed "s/<title>#/<title>${TITLE} \&mdash\; DistressNetwork°/1" -i'' $OUT
-printf '[ok] title: %s\n' "$(echo "$TITLE" | unesc)"
+printf "[ok] \ttitle: %s\n" "$(echo "$TITLE" | unesc)"
BOMBER=$(grep -e '^bomber: ' -m 1 $IN | cut -f 2- -d ' ' | sedesc)
sed "s/<div class=\"bomber\">#/<div class=\"bomber\">${BOMBER}/1" -i'' $OUT
-printf '[ok] bomber: %s\n' "$(echo "$BOMBER" | unesc)"
+printf "[ok] \tbomber: %s\n" "$(echo "$BOMBER" | unesc)"
MDATE=$(stat -c '%y' $IN | sed -e 's/\.[0-9]* //' -e 's/\(..\)\(..\)$/\1:\2/') # format: "yyyy-mm-dd hh:mm:ss±zz:zz" (ISO 8601)
DATE=$(echo $MDATE | cut -f 1 -d ' ' | sed -e 's/-//g' -e 's/^..//') # format: "yymmdd" (for humans)
sed "s;<div class=\"ident\"><time>#;<div class=\"ident\"><time datetime=\"${MDATE}\">${DATE};1" -i'' $OUT
sed "/^<\/head>/i <meta http-equiv=\"last-modified\" content=\"${MDATE}\" />" -i'' $OUT
-printf '[ok] date: %s (%s)\n' "$DATE" "$MDATE"
+printf "[ok] \tdate: %s (%s)\n" "$DATE" "$MDATE"
LEADING=$(grep -e '^leading: ' -m 1 $IN | cut -f 2- -d ' ' | sedesc)
sed "s;<div class=\"leading\">#;<div class=\"leading\">${LEADING};1" -i'' $OUT
-printf '[ok] leading: %s\n' "$(echo "$LEADING" | unesc)"
+printf "[ok] \tleading: %s\n" "$(echo "$LEADING" | unesc)"
METADESC="\&laquo\;${BOMBER}\&raquo\; \&mdash\; ${LEADING}"
sed "s;<meta name=\"description\" content=\"#;<meta name=\"description\" content=\"${METADESC};1" -i'' $OUT
-printf '[ok] meta description\n'
+printf "[ok] \tmeta description\n"
if [ -f $(echo $IN | cut -f 1 -d /)/nav.html ] ; then
NAVLINE=$(grep -n '<nav>' $OUT | cut -f 1 -d :) ;
sed "${NAVLINE}r $(echo $OUT | cut -f 1 -d /)/nav.html" -i'' $OUT ;
-printf '[ok] sitemap\n' ;
+printf "[ok] \tsitemap\n" ;
fi
[ "$(grep -n '<p><img' $OUT)" ] && {
@@ -102,10 +98,10 @@ while IFS='' read -r data ; do
if [ "$CAPT" = "#tex" ] ; then # for tex figures: only remove caption and containers
sed "${LINE}s;.*;<figure><img src=\"${FILE}\" alt=\"\"></figure>;" -i'' $OUT ;
- printf '[ok] tex figure at line %s\n' "$LINE" ;
+ printf "[ok] \ttex figure at line %s\n" "$LINE" ;
else
sed "${LINE}s;.*;<figure><a href=\"${FILE}\"><img src=\"${FILE}\" alt=\"\"></a><figcaption><p>${CAPT}</p></figcaption></figure>;" -i'' $OUT ;
- printf '[ok] image at line %s\n' "$LINE" ;
+ printf "[ok] \timage at line %s\n" "$LINE" ;
fi
done
@@ -114,8 +110,8 @@ done
toc() {
-[ "$(which fzf)" ] || { echo "[warning] fzf not found, skipping toc" ; return ; }
-[ -f ./urlencode ] || { echo "[warning] urlencode not found, skipping toc" ; return ; }
+[ "$(which fzf)" ] || { printf "[warn] \tfzf not found, skipping toc\n" ; return ; }
+[ -f ./urlencode ] || { printf "[warn] \turlencode not found, skipping toc\n" ; return ; }
tmp=$(mktemp -p /tmp) # using a tempfile, more convenient for storage and operations
@@ -140,7 +136,7 @@ cat $tmp | while IFS='' read -r data ; do
IDLINE=$(grep -ne "^<h[[:digit:]] id=" $OUT | fzf -f "$(echo $HEADER | unesc)" | head -n 1 | cut -f 1 -d :) ;
if [ "$IDLINE" ] ; then
sed -e "${IDLINE}s;id=\".*\">.*</h;id=\"${ID}\">${HEADER}</h;" -i'' $OUT ;
- printf ' assembled header: %s\n' "$(echo $HEADER | unesc)" ;
+ printf "\tassembled header: %s\n" "$(echo $HEADER | unesc)" ;
fi ;
done
@@ -156,7 +152,7 @@ sed "${TOCLINE}r $tmp" -i'' $OUT
rm $tmp # cleanup
-echo '[ok] table of contents'
+printf "[ok] \ttable of contents\n"
}
@@ -171,22 +167,22 @@ case "$opts" in
(*[Ff]*)
sed "/^<footer>/,/^<\/footer>/d" -i'' $OUT
- echo "[ok] footerless"
+ printf "[ok] \tfooterless\n"
opts=$(echo $opts | sed 's/[Ff]//g')
;;
(*[Hh]*)
sed "/^<header>/,/^<\/header>/d" -i'' $OUT
sed "/bg.js/d" -i'' $OUT
- echo "[ok] headerless"
+ printf "[ok] \theaderless\n"
opts=$(echo $opts | sed 's/[Hh]//g')
;;
(*)
- echo "[warning] metadata: unrecognized option(s) \"${opts}\""
+ printf "[warn] \tmetadata: unrecognized option(s) \"$s\"\n" "${opts}"
;;
esac
done
-echo "---- build complete: ${OUT} ----"
+printf "%s \tbuild complete: %s\n" "[->]" "$OUT"
diff --git a/plain.sh b/plain.sh
index f572701..79283be 100755
--- a/plain.sh
+++ b/plain.sh
@@ -24,14 +24,14 @@ OUT="$2"
[ "$1" ] || { echo "usage: ./plain.sh <input txt> <output html>" ; exit 1 ; }
-[ -f $IN ] || { echo "---- [FATAL] $IN not found ----" ; exit 1 ; }
-[ -f plain-header ] || { echo "---- [FATAL] plain-header not found ----" ; exit 1 ; }
+[ -f $IN ] || { printf "%s \tFATAL: %s not found\n" "[->]" "$IN" ; exit 1 ; }
+[ -f plain-header ] || { printf "%s \tFATAL: plain-header not found\n" "[->]" ; exit 1 ; }
cat plain-header > $2
cat $1 >> $2
printf "</pre>\n</body>\n</html>" >> $2
-echo '[ok] initial assembly'
+printf "[ok] \tinitial assembly\n"
# hack to fix double <pre> when generating from nav.sh
sed -e "/^<pre>$/ {n;/^<pre>$/d}" -e "/^<\/pre>$/ {n;/^<\/pre>$/d}" -i'' $2
@@ -43,11 +43,11 @@ sedesc() {
TITLE=$(grep -e '^<!--title: ' -m 1 $1 | cut -f 2- -d ' ' | sedesc)
sed -e "/^<!--title:/d" -e "s;<title>#;<title>${TITLE};1" -i'' $2
-printf '[ok] title: %s\n' "$TITLE"
+printf "[ok] \ttitle: %s\n" "$TITLE"
MDATE=$(stat -c '%y' $1 | sed -e 's/\.[0-9]* //' -e 's/\(..\)\(..\)$/\1:\2/') # ISO 8601 format: "yyyy-mm-dd hh:mm:ss±zz:zz"
sed "/^<\/head>/i <meta http-equiv=\"last-modified\" content=\"${MDATE}\" />" -i'' $2
-printf '[ok] date: %s\n' "$MDATE"
+printf "[ok] \tdate: %s\n" "$MDATE"
-echo "---- build complete: $2 ----"
+printf "%s \tbuild complete: %s\n" "[->]" "$2"
diff --git a/reload.sh b/reload.sh
index af9044c..a67cd3b 100755
--- a/reload.sh
+++ b/reload.sh
@@ -5,21 +5,21 @@ rebuild() {
find -L distress.network | grep '/src.md' | sed 's;/src.md$;;' | \
while IFS='' read -r data ; do
sh ./md.sh ${data} > /dev/null ;
- echo " built: ${data}" ;
+ printf "\tbuilt: %s\n" "$data" ;
done
}
sh ./nav.sh distress.network distress.network/nav.html > /dev/null
-echo "[ok] nav embed"
+printf "[ok] \tnav embed\n"
if [ "$1" = -r ] ; then
rebuild ;
- echo "[ok] full rebuild";
+ printf "[ok] \tfull rebuild\n";
fi
sh ./plain.sh distress.network/nav.html distress.network/meta/sitemap/index.html > /dev/null
sed 's/\(line-height:\) 1.5em/\1 1.25em/' -i'' distress.network/meta/sitemap/index.html
-echo "[ok] nav page"
+printf "[ok] \tnav page\n"
sh ./sitemap.sh distress.network distress.network/sitemap.xml > /dev/null
-echo "[ok] sitemap.xml"
+printf "[ok] \tsitemap.xml\n"
diff --git a/svgtex.sh b/svgtex.sh
index b7c590b..04c372e 100755
--- a/svgtex.sh
+++ b/svgtex.sh
@@ -21,8 +21,7 @@ set -e
tmp=$(mktemp -p /tmp)
eqn=$(cat /dev/stdin)
-echo "---- begin assembly: ----"
-printf "%s\n" "$eqn"
+printf "[ok] \teqn: %s\n" "$eqn"
echo "\\\documentclass[10pt,fleqn]{standalone}
\\\usepackage{standalone,amsmath,amssymb,xcolor}
@@ -35,18 +34,18 @@ echo "\\\end{document}" >> $tmp
# now this is where the fun begins
-latex -interaction=batchmode $tmp
+latex -interaction=batchmode $tmp > /dev/null
-[ -f tmp.dvi ] || { echo "---- [FATAL] tex output failed ----" ; exit 1 ; } # make sure output exists before continuing
+[ -f tmp.dvi ] || { printf "%s \tFATAL: tex output failed\n" "[->]" ; exit 1 ; } # make sure output exists before continuing
-echo "[ok] tex finished typesetting"
+printf "[ok] \ttex finished typesetting\n"
-dvisvgm tmp.dvi -f ttf -T S2
+dvisvgm tmp.dvi -f ttf -T S2 > /dev/null 2>&1
-echo "[ok] conversion to svg"
+printf "[ok] \tconversion to svg\n"
mv tmp.svg $1 # final move to desired path
rm tmp.aux tmp.log tmp.dvi $tmp # cleanup
-echo "---- build complete: $1 ----"
+printf "%s \tbuild complete: %s\n" "[->]" "$1"