about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2023-02-16 20:52:49 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2023-02-16 20:52:49 +0900
commit21f317aab2368ec6ef341dc23b4257ffa24946af (patch)
treef525eb1f04c031dc5b3d3817e7588f860d0cad3f
parente24d423e566d3cc688acd359991359d59990e3cb (diff)
downloadpx-21f317aab2368ec6ef341dc23b4257ffa24946af.tar.gz
Use symlink instead of meta refresh redirect
I couldn't figure out a way to disable caching for the latter.
-rw-r--r--Makefile12
-rw-r--r--README.md4
-rw-r--r--index.xhtml6
-rw-r--r--page.xslt10
-rw-r--r--shell.nix (renamed from live.nix)2
5 files changed, 18 insertions, 16 deletions
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 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <meta http-equiv="refresh" content="0; url=/06/"/>
-  <link rel="alternate" type="application/atom+xml" href="/atom.xml"/>
-</html>
diff --git a/page.xslt b/page.xslt
index a9ea776..0cbc2bc 100644
--- a/page.xslt
+++ b/page.xslt
@@ -17,6 +17,11 @@
           <h1>PAGE <xsl:value-of select="@curr"/></h1>
           <xsl:if test="@next != ''"><a href="/{@next}/">NEXT</a></xsl:if>
         </nav>
+        <xsl:variable name="base">
+          <xsl:text>/</xsl:text>
+          <xsl:value-of select="@curr"/>
+          <xsl:text>/</xsl:text>
+        </xsl:variable>
 
         <xsl:for-each select="post">
           <xsl:variable name="id">
@@ -27,8 +32,9 @@
               <xsl:value-of select="@title"/>
             </a></h2>
             <xsl:for-each select="picture">
-              <a href="{@filename}.jpg">
-                <img alt="{@desc}" title="{@desc}" src="{@filename}.small.jpg"/>
+              <a href="{$base}{@filename}.jpg">
+                <img alt="{@desc}" title="{@desc}"
+                     src="{$base}{@filename}.small.jpg"/>
               </a><br/>
             </xsl:for-each>
           </article>
diff --git a/live.nix b/shell.nix
index b18b5ad..667fe41 100644
--- a/live.nix
+++ b/shell.nix
@@ -1,6 +1,6 @@
 with import <nixpkgs> {};
 mkShell {
-  packages = [ busybox epeg libxslt webfs ];
+  packages = [ busybox epeg inotify-tools libxslt webfs ];
   shellHook = ''
     make -j $(nproc) live
     webfsd -p 28792 -f index.xml