Skip to content

Commit

Permalink
Add web cover images
Browse files Browse the repository at this point in the history
Affects: #27
  • Loading branch information
io7m committed Sep 15, 2024
1 parent b4d00b2 commit a03ea9e
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ file2.txt
element.
</Paragraph>
</Subsection>
<Subsection title="com.io7m.xstructural.web.cover">
<Paragraph>
The contents of this property denote the relative (to the input document) filename of the cover image that will
be used for the book.
</Paragraph>
</Subsection>
</Subsection>

<Footnote id="7c66cd52-4ace-4fd6-a05d-fd0255e441bb">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<MetaProperty name="com.io7m.xstructural.epub.cover">cover.jpg</MetaProperty>
<MetaProperty name="com.io7m.xstructural.web.branding.header">brand.xml</MetaProperty>
<MetaProperty name="com.io7m.xstructural.web.branding.footer">brand.xml</MetaProperty>
<MetaProperty name="com.io7m.xstructural.web.cover">banner.jpg</MetaProperty>
</Metadata>

<xi:include href="language.xml"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,15 @@ h6
text-align: left;
padding-right: 1em;
}

/*
* Cover image.
*/

.stWebCoverImage img
{
max-width: 100%;
max-height: 100%;
width: 100%;
height: auto;
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,35 @@
</xsl:choose>
</xsl:template>

<xdoc:doc>
Generate a document title image element in a rendered document.
</xdoc:doc>

<xsl:template match="s:Document"
mode="xstructural.documentTitleImageElement">
<xsl:if test="s:Metadata/s:MetaProperty[@name='com.io7m.xstructural.web.cover']">
<xsl:variable name="content" as="element()">
<div class="stWebCoverImage">
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="s:Metadata/s:MetaProperty[@name='com.io7m.xstructural.web.cover']"/>
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="normalize-space(s:Metadata/dc:title)"/>
</xsl:attribute>
</xsl:element>
</div>
</xsl:variable>

<xsl:call-template name="xstructural.regions.standardRegion">
<xsl:with-param name="class"
select="'stWebCoverImage'"/>
<xsl:with-param name="stMarginNode">
<xsl:comment>Empty</xsl:comment>
</xsl:with-param>
<xsl:with-param name="stContentNode" select="$content"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
<xsl:apply-templates select="."
mode="xstructural.titleElement"/>

<xsl:apply-templates select="."
mode="xstructural.documentTitleImageElement"/>

<xsl:apply-templates select="s:Metadata"
mode="xstructural.metadata.table"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
<xsl:apply-templates select="."
mode="xstructural.titleElement"/>

<xsl:apply-templates select="."
mode="xstructural.documentTitleImageElement"/>

<xsl:apply-templates select="s:Metadata"
mode="xstructural.metadata.table"/>

Expand Down

0 comments on commit a03ea9e

Please sign in to comment.