Skip to content

Commit

Permalink
add tracker jobfile xsl stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
voc authored and a-tze committed Mar 11, 2024
1 parent e72c881 commit a1757f5
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Application/Controller/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function addHeaders() {
$this->Response->addHeader(
'Content-Security-Policy',
'default-src \'self\';' .
'font-src \'none\'; frame-src \'none\'; object-src \'none\';'
'font-src \'none\'; style-src \'self\' \'unsafe-inline\'; frame-src \'none\'; object-src \'none\';'
);

$this->Response->addHeader('X-Content-Type-Options', 'nosniff');
Expand Down
4 changes: 3 additions & 1 deletion src/Application/Model/EncodingProfileVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getJobfile(array $properties) {
// Process templates as XSL

$content = new DOMDocument('1.0', 'UTF-8');

$parent = $content->createElement('properties');

foreach ($properties as $name => $value) {
Expand All @@ -59,6 +60,7 @@ public function getJobfile(array $properties) {

// pretty print
$output = $processor->transformToDoc($content);
$output->insertBefore($output->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="/xsl/jobstyle.xsl"'), $output->firstChild);

if (!$output or !$output instanceOf DOMDocument) {
throw EncodingProfileTemplateException::fromLibXMLErrors();
Expand Down Expand Up @@ -134,4 +136,4 @@ public static function fromLibXMLErrors() {

}

?>
?>
67 changes: 67 additions & 0 deletions src/Public/xsl/jobstyle.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<style>
pre {
white-space: pre-wrap;
}
span {
color: grey;
}
.file {
color: orange;
}
.exe {
color: blue;
}
</style>
</head>
<body spellcheck="false">
<h1>CRS Tasks</h1>
<xsl:for-each select="job/tasks/task">
<h3>
<xsl:value-of select="@type"/>
</h3>

<pre contenteditable="true">
<xsl:for-each select="option">
<xsl:variable name="value" select="text()"/>
<xsl:variable name="type" select="@filetype"/>

<!-- Add linebreaks for some options, but only when a new parameter starts -->
<xsl:if test="starts-with($value, '-')">
<xsl:if test="starts-with($value, '-map') or string-length($value) &gt; 7">
<xsl:text>\&#xa;&#x20;&#x20;</xsl:text>
</xsl:if>
</xsl:if>

<!-- Quote & format the value if required -->
<xsl:choose>
<xsl:when test="contains($value, ';')">
<!-- xsl:variable name="x" select="replace($value, ' ; ', ' ;&#xa; ')"/ -->
<span class="filter"><xsl:value-of select="concat('&quot;', $value, '&quot;')"/></span>
</xsl:when>
<xsl:when test="contains($value, ' ') and not(@quoted = 'no')">
<span><xsl:value-of select="concat('&quot;', $value, '&quot;')"/></span>
</xsl:when>
<xsl:when test="$type">
<span class="file">
<xsl:attribute name="class"><xsl:value-of select="concat('file ', @filetype)" /></xsl:attribute>
<xsl:value-of select="$value"/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#x20;</xsl:text>
</xsl:for-each>
</pre>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

0 comments on commit a1757f5

Please sign in to comment.