2024-01-09 20:00:48 -05:00
|
|
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
|
|
|
|
#
|
2024-07-13 01:22:04 -04:00
|
|
|
#> Manage building Hugo website
|
|
|
|
#>
|
|
|
|
#> Andrew Stryker <axs@sdf.org>
|
|
|
|
#>
|
2024-01-09 20:00:48 -05:00
|
|
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Configuration
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------#
|
2023-12-20 13:02:10 -05:00
|
|
|
|
2024-07-13 14:53:09 -04:00
|
|
|
SHELL = /usr/bin/bash
|
|
|
|
|
2023-12-20 13:02:10 -05:00
|
|
|
DEST ?= axs@sdf.org:html
|
|
|
|
SITE_URL ?= https://axs.sdf.org
|
|
|
|
|
2024-07-13 14:53:09 -04:00
|
|
|
HUGO_SERVE_FLAGS ?= --buildDrafts
|
|
|
|
hugo_serve_cmd = hugo server ${HUGO_SERVE_FLAGS}
|
|
|
|
|
2024-07-13 01:22:04 -04:00
|
|
|
help_generator = generate-help.awk
|
|
|
|
|
2024-01-09 20:00:48 -05:00
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Define user interface
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
|
|
|
|
.PHONY: default help publish build
|
|
|
|
|
|
|
|
default: build
|
2023-12-20 13:02:10 -05:00
|
|
|
|
2024-07-13 01:22:04 -04:00
|
|
|
build: .build_sentinel #> Build site with Hugo (default)
|
2023-12-20 13:02:10 -05:00
|
|
|
|
|
|
|
publish: build #> Publish site
|
2024-01-09 20:00:48 -05:00
|
|
|
@echo "📰Publishing..."
|
2023-12-20 13:02:10 -05:00
|
|
|
@# rsync options:
|
|
|
|
@# verbose: show each operation
|
|
|
|
@# links: preserve symlinks
|
|
|
|
@# safe-links: ignore symlinks that point outside of tree
|
|
|
|
@# times: preserve modification times
|
|
|
|
@# delete: delete extraneous files, i.e., files on destination
|
|
|
|
@# chmod: set permsions
|
2024-01-09 20:00:48 -05:00
|
|
|
@echo "\t 📡 Copying from public to ${DEST}"
|
2023-12-20 13:02:10 -05:00
|
|
|
@rsync \
|
|
|
|
--verbose \
|
|
|
|
--recursive \
|
|
|
|
--links \
|
|
|
|
--safe-links \
|
|
|
|
--times \
|
|
|
|
--delete \
|
|
|
|
--cvs-exclude \
|
|
|
|
--chmod=D755,F644 \
|
|
|
|
public/ \
|
|
|
|
${DEST}
|
|
|
|
@echo "\t 🛡️ Setting permissions"
|
|
|
|
@ssh axs@sdf.org 'mkhomepg -p'
|
|
|
|
@echo "✓ Publising complete"
|
|
|
|
@echo "\nThe site should be available on ${SITE_URL}"
|
2024-01-09 20:00:48 -05:00
|
|
|
|
2024-07-13 14:53:09 -04:00
|
|
|
serve: #> Start a Hugo server
|
|
|
|
@if [[ -z $${TMUX} ]]; \
|
|
|
|
then \
|
|
|
|
echo not tmux; \
|
|
|
|
else \
|
|
|
|
echo Starting a Hugo server in a new Tmux window; \
|
|
|
|
tmux neww ${hugo_serve_cmd}; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-13 01:22:04 -04:00
|
|
|
help: #> Generate this help message
|
|
|
|
@gawk -f ${help_generator} $(MAKEFILE_LIST)
|
|
|
|
|
2024-01-09 20:04:41 -05:00
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
#
|
|
|
|
# Define file interface
|
|
|
|
#
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
|
2023-12-20 14:08:42 -05:00
|
|
|
.build_sentinel: $(wildcard content/*/*)
|
|
|
|
@echo "\t 🏗️ Building site"
|
|
|
|
@# We call hugo with two options:
|
|
|
|
@# --cleanDestinationDir, to remove deleted files
|
|
|
|
@# --minify, to compress files my removing extra whitespace
|
|
|
|
hugo --cleanDestinationDir --minify
|
|
|
|
@touch $@
|
2024-01-09 20:04:41 -05:00
|
|
|
@echo "✓ Building complete"
|
|
|
|
|
2024-01-09 20:00:48 -05:00
|
|
|
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-#
|