]> Lady’s Gitweb - Shushe/commitdiff
Provide $buildtime, $srctime, and $path variables 0.2.0
authorLady <redacted>
Tue, 2 Jan 2024 18:20:30 +0000 (13:20 -0500)
committerLady <redacted>
Tue, 2 Jan 2024 18:27:24 +0000 (13:27 -0500)
GNUmakefile
README.markdown
lib/catalog2transform.xslt

index 6d68702280c8899fbbbc9464802c57a2a87b0085..e8624778763b08e1aaefa0ea337ce16a3afaabaf 100644 (file)
@@ -16,6 +16,7 @@ override define makefileinfo
 ║│                                                            │║
 ║│ • cat                                                      │║
 ║│ • cp                                                       │║
 ║│                                                            │║
 ║│ • cat                                                      │║
 ║│ • cp                                                       │║
+║│ • date                                                     │║
 ║│ • echo                                                     │║
 ║│ • file                                                     │║
 ║│ • find                                                     │║
 ║│ • echo                                                     │║
 ║│ • file                                                     │║
 ║│ • find                                                     │║
@@ -25,6 +26,7 @@ override define makefileinfo
 ║│ • rm                                                       │║
 ║│ • sed                                                      │║
 ║│ • sleep                                                    │║
 ║│ • rm                                                       │║
 ║│ • sed                                                      │║
 ║│ • sleep                                                    │║
+║│ • stat                                                     │║
 ║│ • test                                                     │║
 ║│ • touch                                                    │║
 ║│ • tr (requires support for `-d´)                           │║
 ║│ • test                                                     │║
 ║│ • touch                                                    │║
 ║│ • tr (requires support for `-d´)                           │║
@@ -79,6 +81,7 @@ endef
 # different implementation, you can override the appropriate variable.
 CAT := cat
 CP := cp
 # different implementation, you can override the appropriate variable.
 CAT := cat
 CP := cp
+DATE := date
 ECHO := echo
 FILE := file
 FIND := find
 ECHO := echo
 FILE := file
 FIND := find
@@ -88,6 +91,7 @@ PRINTF := printf
 RM := rm
 SED := sed
 SLEEP := sleep
 RM := rm
 SED := sed
 SLEEP := sleep
+STAT := stat
 TEST := test
 TOUCH := touch
 TR := tr
 TEST := test
 TOUCH := touch
 TR := tr
@@ -425,7 +429,7 @@ $(BUILDDIR)/transform.xslt: $(BUILDDIR)/transform.catalog $(THISDIR)/lib/catalog
 $(call compiled,$(compilablefiles)): $(BUILDDIR)/public/%: $$(call parsed,$(SRCDIR)/%) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$(SRCDIR)/%))
        $(silent)$(call ensuredirectory,$(dir $@))
        @$(PRINTF) '%s\n' $(call quote,Compiling `$*´…)
 $(call compiled,$(compilablefiles)): $(BUILDDIR)/public/%: $$(call parsed,$(SRCDIR)/%) $(BUILDDIR)/transform.xslt $$(call parsed,$$(call dependencies,$(SRCDIR)/%))
        $(silent)$(call ensuredirectory,$(dir $@))
        @$(PRINTF) '%s\n' $(call quote,Compiling `$*´…)
