summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
8b898cc)
`@书社:cksum`, `@书社:mtime`, and `@书社:identifier` are now all added
during the parsing phase. (`@书社:identifier` used to be added during
the transformation phase, but badly. `@书社:mtime` is new.)
This hardcodes the location of the metadata file for now; ideally the
metadata would be embedded.
# (callable) Quote the given string for use within shell calls.
override quote = '$(subst ','"'"',$1)'
# (callable) Quote the given string for use within shell calls.
override quote = '$(subst ','"'"',$1)'
-# (callable) Get the modified time of the provided file.
-#
-# This touches a file containing only a newline and then diffs it with `/dev/null´ and extracts the timestamp from the diff.
-# Interestingly, on Macintosh, the format of `diff -u´ is only Posixy (including a fractional component and timezone) when `COMMAND_MODE=legacy´; however, the timezone will always be zero and the fractional component is ignorable, so it’s not necessary to worry about that here.
-#
-# The diff will always have an exit status of 1, but this is ignored by piping into Sed.
-#
-# ☡ This variable creates a subshell every time it is computed.
-override modtime = $(shell if $(TEST) ! -f $(call quote,$(BUILDDIR)/.mtime); then $(PRINTF) '%b' '\n' > $(call quote,$(BUILDDIR)/.mtime); fi; $(TOUCH) -r $(call quote,$1) $(call quote,$(BUILDDIR)/.mtime); TZ=UTC0 $(DIFF) -u $(call quote,$(BUILDDIR)/.mtime) /dev/null | $(SED) '1!d;s/.* \([^ ]*\) \([^ ]*\).*$$/\1T\2Z/')
-
# ─ ¶ Recipe Variable Definitions ─────────────────────────────────────
# Outputs an `@´ to silence rules, unless `VERBOSE´ is non·empty.
# ─ ¶ Recipe Variable Definitions ─────────────────────────────────────
# Outputs an `@´ to silence rules, unless `VERBOSE´ is non·empty.
# List all source files and includes and their computed types.
list :
# List all source files and includes and their computed types.
list :
- @$(PRINTF) '%b' $(call quote,$(foreach file,$(sort $(sourcefiles)) $(sort $(sourceincludes)),\0033[1m$(file)\0033[22m|$(call typeoffile,$(file))|[\0033[3m$(if $(filter $(file),$(xmlfiles)),xml,$(if $(filter $(file),$(plaintextfiles)),text,asset))$(if $(filter $(file),$(sourceincludes)),|include,)\0033[23m] Modified:|$(call modtime,$(file))$(if $(call dependencies,$(file))$(call recursives,$(file)), $(strip $(foreach recursive,$(call recursives,$(file)),\0033[93;41m•|Recursive|Dependency|\0033[39;49m|$(recursive)) $(foreach dependency,$(call dependencies,$(file)),\0033[2m•|Dependency|\0033[22m|$(dependency))))$(if $(filter $(file),$(sourcefiles)), →|<\0033[4m/$(call destination,$(file))\0033[24m>,) )) | $(TR) ' |' '\n '
+ @$(PRINTF) '%b' $(call quote,$(foreach file,$(sort $(sourcefiles)) $(sort $(sourceincludes)),\0033[1m$(file)\0033[22m|$(call typeoffile,$(file))|[\0033[3m$(if $(filter $(file),$(xmlfiles)),xml,$(if $(filter $(file),$(plaintextfiles)),text,asset))$(if $(filter $(file),$(sourceincludes)),|include,)\0033[23m]$(if $(call dependencies,$(file))$(call recursives,$(file)), $(strip $(foreach recursive,$(call recursives,$(file)),\0033[93;41m•|Recursive|Dependency|\0033[39;49m|$(recursive)) $(foreach dependency,$(call dependencies,$(file)),\0033[2m•|Dependency|\0033[22m|$(dependency))))$(if $(filter $(file),$(sourcefiles)), →|<\0033[4m/$(call destination,$(file))\0033[24m>,) )) | $(TR) ' |' '\n '
# Lists out the destinations of all resulting files (relative to `DESTDIR´).
listout :
# Lists out the destinations of all resulting files (relative to `DESTDIR´).
listout :
$(call parsed,$(sourcefiles) $(sourceincludes)) : % : $$(call unparsed,$$@) $(BUILDDIR)/parser.xslt $(typeupdates)
$(call inform,$(PRINTF) '%s\n' $(call quote,Processing `$<´…) >&2)
$(silent)$(call ensuredirectory,$(dir $@))
$(call parsed,$(sourcefiles) $(sourceincludes)) : % : $$(call unparsed,$$@) $(BUILDDIR)/parser.xslt $(typeupdates)
$(call inform,$(PRINTF) '%s\n' $(call quote,Processing `$<´…) >&2)
$(silent)$(call ensuredirectory,$(dir $@))
- $(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,<?xml version="1.0"?><object xmlns="http://www.w3.org/1999/xhtml" type="$(call typeoffile,$<)" data="$(call datauri,$<)"/>) >|$(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(call serializexml,$<)) | $(XSLTPROC) --nonet --novalid -o $(call quote,$@) --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam IDENTIFIER $(call quote,$(call localuri,$<)) --stringparam SRCTIME '$(call modtime,$<)' --stringparam CKSUM $$($(CKSUM) $(call quote,$<) | $(SED) 's/[ ].*//')$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/parser.xslt) -)
+ $(silent)$(if $(filter $<,$(assetfiles)),$(PRINTF) '%s\n' $(call quote,<?xml version="1.0"?><object xmlns="http://www.w3.org/1999/xhtml" type="$(call typeoffile,$<)" data="$(call datauri,$<)"/>) >|$(call quote,$@),$(if $(filter $<,$(plaintextfiles)),$(call wrapplaintext,$<),$(call serializexml,$<)) | $(XSLTPROC) --nonet --novalid -o $(call quote,$@) --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam IDENTIFIER $(call quote,$(call localuri,$<))$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/parser.xslt) -)
# Collect the metadata into a single file.
$(BUILDDIR)/metadata : $(call diffprereqs,metadatas,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))))
# Collect the metadata into a single file.
$(BUILDDIR)/metadata : $(call diffprereqs,metadatas,$(call metadata,$(sort $(sourcefiles) $(sourceincludes))))
$(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 $@))
$(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 -o $(call quote,$@) --stringparam METADATA 'metadata' --stringparam BUILDTIME $$($(DATE) -u '+%Y-%m-%dT%H:%M:%SZ') --stringparam SRCTIME '$(call modtime,$(call uncompiled,$@))' --stringparam IDENTIFIER $(call quote,$(call localuri,$(call uncompiled,$@))) --stringparam PATH $(call quote,/$*) --stringparam CKSUM $$($(CKSUM) $(call quote,$(call uncompiled,$@)) | $(SED) 's/[ ].*//')$(if $(THISREV), --stringparam THISREV $(call quote,$(THISREV)),)$(if $(SRCREV), --stringparam SRCREV $(call quote,$(SRCREV)),) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
+ $(silent)$(XSLTPROC) --nonet --novalid -o $(call quote,$@) --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,$<)
# Create the final files from the compiled results (or error in the case of recursive ones).
$(call built,$(compilablefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/%
# Create the final files from the compiled results (or error in the case of recursive ones).
$(call built,$(compilablefiles)) : $(BUILDDIR)/public/% : $(BUILDDIR)/results/%
⛩️📰 书社 will add a few attributes to the output of the parsing step,
namely :—
⛩️📰 书社 will add a few attributes to the output of the parsing step,
namely :—
-- A `@书社:cksum` attribute on toplevel result elements, giving the
- `cksum` checksum of the corresponding source file.
+- For toplevel result elements :—
+
+ - A `@书社:cksum` attribute giving the `cksum` checksum of the
+ corresponding source file.
+
+ - A `@书社:mtime` attribute giving the last modified time of the
+ corresponding source file.
+
+ - A `@书社:identifier` attribute giving the ⛩️📰 书社 identifier
+ (i·e, starting with `about:shushe?`) of the corresponding source
+ file.
- For the elements which result from parsing plaintext `<html:script>`
elements :—
- For the elements which result from parsing plaintext `<html:script>`
elements :—
- **`BUILDTIME`:**
The current time.
- **`BUILDTIME`:**
The current time.
-- **`CKSUM`:**
- The checksum of the source file (⅌ `cksum`).
-
- **`IDENTIFIER`:**
The ⛩️📰 书社 identifier of the source file (a u·r·i beginning with
`about:shushe`).
- **`IDENTIFIER`:**
The ⛩️📰 书社 identifier of the source file (a u·r·i beginning with
`about:shushe`).
- **`SRCREV`:**
The value of the `SRCREV` variable (if present).
- **`SRCREV`:**
The value of the `SRCREV` variable (if present).
-- **`SRCTIME`:**
- The time at which the source file was last modified.
-
- **`THISREV`:**
The value of the `THISREV` variable (if present).
- **`THISREV`:**
The value of the `THISREV` variable (if present).
xmlns:exsl="http://exslt.org/common"
xmlns:exslstr="http://exslt.org/strings"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:exsl="http://exslt.org/common"
xmlns:exslstr="http://exslt.org/strings"
xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:nfo="http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xslt="http://www.w3.org/1999/XSL/TransformAlias"
xmlns:书社="urn:fdc:ladys.computer:20231231:Shu1She4"
<template match="/">
<xslt:transform extension-element-prefixes="exsl" version="1.0">
<xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
<template match="/">
<xslt:transform extension-element-prefixes="exsl" version="1.0">
<xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
- <xslt:param name="CKSUM" select="false()"/>
<xslt:param name="IDENTIFIER" select="false()"/>
<xslt:param name="SRCREV" select="false()"/>
<xslt:param name="IDENTIFIER" select="false()"/>
<xslt:param name="SRCREV" select="false()"/>
- <xslt:param name="SRCTIME" select="'1972-12-31T00:00:00Z'"/>
<xslt:param name="THISREV" select="false()"/>
<xslt:variable name="书社:parsers">
<html:dl>
<xslt:param name="THISREV" select="false()"/>
<xslt:variable name="书社:parsers">
<html:dl>
<xslt:when test="self::*">
<xslt:copy>
<xslt:attribute name="书社:cksum">
<xslt:when test="self::*">
<xslt:copy>
<xslt:attribute name="书社:cksum">
- <xslt:value-of select="$CKSUM"/>
+ <xslt:value-of select="document('metadata')//*[@rdf:about=$IDENTIFIER]/nfo:hasHash[@nfo:hashAlgorithm='CRC32']/@nfo:hashValue"/>
- <xslt:copy-of select="@*|node()"/>
+ <xslt:attribute name="书社:identifier">
+ <xslt:value-of select="$IDENTIFIER"/>
+ </xslt:attribute>
+ <xslt:attribute name="书社:mtime">
+ <xslt:value-of select="document('metadata')//*[@rdf:about=$IDENTIFIER]/nfo:fileLastModified"/>
+ </xslt:attribute>
+ <xslt:copy-of select="@*[namespace-uri()!='urn:fdc:ladys.computer:20231231:Shu1She4' or not(contains(' cksum identifier mtime ', concat(' ', local-name(), ' ')))]|node()"/>
</xslt:copy>
</xslt:when>
<xslt:otherwise>
</xslt:copy>
</xslt:when>
<xslt:otherwise>
<template match="/">
<xslt:transform exclude-result-prefixes="nie nfo" extension-element-prefixes="exsl exslstr" version="1.0">
<xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
<template match="/">
<xslt:transform exclude-result-prefixes="nie nfo" extension-element-prefixes="exsl exslstr" version="1.0">
<xslt:param name="BUILDTIME" select="'1972-12-31T00:00:00Z'"/>
- <xslt:param name="CKSUM" select="false()"/>
<xslt:param name="IDENTIFIER" select="false()"/>
<xslt:param name="METADATA" select="'metadata'"/>
<xslt:param name="PATH" select="'/unknown'"/>
<xslt:param name="SRCREV" select="false()"/>
<xslt:param name="IDENTIFIER" select="false()"/>
<xslt:param name="METADATA" select="'metadata'"/>
<xslt:param name="PATH" select="'/unknown'"/>
<xslt:param name="SRCREV" select="false()"/>
- <xslt:param name="SRCTIME" select="'1972-12-31T00:00:00Z'"/>
<xslt:param name="THISREV" select="false()"/>
<xslt:variable name="书社:source" select="/"/>
<xslt:variable name="书社:expansion">
<xslt:param name="THISREV" select="false()"/>
<xslt:variable name="书社:source" select="/"/>
<xslt:variable name="书社:expansion">
</xslt:template>
<xslt:template match="/node()" mode="书社:expand" priority="0">
<xslt:copy>
</xslt:template>
<xslt:template match="/node()" mode="书社:expand" priority="0">
<xslt:copy>
- <xslt:attribute name="书社:identifier">
- <xslt:value-of select="$IDENTIFIER"/>
- </xslt:attribute>
<xslt:choose>
<xslt:when test="self::html:*">
<xslt:attribute name="itemscope">itemscope</xslt:attribute>
<xslt:choose>
<xslt:when test="self::html:*">
<xslt:attribute name="itemscope">itemscope</xslt:attribute>
</xslt:variable>
<xslt:for-each select="exsl:node-set($expanded)/node()">
<xslt:copy>
</xslt:variable>
<xslt:for-each select="exsl:node-set($expanded)/node()">
<xslt:copy>
- <xslt:attribute name="书社:identifier">
- <xslt:value-of select="$identifier"/>
- </xslt:attribute>
<xslt:choose>
<xslt:when test="self::html:*">
<xslt:attribute name="itemscope">itemscope</xslt:attribute>
<xslt:choose>
<xslt:when test="self::html:*">
<xslt:attribute name="itemscope">itemscope</xslt:attribute>
<xslt:value-of select="."/>
</xslt:for-each>
</xslt:attribute>
<xslt:value-of select="."/>
</xslt:for-each>
</xslt:attribute>
- <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype')) and not(namespace-uri()='&书社;' and local-name()='identifier')]|node()"/>
+ <xslt:copy-of select="@*[not(namespace-uri()='' and (local-name()='itemscope' or local-name()='itemtype'))]|node()"/>
</xslt:when>
<xslt:otherwise>
</xslt:when>
<xslt:otherwise>
- <xslt:apply-templates select="@*[not(namespace-uri()='&书社;' and local-name()='identifier')]|node()" mode="书社:expand"/>
+ <xslt:apply-templates select="@*|node()" mode="书社:expand"/>
</xslt:otherwise>
</xslt:choose>
</xslt:copy>
</xslt:otherwise>
</xslt:choose>
</xslt:copy>