From 21f317aab2368ec6ef341dc23b4257ffa24946af Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 16 Feb 2023 20:52:49 +0900 Subject: Use symlink instead of meta refresh redirect I couldn't figure out a way to disable caching for the latter. --- Makefile | 12 +++++++----- README.md | 4 ++-- index.xhtml | 6 ------ live.nix | 9 --------- page.xslt | 10 ++++++++-- shell.nix | 9 +++++++++ 6 files changed, 26 insertions(+), 24 deletions(-) delete mode 100644 index.xhtml delete mode 100644 live.nix create mode 100644 shell.nix diff --git a/Makefile b/Makefile index c6671a8..7f69823 100644 --- a/Makefile +++ b/Makefile @@ -8,16 +8,19 @@ PREFIX ?= /tmp/px.cnx.gdn PICTURES := $(filter-out %.small.jpg $(PREFIX)/%.jpg, $(wildcard */*.jpg)) THUMBNAILS := $(patsubst %.jpg,%.small.jpg,$(PICTURES)) -DATA := $(wildcard */index.xml) +DATA := $(wildcard */index.xml) index.xml PAGES := $(patsubst %.xml,%.xhtml,$(DATA)) OUTPUTS := $(THUMBNAILS) $(PAGES) atom.xml -ALL := $(OUTPUTS) $(PICTURES) index.xhtml favicon.png style.css +ALL := $(OUTPUTS) $(PICTURES) favicon.png style.css all: $(OUTPUTS) %.small.jpg: %.jpg epeg -w 1024 -p -q 80 $< $@ +index.xml: 06/index.xml + ln -fs $< $@ + %.xhtml: %.xml page.xslt xsltproc page.xslt $< > $@ @@ -25,7 +28,7 @@ atom.xml: atom.xslt $(DATA) $(wildcard *.svg) xsltproc atom.xslt > atom.xml clean: - rm -f atom.xml */{index.xhtml,*.small.jpg} + rm -f atom.xml index.{xml,xhtml} */{index.xhtml,*.small.jpg} $(PREFIX)/%: % install -Dm644 $< $@ @@ -35,7 +38,6 @@ install: all $(addprefix $(PREFIX)/,$(ALL)) uninstall: rm -fr $(PREFIX) -live: $(THUMBNAILS) - ln -fs index.xhtml index.xml +live: $(THUMBNAILS) index.xml atom.xml .PHONY: all clean install uninstall live diff --git a/README.md b/README.md index 7094b25..0b70043 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ for displaying my photos. ## Hacking -Run `nix-shell live.nix` and open `http://localhost:28792`. +Run `nix-shell` and open `http://localhost:28792`. Changes to `*/index.xml` will be live reloaded thanks to modern browsers' native support for XSLT. The web feed -has to me manually regenerated with `make atom.xml` however. +has to be manually regenerated with `make atom.xml` however. ## Deployment diff --git a/index.xhtml b/index.xhtml deleted file mode 100644 index de0f040..0000000 --- a/index.xhtml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/live.nix b/live.nix deleted file mode 100644 index b18b5ad..0000000 --- a/live.nix +++ /dev/null @@ -1,9 +0,0 @@ -with import {}; -mkShell { - packages = [ busybox epeg libxslt webfs ]; - shellHook = '' - make -j $(nproc) live - webfsd -p 28792 -f index.xml - trap "kill $(pgrep -f 'webfsd -p 28792')" EXIT INT TERM - ''; -} diff --git a/page.xslt b/page.xslt index a9ea776..0cbc2bc 100644 --- a/page.xslt +++ b/page.xslt @@ -17,6 +17,11 @@

PAGE

NEXT + + / + + / + @@ -27,8 +32,9 @@ - - {@desc} + + {@desc}
diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..667fe41 --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +with import {}; +mkShell { + packages = [ busybox epeg inotify-tools libxslt webfs ]; + shellHook = '' + make -j $(nproc) live + webfsd -p 28792 -f index.xml + trap "kill $(pgrep -f 'webfsd -p 28792')" EXIT INT TERM + ''; +} -- cgit 1.4.1