prez-biblio/Makefile

94 lines
2.5 KiB
Makefile

# Variables.
# À modifier pour adapter aux usages.
SASS = ./node_modules/.bin/sass
BS = ./node_modules/.bin/browser-sync
REVEALJS = node_modules/reveal.js
PORT = 8080
SLIDES_FILE = slides.md
SLIDES_DIR = sources/slides
THEME_SOURCE = src/scss/bunige.scss
THEME = static/css/bunige.css
TEMPLATE = static/templates/template.html
OUTPUT_FILE = index.html
SITE_DIR = _site
WORKTREE_DIR = .worktree/pages
VERSION := $(shell git describe --tags --exact-match 2>/dev/null || git rev-parse --short HEAD)
.PHONY: all serve watch clean css html watch-css site publish
all: html
css: $(THEME)
# Compile le thème à partir des sources SCSS
$(THEME): $(THEME_SOURCE)
$(SASS) --load-path=. $< $@
html: $(OUTPUT_FILE)
# Converti la présentation au format HTML
$(OUTPUT_FILE): $(SLIDES_DIR)/$(SLIDES_FILE) $(THEME) $(TEMPLATE)
pandoc \
--to=revealjs \
--standalone \
--citeproc \
--template=$(TEMPLATE) \
--variable revealjs-url=$(REVEALJS) \
--variable version=$(VERSION) \
--syntax-highlighting=zenburn \
--slide-level=2 \
--css $(THEME) \
-V pdfSeparateFragments=false \
-o $@ \
$(SLIDES_DIR)/$(SLIDES_FILE)
# Sert localement la présentation
# et recharge la page du navigateur lors de modifications.
serve:
$(BS) start \
--server \
--port $(PORT) \
--files "$(OUTPUT_FILE), $(THEME)" \
--startPath /$(OUTPUT_FILE)
# Observe les modifications des fichiers sources
# et relance les compilations nécessaires.
watch:
watchexec -r \
-w . \
-i $(OUTPUT_FILE) \
-- $(MAKE) all
watch-css:
$(SASS) --watch --load-path=. $(THEME_SOURCE):$(THEME)
# Supprime les fichiers compilés (index.html, static/css/bunige.css).
clean:
rm -f $(OUTPUT_FILE) $(THEME)
# Crée une copie du projet prête à être servie en ligne.
# Comprend les dépendances nécessaires (revealjs).
site: all
rm -rf $(SITE_DIR)
mkdir -p $(SITE_DIR)/static $(SITE_DIR)/node_modules
cp $(OUTPUT_FILE) $(SITE_DIR)/
cp -r static/* $(SITE_DIR)/static/
cp -r node_modules/reveal.js $(SITE_DIR)/node_modules/
# Prépare la présentation pour publication.
# Installe les dépendance (cible `site` ci-dessus)
# Crée la branche `pages` dans le *worktree*.
# Pousse la branche.
# Fonctionne avec codeberg.page.
.PHONY: publish
publish: site
rsync -a --delete --exclude='.git' \
--exclude='test/' \
--exclude='examples/' \
$(SITE_DIR)/ $(WORKTREE_DIR)/
cd $(WORKTREE_DIR) && git add -A
cd $(WORKTREE_DIR) && git commit -m "Deploy $$(date -Iseconds)" || echo "Rien à publier"
cd $(WORKTREE_DIR) && git push mine pages