Skip to content

Commit

Permalink
Merge branch 'release/1.7.0'
Browse files Browse the repository at this point in the history
Release: com.io7m.xstructural 1.7.0
Change: Add the ability to add extra EPUB resources. (Ticket: #19)
  • Loading branch information
io7m committed Sep 20, 2022
2 parents 7038bde + 3764f82 commit e9a4b3b
Show file tree
Hide file tree
Showing 19 changed files with 350 additions and 35 deletions.
11 changes: 10 additions & 1 deletion README-CHANGES.xml
Expand Up @@ -58,12 +58,21 @@
<c:change date="2022-06-30T00:00:00+00:00" summary="Update dependencies"/>
</c:changes>
</c:release>
<c:release date="2022-09-20T09:27:44+00:00" is-open="false" ticket-system="com.github.io7m.xstructural" version="1.6.0">
<c:release date="2022-09-20T00:00:00+00:00" is-open="false" ticket-system="com.github.io7m.xstructural" version="1.6.0">
<c:changes>
<c:change date="2022-09-20T00:00:00+00:00" summary="Update slf4j to 2.0.1"/>
<c:change date="2022-09-20T00:00:00+00:00" summary="Update logback to 1.4.1"/>
</c:changes>
</c:release>
<c:release date="2022-09-20T18:25:13+00:00" is-open="false" ticket-system="com.github.io7m.xstructural" version="1.7.0">
<c:changes>
<c:change date="2022-09-20T00:00:00+00:00" summary="Add the ability to add extra EPUB resources.">
<c:tickets>
<c:ticket id="19"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
</c:releases>
<c:ticket-systems>
<c:ticket-system default="true" id="com.github.io7m.xstructural" url="https://www.github.com/io7m/xstructural/issues/"/>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.xstructural.api/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.xstructural</artifactId>
<groupId>com.io7m.xstructural</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>

<artifactId>com.io7m.xstructural.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.xstructural.cmdline/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.xstructural</artifactId>
<groupId>com.io7m.xstructural</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>

<artifactId>com.io7m.xstructural.cmdline</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.xstructural.documentation/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.xstructural</artifactId>
<groupId>com.io7m.xstructural</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>

<artifactId>com.io7m.xstructural.documentation</artifactId>
Expand Down
Expand Up @@ -57,6 +57,40 @@
inserted into the <Term type="term">colophon</Term> page of the generated EPUB.
</Paragraph>
</Subsection>
<Subsection title="com.io7m.xstructural.epub.resource">
<Paragraph>
The contents of this property add an extra file to the manifest. The property can be specified multiple times to
add multiple resources. The resources are resolved relative to the source directory of the document.
</Paragraph>
</Subsection>
<Subsection title="com.io7m.xstructural.epub.resource-list">
<Paragraph>
The contents of this property denote a file that contains a list of extra resources to add to the manifest. The
file name is resolved relative to the source directory of the document. The file must contain one resource file
per line. For example, if a file named
<Term type="file">extra-files.txt</Term>
contains the following text:
</Paragraph>
<FormalItem title="Example File List">
<Verbatim><![CDATA[file0.txt
file1.txt
file2.txt
]]></Verbatim>
</FormalItem>
<Paragraph>
Then the following <Term type="expression">MetaProperty</Term> declarations are effectively equivalent:
</Paragraph>
<FormalItem title="Example File List">
<Verbatim>
<![CDATA[<MetaProperty name="com.io7m.xstructural.epub.resource-list">extra-files.txt</MetaProperty>]]></Verbatim>
</FormalItem>
<FormalItem title="Example Files">
<Verbatim><![CDATA[<MetaProperty name="com.io7m.xstructural.epub.resource">file0.txt</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource">file1.txt</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource">file2.txt</MetaProperty>
]]></Verbatim>
</FormalItem>
</Subsection>
<Subsection title="Examples">
<FormalItem title="EPUB Example">
<Verbatim><![CDATA[
Expand All @@ -66,6 +100,10 @@
<dc:title>Example Document</dc:title>
<MetaProperty name="com.io7m.xstructural.epub.colophon">colophon_extra.xml</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.cover">cover.jpg</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource">file0.txt</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource">file1.txt</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource">file2.txt</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource-list">extra-files.txt</MetaProperty>
</Metadata>
...
]]></Verbatim>
Expand Down
2 changes: 1 addition & 1 deletion com.io7m.xstructural.tests/pom.xml
Expand Up @@ -8,7 +8,7 @@
<parent>
<artifactId>com.io7m.xstructural</artifactId>
<groupId>com.io7m.xstructural</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>

<artifactId>com.io7m.xstructural.tests</artifactId>
Expand Down
Expand Up @@ -23,6 +23,7 @@

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -1062,4 +1063,104 @@ public void testTransformXHTMLEPUBOKExampleTwice_80()
Assertions.assertEquals(0, main.exitCode());
}
}

@Test
public void testTransformEPUB4_80()
throws Exception
{
final var file0 =
Files.writeString(
this.sourceDirectory.resolve("file0.txt"),
"Text 0."
);
final var file1 =
Files.writeString(
this.sourceDirectory.resolve("file1.txt"),
"Text 1."
);
final var file2 =
Files.writeString(
this.sourceDirectory.resolve("file2.txt"),
"Text 2."
);

final var main = new Main(new String[]{
"epub",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example4_80.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--traceFile",
this.directory.resolve("trace.xml").toString(),
"--messagesFile",
this.directory.resolve("messages.log").toString(),
"--verbose",
"trace"
});

final var capture =
XSOutputCaptured.capture(main::run);

Assertions.assertEquals(0, main.exitCode());
}

