noxz-sites

A collection of a builder and various scripts creating the noxz.tech sites
git clone https://noxz.tech/git/noxz-sites.git
Log | Files | README | LICENSE

commit: 412683446822f0329316cc3445c23c16c3ffa7e9
parent: c27249132ebb72b78a6ad939b3f928bc09409e8e
author: Chris Noxz <chris@noxz.tech>
date:   Sun, 21 Jan 2024 16:56:33 +0100
add changes for eqn rendering and more
Mbuild42++++++++++++-
Aconfig/eqn.conf10+++
Mconfig/main.html2+-
Mconfig/www.conf10---
Mnoxz.tech/pub/.assemble1+
Anoxz.tech/pub/howto.svg64++++++++++++++++++++
Mnoxz.tech/pub/style.css29++++++++-
7 files changed, 141 insertions(+), 17 deletions(-)
diff --git a/build b/build
@@ -16,8 +16,9 @@ SITE_HTML=
 SITE_REPLACE_DOT=1
 # ------------------------------ config files ------------------------------- #
 CFG_DIR="./config"
-# ------------------- groff www macro configuration files ------------------- #
+# ------------------------ groff configuration files ------------------------ #
 CFG_GROFF_WWW_MACRO="${CFG_DIR}/www.conf"
+CFG_GROFF_EQN="${CFG_DIR}/eqn.conf"
 # ---------------------- main html configuration files ---------------------- #
 CFG_MAIN_HTML="${CFG_DIR}/main.html"
 # ---------------------- git html configuration files ----------------------- #
