OC ?= ../oc # not public/: a running `hugo server` renders there, with its live-reload script BUILD ?= build # search index generator (https://pagefind.app), fetched by npx on first use PAGEFIND ?= npx -y pagefind@1 # test server: the web share of barbel-lescar, mounted from the file manager (smb://barbel-lescar/web) DEPLOY_DIR ?= /run/user/$(shell id -u)/gvfs/smb-share:server=barbel-lescar,share=web/oldcomputers DEPLOY_URL ?= https://barbel.synology.me/oldcomputers/ # forum on the server (comment discussions of the news posts, see forum-sync): FORUM_RUN runs a # shell line where the forum lives; empty = no forum, deploy then skips the sync FORUM_RUN ?= ssh -p 27 yannick@192.168.1.98 FORUM_DIR ?= /volume2/web/oldcomputers-forum FORUM_PHP ?= /usr/local/bin/php84 -d memory_limit=512M .PHONY: content build check serve deploy post forum-up forum-import forum-down forum-bundle forum-sync content: ## regenerate content/ and static/media/ from the extraction repo python3 $(OC)/scripts/05_hugo.py --target $(CURDIR) $(if $(wildcard data/forum.json),--forum) build: ## build the site and its search index into $(BUILD)/ rm -rf $(BUILD) hugo --panicOnWarning --minify -d $(BUILD) $(PAGEFIND) --site $(BUILD) check: build ## build, then verify every internal link and image python3 tools/check_links.py $(BUILD) serve: ## local preview on http://localhost:1313 hugo server post: ## new post: make post NAME=my-title, then edit content/post/-my-title.md @test -n "$(NAME)" || { echo "usage: make post NAME=my-title"; exit 1; } hugo new content post/$(shell date +%F)-$(NAME).md forum-sync: ## create the forum discussion of each new news post (updates data/forum_pages.json) ifneq ($(strip $(FORUM_RUN)),) python3 tools/forum_sync.py --run '$(FORUM_RUN)' --dir '$(FORUM_DIR)' --php '$(FORUM_PHP)' --site-url '$(DEPLOY_URL)' endif deploy: forum-sync check ## build, check, and copy $(BUILD)/ to DEPLOY_DIR (served at DEPLOY_URL) @test -d "$(dir $(DEPLOY_DIR))" || { echo "share not mounted: $(dir $(DEPLOY_DIR))"; exit 1; } mkdir -p "$(DEPLOY_DIR)" rsync -r --size-only --info=stats1 $(BUILD)/media/ "$(DEPLOY_DIR)/media/" rsync -rc --delete --exclude=/media/ --info=stats1 $(BUILD)/ "$(DEPLOY_DIR)/" # --- local test forum (Flarum in Docker, see forum/README.md) --- FORUM = docker compose -f forum/docker-compose.yml SITE_URL ?= http://localhost:1313 forum-up: ## start the test forum on http://localhost:8081 (admin / adminadmin) $(FORUM) up -d --build forum-import: ## export the archived comments and import them into the test forum python3 $(OC)/scripts/06_forum.py --target $(CURDIR) $(FORUM) exec -T flarum php flarum oc:import /import/machines.json --site-url=$(SITE_URL) --map=/import/forum.json forum-down: ## stop the test forum (forum-db volume keeps its data) $(FORUM) down forum-bundle: ## build forum/import/forum.tar.gz: Flarum + extension, to copy to the server mkdir -p forum/import $(FORUM) build flarum docker run --rm --entrypoint /bundle.sh -v $(CURDIR)/forum/docker/bundle.sh:/bundle.sh:ro \ -v $(CURDIR)/forum/extension:/extension:ro -v $(CURDIR)/forum/import:/out forum-flarum