Skip to content

Commit

Permalink
ldh:LoadBlockObjectMetadata template is back
Browse files Browse the repository at this point in the history
  • Loading branch information
namedgraph committed Sep 28, 2024
1 parent 15b36fc commit b64c67e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ exclude-result-prefixes="#all"
<!-- update progress bar -->
<ixsl:set-style name="width" select="'75%'" object="."/>
</xsl:for-each>
<xsl:message>ldh:Object ldh:RenderBlock</xsl:message>
<xsl:message>ldh:Object ldh:RenderBlock @about: <xsl:value-of select="@about"/></xsl:message>

<!-- don't use ldh:base-uri(.) because its value comes from the last HTML document load -->
<xsl:variable name="request-uri" select="ldh:href($ldt:base, if (starts-with($graph, $ldt:base)) then $graph else ac:absolute-path(xs:anyURI(ixsl:location())), map{}, ac:document-uri($resource-uri), $graph, ())" as="xs:anyURI"/>
Expand Down Expand Up @@ -195,14 +195,18 @@ exclude-result-prefixes="#all"
<xsl:variable name="resource" select="key('resources', $resource-uri)" as="element()?"/>
<xsl:message>$resource-uri: <xsl:value-of select="$resource-uri"/> $resource: <xsl:value-of select="serialize($resource)"/></xsl:message>

<xsl:apply-templates select="$resource" mode="ldh:RenderBlock">
<xsl:with-param name="this" select="$this"/>
<!-- <xsl:with-param name="block" select="$block"/>-->
<xsl:with-param name="block-uri" select="$block-uri"/>
<xsl:with-param name="container" select="$container"/>
<xsl:with-param name="mode" select="$mode"/>
<xsl:with-param name="show-edit-button" select="$show-edit-button" tunnel="yes"/>
</xsl:apply-templates>
<xsl:variable name="request" as="item()*">
<ixsl:schedule-action http-request="map{ 'method': 'POST', 'href': sd:endpoint(), 'media-type': 'application/sparql-query', 'body': $query-string, 'headers': map{ 'Accept': 'application/rdf+xml' } }">
<xsl:call-template name="ldh:LoadBlockObjectMetadata">
<xsl:with-param name="container" select="$container"/>
<xsl:with-param name="resource" select="$resource"/>
<xsl:with-param name="graph" select="$graph"/>
<xsl:with-param name="mode" select="$mode"/>
<xsl:with-param name="show-edit-button" select="$show-edit-button"/>
</xsl:call-template>
</ixsl:schedule-action>
</xsl:variable>
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
</xsl:for-each>
</xsl:when>
<xsl:when test="?status = 406">
Expand All @@ -226,6 +230,57 @@ exclude-result-prefixes="#all"
</xsl:choose>
</xsl:template>

<!-- replaces the block with a row -->

<xsl:template name="ldh:LoadBlockObjectMetadata">
<xsl:context-item as="map(*)" use="required"/>
<xsl:param name="container" as="element()"/>
<xsl:param name="resource" as="element()"/>
<xsl:param name="graph" as="xs:anyURI?"/>
<xsl:param name="mode" as="xs:anyURI?"/>
<xsl:param name="show-edit-button" as="xs:boolean?"/>

<xsl:message>
ldh:LoadBlockObjectMetadata
?body: <xsl:value-of select="serialize(?body)"/>
</xsl:message>
<xsl:choose>
<xsl:when test="?status = 200 and ?media-type = 'application/rdf+xml'">
<xsl:variable name="object-metadata" select="?body" as="document-node()"/>

<!-- hide progress bar, if any -->
<xsl:for-each select="$container//div[@class = 'progress-bar']">
<ixsl:set-style name="display" select="'none'"/>
</xsl:for-each>

<xsl:variable name="row" as="node()*">
<xsl:apply-templates select="$resource" mode="bs2:Block">
<xsl:with-param name="graph" select="$graph" tunnel="yes"/>
<xsl:with-param name="mode" select="$mode"/>
<xsl:with-param name="show-edit-button" select="$show-edit-button" tunnel="yes"/>
<xsl:with-param name="object-metadata" select="$object-metadata" tunnel="yes"/>
</xsl:apply-templates>
</xsl:variable>

<xsl:message>
ldh:LoadBlockObjectMetadata $resource: <xsl:value-of select="serialize($resource)"/>
ldh:LoadBlockObjectMetadata $row: <xsl:value-of select="serialize($row)"/>
</xsl:message>

<xsl:for-each select="$container">
<xsl:result-document href="?." method="ixsl:replace-content">
<xsl:copy-of select="$row/*"/> <!-- inject the content of div.row-fluid -->
</xsl:result-document>

<xsl:apply-templates select="*" mode="ldh:PostConstruct"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="ixsl:call(ixsl:window(), 'alert', [ ?message ])[current-date() lt xs:date('2000-01-01')]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!-- EVENT LISTENERS -->

<!-- override inline editing form for content types (do nothing if the button is disabled) - prioritize over form.xsl -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ exclude-result-prefixes="#all"
$service-uri: <xsl:value-of select="$service-uri"/>
$service/sd:endpoint/@rdf:resource: <xsl:value-of select="$service/sd:endpoint/@rdf:resource"/>
$endpoint: <xsl:value-of select="$endpoint"/>
$container: <xsl:value-of select="serialize($container)"/>
</xsl:message>

<xsl:choose>
Expand Down

0 comments on commit b64c67e

Please sign in to comment.