print version from Mercurial v_0 v0.6
authorFrantišek Kučera <franta-hg@frantovo.cz>
Fri, 04 Oct 2019 19:40:40 +0200
branchv_0
changeset 49 1dc027689f93
parent 48 904c1827bc38
child 50 1934fc6e5e7b
print version from Mercurial
Makefile
templates/common.xsl
templates/ssm.odt.xsl
templates/ssm.txt.xsl
templates/ssm.xhtml.xsl
--- a/Makefile	Thu Oct 03 17:22:01 2019 +0200
+++ b/Makefile	Fri Oct 04 19:40:40 2019 +0200
@@ -13,6 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+VERSION_PARAMS := $(shell hg log -r '.' --template '--stringparam versionTag {latesttag} --stringparam versionDistance {latesttagdistance} --stringparam versionHash {node|short}') 
+
 all: validate xhtml txt pdf logo-png statistics
 
 validate:
@@ -20,19 +22,19 @@
 
 xhtml:
 	mkdir -p build
-	xsltproc --output build/index.xhtml --nonet templates/ssm.xhtml.xsl text/ssm.en.xml
+	xsltproc $(VERSION_PARAMS) --output build/index.xhtml --nonet templates/ssm.xhtml.xsl text/ssm.en.xml
 	cp templates/*.css build
 	cp templates/*.woff build
 
 pdf:
 	mkdir -p build
-	xsltproc --output build/ssm.en.fodt --nonet templates/ssm.odt.xsl text/ssm.en.xml
+	xsltproc $(VERSION_PARAMS) --output build/ssm.en.fodt --nonet templates/ssm.odt.xsl text/ssm.en.xml
 	libreoffice --convert-to pdf --outdir build build/ssm.en.fodt
 
 # TODO: better line wrapping
 txt:
 	mkdir -p build
-	xsltproc --nonet templates/ssm.txt.xsl text/ssm.en.xml | fmt -w 74 -s | sed -E 's/(  +)([^- ])/\1  \2/g' > build/ssm.en.txt
+	xsltproc $(VERSION_PARAMS) --nonet templates/ssm.txt.xsl text/ssm.en.xml | fmt -w 74 -s | sed -E 's/(  +)([^- ])/\1  \2/g' > build/ssm.en.txt
 
 logo-png:
 	mkdir -p build
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/common.xsl	Fri Oct 04 19:40:40 2019 +0200
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	Sane Software Manifesto helper tools
+	Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, version 3.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+	You should have received a copy of the GNU General Public License
+	along with this program.  If not, see <https://www.gnu.org/licenses/>.
+-->
+<xsl:stylesheet 
+	version="1.0"
+	xmlns:m="tag:globalcode.info,2019:sane-software/manifesto"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:fn="http://www.w3.org/2005/xpath-functions"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	exclude-result-prefixes="fn m xs">
+		
+	<xsl:template name="version">
+		<xsl:param name="tag"/>
+		<xsl:param name="distance"/>
+		<xsl:param name="hash"/>
+		
+		<xsl:value-of select="$tag"/>
+		<xsl:if test="$distance &gt; 1">
+			<xsl:text>+</xsl:text>
+			<xsl:value-of select="$distance - 1"/>
+			<xsl:text> (</xsl:text>
+			<xsl:value-of select="$hash"/>
+			<xsl:text>)</xsl:text>
+		</xsl:if>
+	</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- a/templates/ssm.odt.xsl	Thu Oct 03 17:22:01 2019 +0200
+++ b/templates/ssm.odt.xsl	Fri Oct 04 19:40:40 2019 +0200
@@ -27,9 +27,13 @@
 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 	xmlns:fn="http://www.w3.org/2005/xpath-functions"
 	xmlns:xs="http://www.w3.org/2001/XMLSchema"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="tag:globalcode.info,2019:sane-software/manifesto ssm.xsd"
-	exclude-result-prefixes="fn m xs xsi">
+	exclude-result-prefixes="fn m xs">
+	
+	<xsl:import href="common.xsl"/>
+	
+	<xsl:param name="versionTag"/>
+	<xsl:param name="versionDistance"/>
+	<xsl:param name="versionHash"/>
 	
 	<xsl:output 
 		method="xml" 
@@ -44,8 +48,13 @@
 					<text:p text:style-name="Title">
 						<xsl:value-of select="m:title"/>
 					</text:p>
-					<!-- TODO: remove hardcoded warning, use version from mercurial -->
-					<text:p text:style-name="Subtitle">&lt;DRAFT&gt; Please note that this is a draft version. Stay tuned for v1.0.0! &lt;/DRAFT&gt;</text:p>
+					<text:p text:style-name="Subtitle">
+						<xsl:call-template name="version">
+							<xsl:with-param name="tag" select="$versionTag"/>
+							<xsl:with-param name="distance" select="$versionDistance"/>
+							<xsl:with-param name="hash" select="$versionHash"/>
+						</xsl:call-template>
+					</text:p>
 					<text:p text:style-name="Paragraph">
 						<xsl:value-of select="m:preamble"/>
 					</text:p>
--- a/templates/ssm.txt.xsl	Thu Oct 03 17:22:01 2019 +0200
+++ b/templates/ssm.txt.xsl	Fri Oct 04 19:40:40 2019 +0200
@@ -20,9 +20,13 @@
 	xmlns:m="tag:globalcode.info,2019:sane-software/manifesto"
 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 	xmlns:fn="http://www.w3.org/2005/xpath-functions"
-	xmlns:xs="http://www.w3.org/2001/XMLSchema"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="tag:globalcode.info,2019:sane-software/manifesto ssm.xsd">
+	xmlns:xs="http://www.w3.org/2001/XMLSchema">
+	
+	<xsl:import href="common.xsl"/>
+	
+	<xsl:param name="versionTag"/>
+	<xsl:param name="versionDistance"/>
+	<xsl:param name="versionHash"/>
 	
 	<xsl:output 
 		method="text" 
@@ -32,7 +36,6 @@
 		<xsl:text>                *** </xsl:text>
 		<xsl:value-of select="m:title"/>
 		<xsl:text> ***&#10;&#10;</xsl:text>
-		<!-- TODO: version and draft warning -->
 		<xsl:value-of select="m:preamble"/>
 		<xsl:text>&#10;&#10;</xsl:text>
 		<xsl:apply-templates select="m:chapter"/>
@@ -43,6 +46,13 @@
 		<xsl:text>----------------------------------------------------------------&#10;</xsl:text>
 		<xsl:text>Sane Software Manifesto &lt;https://sane-software.globalcode.info/&gt;&#10;</xsl:text>
 		<xsl:text>Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)&#10;</xsl:text>
+		<xsl:text>Version: </xsl:text>
+		<xsl:call-template name="version">
+			<xsl:with-param name="tag" select="$versionTag"/>
+			<xsl:with-param name="distance" select="$versionDistance"/>
+			<xsl:with-param name="hash" select="$versionHash"/>
+		</xsl:call-template>
+		<xsl:text>&#10;</xsl:text>
 		<xsl:text>This manifesto is licensed under the Creative Commons Attribution-NoDerivatives 4.0 International License &lt;https://creativecommons.org/licenses/by-nd/4.0/&gt;.&#10;</xsl:text>
 		<xsl:text>----------------------------------------------------------------&#10;</xsl:text>
 	</xsl:template>
--- a/templates/ssm.xhtml.xsl	Thu Oct 03 17:22:01 2019 +0200
+++ b/templates/ssm.xhtml.xsl	Fri Oct 04 19:40:40 2019 +0200
@@ -24,9 +24,13 @@
 	xmlns:fn="http://www.w3.org/2005/xpath-functions"
 	xmlns:svg="http://www.w3.org/2000/svg"
 	xmlns:xs="http://www.w3.org/2001/XMLSchema"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="tag:globalcode.info,2019:sane-software/manifesto ssm.xsd"
-	exclude-result-prefixes="fn h m xs xsi">
+	exclude-result-prefixes="fn h m xs">
+	
+	<xsl:import href="common.xsl"/>
+	
+	<xsl:param name="versionTag"/>
+	<xsl:param name="versionDistance"/>
+	<xsl:param name="versionHash"/>
 	
 	<xsl:output 
 		method="xml" 
@@ -49,8 +53,13 @@
 						<xsl:value-of select="m:title"/>
 					</h1>
 				
-					<!-- TODO: remove hardcoded warning, use version from mercurial -->
-					<p style="text-align: center">&lt;DRAFT&gt; Please note that this is a draft version. Stay tuned for v1.0.0! &lt;/DRAFT&gt;</p>
+					<p style="text-align: center">
+						<xsl:call-template name="version">
+							<xsl:with-param name="tag" select="$versionTag"/>
+							<xsl:with-param name="distance" select="$versionDistance"/>
+							<xsl:with-param name="hash" select="$versionHash"/>
+						</xsl:call-template>
+					</p>
 				
 					<p>
 						<xsl:value-of select="m:preamble"/>