From: Lady Date: Sat, 10 Dec 2022 03:29:30 +0000 (-0800) Subject: Change output mode to H·T·M·L X-Git-Tag: 0.2.0~1 X-Git-Url: https://git.ladys.computer/Shrine-XSLT/commitdiff_plain/820c8ba68006a97a11027c972493391bf58b06e9 Change output mode to H·T·M·L --- diff --git a/GNUmakefile b/GNUmakefile index fa30f68..ecf9f9d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -2,9 +2,9 @@ SHELL = /bin/sh # This GNUmakefile searches the `sources/` directory for files with an extension of `.xml` and applies `transform.xslt` to them, outputting the result in one of two locations :— # -# • For files with a location of `sources/index.xml` or `sources/index-*.xml`, the transformed file will be written to `public/%.xhtml` (where `%` is the filename). +# • For files with a location of `sources/index.xml` or `sources/index-*.xml`, the transformed file will be written to `public/%.html` (where `%` is the filename). # -# • For all other files with a location of `sources/*.xml` or `sources/*/*.xml`, the transformed file will be written to `public/%/index.xhtml` (where `%` is the filename and subdirectory if applicable). +# • For all other files with a location of `sources/*.xml` or `sources/*/*.xml`, the transformed file will be written to `public/%/index.html` (where `%` is the filename and subdirectory if applicable). # Only one level of subdirectory is supported. # # By default, running `make` will do this for all applicable source files. @@ -16,7 +16,6 @@ SHELL = /bin/sh # This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. # If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. -XHTMLEXT = xhtml XSLT = xsltproc XSLTOPTS = @@ -25,22 +24,23 @@ footers := $(wildcard *-footer.xml) override prerequisites := transform.xslt $(headers) $(footers) override indexsources := $(wildcard sources/index.xml sources/index-*.xml) -override indices := $(patsubst sources/%.xml,public/%.$(XHTMLEXT),$(indexsources)) +override indices := $(patsubst sources/%.xml,public/%.html,$(indexsources)) override pagesources := $(filter-out $(indexsources),$(wildcard sources/*.xml sources/*/*.xml)) -override pages := $(patsubst sources/%.xml,public/%/index.$(XHTMLEXT),$(pagesources)) +override pages := $(patsubst sources/%.xml,public/%/index.html,$(pagesources)) -override makexslt = $(XSLT) --nonet --novalid $(XSLTOPTS) -o $(2) transform.xslt $(1) +override content := $(indices) $(pages) -all: $(indices) $(pages) ; +override makexslt = $(XSLT) --nonet --novalid $(XSLTOPTS) -o $(2) transform.xslt $(1) -$(indices): public/%.$(XHTMLEXT): sources/%.xml $(prerequisites) - $(call makexslt,$<,$@) +all: $(content) ; -$(pages): public/%/index.$(XHTMLEXT): sources/%.xml $(prerequisites) - $(call makexslt,$<,$@) +$(indices): public/%.html: sources/%.xml $(prerequisites) + @echo "Generating $@…" + @$(call makexslt,$<,$@) -clean: - rm -f $(indices) $(pages) +$(pages): public/%/index.html: sources/%.xml $(prerequisites) + @echo "Generating $@…" + @$(call makexslt,$<,$@) -.PHONY: all clean ; +.PHONY: all ; diff --git a/README.markdown b/README.markdown index 216d4d8..c7b84ae 100644 --- a/README.markdown +++ b/README.markdown @@ -12,11 +12,10 @@ substantially changing the authoring flow. ## Prerequisites -These things come preinstalled on many platforms :— +These things come pre·installed on many platforms :— -- G·N·U Make (run `make --version` to see if it is installed) - -- libxslt (run `xsltproc --version` to see if it is installed) +- G·N·U `make` (run `make --version` to see if it is installed) +- `xsltproc` (run `xsltproc --version` to see if it is installed) You will also need to know how to write X·M·L, and how to navigate to a directory via the command line and run `make`. @@ -48,41 +47,20 @@ page. The ``, ``, and `` elements will be replaced by the page header, content, and footer, respectively. -Finally, just run `make` from this directory, and X·H·T·M·L files +Finally, just run `make` from this directory, and H·T·M·L files corresponding to your source files will be created in the `public/` directory (which you can then serve statically from your server). ## Notes -- The created files have a `.xhtml` extension and *need* to be served - with a `application/xhtml+xml` (or `application/xml`) media type. Not - all servers know how to serve `.xhtml` files; if this is you, you may - have better luck with `make XHTMLEXT=xml` (which will produce `.xml` - files instead). - - - Some free hosting options require that “index” pages have an - extension of `.html`; these will unfortunately not work. It is - possible to extend the makefile to generate `index.html` redirects - to `index.xhtml` with the following code :— - - ```make - override redirects := $(patsubst public/%.$(XHTMLEXT),public/%.html,$(indices) $(pages)) - - all: $(redirects) # in addition to the previously declared prerequisites - - $(redirects): - # You may want a more involved redirect page than this, but it’s an example… - echo '' > $@ - ``` - - This should be considered a last resort, but it can be used to get - your site working on e·g Neocities. +- The created files have a `.html` extension and need to be served + with a `text/html` media type. - Files at `sources/index.xml` and `sources/index-*.xml` will produce - output at `public/%.xhtml` (where `%` is the filename). + output at `public/%.html` (where `%` is the filename). - All other files at `sources/*.xml` and `sources/*/*.xml` will produce - output at `public/%/index.xhtml` (where `%` is the filename and + output at `public/%/index.html` (where `%` is the filename and optional subdirectory). Only one level of subdirectory is supported. - The transformation doesn’t do any rewriting of links. Make sure you diff --git a/template.xml b/template.xml index 01683e8..113ff65 100644 --- a/template.xml +++ b/template.xml @@ -1,10 +1,12 @@ - - - + + +
+
+ diff --git a/transform.xslt b/transform.xslt index 2e3c7bd..0919121 100644 --- a/transform.xslt +++ b/transform.xslt @@ -23,8 +23,6 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. --> - + - - + + @@ -61,7 +59,14 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h - + + + + + + - - + + - + + + + + + - - + + - - + + - + - + - - + - <xslt:apply-templates select="exslt:node-set($source)//html:h1" mode="text"/> + <xslt:apply-templates select="$source//html:h1" mode="text"/> - - + - + - + @@ -136,7 +146,7 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h If no `@data-footer` attribute is provided, no footer is rendered. --> - + @@ -145,7 +155,7 @@ If a copy of the MPL was not distributed with this file, You can obtain one at h Process the content. --> - + +