Skip to content

Commit d2458f9

Browse files
committed
Sync acl:mode() per pane on tab activation
acl:mode() reads the LinkedDataHub.acl-modes window flags, which were set only on document load from the response Link headers. On fetch-less switches between already-loaded tab panes the flags went stale, reflecting the last-loaded document rather than the activated pane. Extract the flag-setting into a reusable ldh:SetAclModes template; stamp each document body with data-acl-modes (from its Link-header modes) via a new acl-modes param threaded through bs2:Document; re-sync the flags from the activated pane's data-acl-modes in ldh:ActivateTab, and re-stamp reused panes.
1 parent 9fdd00d commit d2458f9

3 files changed

Lines changed: 41 additions & 16 deletions

File tree

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/document.xsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ extension-element-prefixes="ixsl"
458458
<xsl:param name="base" as="xs:anyURI?"/>
459459
<xsl:param name="endpoint" as="xs:anyURI?"/>
460460
<xsl:param name="application" as="xs:anyURI?"/>
461+
<xsl:param name="acl-modes" as="xs:anyURI*"/>
461462
<xsl:param name="about" as="xs:anyURI"/>
462463
<xsl:param name="object-metadata" as="document-node()?" tunnel="yes"/>
463464

@@ -477,6 +478,9 @@ extension-element-prefixes="ixsl"
477478
<xsl:if test="$application">
478479
<xsl:attribute name="data-application" select="$application"/>
479480
</xsl:if>
481+
<xsl:if test="exists($acl-modes)">
482+
<xsl:attribute name="data-acl-modes" select="string-join($acl-modes, ' ')"/>
483+
</xsl:if>
480484

481485
<xsl:apply-templates select="." mode="bs2:DocumentBody">
482486
<xsl:with-param name="mode" select="$mode"/>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/layout.xsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ WHERE
849849
<xsl:with-param name="mode" select="ac:mode(root())"/>
850850
<xsl:with-param name="base" select="ldt:base()"/>
851851
<xsl:with-param name="endpoint" select="sd:endpoint()"/>
852+
<xsl:with-param name="acl-modes" select="acl:mode()"/>
852853
<xsl:with-param name="about" select="ac:absolute-path(ldh:base-uri(.))"/>
853854
<xsl:with-param name="object-metadata" select="$object-metadata" tunnel="yes"/>
854855
</xsl:apply-templates>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -447,24 +447,14 @@ WHERE
447447
<xsl:for-each select="$response">
448448
<ixsl:set-style name="cursor" select="'default'" object="ixsl:page()//body"/>
449449

450-
<!-- checking acl:mode here because this template is called after every document load (also the initial load) and has access to ?headers -->
451-
<!-- set LinkedDataHub.acl-modes objects which are later used by the acl:mode function -->
452-
<!-- doing it here because this template is called after every document load (also the initial load) and has access to ?headers -->
450+
<!-- extract acl:mode from the response Link headers here because this template is called after every document load (also the initial load) and has access to ?headers -->
451+
<!-- for proxied documents these are the *remote* node's modes, forwarded by ProxyRequestFilter -->
453452
<xsl:variable name="acl-mode-links" select="tokenize(?headers?link, ',')[contains(., '&acl;mode')]" as="xs:string*"/>
454453
<xsl:variable name="acl-modes" select="for $mode-link in $acl-mode-links return xs:anyURI(substring-before(substring-after(substring-before($mode-link, ';'), '&lt;'), '&gt;'))" as="xs:anyURI*"/>
455-
<ixsl:set-property name="acl-modes" select="ldh:new-object()" object="ixsl:get(ixsl:window(), 'LinkedDataHub')"/>
456-
<xsl:if test="$acl-modes = '&acl;Read'">
457-
<ixsl:set-property name="read" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
458-
</xsl:if>
459-
<xsl:if test="$acl-modes = '&acl;Append'">
460-
<ixsl:set-property name="append" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
461-
</xsl:if>
462-
<xsl:if test="$acl-modes = '&acl;Write'">
463-
<ixsl:set-property name="write" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
464-
</xsl:if>
465-
<xsl:if test="$acl-modes = '&acl;Control'">
466-
<ixsl:set-property name="control" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
467-
</xsl:if>
454+
<!-- set LinkedDataHub.acl-modes flags which are later used by the acl:mode function; re-synced per pane by ldh:ActivateTab -->
455+
<xsl:call-template name="ldh:SetAclModes">
456+
<xsl:with-param name="acl-modes" select="$acl-modes"/>
457+
</xsl:call-template>
468458