-       $(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam catalog 'catalog' $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
+       $(silent)$(XSLTPROC) -o $(call quote,$@) --stringparam catalog 'catalog' --stringparam buildtime '$(shell TZ= $(DATE) '+%Y-%m-%dT%H:%M:%SZ')' --stringparam srctime '$(shell TZ= $(STAT) -f '%Sm' -t '%Y-%m-%dT%H:%M:%SZ' $(call quote,$(SRCDIR)/$*))' --stringparam path $(call quote,/$*) $(call quote,$(BUILDDIR)/transform.xslt) $(call quote,$<)
 $(call compiled,$(filter $(assetfiles),$(sourcefiles))): $(BUILDDIR)/public/%: $(SRCDIR)/%
        @$(PRINTF) '%s\n' $(call quote,Compiling `$*´…)
        $(silent)$(call ensuredirectory,$(dir $@))
 $(call compiled,$(filter $(assetfiles),$(sourcefiles))): $(BUILDDIR)/public/%: $(SRCDIR)/%
        @$(PRINTF) '%s\n' $(call quote,Compiling `$*´…)
        $(silent)$(call ensuredirectory,$(dir $@))
index 6870c4db24535a3dcb587699d8aa6769d3571cac..13cb1d66fbc34cdaed3e28bd2e20a77b92a41cf9 100644 (file)
@@ -93,6 +93,7 @@ In every case, you may supply your own implementation by overriding the
 
 - `cat`
 - `cp`
 
 - `cat`
 - `cp`
+- `date`
 - `echo`
 - `file`
 - `find`
 - `echo`
 - `file`
 - `find`
@@ -102,6 +103,7 @@ In every case, you may supply your own implementation by overriding the
 - `rm`
 - `sed`
 - `sleep`
 - `rm`
 - `sed`
 - `sleep`
+- `stat`
 - `test`
 - `touch`
 - `tr` (requires support for `-d`)
 - `test`
 - `touch`
 - `tr` (requires support for `-d`)
@@ -312,6 +314,11 @@ The following are recommendations on effective creation of
 - Set `@exclude-result-prefixes` on the root `xslt:transform` element
     to reduce the number of declared namespaces in the final result.
 
 - Set `@exclude-result-prefixes` on the root `xslt:transform` element
     to reduce the number of declared namespaces in the final result.
 
+The params `$buildtime`, `$srctime`, and `$path` are available within
+  transforms and are initialized to the current time, the time that the
+  source file was last modified, and the path of the output file within
+  $(DESTDIR).
+
 ## Output Wrapping
 
 ⛩️📰 书社 will wrap the final output of the transforms in appropriate
 ## Output Wrapping
 
 ⛩️📰 书社 will wrap the final output of the transforms in appropriate
index 2a3bc711f64b047fefbeb0f15bfdda0d6278af46..65f5f0f1487ce7b77618a78e35058f38ea85f3d0 100644 (file)
@@ -24,7 +24,10 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
        <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
        <template match="/">
                <xslt:transform exclude-result-prefixes="catalog exsl exslstr" version="1.0">
        <namespace-alias stylesheet-prefix="xslt" result-prefix="#default"/>
        <template match="/">
                <xslt:transform exclude-result-prefixes="catalog exsl exslstr" version="1.0">
+                       <xslt:param name="buildtime" select="'1972-12-31T00:00:00Z'"/>
                        <xslt:param name="catalog" select="'catalog'"/>
                        <xslt:param name="catalog" select="'catalog'"/>
+                       <xslt:param name="srctime" select="'1972-12-31T00:00:00Z'"/>
+                       <xslt:param name="path" select="'/unknown'"/>
                        <xslt:variable name="书社:expansion">
                                <xslt:apply-templates select="/" mode="书社:expand"/>
                        </xslt:variable>
                        <xslt:variable name="书社:expansion">
                                <xslt:apply-templates select="/" mode="书社:expand"/>
                        </xslt:variable>
@@ -119,6 +122,11 @@ If a copy of the M·P·L was not distributed with this file, You can obtain one
                                        <xslt:copy-of select="html:html/@*"/>
                                        <html:head>
                                                <xslt:copy-of select="html:html/html:head/@*"/>
                                        <xslt:copy-of select="html:html/@*"/>
                                        <html:head>
                                                <xslt:copy-of select="html:html/html:head/@*"/>
+                                               <html:script type="text/plain">
+                                                       <xslt:text>buildtime=</xslt:text><xslt:value-of select="$buildtime"/><xslt:text>&#xA;</xslt:text>
+                                                       <xslt:text>srctime=</xslt:text><xslt:value-of select="$srctime"/><xslt:text>&#xA;</xslt:text>
+                                                       <xslt:text>path=</xslt:text><xslt:value-of select="$path"/><xslt:text>&#xA;</xslt:text>
+                                               </html:script>
                                                <html:title>
                                                        <xslt:for-each select="exsl:node-set($metadata)/html:title">
                                                                <xslt:value-of select="."/>
                                                <html:title>
                                                        <xslt:for-each select="exsl:node-set($metadata)/html:title">
                                                                <xslt:value-of select="."/>
This page took 0.026142 seconds and 4 git commands to generate.