@Test
public void testTransformEPUB5_80()
throws Exception
{
final var file =
this.sourceDirectory.resolve("extra-resources.txt");

try (var writer = Files.newBufferedWriter(file, UTF_8)) {
writer.append("file0.txt");
writer.newLine();
writer.append("file1.txt");
writer.newLine();
writer.append("file2.txt");
writer.newLine();
}

final var file0 =
Files.writeString(
this.sourceDirectory.resolve("file0.txt"),
"Text 0."
);
final var file1 =
Files.writeString(
this.sourceDirectory.resolve("file1.txt"),
"Text 1."
);
final var file2 =
Files.writeString(
this.sourceDirectory.resolve("file2.txt"),
"Text 2."
);

final var main = new Main(new String[]{
"epub",
"--sourceFile",
XSTestDirectories.resourceOf(
XSCommandLineTest.class,
this.sourceDirectory,
"example5_80.xml")
.toString(),
"--outputDirectory",
this.outputDirectory.toString(),
"--traceFile",
this.directory.resolve("trace.xml").toString(),
"--messagesFile",
this.directory.resolve("messages.log").toString(),
"--verbose",
"trace"
});

final var capture =
XSOutputCaptured.capture(main::run);

Assertions.assertEquals(0, main.exitCode());
}
}
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!-- Comments! -->

<Document xmlns="urn:com.io7m.structural:8:0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
tableOfContentsDepth="3"
tableOfContents="true">

<!-- Comments! -->

<Metadata>
<dc:contributor>A Contributor</dc:contributor>
<dc:creator>A Creator</dc:creator>
<dc:description>An example article.</dc:description>
<dc:identifier>7486b85a-30de-4007-8b32-679b8a851b91</dc:identifier>
<dc:language>English</dc:language>
<dc:publisher>A Publisher</dc:publisher>
<dc:relation>A Relation</dc:relation>
<dc:rights>CC-0</dc:rights>
<dc:source>A Source</dc:source>
<dc:title>Example Document</dc:title>

<MetaProperty name="com.io7m.xstructural.epub.resource">file0.txt</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource">file1.txt</MetaProperty>
<MetaProperty name="com.io7m.xstructural.epub.resource">file2.txt</MetaProperty>
</Metadata>

<Section title="08eb2001-58ef-44be-acce-5eecee051515">
<Paragraph>
No bagel.
</Paragraph>
<Paragraph>
No bagel.
</Paragraph>
<Paragraph>
No bagel.
</Paragraph>
<Paragraph>
No bagel.
</Paragraph>
</Section>

</Document>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>

<!-- Comments! -->

<Document xmlns="urn:com.io7m.structural:8:0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
tableOfContentsDepth="3"
tableOfContents="true">

<!-- Comments! -->

<Metadata>
<dc:contributor>A Contributor</dc:contributor>
<dc:creator>A Creator</dc:creator>
<dc:description>An example article.</dc:description>
<dc:identifier>7486b85a-30de-4007-8b32-679b8a851b91</dc:identifier>
<dc:language>English</dc:language>
<dc:publisher>A Publisher</dc:publisher>
<dc:relation>A Relation</dc:relation>
<dc:rights>CC-0</dc:rights>
<dc:source>A Source</dc:source>
<dc:title>Example Document</dc:title>

<MetaProperty name="com.io7m.xstructural.epub.resource-list">extra-resources.txt</MetaProperty>
</Metadata>

<Section title="08eb2001-58ef-44be-acce-5eecee051515">
<Paragraph>
No bagel.
</Paragraph>
<Paragraph>
No bagel.
</Paragraph>
<Paragraph>
No bagel.
</Paragraph>
<Paragraph>
No bagel.
</Paragraph>
</Section>

</Document>
6 changes: 5 additions & 1 deletion com.io7m.xstructural.vanilla/pom.xml
Expand Up @@ -9,7 +9,7 @@
<parent>
<artifactId>com.io7m.xstructural</artifactId>
<groupId>com.io7m.xstructural</groupId>
<version>1.7.0-SNAPSHOT</version>
<version>1.7.0</version>
</parent>

<artifactId>com.io7m.xstructural.vanilla</artifactId>
Expand Down Expand Up @@ -70,6 +70,10 @@
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
</dependency>
</dependencies>

</project>
Expand Up @@ -144,6 +144,11 @@ private void executeTransform()
QName.fromEQName("outputFile"),
XdmValue.makeValue(outputFile.toUri().toString())
);
transformer.setParameter(
QName.fromEQName("sourceDirectory"),
XdmValue.makeValue(
this.request.sourceFile().getParent().toUri().toString())
);

LOG.debug("output file: {}", outputFile);
LOG.debug("executing stylesheet");
Expand Down
Expand Up @@ -162,6 +162,12 @@ private void executeTransform()
XdmValue.makeValue(outputPath.toUri().toString())
);

transformer.setParameter(
QName.fromEQName("xstructural.sourceDirectory"),
XdmValue.makeValue(
this.request.sourceFile().getParent().toUri().toString())
);

this.request.brandingFile()
.ifPresent(path -> {
LOG.debug("branding file: {}", path);
Expand Down

0 comments on commit e9a4b3b

Please sign in to comment.