--- a/Makefile Thu May 09 23:35:47 2024 +0200
+++ b/Makefile Thu May 09 23:47:53 2024 +0200
@@ -15,16 +15,34 @@
VERSION_PARAMS := $(shell hg log -r '.' --template '--stringparam versionTag {latesttag} --stringparam versionDistance {latesttagdistance} --stringparam versionHash {node|short}') "--stringparam" "versionChangedFiles" $(shell hg status | wc -l)
-all: validate xhtml txt pdf logo-png statistics
+all: validate xhtml txt pdf build/ssm.en.epub logo-png statistics
validate:
xmllint --noout --schema schema/ssm.xsd text/ssm.en.xml
-xhtml: templates/cmunrm.woff templates/cmunbx.woff
+xhtml: text/ssm.en.xml templates/cmunrm.woff templates/cmunbx.woff
mkdir -p build
xsltproc $(VERSION_PARAMS) --output build/index.xhtml --nonet templates/ssm.xhtml.xsl text/ssm.en.xml
- cp templates/*.css build
- cp templates/*.woff build
+ cp --reflink=auto templates/*.css build
+ cp --reflink=auto templates/*.woff build
+
+build/ssm.en.epub: text/ssm.en.xml templates/ssm.xhtml.xsl templates/cmunrm.woff templates/cmunbx.woff
+ mkdir -p "build/epub/META-INF"
+ mkdir -p "build/epub/OEBPS"
+ echo -n "application/epub+zip" > "build/epub/mimetype"
+ xsltproc \
+ --nonet \
+ --xinclude \
+ $(VERSION_PARAMS) \
+ --output "build/epub/" \
+ "templates/ssm.epub.xsl" \
+ $(<)
+ cp --reflink=auto templates/*.css "build/epub/OEBPS/"
+ cp --reflink=auto templates/*.woff "build/epub/OEBPS/"
+ cd "build/epub/"; zip -r ../../$(@) \
+ -X \
+ --suffixes mimetype:jpg:jpeg:png:gif \
+ mimetype "META-INF/" "OEBPS/"
templates/cmunrm.ttf:
cd templates/; ln -s /usr/share/fonts/truetype/cmu/cmunrm.ttf
@@ -57,8 +75,8 @@
rm -rf build
publish:
- scp build/* globalcode.info:/var/www/sane-software.globalcode.info/v_0/
- scp license/* globalcode.info:/var/www/sane-software.globalcode.info/license/
+ scp build/*.* globalcode.info:/var/www/sane-software.globalcode.info/v_0/
+ scp license/*.* globalcode.info:/var/www/sane-software.globalcode.info/license/
# Described at: https://relational-pipes.globalcode.info/v_0/examples-in-xmltable-ssm-gui.xhtml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/ssm.epub.xsl Thu May 09 23:47:53 2024 +0200
@@ -0,0 +1,249 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Sane software manifesto helper tools
+ Copyright © 2019-2024 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="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://www.w3.org/1999/xhtml"
+ 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:exsl="http://exslt.org/common"
+ extension-element-prefixes="exsl"
+ exclude-result-prefixes="fn h m xs exsl"
+>
+
+ <xsl:import href="ssm.xhtml.xsl"/>
+
+ <xsl:output
+ method="xml"
+ indent="yes"
+ encoding="UTF-8"
+ />
+
+ <xsl:template match="/m:manifesto">
+
+ <exsl:document href="META-INF/container.xml">
+ <container
+ xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
+ version="1.0"
+ >
+ <rootfiles>
+ <rootfile
+ full-path="OEBPS/content.opf"
+ media-type="application/oebps-package+xml"
+ />
+ </rootfiles>
+ </container>
+ </exsl:document>
+
+ <exsl:document href="OEBPS/content.opf">
+ <package
+ xmlns="http://www.idpf.org/2007/opf"
+ version="2.0"
+ unique-identifier="bookid"
+ >
+ <metadata>
+ <dc:identifier
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ id="bookid"
+ >
+ <xsl:value-of select="m:id"/>
+ </dc:identifier>
+ <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <xsl:value-of select="m:title"/>
+ </dc:title>
+ <dc:language xmlns:dc="http://purl.org/dc/elements/1.1/">
+ en
+ </dc:language>
+ </metadata>
+ <manifest>
+ <xsl:for-each select="m:chapter">
+ <item
+ id="{m:id}"
+ href="{m:id}.xhtml"
+ media-type="application/xhtml+xml"/>
+ </xsl:for-each>
+ <item
+ id="ncxtoc"
+ media-type="application/x-dtbncx+xml"
+ href="toc.ncx"/>
+ <item
+ id="style_css"
+ media-type="text/css"
+ href="style.css"/>
+ <item
+ id="cmunrm_woff"
+ media-type="font/woff"
+ href="cmunrm.woff"/>
+ <item
+ id="cmunbx_woff"
+ media-type="font/woff"
+ href="cmunbx.woff"/>
+ <item
+ id="htmltoc"
+ media-type="application/xhtml+xml"
+ href="index.xhtml"/>
+ </manifest>
+ <spine toc="ncxtoc">
+ <itemref idref="htmltoc" linear="yes"/>
+ <xsl:for-each select="m:chapter">
+ <itemref idref="{m:id}"/>
+ </xsl:for-each>
+ </spine>
+ <guide>
+ <reference
+ href="index.xhtml"
+ type="toc"
+ title="Table of Contents"/>
+ </guide>
+ </package>
+ </exsl:document>
+
+ <exsl:document href="OEBPS/toc.ncx">
+ <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
+ <head>
+ <meta name="dtb:uid" content="{m:id}"/>
+ </head>
+ <docTitle>
+ <text>
+ <xsl:value-of select="m:title"/>
+ </text>
+ </docTitle>
+ <navMap>
+ <navPoint id="{m:id}_preamble" playOrder="1">
+ <navLabel>
+ <text>
+ <xsl:value-of select="m:title"/>
+ </text>
+ </navLabel>
+ <content src="index.xhtml"/>
+ <xsl:for-each select="m:chapter">
+ <navPoint
+ id="{m:id}"
+ playOrder="{count(preceding::m:chapter)+2}"
+ >
+ <navLabel>
+ <text>
+ <xsl:value-of select="m:name"/>
+ </text>
+ </navLabel>
+ <content src="{m:id}.xhtml"/>
+ </navPoint>
+ </xsl:for-each>
+ </navPoint>
+ </navMap>
+ </ncx>
+ </exsl:document>
+
+ <exsl:document href="OEBPS/index.xhtml">
+ <html>
+ <head>
+ <title>
+ <xsl:value-of select="m:title"/>
+ </title>
+ <link href="style.css" type="text/css" rel="StyleSheet"/>
+ </head>
+ <body>
+ <div id="content">
+ <h1>
+ <xsl:value-of select="m:title"/>
+ </h1>
+
+ <xsl:call-template name="versionParagraph"/>
+
+ <p>
+ <xsl:value-of select="m:preamble"/>
+ </p>
+
+ <p>Table of contents:</p>
+ <ul>
+ <xsl:for-each select="m:chapter">
+ <li>
+ <a href="{m:id}.xhtml">
+ <xsl:value-of select="m:name"/>
+ </a>
+ </li>
+ </xsl:for-each>
+ </ul>
+
+ <xsl:call-template name="footerEPUB"/>
+
+ </div>
+ </body>
+ </html>
+ </exsl:document>
+
+
+ <xsl:for-each select="m:chapter">
+ <exsl:document href="OEBPS/{m:id}.xhtml">
+ <html>
+ <head>
+ <title>
+ <xsl:value-of select="m:name"/>
+ </title>
+ <link
+ href="style.css"
+ type="text/css"
+ rel="StyleSheet"/>
+ </head>
+ <body>
+ <div id="content">
+ <h1>
+ <xsl:value-of select="/m:manifesto/m:title"/>
+ </h1>
+
+ <h2>
+ <xsl:value-of select="m:name"/>
+ </h2>
+
+ <ul>
+ <xsl:apply-templates select="m:item"/>
+ </ul>
+
+ <xsl:call-template name="footerEPUB"/>
+ </div>
+ </body>
+ </html>
+ </exsl:document>
+ </xsl:for-each>
+
+ </xsl:template>
+
+ <xsl:template name="footerEPUB">
+ <xsl:call-template name="footer">
+ <!-- We need absolute URL in EPUB. -->
+ <!-- Or maybe attach PDF and TXT inside EPUB? -->
+ <xsl:with-param name="otherFormatsURL">
+ https://sane-software.globalcode.info/v_0/
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="m:item">
+ <li id="{m:id}" class="{m:type}">
+ <xsl:apply-templates select="m:text"/>
+ <xsl:if test="m:item">
+ <ul>
+ <xsl:apply-templates select="m:item"/>
+ </ul>
+ </xsl:if>
+ </li>
+ </xsl:template>
+
+</xsl:stylesheet>
--- a/templates/ssm.xhtml.xsl Thu May 09 23:35:47 2024 +0200
+++ b/templates/ssm.xhtml.xsl Thu May 09 23:47:53 2024 +0200
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Sane software manifesto helper tools
- Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+ Copyright © 2019-2024 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
@@ -15,31 +15,31 @@
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
+<xsl:stylesheet
version="1.0"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://www.w3.org/1999/xhtml"
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:svg="http://www.w3.org/2000/svg"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
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:param name="versionChangedFiles"/>
-
- <xsl:output
- method="xml"
- indent="yes"
- encoding="UTF-8"
- doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
- doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
-
+
+ <xsl:output
+ method="xml"
+ indent="yes"
+ encoding="UTF-8"
+ doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
+ doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"
+ />
+
<xsl:template match="/m:manifesto">
<html>
<head>
@@ -53,49 +53,59 @@
<h1>
<xsl:value-of select="m:title"/>
</h1>
-
- <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:with-param name="changedFiles" select="$versionChangedFiles"/>
- </xsl:call-template>
- </p>
-
+
+ <xsl:call-template name="versionParagraph"/>
+
<p>
<xsl:value-of select="m:preamble"/>
</p>
-
+
<xsl:apply-templates select="m:chapter"/>
-
- <hr/>
- <p class="footer">
- <a href="{m:url}">
- <xsl:value-of select="m:title"/>
- </a>
- (<a href="https://hg.globalcode.info/sane-software/sane-software-manifesto/">sources</a>)
- other formats:
- <a href="ssm.en.pdf">PDF</a>,
- <a href="ssm.en.txt">TXT</a>
- <br/>
- Copyright © <xsl:value-of select="m:license/m:year"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="m:author"/>
- <br/>
- <xsl:value-of select="m:license/m:prefix"/>
- <a href="{m:license/m:url}">
- <xsl:value-of select="m:license/m:name"/>
- </a>
- <xsl:value-of select="m:license/m:suffix"/>
- </p>
+
+ <xsl:call-template name="footer"/>
</div>
</body>
</html>
</xsl:template>
-
-
+
+ <xsl:template name="versionParagraph">
+ <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:with-param name="changedFiles" select="$versionChangedFiles"/>
+ </xsl:call-template>
+ </p>
+ </xsl:template>
+
+ <xsl:template name="footer">
+ <xsl:param name="otherFormatsURL"/>
+ <hr/>
+ <p class="footer">
+ <a href="{/m:manifesto/m:url}">
+ <xsl:value-of select="/m:manifesto/m:title"/>
+ </a>
+ (<a href="https://hg.globalcode.info/sane-software/sane-software-manifesto/">sources</a>)
+ other formats:
+ <a href="{normalize-space($otherFormatsURL)}ssm.en.pdf">PDF</a>,
+ <a href="{normalize-space($otherFormatsURL)}ssm.en.txt">TXT</a>,
+ <a href="{normalize-space($otherFormatsURL)}ssm.en.epub">EPUB</a>
+ <br/>
+ Copyright © <xsl:value-of select="/m:manifesto/m:license/m:year"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="/m:manifesto/m:author"/>
+ <br/>
+ <xsl:value-of select="/m:manifesto/m:license/m:prefix"/>
+ <a href="{/m:manifesto/m:license/m:url}">
+ <xsl:value-of select="/m:manifesto/m:license/m:name"/>
+ </a>
+ <xsl:value-of select="/m:manifesto/m:license/m:suffix"/>
+ </p>
+ </xsl:template>
+
+
<xsl:template match="m:chapter">
<div id="{m:id}" class="chapter">
<h2>
@@ -108,8 +118,8 @@
</ul>
</div>
</xsl:template>
-
-
+
+
<xsl:template match="m:item">
<li id="{m:id}" class="{m:type}">
<xsl:apply-templates select="m:text"/>
@@ -122,7 +132,7 @@
</xsl:if>
</li>
</xsl:template>
-
+
<xsl:template match="m:text">
<xsl:apply-templates/>
<xsl:text> </xsl:text>