From ff40558f11cb2e4b09adec5c73c281624afbab2c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 20 Jul 2025 19:10:57 +0300 Subject: feat(generate)!: Use dunbar instead of csg for site generation --- .gitmodules | 6 +++--- csg | 1 - dunbar | 1 + generate.sh | 68 +++++++++++++++++++++++-------------------------------------- 4 files changed, 30 insertions(+), 46 deletions(-) delete mode 160000 csg create mode 160000 dunbar diff --git a/.gitmodules b/.gitmodules index 600c751..a74f9ed 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "csg"] - path = csg - url = https://gitlab.com/Syndamia/csg.git +[submodule "dunbar"] + path = dunbar + url = https://gitlab.com/Syndamia/dunbar.git diff --git a/csg b/csg deleted file mode 160000 index 4409b3c..0000000 --- a/csg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4409b3c0998d06ef3f06f40d1f691e8bf0328e2d diff --git a/dunbar b/dunbar new file mode 160000 index 0000000..cbd15ad --- /dev/null +++ b/dunbar @@ -0,0 +1 @@ +Subproject commit cbd15add4312e0ef471b1b792387017fc1533e75 diff --git a/generate.sh b/generate.sh index 43023af..cb3f7c6 100755 --- a/generate.sh +++ b/generate.sh @@ -1,20 +1,19 @@ #!/bin/bash -: ${REPO_FOLDER:=.} -: ${GEN_FOLDER:=./website} -: ${GEN_TINY_FOLDER:=./website.tiny} -: ${AWK_FOLDER:=./awk-edits} +: ${SRC_DIR:=$PWD/src} +: ${GEN_DIR:=./website} +: ${META_FILE:=meta.tsv} # Relative to SRC_DIR # 0 Fix hardlinks {{{ while read -r folder do - if [ -f "$folder.md" ] && [ ! "$folder.md" -ef "$folder/index.md" ] + if [ -f "$folder.du" ] && [ ! "$folder.du" -ef "$folder/index.du" ] then - rm "$folder/index.md" >/dev/null 2>&1 - ln "$folder.md" "$folder/index.md" + rm "$folder/index.du" >/dev/null 2>&1 + ln "$folder.du" "$folder/index.du" fi done << EOF -$(find "$REPO_FOLDER/src" -maxdepth 1 -type d) +$(find "$SRC_DIR" -maxdepth 1 -type d) EOF if [ ! "src/favicon.ico" -ef "src/img/favicon.ico" ] then @@ -23,42 +22,27 @@ EOF fi echo "[Stage 0] Fixed folder/index.md hardlinks" # }}} -# 1. Markdown source to HTML {{{ - [ $# -eq 0 -a "$(id -u -n)" != "www-data" ] && echo "[Warning] Running in \"production\" by a user that isn't www-root!" - - [ ! -d "$GEN_FOLDER" ] && mkdir "$GEN_FOLDER" - [ $# -eq 0 -a "$(stat -c %U "$GEN_FOLDER")" != "www-data" ] && echo "[Warning] Running in \"production\" while $GEN_FOLDER isn't owned by www-data!" - - /usr/bin/env dash ./csg/csg "$REPO_FOLDER/src" "$GEN_FOLDER" '& \\— Syndamia' 'https://syndamia.com' "$AWK_FOLDER" -# }}} -# 2. Tiny version, strip away styles and other stuff {{{ - [ ! -d "$GEN_TINY_FOLDER" ] && mkdir "$GEN_TINY_FOLDER" - [ $# -eq 0 -a "$(stat -c %U "$GEN_TINY_FOLDER")" != "www-data" ] && echo "[Warning] Running in \"production\" while $GEN_TINY_FOLDER isn't owned by www-data!" - - # Just take what is already made, no need to regenerate everything - cp -r "$GEN_FOLDER"/* "$GEN_TINY_FOLDER" +# 1. Dunbar source to HTML {{{ + [ ! -d "$GEN_DIR" ] && mkdir "$GEN_DIR" - # Remove unnecessary files - rm -f "$GEN_TINY_FOLDER"/*.css - rm -rf "$GEN_TINY_FOLDER"/fonts/ - rm -f "$GEN_TINY_FOLDER"/.files + mkdir -p "$GEN_DIR" + cp -a "$SRC_DIR/." "$GEN_DIR" + rm "$GEN_DIR/$META_FILE" "$GEN_DIR/."* - improveForTINY() { - for file in $(find "$GEN_TINY_FOLDER" -type f -name "*.html"); do - # Remove references to stylesheets in all files - sed -i -E 's/^.*(rel="stylesheet|\Content/
Content/g' $file - # Fix svg images being too big (scaling without limit) - sed -i 's/<\/head>/\t