engine

website and gopher hole static engine
git clone git://kh1b.org/engine
Log | Files | Refs

commit a09c770599eeb777019541ece3f1a7c0acc0d5a9
Author: bazizi khaled <contact@kh1b.org>
Date:   Wed, 18 Dec 2024 19:33:30 +0100

Initial commit

Diffstat:
Awww/Makefile | 26++++++++++++++++++++++++++
Awww/config.mk | 2++
Awww/git.kh1b.org/Makefile | 37+++++++++++++++++++++++++++++++++++++
Awww/git.kh1b.org/config.mk | 6++++++
Awww/git.kh1b.org/style.css | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Awww/kh1b.org/Makefile | 25+++++++++++++++++++++++++
Awww/kh1b.org/config.mk | 10++++++++++
Awww/kh1b.org/index.md | 16++++++++++++++++
Awww/kh1b.org/style.css | 14++++++++++++++
Awww/pub.kh1b.org/Makefile | 23+++++++++++++++++++++++
Awww/pub.kh1b.org/config.mk | 7+++++++
Awww/pub.kh1b.org/style.css | 14++++++++++++++
Awww/utils/deploy.sh | 23+++++++++++++++++++++++
Awww/utils/head.html | 10++++++++++
Awww/utils/indexof.sh | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Awww/utils/stagit-clean.sh | 26++++++++++++++++++++++++++
Awww/utils/tail.html | 3+++
17 files changed, 426 insertions(+), 0 deletions(-)

