Skip to content

Commit ec448e0

Browse files
committed
Use ldh:LoadBlockObjectMetadata only for local resources
1 parent c556fcb commit ec448e0

2 files changed

Lines changed: 55 additions & 16 deletions

File tree

  • src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ exclude-result-prefixes="#all"
177177
</xsl:if>
178178
</xsl:template>
179179

180-
<!-- override inline editing form for content types (do nothing if the button is disabled) - prioritize over form.xsl -->
180+
<!-- override inline editing form for block types (do nothing if the button is disabled) - prioritize over form.xsl -->
181181

182-
<xsl:template match="div[following-sibling::div[@typeof = ('&ldh;XHTML', '&ldh;View', '&ldh;Object')]]//button[contains-token(@class, 'btn-edit')][not(contains-token(@class, 'disabled'))]" mode="ixsl:onclick" priority="1">
182+
<xsl:template match="div[following-sibling::div[@typeof = ('&ldh;XHTML', '&ldh;Object')]]//button[contains-token(@class, 'btn-edit')][not(contains-token(@class, 'disabled'))]" mode="ixsl:onclick" priority="1">
183183
<xsl:param name="block" select="ancestor::div[contains-token(@class, 'block')][1]" as="element()"/>
184184
<!-- for content types, button.btn-edit is placed in its own div.row-fluid, therefore the next row is the actual container -->
185185
<xsl:param name="container" select="$block/descendant::div[@typeof][1]" as="element()"/> <!-- other resources can be nested within object -->
@@ -191,7 +191,7 @@ exclude-result-prefixes="#all"
191191

192192
<!-- append new block form onsubmit (using POST) -->
193193

194-
<xsl:template match="div[@typeof = ('&ldh;XHTML', '&ldh;View', '&ldh;Object')]//form[contains-token(@class, 'form-horizontal')][upper-case(@method) = 'POST']" mode="ixsl:onsubmit" priority="2"> <!-- prioritize over form.xsl -->
194+
<xsl:template match="div[@typeof = ('&ldh;XHTML', '&ldh;Object')]//form[contains-token(@class, 'form-horizontal')][upper-case(@method) = 'POST']" mode="ixsl:onsubmit" priority="2"> <!-- prioritize over form.xsl -->
195195
<xsl:param name="elements" select=".//input | .//textarea | .//select" as="element()*"/>
196196
<xsl:param name="triples" select="ldh:parse-rdf-post($elements)" as="element()*"/>
197197
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
@@ -221,13 +221,13 @@ exclude-result-prefixes="#all"
221221
</xsl:next-match>
222222
</xsl:template>
223223

224-
<!-- delete content onclick (increased priority to take precedence over form.xsl .btn-remove-resource) -->
224+
<!-- delete block onclick (increased priority to take precedence over form.xsl .btn-remove-resource) -->
225225

226-
<xsl:template match="div[@typeof = ('&ldh;XHTML', '&ldh;View', '&ldh;Object')]//button[contains-token(@class, 'btn-remove-resource')]" mode="ixsl:onclick" priority="3">
226+
<xsl:template match="div[@typeof = ('&ldh;XHTML', '&ldh;Object')]//button[contains-token(@class, 'btn-remove-resource')]" mode="ixsl:onclick" priority="3">
227227
<xsl:variable name="block" select="ancestor::div[contains-token(@class, 'block')][1]" as="element()"/>
228228

229229
<xsl:choose>
230-
<!-- delete existing content -->
230+
<!-- delete existing block -->
231231
<xsl:when test="$block/@about">
232232
<!-- show a confirmation prompt -->
233233
<xsl:if test="ixsl:call(ixsl:window(), 'confirm', [ ac:label(key('resources', 'are-you-sure', document(resolve-uri('static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/translations.rdf', $ac:contextUri)))) ])">
@@ -247,7 +247,7 @@ exclude-result-prefixes="#all"
247247
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
248248
</xsl:if>
249249
</xsl:when>
250-
<!-- remove content that hasn't been saved yet -->
250+
<!-- remove block that hasn't been saved yet -->
251251
<xsl:otherwise>
252252
<xsl:for-each select="$block">
253253
<xsl:sequence select="ixsl:call(., 'remove', [])[current-date() lt xs:date('2000-01-01')]"/>
@@ -274,14 +274,14 @@ exclude-result-prefixes="#all"
274274
</xsl:choose>
275275
</xsl:template>
276276

