Skip to content

Commit

Permalink
Content refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
namedgraph committed Dec 21, 2023
1 parent c7c69ae commit 3964391
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,7 @@ exclude-result-prefixes="#all"
</xsl:call-template>

<xsl:variable name="textarea-id" select="$row//textarea[@name = 'query']/ixsl:get(., 'id')" as="xs:string"/>
<!-- initialize YASQE on the textarea -->
<xsl:variable name="js-statement" as="element()">
<root statement="YASQE.fromTextArea(document.getElementById('{$textarea-id}'), {{ persistent: null }})"/>
</xsl:variable>
<ixsl:set-property name="{$textarea-id}" select="ixsl:eval(string($js-statement/@statement))" object="ixsl:get(ixsl:window(), 'LinkedDataHub.yasqe')"/>
</xsl:template>

<xsl:template match="div[contains-token(@typeof, '&sp;Select')] | div[contains-token(@typeof, '&sp;Ask')] | div[contains-token(@typeof, '&sp;Describe')] | div[contains-token(@typeof, '&sp;Construct')]" mode="ldh:RenderOverrideContent">
<xsl:variable name="textarea-id" select=".//textarea[@name = 'query']/ixsl:get(., 'id')" as="xs:string"/>
<!-- initialize YASQE on the textarea -->
<xsl:variable name="js-statement" as="element()">
<root statement="YASQE.fromTextArea(document.getElementById('{$textarea-id}'), {{ persistent: null }})"/>
</xsl:variable>
<ixsl:set-property name="{$textarea-id}" select="ixsl:eval(string($js-statement/@statement))" object="ixsl:get(ixsl:window(), 'LinkedDataHub.yasqe')"/>
<xsl:apply-templates select="id($textarea-id, ixsl:page())" mode="ldh:PostConstruct"/>
</xsl:template>

<!-- .xhtml-content referenced from .resource-content (XHTML transclusion) -->
Expand Down Expand Up @@ -1345,7 +1332,7 @@ exclude-result-prefixes="#all"
<xsl:param name="refresh-content" as="xs:boolean?"/>
<xsl:variable name="this" select="ancestor::div[@about][1]/@about" as="xs:anyURI"/>
<xsl:variable name="content-uri" select="(@about, $this)[1]" as="xs:anyURI"/> <!-- fallback to @about for charts, queries etc. -->
<xsl:variable name="content-value" select="ixsl:get(., 'dataset.contentValue')" as="xs:anyURI"/> <!-- get the value of the @data-content-value attribute -->
<xsl:variable name="content-value" select="if (contains-token(@class, 'override-content)) then @about else ixsl:get(., 'dataset.contentValue')" as="xs:anyURI"/> <!-- get the value of the @data-content-value attribute -->
<xsl:variable name="graph" select="if (ixsl:contains(., 'dataset.contentGraph')) then xs:anyURI(ixsl:get(., 'dataset.contentGraph')) else ()" as="xs:anyURI?"/> <!-- get the value of the @data-content-graph attribute -->
<xsl:variable name="mode" select="if (ixsl:contains(., 'dataset.contentMode')) then xs:anyURI(ixsl:get(., 'dataset.contentMode')) else ()" as="xs:anyURI?"/> <!-- get the value of the @data-content-mode attribute -->
<xsl:variable name="container" select="." as="element()"/>
Expand Down
16 changes: 4 additions & 12 deletions src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/client.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ WHERE
<ixsl:set-attribute name="type" select="'button'"/> <!-- instead of "submit" -->
</xsl:for-each>
<!-- initialize SPARQL editors -->
<xsl:apply-templates select="ixsl:page()//textarea[contains(@class, 'sparql-query-string')]" mode="ldh:PostConstruct"/> <!-- TO-DO: use the 'elements-by-class' key -->
<!-- <xsl:apply-templates select="ixsl:page()//textarea[contains(@class, 'sparql-query-string')]" mode="ldh:PostConstruct"/> --> <!-- TO-DO: use the 'elements-by-class' key -->
<!-- only show first time message for authenticated agents -->
<xsl:if test="$acl:agent and not(contains(ixsl:get(ixsl:page(), 'cookie'), 'LinkedDataHub.first-time-message'))">
<xsl:for-each select="ixsl:page()//body">
Expand All @@ -258,9 +258,9 @@ WHERE
</xsl:for-each>
</xsl:if>
<!-- initialize form if we're in editing mode -->
<xsl:if test="ixsl:query-params()?mode = '&ac;EditMode'">
<!-- <xsl:if test="ixsl:query-params()?mode = '&ac;EditMode'">
<xsl:apply-templates select="id('content-body', ixsl:page())" mode="ldh:PostConstruct"/>
</xsl:if>
</xsl:if>-->
<!-- initialize LinkedDataHub.apps (and the search dropdown, if it's shown) -->
<ixsl:set-property name="apps" select="$ldh:apps" object="ixsl:get(ixsl:window(), 'LinkedDataHub')"/>
<!-- #search-service may be missing (e.g. suppressed by extending stylesheet) -->
Expand Down Expand Up @@ -510,7 +510,7 @@ WHERE

<!-- this has to go after <xsl:result-document href="#{$container-id}"> because otherwise new elements will be injected and the $resource-content-ids lookup will not work anymore -->
<!-- load resource contents -->
<xsl:variable name="resource-content-ids" select="key('elements-by-class', 'resource-content', ixsl:page())/@id" as="xs:string*"/>
<xsl:variable name="resource-content-ids" select="key('elements-by-class', 'resource-content', ixsl:page())/@id | key('elements-by-class', 'override-content', ixsl:page())/@id" as="xs:string*"/>
<xsl:if test="not(empty($resource-content-ids))">
<xsl:variable name="containers" select="id($resource-content-ids, ixsl:page())" as="element()*"/>
<xsl:for-each select="$containers">
Expand All @@ -534,14 +534,6 @@ WHERE
</xsl:for-each>
</xsl:if>
</xsl:if>

<xsl:variable name="override-content-ids" select="key('elements-by-class', 'override-content', ixsl:page())/@id" as="xs:string*"/>
<xsl:if test="not(empty($override-content-ids))">
<xsl:variable name="containers" select="id($override-content-ids, ixsl:page())" as="element()*"/>
<xsl:for-each select="$containers">
<xsl:apply-templates select="." mode="ldh:RenderOverrideContent"/>
</xsl:for-each>
</xsl:if>

<!-- is a new instance of Service was created, reload the LinkedDataHub.apps data and re-render the service dropdown -->
<xsl:if test="//ldt:base or //sd:endpoint">
Expand Down

0 comments on commit 3964391

Please sign in to comment.