Added random cover graphic selector

This commit is contained in:
skyanth 2019-01-21 15:44:18 +01:00
parent 7ed9e71ec5
commit e07e02a486
5 changed files with 35 additions and 4 deletions

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<frontpage_graphics>
<!-- doctype name should be equal to doc root element -->
<doctype name="pentest_report">
<!-- list available covers below -->
<file name="frontpage_report_1.jpg"/>
<file name="frontpage_report_2.jpg"/>
<!--<file name="frontpage_report_3.jpg"/>-->
</doctype>
<doctype name="offerte">
<file name="frontpage_quote.jpg"/>
</doctype>
</frontpage_graphics>

View File

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="xs" version="2.0">
xmlns:my="http://www.radical.sexy"
exclude-result-prefixes="my xs" version="2.0">
<xsl:template name="layout-master-set">
@ -10,7 +11,11 @@
<!-- Cover page -->
<fo:simple-page-master master-name="Front-Cover" xsl:use-attribute-sets="PortraitPage">
<fo:region-body region-name="cover-flow" xsl:use-attribute-sets="region-body-cover"
/>
>
<xsl:call-template name="select_frontpage_graphic">
<xsl:with-param name="doctype" select="local-name(/*)"/>
</xsl:call-template>
</fo:region-body>
</fo:simple-page-master>
<!-- FrontMatter Content Pages (Odd) -->
<fo:simple-page-master master-name="Front-Content-odd"
@ -77,6 +82,20 @@
</fo:page-sequence-master>
</fo:layout-master-set>
</xsl:template>
<xsl:template name="select_frontpage_graphic">
<xsl:param name="doctype" select="'generic'"/>
<xsl:variable name="graphicsdoc"
select="document('../graphics/frontpage_graphics.xml')/frontpage_graphics/doctype[@name = $doctype]"/>
<xsl:variable name="available_frontpage_graphics" select="count($graphicsdoc/file)"/>
<xsl:variable name="current_second" select="seconds-from-dateTime(current-dateTime())"/>
<xsl:message><xsl:value-of select="$current_second"/></xsl:message>
<!-- taking the current second as a 'random number generator' -->
<xsl:variable name="selected_graphic" select="ceiling(number($available_frontpage_graphics div 60 * $current_second))"/>
<xsl:variable name="frontpage_graphic" select="$graphicsdoc/file[$selected_graphic]/@name"/>
<xsl:attribute name="background-image"
>url(../graphics/<xsl:value-of select="$frontpage_graphic"/>)</xsl:attribute>
</xsl:template>
<xsl:template name="page_footer">
<fo:static-content flow-name="region-after-content-odd" xsl:use-attribute-sets="FooterFont">

View File

@ -26,8 +26,7 @@
<!-- Pages -->
<xsl:attribute-set name="region-body-cover">
<xsl:attribute name="background-image"
>url(../graphics/frontpage_report.jpg)</xsl:attribute>
</xsl:attribute-set>
<!-- Findings -->