Files
maven-plugins/dashboard/src/plugin-resources/templates/dashboard.jsl
T

191 lines
7.4 KiB
XML

<?xml version="1.0"?>
<!--
* ========================================================================
*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ========================================================================
-->
<jsl:stylesheet
select="$doc"
xmlns:j="jelly:core"
xmlns:jsl="jelly:jsl"
xmlns:x="jelly:xml"
xmlns:u="jelly:util"
xmlns:a="jelly:ant"
xmlns="dummy" trim="false">
<jsl:template match="dashboard">
<document>
<properties>
<title>Dashboard Report</title>
</properties>
<body>
<section name="Dashboard report">
<p>
<a href="${maven.dashboard.report.legend.xdoc}.html" target="Legend">Column
legends</a>
</p>
<table>
<tr>
<th>Project</th>
<x:forEach var="aggregatorName" select="project[1]/aggregator/@name">
<th>
<j:set var="labelProperty"
value="maven.dashboard.aggregator.${aggregatorName.value}.label"/>
<j:expr value="${context.getVariable(labelProperty)}"/>
</th>
</x:forEach>
</tr>
<jsl:applyTemplates/>
</table>
</section>
</body>
</document>
</jsl:template>
<jsl:template match="project">
<!-- Decide whether to display project data -->
<j:set var="shallDisplay" value="true"/>
<j:if test="${context.getVariable('maven.dashboard.report.showempty') == 'false'}">
<x:set var="notEmptyElems" select="aggregator[not(text() = '-')]"/>
<j:if test="${notEmptyElems.isEmpty() == 'true'}">
<j:set var="shallDisplay" value="false"/>
</j:if>
</j:if>
<j:if test="${shallDisplay == 'true'}">
<tr>
<x:set var="projecturl1" select="string(@artifactId)"/>
<j:set var="projecturl" value="${maven.multiproject.aggregateDir}${projecturl1}/index.html"/>
<td><a href="${projecturl}"><x:expr select="@name"/></a></td>
<jsl:applyTemplates select="aggregator"/>
</tr>
</j:if>
</jsl:template>
<jsl:template match="aggregator">
<x:set var="aggregatorName" select="string(@name)"/>
<j:set var="aggregatorKey" value="maven.dashboard.aggregator.${aggregatorName}.report"/>
<j:set var="aggregatorHasReport" value="false"/>
<j:set var="aggregatorReport" value="${context.getVariable(aggregatorKey)}"/>
<j:if test="${aggregatorReport != null}">
<u:available file="${maven.build.dir}/docs/${maven.multiproject.aggregateDir}${projecturl1}/${aggregatorReport}">
<j:set var="aggregatorHasReport" value="true"/>
</u:available>
</j:if>
<td>
<x:set var="str" select="string()"/>
<!-- if aggregator output is a not percentage value, just print the value -->
<!-- could print a different background color based on a configurable -->
<!-- range, see MPDASHBOARD-2 in Jira issues for this plugin -->
<j:if test="${str.trim().endsWith('%') == 'false'}">
<j:choose>
<j:when test="${aggregatorHasReport == 'true'}">
<a href="${maven.multiproject.aggregateDir}${projecturl1}/${aggregatorReport}">
<x:expr select="text()"/>
</a>
</j:when>
<j:otherwise>
<x:expr select="text()"/>
</j:otherwise>
</j:choose>
</j:if>
<!-- if aggregator output is a percentage value, print a progress bar -->
<j:if test="${str.trim().endsWith('%') == 'true'}">
<!-- convert percentage string to two complementary numbers -->
<u:replace var="percentStr" value="${str}" oldChar="%" newChar=" " trim="true"/>
<j:set var="percent" value="${0 + percentStr.trim()}"/>
<j:set var="cpercent" value="${100 - percent}"/>
<j:whitespace trim="true">
<table>
<j:if test="${context.getVariable('maven.dashboard.report.bar.displayLabel') == 'true'}">
<tr>
<x:element name="td">
<x:attribute name="colspan">2</x:attribute>
<j:choose>
<j:when test="${aggregatorHasReport == 'true'}">
<a href="${maven.multiproject.aggregateDir}${projecturl1}/${aggregatorReport}">
<j:expr value="${percent}%"/>
</a>
</j:when>
<j:otherwise>
<j:expr value="${percent}%"/>
</j:otherwise>
</j:choose>
</x:element>
</tr>
</j:if>
<tr>
<j:if test="${percent != '0'}">
<x:element name="td">
<x:attribute name="bgcolor">
<j:expr value="${maven.dashboard.report.bar.left}"/>
</x:attribute>
<x:element name="img">
<x:attribute name="hspace">0</x:attribute>
<x:attribute name="vspace">0</x:attribute>
<x:attribute name="src">
<j:expr value="${maven.dashboard.report.bar.image}"/>
</x:attribute>
<x:attribute name="height">
<j:expr value="${maven.dashboard.report.bar.height}"/>
</x:attribute>
<x:attribute name="border">
<j:expr value="${maven.dashboard.report.bar.border}"/>
</x:attribute>
<x:attribute name="width">${percent}</x:attribute>
<x:attribute name="alt">${percent}%</x:attribute>
</x:element>
</x:element>
</j:if>
<j:if test="${cpercent != '0'}">
<x:element name="td">
<x:attribute name="bgcolor">
<j:expr value="${maven.dashboard.report.bar.right}"/>
</x:attribute>
<x:element name="img">
<x:attribute name="hspace">0</x:attribute>
<x:attribute name="vspace">0</x:attribute>
<x:attribute name="src">
<j:expr value="${maven.dashboard.report.bar.image}"/>
</x:attribute>
<x:attribute name="height">
<j:expr value="${maven.dashboard.report.bar.height}"/>
</x:attribute>
<x:attribute name="border">
<j:expr value="${maven.dashboard.report.bar.border}"/>
</x:attribute>
<x:attribute name="width">${cpercent}</x:attribute>
<x:attribute name="alt">${cpercent}%</x:attribute>
</x:element>
</x:element>
</j:if>
</tr>
</table>
</j:whitespace>
</j:if>
</td>
</jsl:template>
</jsl:stylesheet>