From: Lady Date: Sun, 19 May 2024 21:43:05 +0000 (-0400) Subject: Remove support for pagination X-Git-Tag: 0.9.0~2 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/33cd26f85eec175028a9e7ced1562e34ff3d15d6?ds=sidebyside;hp=b620a662b669862cd7bf01aa06c8ad3de2f1a7f4 Remove support for pagination Expanded archives support this need better. --- diff --git a/GNUmakefile b/GNUmakefile index 73c8057..338c55d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -171,7 +171,7 @@ THISDIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) # By default, `find´ will ignore files which begin with a period and those which are likely to cause problems for `make´. EXTRAFINDRULES := EXTRAFINDINCLUDERULES := -FINDRULES := ! '(' '(' -name '[.-]*' -o -name '*[][*?:|$$%\#\\; ]*' -o -name '*"{*' -o -name '*}"*' -o -name '*[)]' ')' -a -prune ')'$(if $(EXTRAFINDRULES), -a $(EXTRAFINDRULES),) +FINDRULES := ! '(' '(' -name '[.-]*' -o -name '*[][*?:|$$%\#\\; ]*' -o -name '*[)]' ')' -a -prune ')'$(if $(EXTRAFINDRULES), -a $(EXTRAFINDRULES),) FINDINCLUDERULES := $(FINDRULES)$(if $(EXTRAFINDINCLUDERULES), -a $(EXTRAFINDINCLUDERULES),) # The list of magic files to use when determining media types. @@ -217,9 +217,6 @@ endif # # • ‹ urn:fdc:ladys.computer:20231231:Shu1She4:mode:archive ›: # Generates archive files from parse results. -# -# • ‹ urn:fdc:ladys.computer:20231231:Shu1She4:mode:paged ›: -# Generates paginated files from parse results. MODE := urn:fdc:ladys.computer:20231231:Shu1She4:mode:default # Set to a non·empty value to print all commands as they run. @@ -286,14 +283,8 @@ override xpath = $(XMLLINT) --xpath $(call quote,$1) $(call quote,$2) > /dev/nul # (callable) Extract the value of the text nodes in the provided X·M·L document and print them to `stdout´. override extracttext = $(PRINTF) '%s' '' | $(XSLTPROC) --nonet --novalid - $(call quote,$1) -# (callable) List the files in the provided directory which are associated with the provided filename, one per line. -override associatedfiles = $(LS) -1 $(call quote,$1) | $(SED) '/.*"{.*}".*/!d;s/^\(.*\)"{.*}"\(.*\)$$/\1\2|&/' | $(GREP) -F -e $(call quote,$2|) | $(SED) 's/^.*|//' - -# (callable) Remove files associated with the provided file. -override removeassociatedfiles = ASSOCIATED="$$($(call associatedfiles,$(dir $1),$(notdir $1)) | $(TR) '\n' ' ')"; if $(TEST) -n "$$ASSOCIATED"; then cd $(call quote,$(dir $1)) && $(PRINTF) '%s\n' "$$ASSOCIATED" | $(SED) 's/ \{2,\}/ /g;s/^ //;s/ $$//' | $(TR) ' ' '\n' | $(xargsmultiquote) | $(XARGS) -E '' $(RM); fi - # (callable) Process the provided transformation result and output the result to the provided location, given the provided relative path. -override processresultto = if $(call xpath,/*[local-name()="raw-text" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(call extracttext,$1) > $(call quote,$2); $(call removeassociatedfiles,$2); elif $(call xpath,/*[local-name()="base64-binary" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then { $(PRINTF) '%s\n' 'begin-base64 644 -'; $(call extracttext,$1) | $(TR) -d '\t\n\f\r '; $(PRINTF) '\n%s\n' '===='; } | $(UUDECODE) -o /dev/stdout > $(call quote,$2); $(call removeassociatedfiles,$2); elif $(call xpath,/*[local-name()="archive" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(MAKE) -f $(call quote,$(abspath $(THISDIR)/GNUmakefile)) $(call quote,$2) NAME=$(call quote,$3) SRC=$(call quote,$1) BUILDDIR=$(call quote,$(BUILDDIR)/archive/$3) DESTDIR=$(call quote,$(patsubst %/,%,$(dir $2))) MODE='urn:fdc:ladys.computer:20231231:Shu1She4:mode:archive'; $(call removeassociatedfiles,$2); elif $(call xpath,//*[local-name()="page" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(MAKE) -f $(call quote,$(abspath $(THISDIR)/GNUmakefile)) $(call quote,$2) NAME=$(call quote,$3) SRC=$(call quote,$1) BUILDDIR=$(call quote,$(BUILDDIR)/paged/$3) DESTDIR=$(call quote,$(patsubst %/,%,$(dir $2))) MODE='urn:fdc:ladys.computer:20231231:Shu1She4:mode:paged'; else $(XMLLINT) --nsclean $(call quote,$1) > $(call quote,$2); $(call removeassociatedfiles,$2); fi +override processresultto = if $(call xpath,/*[local-name()="raw-text" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(call extracttext,$1) > $(call quote,$2); elif $(call xpath,/*[local-name()="base64-binary" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then { $(PRINTF) '%s\n' 'begin-base64 644 -'; $(call extracttext,$1) | $(TR) -d '\t\n\f\r '; $(PRINTF) '\n%s\n' '===='; } | $(UUDECODE) -o /dev/stdout > $(call quote,$2); elif $(call xpath,/*[local-name()="archive" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$1); then $(MAKE) -f $(call quote,$(abspath $(THISDIR)/GNUmakefile)) $(call quote,$2) NAME=$(call quote,$3) SRC=$(call quote,$1) BUILDDIR=$(call quote,$(BUILDDIR)/archive/$3) DESTDIR=$(call quote,$(patsubst %/,%,$(dir $2))) MODE='urn:fdc:ladys.computer:20231231:Shu1She4:mode:archive'; else $(XMLLINT) --nsclean $(call quote,$1) > $(call quote,$2); fi # ━ § BEGIN DEFAULT MAKE·FILE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -659,7 +650,6 @@ $(call installed,$(recursivefiles) $(installablefiles)) : $(DESTDIR)/% : $(BUILD $(silent)$(call ensuredirectory,$(dir $@)) $(silent)$(RM) -f -R $(call quote,$@) $(silent)$(CP) -R $(call quote,$<) $(call quote,$@) - $(silent)for associated in $$($(call associatedfiles,$(dir $<),$(notdir $<))); do $(PRINTF) '%s\n' "$$associated" | $(SED) 's/^\(.*\)"{\(.*\)}"\(.*\)$$/\1\2\3/' | $(xargsquote) | $(XARGS) -E '' $(PRINTF) '%s%s\n' $(call quote,$(dir $@)) | $(xargsquote) | $(XARGS) -E '' $(CP) $(call quote,$(dir $<))"$$associated"; done # ━ § BEGIN ARCHIVE MAKE·FILE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -717,61 +707,6 @@ $(DESTDIR)/% : $(SRC) $(foreach file,$(archivefiles),$(BUILDDIR)/files/$(file)) $(silent)$(RM) -f -R $(call quote,$@) $(silent)cd $(call quote,$(BUILDDIR)/files); if $(call xpath,/*/@*[local-name()="expanded" and namespace-uri()="urn:fdc:ladys.computer:20231231:Shu1She4"],$(abspath $<)); then $(MKDIR) -p $(call quote,$(abspath $@)); $(PRINTF) '%s\n' $(foreach file,$(archivefiles),$(call quote,$(file))) | $(PAX) -r -w $(call quote,$(abspath $@)); else $(PRINTF) '%s\n' $(foreach file,$(archivefiles),$(call quote,$(file))) | $(PAX) -w -x ustar > $(call quote,$(abspath $@)); fi -# ━ § BEGIN PAGED MAKE·FILE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -else ifeq ($(MODE),urn:fdc:ladys.computer:20231231:Shu1She4:mode:paged) - -# ─ ¶ Non‐Recipe Variable Definitions ───────────────────────────────── - -# Get the list of pages. -ifneq ($(wildcard $(BUILDDIR)/index),) -override pagefiles := $(patsubst ./pages/%,%,$(shell $(CAT) $(call quote,$(BUILDDIR)/index))) -endif - -# ─ ¶ Recipe Variable Definitions ───────────────────────────────────── - -# ─ ¶ Phony Targets ─────────────────────────────────────────────────── - -# ─ ¶ Special Targets ───────────────────────────────────────────────── - -# Reload this make·file if the pages have changed. -$(THISDIR)/GNUmakefile : $(BUILDDIR)/index - $(silent)$(TOUCH) $(THISDIR)/GNUmakefile - @$(PRINTF) '%b\n' $(call quote,\0033[1mPages for updated. Restarting…\0033[22m) - -# ─ ¶ Build Targets ─────────────────────────────────────────────────── - -# Build the extractor transform for extracting the pages of the paged source file. -$(BUILDDIR)/extractor.xslt : $(SRC) $(THISDIR)/lib/paged2extractor.xslt - $(silent)$(call ensuredirectory,$(dir $@)) - $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) --stringparam NAME $(call quote,$(call notdir,$<)) $(call quote,$(THISDIR)/lib/paged2extractor.xslt) $(call quote,$<) - -# Use the extractor transform to extract the paged source file out into its pages. -# -# This target sleeps for 1 second to ensure the resulting index will always be newer than this make·file. -$(BUILDDIR)/index : $(BUILDDIR)/extractor.xslt $(SRC) - @$(PRINTF) '%s\n' $(call quote,Extracting pages for …) - $(silent)$(SLEEP) 1 - $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) --writesubtree $(call quote,$(dir $@)) $(call quote,$<) $(call quote,$(SRC)) - -# All other pages are extracted alongside the base. -$(foreach file,$(pagefiles),$(BUILDDIR)/pages/$(file)) : $(BUILDDIR)/index ; - -# Process each page into its final form. -$(foreach file,$(pagefiles),$(BUILDDIR)/public/$(file)) : $(BUILDDIR)/public/% : $(BUILDDIR)/pages/% - @$(PRINTF) '%s\n' $(call quote,Building page `$(subst }",,$(subst "{,,$*))´ of …) - $(silent)$(call ensuredirectory,$(dir $@)) - $(silent)$(call processresultto,$<,$@,$*) - -# Archive all components in the file to the destination. -# -# This is a match‐anything target, with the assumption that this make·file is being called recursively from the default mode. -$(DESTDIR)/% : $(foreach file,$(pagefiles),$(BUILDDIR)/public/$(file)) - @$(PRINTF) '%s\n' $(call quote,Collecting pages for …) - $(silent)$(call ensuredirectory,$(dir $@)) - $(silent)$(call removeassociatedfiles,$@) - $(silent)cp $(foreach file,$(pagefiles),$(call quote,$(BUILDDIR)/public/$(file))) $(DESTDIR) - # ━ § END DEFINED MAKE·FILE MODES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ else diff --git a/README.markdown b/README.markdown index 952f4ee..86d57bc 100644 --- a/README.markdown +++ b/README.markdown @@ -335,14 +335,12 @@ Source files whose media type does not have an associated X·S·L·T contain Ascii white·space, colons (`:`), semis (`;`), pipes (`|`), bucks (`$`), percents (`%`), hashes (`#`), asterisks (`*`), brackets (`[` or `]`), erotemes (`?`), backslashes (`\`), or control - characters, must not begin with a hyphen‐minus (`-`), must not end - with a cloparen (`)`), and must not contain quoted braces (`"{` or - `}"`).** + characters, must not begin with a hyphen‐minus (`-`), and must not end + with a cloparen (`)`).** The former characters have the potential to conflict with make syntax, - a leading hyphen‐minus is confusable for a command‐line argument, a + a leading hyphen‐minus is confusable for a commandline argument, and a trailing cloparen [activates a bug in G·N·U Make - 3.81](https://stackoverflow.com/questions/17148468/capturing-filenames-including-parentheses-with-gnu-makes-wildcard-function#comment24825307_17148894), - and quoted braces are used internally by the program. + 3.81](https://stackoverflow.com/questions/17148468/capturing-filenames-including-parentheses-with-gnu-makes-wildcard-function#comment24825307_17148894). ## Parsers @@ -689,29 +687,6 @@ They are :⁠— A plaintext (U·T·F‐8) file will be produced from the text nodes in the transformation result. -## Pagination - -It is possible to have a single source file produce multiple output - files via `<书社:page>` elements, whose `@name` gives the name of the - page. -If a parsed document has a `@书社:destination` which contains `%s`, - the `%s` will be replaced with the `@name` for each `<书社:page>` (and - removed for the main output). -Otherwise, the `@name` is inserted before the first period of the - filename (or at the end of the filename for those with no period). -If `<书社:page>`s do not have a `@name`, they are numbered - sequentially. -The destination of pages must be in the same directory as their parent. - -Pagination essentially forms a limited convenience for the more - sophisticated technique of creating an archive with ⛩️📰 书社 and - then unarchiving it. -Pages are, from Make’s point of view, untracked side·effects of - installing the main output, meaning they cannot be targeted directly - and will not appear in `make list` or `make listout`. -They are intended solely for the like of indices and feeds, for which - convenience and necessity outweigh their flaws. - ## License This repository conforms to [REUSE][]. diff --git a/lib/catalog2destinations.xslt b/lib/catalog2destinations.xslt index ae1ea29..411c454 100644 --- a/lib/catalog2destinations.xslt +++ b/lib/catalog2destinations.xslt @@ -28,23 +28,7 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one | - - - - / - - - - - - - - - - - - - + diff --git a/lib/catalog2transform.xslt b/lib/catalog2transform.xslt index 3fb4c33..67ddb88 100644 --- a/lib/catalog2transform.xslt +++ b/lib/catalog2transform.xslt @@ -58,30 +58,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one - - - - - / - - - - - - - - - - - %s. - - - - - %s - - - @@ -308,33 +284,17 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one - - + + - + - - - - %22%7B - - - - - - - - - %7D%22 - - - diff --git a/lib/paged2extractor.xslt b/lib/paged2extractor.xslt deleted file mode 100644 index 5d1a155..0000000 --- a/lib/paged2extractor.xslt +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - -