Skip to content

Commit

Permalink
#27 pmp artifacts
Browse files Browse the repository at this point in the history
yegor256 committed Jul 6, 2024
1 parent e4fc393 commit 20617f8
Showing 4 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ target/xsl/%.xsl: xsl/%.xsl | target/xsl

target/html/%.html: target/fb/%.fb xsl/*.xsl entry.sh Makefile target/css/main.css $(SAXON) | target/html
export INPUT_VERBOSE=yes
export INPUT_OPTIONS=testing=yes
export GITHUB_WORKSPACE=.
export INPUT_FACTBASE=$<
fb=$$(basename $<)
4 changes: 4 additions & 0 deletions tests/simple.yml
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
---
-
what: pmp
area: hr
days_of_running_balance: 28
-
time: 2024-05-18T22:22:22.8492Z
award: 15
11 changes: 5 additions & 6 deletions xsl/awards.xsl
Original file line number Diff line number Diff line change
@@ -22,23 +22,24 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:z="https://www.zerocracy.com" version="2.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:z="https://www.zerocracy.com" version="2.0" exclude-result-prefixes="z">
<xsl:function name="z:award">
<xsl:param name="a"/>
<xsl:if test="$a &gt; 0">
<xsl:text>+</xsl:text>
</xsl:if>
<xsl:value-of select="$a"/>
</xsl:function>
<xsl:variable name="since" select="current-dateTime() - xs:dayTimeDuration(concat('P', z:pmp(/fb, 'hr', 'days_of_running_balance'), 'D'))"/>
<xsl:template match="/" mode="awards">
<xsl:apply-templates select="/fb" mode="awards"/>
<xsl:apply-templates select="/fb" mode="awards"/>
</xsl:template>
<xsl:template match="/fb[not(f[who_name and award])]" mode="awards">
<xsl:template match="/fb[not(f[award and when &gt; $since])]" mode="awards">
<p>
<xsl:text>No awards as of yet.</xsl:text>
</p>
</xsl:template>
<xsl:template match="/fb[f]" mode="awards">
<xsl:template match="/fb[f[award and when &gt; $since]]" mode="awards">
<table id="awards" border="1">
<colgroup>
<col style="width: 2em;"/>
@@ -77,8 +78,6 @@ SOFTWARE.
</tbody>
</table>
</xsl:template>
<xsl:template match="fb" mode="awards">
</xsl:template>
<xsl:template name="programmer">
<xsl:param name="name"/>
<tr>
26 changes: 25 additions & 1 deletion xsl/index.xsl
Original file line number Diff line number Diff line change
@@ -22,13 +22,37 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:z="https://www.zerocracy.com" exclude-result-prefixes="z">
<xsl:import href="awards.xsl"/>
<xsl:output method="xml" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes"/>
<xsl:param name="css"/>
<xsl:param name="name"/>
<xsl:param name="logo"/>
<xsl:param name="version"/>
<xsl:function name="z:pmp">
<xsl:param name="fb"/>
<xsl:param name="area"/>
<xsl:param name="param"/>
<xsl:variable name="a" select="$fb/f[what='pmp' and area=$area]"/>
<xsl:if test="not($a)">
<xsl:message terminate="yes">
<xsl:text>There is no PMP fact for the area '</xsl:text>
<xsl:value-of select="$area"/>
<xsl:text>'</xsl:text>
</xsl:message>
</xsl:if>
<xsl:variable name="v" select="$a/*[name()=$param]/text()"/>
<xsl:if test="not($v)">
<xsl:message terminate="yes">
<xsl:text>There is no parameter '</xsl:text>
<xsl:value-of select="$param"/>
<xsl:text>' in the PMP artifact for the '</xsl:text>
<xsl:value-of select="$area"/>
<xsl:text>' area</xsl:text>
</xsl:message>
</xsl:if>
<xsl:value-of select="$v"/>
</xsl:function>
<xsl:template name="javascript">
<xsl:param name="url"/>
<script type="text/javascript" src="{$url}">

0 comments on commit 20617f8

Please sign in to comment.