From b88c1dc84d04ced9c1d1749a458bc938124573bd Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 16 Sep 2023 12:34:25 +0200 Subject: Fix XML feed style --- Dockerfile | 1 + Makefile | 9 +++++- config.toml | 2 +- src/index.ts | 2 +- templates/atom.xml | 2 +- templates/feed-styles.html | 71 +++++++++++++++++++++++++--------------------- 6 files changed, 50 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4261ce2..a455c0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,6 +52,7 @@ COPY --from=ssg /web/config.toml ./ COPY --from=ssg /web/content content COPY --from=ssg /web/public public +RUN make postprocess RUN make -j4 format compress # Final stage for app image diff --git a/Makefile b/Makefile index 0d658d4..d40c117 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,16 @@ build: $(PREFIX)/index.html $(PREFIX)/index.html: config.toml $(md_files) zola build --force --output-dir $(PREFIX) +$(PREFIX)/feed-styles.xsl: $(PREFIX)/index.html + mv $(PREFIX)/feed-styles/index.html $@ + rm -fr $(PREFIX)/feed-styles + +postprocess: $(PREFIX)/feed-styles.xsl + touch .postprocessstamp + format: .formatstamp -.formatstamp: $(PREFIX)/index.html +.formatstamp: $(PREFIX)/index.html .postprocessstamp @echo "Formatting HTML..." @prettier --write --parser html --print-width 200 "$(PREFIX)/**/*.html" > /dev/null @touch .formatstamp diff --git a/config.toml b/config.toml index d2a22ad..7dbffcc 100644 --- a/config.toml +++ b/config.toml @@ -29,7 +29,7 @@ webserver_sends_csp_headers = true cache-control = "max-age=14400" x-content-type-options = "nosniff" strict-transport-security = "max-age=31536000; includeSubdomains; preload" -content-security-policy = "default-src 'none'; img-src 'self'; object-src 'none'; script-src 'none'; style-src 'unsafe-inline'; form-action 'none'; base-uri 'self'" +content-security-policy = "default-src 'none'; img-src 'self'; object-src 'none'; script-src 'self'; style-src 'unsafe-inline'; form-action 'none'; base-uri 'self'" [[extra.main_menu]] name = "Posts" diff --git a/src/index.ts b/src/index.ts index 0667115..8bdc80e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,7 +66,7 @@ function registerFile( filename, relPath: "/" + path, handle: handle, - type: pathname.startsWith("/feed-styles") ? "text/xsl" : handle.type, + type: pathname.startsWith("/feed-styles.xsl") ? "text/xsl" : handle.type, headers: pathname === "/404.html" ? Object.assign({}, defaultHeaders, { "cache-control": "no-cache" }) diff --git a/templates/atom.xml b/templates/atom.xml index 3fd5dee..81c9a76 100644 --- a/templates/atom.xml +++ b/templates/atom.xml @@ -1,5 +1,5 @@ - + {{ config.title }} {%- if term %} - {{ term.name }} diff --git a/templates/feed-styles.html b/templates/feed-styles.html index 66dac33..a66ddc0 100644 --- a/templates/feed-styles.html +++ b/templates/feed-styles.html @@ -1,55 +1,60 @@ <?xml version="1.0" encoding="utf-8"?> -<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:atom="http://www.w3.org/2005/Atom"> - <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> +<xsl:stylesheet + version="3.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:atom="http://www.w3.org/2005/Atom" +> + <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> - <title> - RSS Feed | - <xsl:value-of select="/atom:feed/atom:title"/> - - - - + RSS Feed | <xsl:value-of select="/atom:feed/atom:title"/> + + +
- This is an RSS feed. Subscribe by copying - the URL from the address bar into your newsreader. Visit + This is an RSS feed. Subscribe by copying the URL + from the address bar into your newsreader. Visit About Feeds to learn more and get started. It's free.

- - - - - + + + + + + fill="#FFF" + /> + fill="#FFF" + /> RSS Feed Preview | - +