@@ -218,6 +219,7 @@ render_main_menu() {
 render_main_menu_extra() {
 	printf '<li><a class="%s" href="%s">%s</a></li>\n'                      \
 		"pin"    "//[site]/articles/tags/pinned" "pinned articles"          \
+		"howto"  "//[site]/articles/tags/howto"  "how to"                   \
 		"twtxt"  "//[site]/twtxt.txt" "twtxt"                               \
 		"source" "//[site]/git/" "source"                                   \
 	| awk                                                                   \
@@ -304,6 +306,39 @@ render_articles() {
 	echo .DIVE
 }
 
+# fix for grohtml not reliably working for picture extraction
+extract_pictures() {
+	base_path="${SITE_WWW%/*}"
+	eqn=""
+	in_eqn=0
+	i=0
+
+	cat - | while read -r line; do
+		if [ $in_eqn -eq 0 ] && [ "$(echo ${line} | grep '^\.EQ')" = ".EQ" ]; then
+			in_eqn=1
+			eqn=""
+		fi
+		# catch and save every EQN instance
+		if [ $in_eqn -eq 1 ]; then
+			eqn="${eqn}${line}\n"
+		else
+			printf '%s\n' "${line}"
+		fi
+		# render and save EQN instance as a png image
+		if [ $in_eqn -eq 1 ] && [ "$(echo ${line} | grep '^\.EN')" = ".EN" ]; then
+			in_eqn=0
+			echo "${eqn}"                                                   \
+			| cat "${CFG_GROFF_EQN}" -                                      \
+			| groff -e -k -Tpdf                                             \
+			| convert -density 150 pdf:- -trim -quality 100 -sharpen 0x1.0 -resize 70% png:- > "${base_path}"/"eqn-${i}.png"
+			printf '.IMG %s/eqn-%s.png\n'                                   \
+				"${base_path}"                                              \
+				"${i}"
+			i=$((i+1))
+		fi
+	done
+}
+
 prerender() {
 	base_path="${SITE_WWW%/*}"
 	title=""
@@ -401,6 +436,7 @@ render_main_content() {
 			print
 		}
 	' "${SITE_WWW}"                                                         \
+	| extract_pictures  "$1"                                                \
 	| prerender "$1"                                                        \
 	| cat "${CFG_GROFF_WWW_MACRO}" -                                        \
 	| groff                                                                 \
@@ -460,8 +496,8 @@ render_main_content() {
 		-e 's/<dd>/<dd><p>/g'                                               \
 		-e 's/<p><!--/<!--/g' -e 's/--><\/p>/-->/g'                         \
 		-e 's/\[at\]/<span>\&#64;<\/span>/g'                                \
-		-e 's/\(src\|alt\)="[^"]*\(grohtml--[0-9]*.png\)/\1="\2/g'          \
-		-e 's/<p align="center"[^>]*>\(<img src="grohtml--[0-9]*.png\)/<p class="grohtml">\1/g' \
+		-e 's/\(src\|alt\)="[^"]*\(eqn-[0-9]*.png\)/\1="\2/g'               \
+		-e 's/\(<img src="eqn-[0-9]*.png" alt="eqn-[0-9]*.png"\)[^>]*>/<p class="eqn">\1\/><\/p>/g' \
 		-e 's/<p align="\(left\|center\|right\)"[^>]*>/<p class="\1">/g'    \
 		-e 's/<pre><code>/<div class="code-wrap"><pre><code>/g'             \
 		-e 's/<\/code><\/pre>/<\/code><\/pre><\/div>/g'                     \
diff --git a/config/eqn.conf b/config/eqn.conf
@@ -0,0 +1,10 @@
+.defcolor hicolor rgb .90f .40f .69f
+.EQ
+define iff '\[u21D4]'
+define implies '~\[u21D2]~'
+define hi 'special Hi'
+gsize 14
+.EN
+.de Hi
+.ds 0s \m[hicolor]\\*(0s\m[]
+..
diff --git a/config/main.html b/config/main.html
@@ -40,7 +40,7 @@
 		</div>
 	</div>
 	<hr class="hidden-ruler"/>
-	<div id="footer">
+	<div id="footer" data-date="{:year:}">
 		<div>
 		<span class="right">
 			Copyright &copy; 2006-{:year:} Chris Noxz
diff --git a/config/www.conf b/config/www.conf
@@ -109,15 +109,5 @@
 .       HTML <span class="\\$1">\\$2</span>\\$3
 .   \}
 ..
-.defcolor hicolor rgb .90f .40f .69f
-.EQ
-define iff '\[u21D4]'
-define implies '~\[u21D2]~'
-define hi 'special Hi'
-gsize 14
-.EN
-.de Hi
-.ds 0s \m[hicolor]\\*(0s\m[]
-..
 .NHR
 .HX -1
diff --git a/noxz.tech/pub/.assemble b/noxz.tech/pub/.assemble
@@ -1,6 +1,7 @@
 logo.black.svg
 logo.svg
 twtxt.svg
+howto.svg
 pin.svg
 source.svg
 author.svg
diff --git a/noxz.tech/pub/howto.svg b/noxz.tech/pub/howto.svg
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   enable-background="new 0 0 12 12"
+   width="12"
+   height="12"
+   version="1.1"
+   viewBox="0 0 12 12"
+   xml:space="preserve"
+   id="svg4"
+   sodipodi:docname="howto.svg"
+   inkscape:version="1.3 (0e150ed6c4, 2023-07-21)"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg"><defs
+   id="defs4" /><sodipodi:namedview
+   id="namedview4"
+   pagecolor="#ffffff"
+   bordercolor="#000000"
+   borderopacity="0.25"
+   inkscape:showpageshadow="2"
+   inkscape:pageopacity="0.0"
+   inkscape:pagecheckerboard="0"
+   inkscape:deskcolor="#d1d1d1"
+   inkscape:zoom="16"
+   inkscape:cx="-5.84375"
+   inkscape:cy="6.46875"
+   inkscape:window-width="2560"
+   inkscape:window-height="1061"
+   inkscape:window-x="0"
+   inkscape:window-y="19"
+   inkscape:window-maximized="1"
+   inkscape:current-layer="svg4" />&#10;<g
+   id="g4">&#10;<polyline
+   clip-rule="evenodd"
+   fill="#000000"
+   fill-rule="evenodd"
+   points="0,0 12,0 12,12 0,12"
+   id="polyline1" />&#10;&#10;&#10;&#10;</g>&#10;<circle
+   style="fill:#ffffff"
+   id="path4"
+   cx="6"
+   cy="5"
+   r="4" /><circle
+   style="fill:#ffffff;stroke-width:0.25"
+   id="path4-3"
+   cx="6"
+   cy="10"
+   r="1" /><rect
+   style="fill:#ffffff;stroke-width:1.31555"
+   id="rect4"
+   width="2"
+   height="2"
+   x="5"
+   y="8" /><path
+   style="fill:none;fill-opacity:1;stroke:#000000;stroke-linecap:round;stroke-opacity:1;stroke-width:0.6;stroke-dasharray:none"
+   d="m 2.856618,4.8002773 c 0,0 0.5082559,-2.8444171 3.1733026,-2.8420744"
+   id="path5" /><path
+   style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"
+   d="M 5.9834189,9.4135236 V 7.2833767 L 6.8988626,6.367933"
+   id="path8" /><path
+   style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1"
+   d="M 5.9755317,7.3563811 5.0291468,6.3668594"
+   id="path9" /></svg>
diff --git a/noxz.tech/pub/style.css b/noxz.tech/pub/style.css
@@ -284,6 +284,7 @@ span.right {
 	font-family     : sans-serif;
 	font-size       : 80%;
 	border-radius   : 0.5rem;
+	margin-bottom   : 1rem;
 }
 
 #main .edit-note dl {
@@ -310,6 +311,12 @@ span.right {
 	padding         : 0 1rem;
 }
 
+#main p.preamble
+{
+	font-size       : 120%;
+	font-style      : italic;
+}
+
 #main p.article-author, #main p.article-date {
 	background      : none no-repeat 0rem center;
 	padding-left    : 1.5rem;
@@ -405,7 +412,7 @@ span.right {
 	margin          : 0;
 }
 
-a.twtxt, a.source, a.pin {
+a.twtxt, a.howto, a.source, a.pin {
 	display         : block;
 	background      : none no-repeat 0.7em center;
 	background-size : 0.95em;
@@ -417,6 +424,10 @@ a.twtxt {
 	background-image: url("./twtxt.svg");
 }
 
+a.howto {
+	background-image: url("./howto.svg");
+}
+
 a.pin {
 	background-image: url("./pin.svg");
 }
@@ -475,7 +486,7 @@ ul.repo-log li .log-date {
 }
 
 
-.grohtml img {
+.eqn img {
 	margin-left     : 2em;
 	padding         : 1em 1.5em;
 	border          : 1px solid #ccc;
@@ -572,7 +583,19 @@ dl>dt {
 	#header-source {
 		display     : none;
 	}
-	a.twtxt, a.source {
+	a.twtxt, a.howto, a.source {
 		display         : block !important;
 	}
 }
+
+@media print {
+	#header, #nav { display: none }
+	#content>div, #footer>div { max-width: inherit; }
+	#footer .right {display: none }
+	#footer::after {
+		content: "Copyright © 2006-" attr(data-date) " Chris Noxz";
+		display: block;
+		text-align: right;
+	}
+	.code-wrap, p { page-break-inside: avoid; break-inside: avoid; }
+}