From: Lady Date: Sun, 2 Jun 2024 02:11:10 +0000 (-0400) Subject: Simplify metadata using new 书社vocab terms X-Git-Tag: 0.11.0^0 X-Git-Url: https://git.ladys.computer/Shushe/commitdiff_plain/078634e919648c17178b533fb7a98ee501caec59?ds=sidebyside Simplify metadata using new 书社vocab terms This commit also changes the behaviour of `@书社:destination`: Formerly, the value of this attribute needed to be a percent·encoded; now, it must _not_ be percent·encoded. --- diff --git a/GNUmakefile b/GNUmakefile index 99e94cf..3c49432 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -478,7 +478,8 @@ ifneq ($(wildcard $(BUILDDIR)/destinations),) override destinations := $(shell $(CAT) $(BUILDDIR)/destinations) # Pair source files and their destinations. -override sourcedestinationpair := $(foreach destination,$(destinations),$(call sourcefile,$(firstword $(subst |, ,$(destination))))|$(call perdec,$(subst $(space),|,$(wordlist 2,$(words $(subst |, ,$(destination))),$(subst |, ,$(destination)))))) +override sourcedestinationpair := $(foreach destination,$(destinations),$(call sourcefile,$(firstword $(subst |, ,$(destination))))|$(subst $(space),|,$(wordlist 2,$(words $(subst |, ,$(destination))),$(subst |, ,$(destination))))) +endif # (callable) Get the destination for the given source files, or return `.NOTDEF/$1´. # @@ -502,7 +503,6 @@ override unbuilt = $(foreach file,$1,$(call uncompiled,$(patsubst $(BUILDDIR)/pu # (callable) Get the installed locations for the given source files. override installed = $(foreach file,$1,$(DESTDIR)/$(call destination,$(file))) -endif # ─ ¶ Recipe Variable Definitions ───────────────────────────────────── @@ -631,10 +631,12 @@ $(BUILDDIR)/parser.xslt : $(BUILDDIR)/parser.catalog $(THISDIR)/lib/catalog2pars $(silent)$(TOUCH) $(call quote,$(BUILDDIR)/.update-types) # Generate R·D·F metadata for files. -$(call metadata,$(sourcefiles) $(sourceincludes)) : % : $$(call datadata,$$@) $(typeupdates) +# +# This “depends” on `$(THISDIR)/lib/expandmetadata.xslt´ not because it is an actual dependency, but because a change to that file strongly suggests a change to these rules has occurred as well. +$(call metadata,$(sourcefiles) $(sourceincludes)) : % : $$(call datadata,$$@) $(THISDIR)/lib/expandmetadata.xslt $(typeupdates) $(call inform,$(PRINTF) '%s\n' $(call quote,Generating metadata for `$<´…) >&2) $(silent)$(call ensuredirectory,$(dir $@)) - $(silent){ if $(TEST) ! -f $(call quote,$(BUILDDIR)/.mtime); then $(PRINTF) '%b' '\n' >|$(call quote,$(BUILDDIR)/.mtime); fi; $(TOUCH) -r $(call quote,$<) $(call quote,$(BUILDDIR)/.mtime); $(DIFF) -u $(call quote,$(BUILDDIR)/.mtime) /dev/null | $(SED) '1!d;s/.* \([^ ]*\) \([^ ]*\).*$$/\1T\2Z/'; $(CKSUM) $(call quote,$<) | $(SED) 's/[ ].*//'; } | $(xargsmultiquote) | $(XARGS) -E '' $(PRINTF) '$(if $(filter $<,$(assetfiles)),,)%s' $(call quote,$(call attresc,$(call localuri,$<))) $(call quote,$(call attresc,$(if $(filter $<,$(sourceincludes)),$(call includepath,$<),$(call sourcepath,$<)))) $(call quote,$(call attresc,$(call fileuri,$<))) $(call quote,$(call attresc,$(call typeoffile,$<))) >|$(call quote,$@) + $(silent){ if $(TEST) ! -f $(call quote,$(BUILDDIR)/.mtime); then $(PRINTF) '%b' '\n' >|$(call quote,$(BUILDDIR)/.mtime); fi; $(TOUCH) -r $(call quote,$<) $(call quote,$(BUILDDIR)/.mtime); $(DIFF) -u $(call quote,$(BUILDDIR)/.mtime) /dev/null | $(SED) '1!d;s/.* \([^ ]*\) \([^ ]*\).*$$/\1T\2Z/'; $(CKSUM) $(call quote,$<) | $(SED) 's/[ ].*//'; } | $(xargsmultiquote) | $(XARGS) -E '' $(PRINTF) '<书社vocab:$(if $(filter $<,$(sourceincludes)),IncludeFile,SourceFile) xmlns:nie="http://www.semanticdesktop.org/ontologies/2007/01/19/nie#" xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:书社vocab="urn:fdc:ladys.computer:20231231:Shu1She4:vocab:" rdf:about="%s" 书社vocab:path="%s">$(if $(filter $<,$(assetfiles)),,)%s' $(call quote,$(call attresc,$(call localuri,$<))) $(call quote,$(call attresc,$(if $(filter $<,$(sourceincludes)),$(call includepath,$<),$(call sourcepath,$<)))) $(call quote,$(call attresc,$(call typeoffile,$<))) >|$(call quote,$@) # Parse the files. # @@ -648,7 +650,7 @@ $(call parsed,$(sourcefiles) $(sourceincludes)) : % : $$(call unparsed,$$@) $(BU # Collect the metadata into a single file. $(BUILDDIR)/metadata : $(call diffprereqs,metadatas,$(call metadata,$(sort $(sourcefiles) $(sourceincludes)))) $(call parsed,$(filter-out $(assetfiles),$(sourcefiles) $(sourceincludes))) $(THISDIR)/lib/expandmetadata.xslt $(call inform,$(PRINTF) '%s\n' 'Compiling metadata…' >&2) - $(silent){ $(PRINTF) '' $(call quote,$(call attresc,$(call fileuri,$(BUILDDIR)))); { $(foreach meta,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))),$(CAT) $(call quote,$(meta));) } | $(SED) 's///g'; $(PRINTF) '%s\n' ''; } | $(XSLTPROC) --nonet --novalid --nomkdir --nowrite $(call quote,$(THISDIR)/lib/expandmetadata.xslt) - | $(XMLLINT) --nonet --nsclean - >|$(call quote,$@) + $(silent){ $(PRINTF) '<书社vocab:BuildDirectory nfo:fileUrl="%s"/>' $(call quote,$(call attresc,$(call fileuri,$(BUILDDIR)))); { $(foreach meta,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))),$(CAT) $(call quote,$(meta));) } | $(SED) 's///g'; $(PRINTF) '%s\n' ''; } | $(XSLTPROC) --nonet --novalid --nomkdir --nowrite $(call quote,$(THISDIR)/lib/expandmetadata.xslt) - | $(XMLLINT) --nonet --nsclean - >|$(call quote,$@) # Build a list of dependencies for each parsed file. $(BUILDDIR)/dependencies : $(BUILDDIR)/metadata $(THISDIR)/lib/metadata2dependencies.xslt @@ -678,7 +680,7 @@ $(BUILDDIR)/transform.xslt : $(BUILDDIR)/transform.catalog $(BUILDDIR)/metadata $(call compiled,$(compilablefiles)) : $(BUILDDIR)/results/% : $$(call parsed,$$(call uncompiled,$$@)) $$(call parsed,$$(call dependencies,$$(call uncompiled,$$@))) $(BUILDDIR)/transform.xslt $(BUILDDIR)/metadata $(call inform,$(PRINTF) '%s\n' $(call quote,Compiling …) >&2) $(silent)$(call ensuredirectory,$(dir $@)) - $(silent)$(XSLTPROC) --nonet --novalid --nomkdir --nowrite --stringparam METADATA 'metadata' --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*)$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<) >|$(call quote,$@) + $(silent)$(XSLTPROC) --nonet --novalid --nomkdir --nowrite --stringparam METADATA 'metadata' --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@)))$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<) >|$(call quote,$@) # Create the final files from the compiled results (or error in the case of recursive ones). $(call built,$(compilablefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/% diff --git a/README.markdown b/README.markdown index 4ce9994..37cc7f7 100644 --- a/README.markdown +++ b/README.markdown @@ -618,11 +618,6 @@ The following params are made available globally in parsers and - **`THISREV`:** The value of the `THISREV` variable (if present). -The following params are only available in transforms :⁠— - -- **`PATH`:** - The path of the output file (within `DESTDIR`). - ## Output Wrapping Provided at least one toplevel result element belongs to the H·T·M·L diff --git a/lib/catalog2transform.xslt b/lib/catalog2transform.xslt index 5098a2c..e169fa7 100644 --- a/lib/catalog2transform.xslt +++ b/lib/catalog2transform.xslt @@ -17,7 +17,6 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one ]> +