Added variable CSS support.

This commit is contained in:
Atlas Cove 2023-02-11 18:00:31 +00:00
parent 73989bbb7e
commit c2ca1e0e42
5 changed files with 19 additions and 16 deletions

View File

@ -7,7 +7,7 @@ insert_final_newline=true
[{Makefile,*.s[ac]ss}] [{Makefile,*.s[ac]ss}]
indent_style=tab indent_style=tab
indent_size=1 indent_size=1
[{ignore.txt,*.csv}] [{ignore.txt,*.csv,m4/*}]
insert_final_newline=false insert_final_newline=false
[*.rb] [*.rb]
indent_style=space indent_style=space

View File

@ -1,4 +1,7 @@
#!/usr/bin/awk #!/usr/bin/awk
BEGIN{FS="/";x=2} BEGIN{FS="/";x=2}
function none() {print "main";exit}
NF==1{none()}
/\.\//{x++} /\.\//{x++}
{gsub($0,"./","");print $x;exit} $x~/\.(txti|html|org|md)/{none()}
{if($x=="dnd")none();print $x;exit}

View File

@ -1,5 +1,6 @@
divert(-1) divert(-1)
# extra macros for site structure # extra macros for site structure
define(`ytv',`<iframe width="ifdef(`$3',$1,560)" height="ifdef(`$3',$3,315)" src="$1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>') define(`_ytv',`<iframe width="ifdef(`$3',$1,560)" height="ifdef(`$3',$3,315)" src="$1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')
define(`wrap',<$1>$2</$1>) define(`_wrap',<$1>$2</$1>)
divert define(`_empty',`')
divert dnl

View File

@ -1,14 +1,12 @@
dnl template.m4.html v1.3-p1 dnl template.m4.html v1.4-p1
dnl Part of the tape-and-string suite used to construct the website dnl Part of the tape-and-string suite used to construct the website
ifdef(`DEBUG',`traceon')dnl
include(`m4/lib.m4')dnl include(`m4/lib.m4')dnl
ifdef(`CSS_INC',`', define(`CSS_INC', `main'))dnl
ifelse(CSS_INC,`dnd',define(`CSS_INC',`main'))dnl
define(`_CSS',`/css/CSS_INC.css')dnl
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<style> <style>
@import url("_CSS"); @import url("/css/CSSI().css'");
</style> </style>
<title>TITLE</title> <title>TITLE</title>
</head> </head>
@ -17,7 +15,8 @@ define(`_CSS',`/css/CSS_INC.css')dnl
<a href="/">Home</a> <a href="/">Home</a>
</div> </div>
<div class="content"> <div class="content">
include(`/dev/stdin')dnl Probably not a good idea, but whatever. temp
dnl include(`/dev/stdin')dnl Probably not a good idea, but whatever.
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# render.sh: part of the tape-and-string framework. # render.sh: part of the tape-and-string framework.
# v3.3-p1 # v3.3-p2
#B: Load #B: Load
enable -f /usr/lib/bash/csv csv enable -f /usr/lib/bash/csv csv
declare -A title declare -A title
@ -18,7 +18,7 @@ function wrn { echo -e "\x1B[1;93mWRN\x1B[0m: $*"; }
function err { echo -e "\x1B[1;31mERR\x1B[0m: $*"; } function err { echo -e "\x1B[1;31mERR\x1B[0m: $*"; }
function tape { function tape {
if test -d "$1"; then if test -d "$1"; then
err "tape: Passed directory, $1" err "tape: Passed directory, $1"
return 1 return 1
fi fi
case $1 in case $1 in
@ -26,7 +26,7 @@ function tape {
*.org) org-ruby --translate html "$1" ;; *.org) org-ruby --translate html "$1" ;;
*.md) comrak --gfm "$1" ;; *.md) comrak --gfm "$1" ;;
*.html) cat $1 ;; *.html) cat $1 ;;
*.s[ac]ss) err "Told to render $1, shouldn't happen"; return 1 ;; *.s[ac]ss) err "Told to render $1, shouldn't happen"; return 1 ;;
*) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;; *) pandoc --columns 168 -t html "$1" || echo "Skipping $i, unknown format" ;;
esac esac
} }
@ -56,9 +56,9 @@ function docs {
o="${i/in/out}" o="${i/in/out}"
echo "$i => $o" echo "$i => $o"
if test -z "${title[$i]}"; then if test -z "${title[$i]}"; then
tape $i | m4 -DCSS_INC=$(awk -f get_sd.awk "$i") m4/main.html.m4 > ${o%.*}.html tape $i | m4 -DCSSI=$(awk -f get_sd.awk <<< "$i") m4/main.html.m4 > ${o%.*}.html
else else
tape $i | m4 -DCSS_INC=$(awk -f get_sd.awk "$i") -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html tape $i | m4 -DCSSI=$(awk -f get_sd.awk <<< "$i") -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html
fi fi
done done
} }