277-
<!-- dragging content over other block -->
277+
<!-- dragging block over other block -->
278278

279279
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragover">
280280
<xsl:sequence select="ixsl:call(ixsl:event(), 'preventDefault', [])"/>
281281
<ixsl:set-property name="dataTransfer.dropEffect" select="'move'" object="ixsl:event()"/>
282282
</xsl:template>
283283

284-
<!-- change the style of blocks when content is dragged over them -->
284+
<!-- change the style of blocks when block is dragged over them -->
285285

286286
<xsl:template match="div[@id = 'content-body']/div[ixsl:query-params()?mode = '&ldh;ContentMode'][@about][contains-token(@class, 'block')][acl:mode() = '&acl;Write']" mode="ixsl:ondragenter">
287287
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', true() ])[current-date() lt xs:date('2000-01-01')]"/>
@@ -305,7 +305,7 @@ exclude-result-prefixes="#all"
305305

306306
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'drag-over', false() ])[current-date() lt xs:date('2000-01-01')]"/>
307307

308-
<!-- only persist the change if the content is already saved and has an @about -->
308+
<!-- only persist the change if the block is already saved and has an @about -->
309309
<xsl:if test="$block-uri">
310310
<!-- move dropped element after this element, if they're not the same -->
311311
<xsl:if test="not($block-uri = $drop-block-uri)">
@@ -330,7 +330,7 @@ exclude-result-prefixes="#all"
330330

331331
<!-- CALLBACKS -->
332332

333-
<!-- content delete -->
333+
<!-- block delete -->
334334

335335
<xsl:template name="onBlockDelete">
336336
<xsl:context-item as="map(*)" use="required"/>
@@ -345,12 +345,12 @@ exclude-result-prefixes="#all"
345345
</xsl:for-each>
346346
</xsl:when>
347347
<xsl:otherwise>
348-
<xsl:sequence select="ixsl:call(ixsl:window(), 'alert', [ 'Could not delete content' ])[current-date() lt xs:date('2000-01-01')]"/>
348+
<xsl:sequence select="ixsl:call(ixsl:window(), 'alert', [ 'Could not delete block' ])[current-date() lt xs:date('2000-01-01')]"/>
349349
</xsl:otherwise>
350350
</xsl:choose>
351351
</xsl:template>
352352

353-
<!-- content swap (drag & drop) -->
353+
<!-- block swap (drag & drop) -->
354354

