Skip to content

Commit

Permalink
Merge pull request #620 from openSUSE/fix-jsonld-about
Browse files Browse the repository at this point in the history
Fix #617: Put task and webpage both into "about"
  • Loading branch information
tomschr authored Mar 25, 2024
2 parents 58eb5a0 + 09615e7 commit 15edc65
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions suse2022-ns/xhtml/json-ld.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,13 @@
<xsl:call-template name="json-ld-category">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<xsl:call-template name="json-ld-task">
<xsl:call-template name="json-ld-about"><!-- both task & webpages integrated into "about" property -->
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<!-- Belongs to type "SoftwareApplication" -->
<xsl:call-template name="json-ld-software">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<xsl:call-template name="json-ld-webpages">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<xsl:call-template name="json-ld-releasenotes">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
Expand Down Expand Up @@ -756,16 +753,28 @@
</xsl:if>
</xsl:template>

<xsl:template name="json-ld-about">
<xsl:param name="node" select="."/>

"about": [
<xsl:call-template name="json-ld-task">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
<xsl:call-template name="json-ld-webpages">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
],
</xsl:template>

<xsl:template name="json-ld-task">
<xsl:param name="node" select="."/>
<xsl:variable name="task" select="$node/d:info/d:meta[@name='task']/d:phrase"/>
<xsl:if test="count($task) > 0">
"about": [<xsl:for-each select="$task">{
<xsl:for-each select="$task">{
"@type": "Thing",
"name": "<xsl:value-of select="normalize-space(.)"/>"
}<xsl:if test="position() != last()">,&#10; </xsl:if>
},<!-- <== This comma is essential here. -->
</xsl:for-each>
],
</xsl:if>
</xsl:template>

Expand Down Expand Up @@ -849,7 +858,7 @@
</xsl:variable>
<xsl:variable name="format-node" select="exsl:node-set($candicate-format-node)/*/*"/>

"about": [<xsl:for-each select="$format-node">
<xsl:for-each select="$format-node">
<xsl:variable name="attr" select="."/>
<xsl:variable name="candidate-url" select="concat($json-ld-fallback-author-url, '/',
$candidate-productid, '/',
Expand Down Expand Up @@ -880,6 +889,5 @@
"encodingFormat": "<xsl:value-of select="$encodingformat"/>"</xsl:if>
}<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
],
</xsl:template>
</xsl:stylesheet>

0 comments on commit 15edc65

Please sign in to comment.