site

scripts to generate personal blog and git repositories

git clone https://9o.is/git/site.git

commit b86063e8cb131c580ef8148cd9751f5834647111
parent 958c20863903d958dfca2d3f8a234b0a9e053e4b
Author: Jul <jul@9o.is>
Date:   Thu, 15 Jan 2026 17:18:57 -0500

add stagit to makefile

Diffstat:
M.gitignore | 1+
MMakefile | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Apost-receive.sample | 31+++++++++++++++++++++++++++++++
Astagit/site.git | 3+++
Astagit/stagit.git | 3+++
5 files changed, 100 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,4 @@ /output /pages/*.html /pages/*.cfg +/stagit/*.out diff --git a/Makefile b/Makefile @@ -1,26 +1,71 @@ .POSIX: -.SUFFIXES: .md .cfg .html +.SUFFIXES: .md .cfg .html .git .out -LOWDOWN = lowdown -OUTDIR = output +SAAIT = saait +STAGIT = stagit +STAGIT_INDEX = stagit-index +LOWDOWN = lowdown +RCLONE = rclone +OUTDIR = output +RCLONE_ARGS = -v --size-only --stats 5s --stats-one-line +REPOS != find stagit -type f -name '*.git' PAGES != find pages -type f -name '*.md' -PAGES_CFG != printf "$(PAGES)" | sed 's|\.md$$|.cfg|g' -PAGES_HTML != printf "$(PAGES)" | sed 's|\.md$$|.html|g' +REPOS_OUT != echo "$(REPOS)" | tr ' ' '\n' | sed 's|\.git$$|.out|g' +PAGES_CFG != echo "$(PAGES)" | tr ' ' '\n' | sed 's|\.md$$|.cfg|g' +PAGES_HTML != echo "$(PAGES)" | tr ' ' '\n' | sed 's|\.md$$|.html|g' -all: $(OUTDIR)/index.html +all: $(OUTDIR)/index.html $(OUTDIR)/git/index.html stagit-all $(OUTDIR)/index.html: $(PAGES_HTML) $(PAGES_CFG) @printf " %-8s %s\n" "SAAIT" "$@" @mkdir -p $(OUTDIR) - @printf "$(PAGES_CFG)" | tr ' ' '\0' | sort -zr | xargs -0 saait + @printf "$(PAGES_CFG)" | sort -r | xargs $(SAAIT) @cp styles/*.css $(OUTDIR) -sync: $(OUTDIR)/index.html - rclone sync -vu output sftp:htdocs +$(OUTDIR)/git/index.html: $(REPOS_OUT) + @printf " %-8s %s\n" "STAGIT" "$@" + @mkdir -p $(OUTDIR)/git + @repos=''; \ + for repo in $(REPOS); do \ + source $$repo && repos="$$repos $$path"; \ + done; \ + $(STAGIT_INDEX) $$repos > $@ + +stagit-all: $(REPOS_OUT) + @for repo in $(REPOS); do \ + source $$repo && $(MAKE) REPO=$$name stagit; \ + done + +stagit-sync-all: $(REPOS_OUT) + @for repo in $(REPOS); do \ + source $$repo && $(MAKE) REPO=$$name sync-stagit; \ + done + +stagit: $(OUTDIR)/git/index.html + @test "$(REPO)" || { echo "error: missing REPO argument" 1>&2; exit 1; } + @test -e stagit/$(REPO).git || { echo "error: $(REPO) not configured" 1>&2; exit 1; } + @printf " %-8s %s\n" "STAGIT" "$(REPO)" + @mkdir -p $(OUTDIR)/git/$(REPO) + @source stagit/$(REPO).git; \ + cd $(OUTDIR)/git/$(REPO); \ + $(STAGIT) $$path + +sync-stagit: stagit + @printf " %-8s %s\n" "SYNC" "$(REPO)" + @$(RCLONE) $(RCLONE_ARGS) sync \ + --include '/index.html' --include '/$(REPO)/**' \ + output/git sftp:htdocs/git + +sync-blog: $(OUTDIR)/index.html + @printf " %-8s %s\n" "SYNC" "blog" + @$(RCLONE) $(RCLONE_ARGS) sync --max-depth 1 output sftp:htdocs clean: @rm -rf $(OUTDIR) + @rm -f pages/*.cfg + @rm -f pages/*.html + @rm -f stagit/*.out .md.cfg: @printf " %-8s %s\n" "LOWDOWN" "$@" @@ -33,4 +78,11 @@ clean: @printf " %-8s %s\n" "LOWDOWN" "$@" @$(LOWDOWN) --html-no-skiphtml --html-no-escapehtml $< > $@ -.PHONY: all sync clean +.git.out: + @printf " %-8s %s\n" "GEN" "$<" + @source $<; \ + printf "$$description" > $$path/description; \ + printf "https://qh.is/git/%s.git" "$$name" > $$path/url; \ + touch $@ + +.PHONY: all stagit stagit-all stagit-sync-all sync-stagit sync-blog clean diff --git a/post-receive.sample b/post-receive.sample @@ -0,0 +1,31 @@ +#!/bin/sh +set -eu + +# Place this in bare repo's hooks/post-receive as executable. +# Manually set REPO variable and additional make targets if necessary. + +TARGET="REPO={{REPO}} sync-stagit" + +SITE_DIR=/home/user/site +BUILD_DIR=/tmp/git-site-build +LOCKFILE=$BUILD_DIR.lock + +read oldrev newrev refname + +if [ "$refname" != 'refs/heads/main' ]; then + echo "Push received for $refname. Skipping build (only 'main' triggers build)." + exit 0 +fi + +( + echo "--- Acquiring Lock for $newrev ---" + flock -x 200 || exit 1 + echo "--- Starting Build for $newrev ---" + + rm -rf "$BUILD_DIR" && mkdir -p "$BUILD_DIR" + git --work-tree="$BUILD_DIR" --git-dir="$SITE_DIR" checkout -f main + cd "$BUILD_DIR" || exit + make $TARGET + + echo "--- Build Complete ---" +) 200>"$LOCKFILE" diff --git a/stagit/site.git b/stagit/site.git @@ -0,0 +1,3 @@ +name=site +path=~/site +description="scripts to generate personal blog and git repositories" diff --git a/stagit/stagit.git b/stagit/stagit.git @@ -0,0 +1,3 @@ +name=stagit +path=~/stagit +description="static git repository generator"