Image attributions are now paired with random selector

This commit is contained in:
skyanth 2019-01-22 11:10:04 +01:00
parent c3572b6996
commit 12263f030e
5 changed files with 46 additions and 12 deletions

View File

@ -3,11 +3,26 @@
<!-- 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_1.jpg">
<attribution>Front page image by Slava
(https://secure.flickr.com/photos/slava/496607907/), "Mango HaX0ring", Image styling
by Patricia Piolon,
https://creativecommons.org/licenses/by-sa/2.0/legalcode.</attribution>
</file>
<file name="frontpage_report_2.jpg">
<attribution>Front page image by dougwoods
(https://www.flickr.com/photos/deerwooduk/682390157/), "Cat on laptop", Image
styling by Patricia Piolon,
https://creativecommons.org/licenses/by-sa/2.0/legalcode.</attribution>
</file>
<!--<file name="frontpage_report_3.jpg"/>-->
</doctype>
<doctype name="offerte">
<file name="frontpage_quote.jpg"/>
<file name="frontpage_quote.jpg">
<attribution>Front page image by kallerna
(https://commons.wikimedia.org/wiki/File:Rock_climber_Phra_Nang_1.jpg), "Rock
climber Phra Nang 1", Image styling by Patricia Piolon,
https://creativecommons.org/licenses/by-sa/3.0/legalcode</attribution>
</file>
</doctype>
</frontpage_graphics>

View File

@ -22,6 +22,9 @@
<xsl:variable name="hourly_fee" select="/contract/meta/contractor/hourly_fee * 1"/>
<xsl:variable name="plannedHours" select="/contract/meta/work/planning/hours * 1"/>
<xsl:variable name="total_fee" select="$hourly_fee * $plannedHours"/>
<!-- current second ('random' seed) -->
<xsl:variable name="current_second" select="ceiling(seconds-from-dateTime(current-dateTime()))"/>
<!-- finding colors (used in findings & pie charts) -->
<!-- threatlevel -->

View File

@ -104,12 +104,6 @@
</fo:footnote-body>
</fo:footnote>
</xsl:template>
<xsl:template name="ImageAttribution">
<fo:block xsl:use-attribute-sets="coc" break-after="page">
kallerna (https://commons.wikimedia.org/wiki/File:Rock_climber_Phra_Nang_1.jpg), "Rock climber Phra Nang 1", Image styling by Patricia Piolon, https://creativecommons.org/licenses/by-sa/3.0/legalcode </fo:block>
</xsl:template>
<!-- CONTACT BOX (comes at the end, is just the address, no title/table) -->
<xsl:template match="contact">

View File

@ -409,14 +409,34 @@
</xsl:template>
<xsl:template name="ImageAttribution">
<fo:block xsl:use-attribute-sets="coc" break-after="page"> Front page image by Slava
(https://secure.flickr.com/photos/slava/496607907/), "Mango HaX0ring", Image styling by Patricia Piolon, https://creativecommons.org/licenses/by-sa/2.0/legalcode. </fo:block>
<fo:block xsl:use-attribute-sets="coc" break-after="page">
<xsl:call-template name="select_frontpage_graphic_attribution">
<xsl:with-param name="doctype" select="local-name(/*)"/>
<xsl:with-param name="current_second" select="$current_second"/>
</xsl:call-template>
</fo:block>
</xsl:template>
<xsl:template match="subtitle">
<xsl:apply-templates/>
</xsl:template>
<xsl:template name="select_frontpage_graphic_attribution">
<xsl:param name="doctype" select="'generic'"/>
<xsl:param name="current_second" select="1"/>
<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: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_attribution"
select="$graphicsdoc/file[$selected_graphic]/attribution"/>
<xsl:value-of select="$frontpage_graphic_attribution"/>
</xsl:template>
</xsl:stylesheet>

View File

@ -14,6 +14,7 @@
>
<xsl:call-template name="select_frontpage_graphic">
<xsl:with-param name="doctype" select="local-name(/*)"/>
<xsl:with-param name="current_second" select="$current_second"/>
</xsl:call-template>
</fo:region-body>
</fo:simple-page-master>
@ -85,10 +86,11 @@
<xsl:template name="select_frontpage_graphic">
<xsl:param name="doctype" select="'generic'"/>
<xsl:param name="current_second" select="1"/>
<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))"/>