diff options
| Commit | ff40558f11cb2e4b09adec5c73c281624afbab2c (patch) | |
|---|---|---|
| Author | 2025-07-20 19:10:57 +0300 | |
| Committer | 2025-07-20 19:10:57 +0300 | |
| Files | d764a44abba8cd5ac60b79b615a18dcf913d5ff7 | |
| syndamia.com-ff40558f11cb2e4b09adec5c73c281624afbab2c.tar syndamia.com-ff40558f11cb2e4b09adec5c73c281624afbab2c.tar.gz syndamia.com-ff40558f11cb2e4b09adec5c73c281624afbab2c.zip | ||
| Parent | 61243759b66aadc6375842bb230be11f116bd1f9 (diff) | |
feat(generate)!: Use dunbar instead of csg for site generation
4 files changed, 29 insertions, 45 deletions
| -rw-r--r-- | .gitmodules | 6 | ||||
| m--------- | csg | 0 | ||||
| m--------- | dunbar | 0 | ||||
| -rwxr-xr-x | generate.sh | 68 |
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 -Subproject 4409b3c0998d06ef3f06f40d1f691e8bf0328e2 diff --git a/dunbar b/dunbar new file mode 160000 +Subproject cbd15add4312e0ef471b1b792387017fc1533e7 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|\<script|btn).*//g' $file - sed -i 's/<span>Content/<br><span>Content/g' $file - # Fix svg images being too big (scaling without limit) - sed -i 's/<\/head>/\t<style>img[src$="svg"] { max-height: 1em; } #index-contents-img { max-width: 7.6em; }<\/style>\n<\/head>/' $file - done - } + META="$SRC_DIR/$META_FILE" + export META - echo "[Stage 3] Tiny website" - if [ $# -eq 0 ]; then - improveForTINY + /usr/bin/env dash ./dunbar/dunbar_awk/dunbar.sh html \ + -o . \ + -e ./ext/meta.awk -e ./ext/attention.awk \ + -e ./ext/heading-anchors.awk -e ./ext/pagenav.awk \ + -wo \ + -he ./ext/header.du.html -fo ./ext/footer.du.html \ + ./ext/*.du \ + $(find "$GEN_DIR" -type f -name "*.du") - - else - improveForTINY - fi + rm ./ext/icons.html +# }}} +# 2. Tiny version, strip away styles and other stuff {{{ + # TODO # }}} |