469459
<xsl:variable name="etag" select="?headers?etag" as="xs:string?"/>
470460

@@ -542,6 +532,11 @@ WHERE
542532
</xsl:result-document>
543533
</xsl:for-each>
544534

535+
<!-- re-stamp the pane's modes: acl:mode is per-document, and the reused pane now shows a different document -->
536+
<xsl:for-each select="$reuse-pane">
537+
<ixsl:set-attribute name="data-acl-modes" select="string-join($acl-modes, ' ')" object="."/>
538+
</xsl:for-each>
539+
545540
<!-- sync the corresponding tab <li> to the new doc URI; data-uri keys downstream lookups -->
546541
<xsl:if test="string($doc-uri) ne $old-about">
547542
<xsl:for-each select="id('tab-bar-list', ixsl:page())/li[ixsl:get(., 'dataset.uri') = $old-about]">
@@ -567,6 +562,7 @@ WHERE
567562
<xsl:with-param name="base" select="$tab-base"/>
568563
<xsl:with-param name="endpoint" select="$endpoint"/>
569564
<xsl:with-param name="application" select="$application"/>
565+
<xsl:with-param name="acl-modes" select="$acl-modes"/>
570566
<xsl:with-param name="about" select="$doc-uri"/>
571567
<xsl:with-param name="object-metadata" select="$context('object-metadata')" tunnel="yes"/>
572568
<xsl:with-param name="property-metadata" select="$context('property-metadata')" tunnel="yes"/>
@@ -793,9 +789,33 @@ WHERE
793789
<xsl:for-each select="id('tab-content', ixsl:page())/div[contains-token(@class, 'tab-pane')][./div[contains-token(@class, 'document-body')]/@about = $doc-uri]">
794790
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'add', [ 'active' ])[current-date() lt xs:date('2000-01-01')]"/>
795791
<ixsl:set-style name="display" select="'block'" object="."/>
792+
793+
<!-- sync acl:mode() to this pane's data-acl-modes (stamped from its document's Link header); the window flags otherwise go stale on fetch-less tab switches between panes -->
794+
<xsl:call-template name="ldh:SetAclModes">
795+
<xsl:with-param name="acl-modes" select="if (ixsl:contains(., 'dataset.aclModes')) then (for $mode in tokenize(ixsl:get(., 'dataset.aclModes'), ' ')[.] return xs:anyURI($mode)) else ()"/>
796+
</xsl:call-template>
796797
</xsl:for-each>
797798
</xsl:template>
798799

800+
<!-- set the LinkedDataHub.acl-modes flags read by acl:mode(); called on document load (from the response Link headers) and on tab activation (from the pane's data-acl-modes) -->
801+
<xsl:template name="ldh:SetAclModes">
802+
<xsl:param name="acl-modes" as="xs:anyURI*"/>
803+
804+
<ixsl:set-property name="acl-modes" select="ldh:new-object()" object="ixsl:get(ixsl:window(), 'LinkedDataHub')"/>
805+
<xsl:if test="$acl-modes = '&acl;Read'">
806+
<ixsl:set-property name="read" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
807+
</xsl:if>
808+
<xsl:if test="$acl-modes = '&acl;Append'">
809+
<ixsl:set-property name="append" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
810+
</xsl:if>
811+
<xsl:if test="$acl-modes = '&acl;Write'">
812+
<ixsl:set-property name="write" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
813+
</xsl:if>
814+
<xsl:if test="$acl-modes = '&acl;Control'">
815+
<ixsl:set-property name="control" select="true()" object="ixsl:get(ixsl:window(), 'LinkedDataHub.acl-modes')"/>
816+
</xsl:if>
817+
</xsl:template>
818+
799819
<!-- render RDF results into a tab pane identified by @about = $doc-uri -->
800820
<!-- works for both local (#content-body) and external panes -->
801821
<xsl:template name="ldh:RenderTab">

0 commit comments

Comments
 (0)