355355
<xsl:template name="onBlockSwap">
356356
<xsl:context-item as="map(*)" use="required"/>
@@ -361,7 +361,7 @@ exclude-result-prefixes="#all"
361361
<xsl:when test="?status = 204">
362362
</xsl:when>
363363
<xsl:otherwise>
364-
<xsl:sequence select="ixsl:call(ixsl:window(), 'alert', [ 'Could not swap content' ])[current-date() lt xs:date('2000-01-01')]"/>
364+
<xsl:sequence select="ixsl:call(ixsl:window(), 'alert', [ 'Could not swap block' ])[current-date() lt xs:date('2000-01-01')]"/>
365365
</xsl:otherwise>
366366
</xsl:choose>
367367
</xsl:template>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/block/object.xsl

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ exclude-result-prefixes="#all"
104104
<xsl:for-each select="?body">
105105
<xsl:variable name="resource" select="key('resources', $resource-uri)" as="element()?"/>
106106
<xsl:choose>
107-
<xsl:when test="$resource">
107+
<!-- only attempt to load object metadata for local resources -->
108+
<xsl:when test="$resource and starts-with($resource-uri, $ldt:base)">
108109
<xsl:variable name="object-uris" select="distinct-values($resource/*/@rdf:resource[not(key('resources', ., root($resource)))])" as="xs:string*"/>
109110
<xsl:variable name="query-string" select="$object-metadata-query || ' VALUES $this { ' || string-join(for $uri in $object-uris return '&lt;' || $uri || '&gt;', ' ') || ' }'" as="xs:string"/>
110111
<xsl:variable name="request" as="item()*">
@@ -121,6 +122,28 @@ exclude-result-prefixes="#all"
121122
</xsl:variable>
122123
<xsl:sequence select="$request[current-date() lt xs:date('2000-01-01')]"/>
123124
</xsl:when>
125+
<xsl:when test="$resource">
126+
<xsl:variable name="row" as="node()*">
127+
<xsl:apply-templates select="$resource" mode="bs2:Row">
128+
<xsl:with-param name="graph" select="$graph" tunnel="yes"/>
129+
<xsl:with-param name="mode" select="$mode"/>
130+
<xsl:with-param name="show-edit-button" select="$show-edit-button" tunnel="yes"/>
131+
<xsl:with-param name="show-row-block-controls" select="false()"/> <!-- blocks nested within ldh:Object do not show their own progress bars -->
132+
<xsl:with-param name="draggable" select="false()"/> <!-- blocks nested within ldh:Object are not draggable -->
133+
</xsl:apply-templates>
134+
</xsl:variable>
135+
136+
<xsl:for-each select="$container">
137+
<xsl:result-document href="?." method="ixsl:replace-content">
138+
<!-- wrap the row -->
139+
<div class="span12">
140+
<xsl:copy-of select="$row"/>
141+
</div>
142+
</xsl:result-document>
143+
144+
<xsl:apply-templates mode="ldh:RenderRow"/> <!-- recurse down the block hierarchy -->
145+
</xsl:for-each>
146+
</xsl:when>
124147
<xsl:otherwise>
125148
<xsl:for-each select="$container">
126149
<xsl:result-document href="?." method="ixsl:replace-content">
@@ -133,14 +156,30 @@ exclude-result-prefixes="#all"
133156
</xsl:choose>
134157
</xsl:for-each>
135158
</xsl:when>
136-
<xsl:otherwise>
159+
<xsl:when test="?status = 406">
137160
<xsl:for-each select="$container">
138161
<xsl:result-document href="?." method="ixsl:replace-content">
139162
<div class="offset2 span7 main">
140163
<object data="{$resource-uri}"/>
141164
</div>
142165
</xsl:result-document>
143166

167+
<!-- hide the progress bar -->
168+
<xsl:for-each select="ancestor::div[contains-token(@class, 'span12')][contains-token(@class, 'progress')][contains-token(@class, 'active')]">
169+
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress', false() ])[current-date() lt xs:date('2000-01-01')]"/>
170+
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress-striped', false() ])[current-date() lt xs:date('2000-01-01')]"/>
171+
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'active', false() ])[current-date() lt xs:date('2000-01-01')]"/>
172+
</xsl:for-each>
173+
</xsl:for-each>
174+
</xsl:when>
175+
<xsl:otherwise>
176+
<xsl:for-each select="$container">
177+
<xsl:result-document href="?." method="ixsl:replace-content">
178+
<div class="alert alert-block">
179+
<strong>Could not load resource: <a href="{$resource-uri}"><xsl:value-of select="$resource-uri"/></a></strong>
180+
</div>
181+
</xsl:result-document>
182+
144183
<!-- hide the progress bar -->
145184
<xsl:for-each select="ancestor::div[contains-token(@class, 'span12')][contains-token(@class, 'progress')][contains-token(@class, 'active')]">
146185
<xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress', false() ])[current-date() lt xs:date('2000-01-01')]"/>

0 commit comments

Comments
 (0)