diff --git a/www/Makefile b/www/Makefile @@ -0,0 +1,26 @@ +.PHONY: all clean install deploy install + +include config.mk + +all: + @for dir in $(SUBDIRS); do \ + echo "Building in $$dir..."; \ + $(MAKE) -C $$dir; \ + done + +install: + @for dir in $(SUBDIRS); do \ + echo "installing $$dir..."; \ + $(MAKE) -C $$dir install; \ + done + +clean: + @for dir in $(SUBDIRS); do \ + echo "Cleaning in $$dir..."; \ + $(MAKE) -C $$dir clean; \ + done + +deploy: + @echo "Running deploy script..." + @$(DEPLOY_SCRIPT) + diff --git a/www/config.mk b/www/config.mk @@ -0,0 +1,2 @@ +SUBDIRS := git.kh1b.org kh1b.org pub.kh1b.org +DEPLOY_SCRIPT := utils/deploy.sh diff --git a/www/git.kh1b.org/Makefile b/www/git.kh1b.org/Makefile @@ -0,0 +1,37 @@ +.PHONY: all clean install + +include config.mk + +all: $(OUTPUT) repos clean_html + +repos: + @for repo in $(REPO_PATHS); do \ + repo_name=$$(basename $$repo); \ + echo "Creating repo dir: $$repo_name"; \ + mkdir -p $$repo_name; \ + cd $$repo_name && stagit $$repo; \ + cd ..; \ + done + +$(OUTPUT): $(REPO_PATHS) + @echo "Generating index file..." + stagit-index $(REPO_PATHS) > $@ + +clean_html: + @echo "cleanup script..." + $(CLEAN_SCRIPT) + +clean: + @echo "Cleaning generated files and directories..." + rm -rf $(OUTPUT) $(WEBROOT) + +install: all + @echo "Generating deployment directory: $(WEBROOT)..." + @mkdir -p $(WEBROOT) + + @echo "Copying index.html and style.css..." + @cp -r index.html style.css $(WEBROOT) + + @echo "Copying all directories..." + @find . -maxdepth 1 -type d ! -name "$(WEBROOT)" ! -name "." -exec cp -r {} $(WEBROOT)/ \; + diff --git a/www/git.kh1b.org/config.mk b/www/git.kh1b.org/config.mk @@ -0,0 +1,6 @@ + +# REPO_PATHS := PATH/TO/REPO + +WEBROOT := .webroot +OUTPUT := index.html +CLEAN_SCRIPT := ../utils/stagit-clean.sh diff --git a/www/git.kh1b.org/style.css b/www/git.kh1b.org/style.css @@ -0,0 +1,115 @@ +a { + color: #957633; + text-decoration: none; +} +a:hover { + color: #AE8834; + text-decoration: underline; +} + +body { + color: #f8f8f8; + background-color: #111; +} + +r: #000; + background-color: #fff; + font-family: monospace; +} + +h1, h2, h3, h4, h5, h6 { + font-size: 1em; + margin: 0; +} + +img, h1, h2 { + vertical-align: middle; +} + +img { + border: 0; +} + +a { + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +#blob a { + color: #957633; +} + +#blob a:hover { + color: #AE8834; + text-decoration: none; +} + +table thead td { + font-weight: bold; +} + +table td { + padding: 0 0.4em; +} + +#content table td { + vertical-align: top; + white-space: nowrap; +} + +#branches tr:hover td, +#tags tr:hover td, +#index tr:hover td, +#log tr:hover td, +#files tr:hover td { + background-color: black; +} + +#index tr td:nth-child(2), +#tags tr td:nth-child(3), +#branches tr td:nth-child(3), +#log tr td:nth-child(2) { + white-space: normal; +} + +td.num { + text-align: right; +} + +.desc { + color: #777; +} + +hr { + border: 0; + border-top: 1px solid #777; + height: 1px; +} + +pre { + font-family: monospace; +} + +pre a.h { + color: #00a; +} + +span.i, +pre a.i { + color: #070; +} + +span.d, +pre a.d { + color: #e00; +} + +pre a.h:hover, +pre a.i:hover, +pre a.d:hover { + text-decoration: none; +} + diff --git a/www/kh1b.org/Makefile b/www/kh1b.org/Makefile @@ -0,0 +1,25 @@ +.PHONY: all clean install + +include config.mk + +all: $(OUTPUT) + +$(OUTPUT): $(HEAD) $(MARKDOWN) $(TAIL) + @echo "Generating $(OUTPUT)..." + cat $(HEAD) > $@ + smu $(MARKDOWN) >> $@ + cat $(TAIL) >> $@ + +clean: + @echo "Cleaning up..." + rm -f $(OUTPUT) + rm -rf $(WEBROOT) + +install: all + @echo "Generating deployment directory: $(WEBROOT)" + @mkdir -p $(WEBROOT) + @cp $(OUTPUT) $(WEBROOT)/ + @cp $(STATIC_ASSETS) $(WEBROOT)/ + + @echo "Deployment files:" + @find $(WEBROOT) -type f diff --git a/www/kh1b.org/config.mk b/www/kh1b.org/config.mk @@ -0,0 +1,10 @@ +HEAD := ../utils/head.html +TAIL := ../utils/tail.html + +MARKDOWN := index.md + +OUTPUT := index.html + +WEBROOT := .webroot + +STATIC_ASSETS := style.css diff --git a/www/kh1b.org/index.md b/www/kh1b.org/index.md @@ -0,0 +1,16 @@ +### Main +- [repositories](https://git.kh1b.org) +- [pub](https://pub.kh1b.org) +- [gopher](gopher://kh1b.org) + +### Contact +- mail: contact AT kh1b DOT org +- kh1b [irc.libera.chat] + +### Links +- [suckless.org](https://suckless.org) +- [z3bra.org](https://z3bra.org) +- [2f30.org](https://2f30.org) +- [dataswamp.org/~solene](https://dataswamp.org/~solene) +- [codemadness.org](https://codemadness.org) +- [gopher://bitreich.org](gopher://bitreich.org) diff --git a/www/kh1b.org/style.css b/www/kh1b.org/style.css @@ -0,0 +1,14 @@ +body { + font-family: sans-serif; + padding-left: 20px; + color: #f8f8f8; + background-color: #111; +} +a { + color: #957633; + text-decoration: none; +} +a:hover { + color: #AE8834; + text-decoration: underline; +} diff --git a/www/pub.kh1b.org/Makefile b/www/pub.kh1b.org/Makefile @@ -0,0 +1,23 @@ +.PHONY: all clean install + +include config.mk + +all: $(TARGET) + +$(TARGET): + @echo "generating index files..." + $(INDEX_SCRIPT) $(ROOT_DIR) + +clean: + @echo "Cleaning generated files and directories..." + find $(ROOT_DIR) -name "index.html" -delete + rm -rf $(WEBROOT) + +install: all + @echo "Generating deployment directory: $(WEBROOT)..." + @mkdir -p $(WEBROOT) + @rsync -av --exclude='Makefile' --exclude='config.mk' --exclude='.git*' ./ $(WEBROOT)/ + + @echo "Files in $(WEBROOT):" + @find $(WEBROOT) -type f + diff --git a/www/pub.kh1b.org/config.mk b/www/pub.kh1b.org/config.mk @@ -0,0 +1,7 @@ +ROOT_DIR := . + +TARGET := index.html + +INDEX_SCRIPT := ../utils/indexof.sh + +WEBROOT := .webroot diff --git a/www/pub.kh1b.org/style.css b/www/pub.kh1b.org/style.css @@ -0,0 +1,14 @@ +body { + font-family: sans-serif; + padding-left: 20px; + color: #f8f8f8; + background-color: #111; +} +a { + color: #957633; + text-decoration: none; +} +a:hover { + color: #AE8834; + text-decoration: underline; +} diff --git a/www/utils/deploy.sh b/www/utils/deploy.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +SERVER_USER="root" +SERVER_HOST="kh1b.org" +BASE_REMOTE_PATH="/var/www" + +DIRECTORIES=( + "pub.kh1b.org" + "git.kh1b.org" + "kh1b.org" +) + + +for dir in "${DIRECTORIES[@]}"; do + if [ -d "$dir/.webroot" ]; then + echo "Deploying $dir to $SERVER_USER@$SERVER_HOST:$BASE_REMOTE_PATH/$dir/ ..." + rsync -avz "$dir/.webroot/" "$SERVER_USER@$SERVER_HOST:$BASE_REMOTE_PATH/$dir/" + else + echo "skipping $dir" + fi +done + +echo "deployment completed." diff --git a/www/utils/head.html b/www/utils/head.html @@ -0,0 +1,10 @@ +<!doctype html> +<html lang="en-US"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width"> + <link rel="stylesheet" type="text/css" href="style.css"> + <title>kh1b.org</title> + </head> + <body> + diff --git a/www/utils/indexof.sh b/www/utils/indexof.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +generate_index() { + local dir="$1" + local rel_path="$2" + + local output="$dir/index.html" + echo "Generating $output" + { + echo "<!DOCTYPE html>" + echo "<html>" + echo "<head>" + echo "<title>Index of $(basename "$dir")</title>" + echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"${rel_path}style.css\" />" + echo "</head>" + echo "<body>" + echo "<hr>" + echo "<h1>Index of $(basename "$dir")</h1>" + echo "<pre>" + printf "%-50s %-20s %-10s\n" "Name" "Last Modified" "Size" + echo "<hr>" + + if [ "$dir" != "." ]; then + printf "<a href=\"../\">%-48s</a> %-20s %-10s\n" "../" "-" "-" + fi + + for item in "$dir"/*; do + local base_item=$(basename "$item") + if [ "$base_item" = "index.html" ]; then + continue + fi + if [ "$dir" = "." ] && { [ "$base_item" = "Makefile" ] || [ "$base_item" = "config.mk" ] || [ "$base_item" = "style.css" ]; }; then + continue + fi + + if [ -d "$item" ]; then + local date=$(stat -c '%y' "$item" | cut -d. -f1) + printf "<a href=\"%s/\">%-48s</a> %-20s %-10s\n" "$base_item" "$base_item/" "$date" "-" + elif [ -f "$item" ]; then + local date=$(stat -c '%y' "$item" | cut -d. -f1) + local size=$(stat -c '%s' "$item") + printf "<a href=\"%s\">%-48s</a> %-20s %-10s\n" "$base_item" "$base_item" "$date" "$size" + fi + done + + echo "</pre>" + echo "<hr>" + echo "</body></html>" + } > "$output" + + for subdir in "$dir"/*; do + if [ -d "$subdir" ]; then + generate_index "$subdir" "$rel_path../" + fi + done +} + +if [ $# -eq 0 ]; then + echo "Usage: $0 <directory>" + exit 1 +fi + +if [ ! -d "$1" ]; then + echo "Error: $1 is not a directory" + exit 1 +fi + +generate_index "$1" "./" + diff --git a/www/utils/stagit-clean.sh b/www/utils/stagit-clean.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +style_root="./style.css" + +clean_file() { + local file="$1" + if [ -f "$file" ]; then + echo "Processing $file" + + sed -i 's#<td><img src="\([^"]*\)" alt="" width="32" height="32" /></td>##g' "$file" + sed -i 's#<link rel="icon" type="image/png" href="\([^"]*\)" />##g' "$file" + sed -i 's#<a href="\([^"]*\)"><img src="\([^"]*\)" alt="" width="32" height="32" /></a>##g' "$file" + + relative_style_path=$(realpath --relative-to="$(dirname "$file")" "$style_root") + + sed -i "s#<link rel=\"stylesheet\" type=\"text/css\" href=\".*style.css\" />#<link rel=\"stylesheet\" type=\"text/css\" href=\"$relative_style_path\" />#g" "$file" + else + echo "File $file not found, skipping." + fi +} + +export -f clean_file +export style_root + +find . -type f -name "*.html" -exec bash -c 'clean_file "$0"' {} \; + diff --git a/www/utils/tail.html b/www/utils/tail.html @@ -0,0 +1,3 @@ + </body> +</html> +