From 3a9c5df1c4ab8262fd3217acacc7a0928e828d84 Mon Sep 17 00:00:00 2001 From: Atlas Cove Date: Fri, 10 Feb 2023 19:02:43 +0000 Subject: [PATCH] site infastructure --- .editorconfig | 7 +- gensmap.sh => gensimap.sh | 3 + ignore.txt | 2 + pfiles.rb | 5 + render.sh | 211 +++++++++++++++++++++++++------------- 5 files changed, 153 insertions(+), 75 deletions(-) rename gensmap.sh => gensimap.sh (88%) create mode 100644 ignore.txt create mode 100644 pfiles.rb diff --git a/.editorconfig b/.editorconfig index 7c5ff04..12679d0 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,5 +5,10 @@ end_of_line=lf trim_trailing_whitespace=true insert_final_newline=true [{Makefile,*.sass}] -indent_type=tab +indent_style=tab indent_size=1 +[{ignore.txt,*.csv}] +insert_final_newline=false +[*.rb] +indent_style=space +indent_size=2 diff --git a/gensmap.sh b/gensimap.sh similarity index 88% rename from gensmap.sh rename to gensimap.sh index afeed85..eaa8add 100755 --- a/gensmap.sh +++ b/gensimap.sh @@ -1,3 +1,6 @@ +#!/bin/bash +# gensimap.sh: Generate a sitemap for my website. +# v2.0p1 function r { echo $@ >> out/sitemap.xml; } test -d out/sitemap.xml && sed -i d sitemap.xml r '' diff --git a/ignore.txt b/ignore.txt new file mode 100644 index 0000000..592c5b9 --- /dev/null +++ b/ignore.txt @@ -0,0 +1,2 @@ +css/extra.scss +dnd/template.org \ No newline at end of file diff --git a/pfiles.rb b/pfiles.rb new file mode 100644 index 0000000..a687918 --- /dev/null +++ b/pfiles.rb @@ -0,0 +1,5 @@ +#!/usr/bin/ruby +ignore=!File.file?('ignore.txt') ? [] : File.readlines('ignore.txt') +switch $ARGV[1] + +end diff --git a/render.sh b/render.sh index 0d01e79..e8378c0 100755 --- a/render.sh +++ b/render.sh @@ -1,19 +1,25 @@ #!/bin/bash # render.sh: part of the tape-and-string framework. -# v3.1 +# v3.2-p1 +#B: Load enable -f /usr/lib/bash/csv csv declare -A title -while read -r ii; do - csv -a i "$ii" - title[in/${i[0]}]=${i[1]} -done $o" - if test -z "${title[$i]}"; then - tape $i | m4 m4/main.html.m4 > ${o%.*}.html - else - tape $i | m4 -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html + if ! test -d out; then + err "Cannot render, directory 'out' does not exist, run ./render.sh dir" + return 1 fi -done + local i o doc + doc=(`find in -type f -name '*.txti' -o -name '*.org' -o -name '*.md'`) + inf "Rendering document files..." + for i in ${doc[@]}; do + if in_arr $i ${ignore[@]}; then + inf "Skipping $i" + continue + fi + o="${i/in/out}" + echo "$i => $o" + if test -z "${title[$i]}"; then + tape $i | m4 m4/main.html.m4 > ${o%.*}.html + else + tape $i | m4 -DTITLE="${title[$i]}" m4/main.html.m4 > ${o%.*}.html + fi + done } function sass { -inf "Rendering sass files..." -if test -z "${sass[@]}"; then - inf "No .sass files detected, skipping" - unset sass -else - for i in ${sass[@]}; do - o="${i/in/out}" - echo "$i => $o" - sassc -a $i ${o/sa/c} - done -fi -if test -z "${scss[@]}"; then - inf "No .scss files detected, skipping." - unset scss -else - for i in ${scss[@]}; do - o="${i/in/out}" - echo "$i => $o" - sassc $i ${o#s} - done -fi + if ! test -d out; then + err "Cannot render, directory 'out' does not exist, run ./render.sh dir" + return 1 + fi + local i o sass scss + sass=(`find in -type f -name '*.sass'`) + scss=(`find in -type f -name '*.scss'`) + inf "Rendering sass files..." + if [ ${#sass[@]} -eq 0 ]; then + inf "No .sass files detected, skipping" + unset sass + else + for i in ${sass[@]}; do + if in_arr $i ${ignore[@]}; then + inf "Skipping $i" + continue + fi + o="${i/in/out}" + o="${o/.sa/.c}" + echo "$i => $o" + sassc -a $i $o + done + fi + if [ ${#scss[@]} -eq 0 ]; then + inf "No .scss files detected, skipping." + unset scss + else + for i in ${scss[@]}; do + if in_arr $i ${ignore[@]}; then + inf "Skipping $i" + continue + fi + o="${i/in/out}" + o="${o/\.s/.}" + echo "$i => $o" + sassc $i $o + done + fi } function other { -inf "Copying other files..." -cp -rv 'in'/* out/ + if ! test -d out; then + err "Cannot render, directory 'out' does not exist, run ./render.sh dir" + return 1 + fi + inf "Copying other files..." + cp -rv 'in'/* out/ } function all { -dirs -docs -sass -other + dirs + docs + sass + other } +function info { + local i + echo "* \$ignore" + if [ ${#ignore[@]} -eq 0 ]; then + echo null + else + for i in ${ignore[@]}; do + echo "- $i" + done + fi + echo "* \$titles" + for i in ${!title[@]}; do + echo " - $i :: ${title[$i]}" + done +} +#E: Definition +#B: Logic +#B: Logic/LoadDefs +#B: Logic/LoadDefs/title +while read -r ii; do + csv -a i "$ii" + title[in/${i[0]}]=${i[1]} +done < title.csv +#E: Logic/LoadDefs/title +unset ii +#B: Logic/LoadDefs/ignore +if test -f ignore.txt; then + while read -r i; do + ignore+=(in/$i) + done < ignore.txt +fi +#E: Logic/LoadDefs/ignore +#E: Logic/LoadDefs if test -z "$*"; then all - exit 0 + exit $? fi case $1 in - dir) dirs;; - doc) docs;; - s[ac]ss) sass;; - other) other;; - all) all;; - *) all;; +dir) dirs;; +doc) docs;; +s[ac]ss) sass;; +other) other;; +rest) other;; +info) info;; +vall) info; all;; +all) all;; +*) all;; esac +#E: Logic +exit $?