@@ -81,7 +81,7 @@ exclude-result-prefixes="#all"
8181 <ixsl : set-style name =" width" select =" '50%'" object =" ." />
8282 </xsl : for-each >
8383
84- <xsl : variable name =" child-promise " as =" item()?" >
84+ <xsl : variable name =" child-thunk " as =" function(map(*)) as item()* ?" >
8585 <xsl : apply-templates mode =" #current" />
8686 </xsl : variable >
8787
@@ -98,18 +98,59 @@ exclude-result-prefixes="#all"
9898 'mode': $mode,
9999 'show-edit-button': $show-edit-button
100100 }" />
101- <xsl : variable name =" self-promise" as =" item()" select =" ixsl:http-request($context('request')) =>
102- ixsl:then(ldh:rethread-response($context, ?)) =>
103- ixsl:then(ldh:handle-response#1) =>
104- ixsl:then(ldh:block-object-value-response#1)" />
105101
106102 <xsl : sequence select ="
107- ixsl:all-settled(
108- array{ $self-promise, $child-promise }
109- ) => ixsl:then(ldh:hide-block-progress-bar($container, ?))
103+ ldh:load-block#4(
104+ $context,
105+ ldh:object-self-thunk#1,
106+ $child-thunk,
107+ ?
108+ )
110109 " />
111110 </xsl : template >
112111
112+ <!-- this is the one thunk you hand to load-block#4 -->
113+ <xsl : function name =" ldh:object-self-thunk" as =" item()*" ixsl : updating =" yes" >
114+ <xsl : param name =" context" as =" map(*)" />
115+ <xsl : message >ldh:object-self-thunk</xsl : message >
116+ <xsl : sequence select ="
117+ ixsl:resolve($context) =>
118+ ixsl:then(ldh:object-value-thunk#1) =>
119+ ixsl:then(ldh:object-metadata-thunk#1)
120+ " />
121+ </xsl : function >
122+
123+ <!-- only the first HTTP → query‐response lives here -->
124+ <xsl : function name =" ldh:object-value-thunk" as =" item()*" ixsl : updating =" yes" >
125+ <xsl : param name =" context" as =" map(*)" />
126+ <xsl : message >ldh:object-value-thunk</xsl : message >
127+ <xsl : sequence select ="
128+ ixsl:http-request($context('request')) =>
129+ ixsl:then(ldh:rethread-response($context, ?)) =>
130+ ixsl:then(ldh:handle-response#1) =>
131+ ixsl:then(ldh:block-object-value-response#1)
132+ " />
133+ </xsl : function >
134+
135+ <xsl : function name =" ldh:object-metadata-thunk" as =" item()*" ixsl : updating =" yes" >
136+ <xsl : param name =" context" as =" map(*)" />
137+ <xsl : message >ldh:object-metadata-thunk</xsl : message >
138+ <xsl : sequence select ="
139+ ixsl:http-request($context('request')) =>
140+ ixsl:then(ldh:rethread-response($context, ?)) =>
141+ ixsl:then(ldh:handle-response#1) =>
142+ ixsl:then(ldh:block-object-metadata-response#1) =>
143+ ixsl:then(ldh:block-object-apply#1) =>
144+ ixsl:then(ldh:invoke-factory#1)
145+ " />
146+ </xsl : function >
147+
148+ <xsl : function name =" ldh:invoke-factory" as =" item()*" ixsl : updating =" yes" >
149+ <xsl : param name =" factory" as =" function(item()?) as item()*?" />
150+ <xsl : message >ldh:invoke-factory</xsl : message >
151+ <xsl : sequence select =" $factory(())" />
152+ </xsl : function >
153+
113154 <xsl : function name =" ldh:block-object-value-response" as =" item()" ixsl : updating =" yes" >
114155 <xsl : param name =" context" as =" map(*)" />
115156 <xsl : variable name =" response" select =" $context('response')" as =" map(*)" />
@@ -127,7 +168,7 @@ exclude-result-prefixes="#all"
127168 <xsl : when test =" ?status = 200 and ?media-type = 'application/rdf+xml'" >
128169 <xsl : for-each select =" $block//div[contains-token(@class, 'bar')]" >
129170 <!-- update progress bar -->
130- <ixsl : set-style name =" width" select =" '88 %'" object =" ." />
171+ <ixsl : set-style name =" width" select =" '33 %'" object =" ." />
131172 </xsl : for-each >
132173
133174 <xsl : for-each select =" ?body" >
@@ -139,7 +180,7 @@ exclude-result-prefixes="#all"
139180 <xsl : variable name =" object-uris" select =" distinct-values($resource/*/@rdf:resource[starts-with(., $ldt:base)][not(key('resources', ., root($resource)))])" as =" xs:string*" />
140181 <xsl : variable name =" query-string" select =" $object-metadata-query || ' VALUES $this { ' || string-join(for $uri in $object-uris return '< ' || $uri || '> ', ' ') || ' }'" as =" xs:string" />
141182 <xsl : variable name =" request" select =" map{ 'method': 'POST', 'href': sd:endpoint(), 'media-type': 'application/sparql-query', 'body': $query-string, 'headers': map{ 'Accept': 'application/rdf+xml' } }" as =" map(*)" />
142- <xsl : variable name = " context " as = " map(*) " select ="
183+ <xsl : sequence select ="
143184 map{
144185 'request': $request,
145186 'block': $block,
@@ -149,23 +190,6 @@ exclude-result-prefixes="#all"
149190 'mode': $mode,
150191 'show-edit-button': $show-edit-button
151192 }" />
152- <!--
153- <ixsl:promise select="
154- ixsl:http-request($context('request')) =>
155- ixsl:then(ldh:rethread-response($context, ?)) =>
156- ixsl:then(ldh:handle-response#1) =>
157- ixsl:then(ldh:block-object-metadata-response#1) =>
158- ixsl:then(ldh:block-object-apply#1)
159- "
160- on-failure="ldh:promise-failure#1"/>
161- -->
162- <xsl : sequence select ="
163- ixsl:http-request($context('request')) =>
164- ixsl:then(ldh:rethread-response($context, ?)) =>
165- ixsl:then(ldh:handle-response#1) =>
166- ixsl:then(ldh:block-object-metadata-response#1) =>
167- ixsl:then(ldh:block-object-apply#1)
168- " />
169193 </xsl : when >
170194 <xsl : otherwise >
171195 <xsl : for-each select =" $container" >
@@ -188,11 +212,11 @@ exclude-result-prefixes="#all"
188212 </xsl : result-document >
189213
190214 <!-- hide the progress bar -->
191- <xsl : for-each select =" ancestor::div[contains-token(@class, 'span12')][contains-token(@class, 'progress')][contains-token(@class, 'active')]" >
215+ <!-- <xsl:for-each select="ancestor::div[contains-token(@class, 'span12')][contains-token(@class, 'progress')][contains-token(@class, 'active')]">
192216 <xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress', false() ])[current-date() lt xs:date('2000-01-01')]"/>
193217 <xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress-striped', false() ])[current-date() lt xs:date('2000-01-01')]"/>
194218 <xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'active', false() ])[current-date() lt xs:date('2000-01-01')]"/>
195- </xsl : for-each >
219+ </xsl:for-each>-->
196220 </xsl : for-each >
197221 </xsl : when >
198222 <xsl : otherwise >
@@ -204,17 +228,17 @@ exclude-result-prefixes="#all"
204228 </xsl : result-document >
205229
206230 <!-- hide the progress bar -->
207- <xsl : for-each select =" ancestor::div[contains-token(@class, 'span12')][contains-token(@class, 'progress')][contains-token(@class, 'active')]" >
231+ <!-- <xsl:for-each select="ancestor::div[contains-token(@class, 'span12')][contains-token(@class, 'progress')][contains-token(@class, 'active')]">
208232 <xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress', false() ])[current-date() lt xs:date('2000-01-01')]"/>
209233 <xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress-striped', false() ])[current-date() lt xs:date('2000-01-01')]"/>
210234 <xsl:sequence select="ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'active', false() ])[current-date() lt xs:date('2000-01-01')]"/>
211- </xsl : for-each >
235+ </xsl:for-each> -->
212236 </xsl : for-each >
237+
238+ <xsl : sequence select =" $context" />
213239 </xsl : otherwise >
214240 </xsl : choose >
215- </xsl : for-each >
216-
217- <xsl : sequence select =" $context" />
241+ </xsl : for-each >
218242 </xsl : function >
219243
220244 <!-- replaces the block with a row -->
@@ -229,11 +253,20 @@ exclude-result-prefixes="#all"
229253 <xsl : variable name =" mode" select =" $context('mode')" as =" xs:anyURI?" />
230254 <xsl : variable name =" show-edit-button" select =" $context('show-edit-button')" as =" xs:boolean?" />
231255
256+ <xsl : message >ldh:block-object-metadata-response</xsl : message >
257+
258+ <xsl : for-each select =" $block//div[contains-token(@class, 'bar')]" >
259+ <!-- update progress bar -->
260+ <ixsl : set-style name =" width" select =" '45%'" object =" ." />
261+ </xsl : for-each >
262+
232263 <xsl : for-each select =" $response" >
233264 <xsl : choose >
234265 <xsl : when test =" ?status = 200 and ?media-type = 'application/rdf+xml'" >
235266 <xsl : variable name =" object-metadata" select =" ?body" as =" document-node()" />
236267
268+ <xsl : message >ldh:block-object-metadata-response 200</xsl : message >
269+
237270 <xsl : variable name =" row" as =" node()*" >
238271 <xsl : apply-templates select =" $resource" mode =" bs2:Row" >
239272 <xsl : with-param name =" graph" select =" $graph" tunnel =" yes" />
@@ -256,54 +289,23 @@ exclude-result-prefixes="#all"
256289 </xsl : for-each >
257290
258291 <xsl : sequence select =" map:put($context, 'obj-value-id', $obj-value-id)" />
259-
260- <!-- <xsl:apply-templates mode="ldh:RenderRow"/> --> <!-- recurse down the block hierarchy -->
261-
262- <!-- <xsl:variable name="promises" as="item()*">
263- <xsl:apply-templates mode="ldh:RenderRow"/> recurse down the block hierarchy
264- </xsl:variable>
265- <xsl:variable name="promise-array" select="array{ $promises }" as="array(item())"/>
266-
267- <xsl:message>
268- $promise-array: <xsl:value-of select="serialize($promise-array, map{ 'method': 'adaptive' })"/>
269- array:size($promise-array): <xsl:value-of select="array:size($promise-array)"/>
270- </xsl:message>
271- <xsl:message>generate-id($container): <xsl:value-of select="generate-id($container)"/></xsl:message>
272-
273- cannot hide the progress bar here as the blocks might continue loading
274-
275- <ixsl:promise select="ixsl:all-settled($promise-array)
276- => ixsl:then(ldh:hide-block-progress-bar($container, ?))"/>-->
277292 </xsl : when >
278293 <xsl : otherwise >
279294 <xsl : value-of select =" ixsl:call(ixsl:window(), 'alert', [ ?message ])[current-date() lt xs:date('2000-01-01')]" />
295+
296+ <xsl : sequence select =" $context" />
280297 </xsl : otherwise >
281298 </xsl : choose >
282- </xsl : for-each >
283-
284- <xsl : sequence select =" $context" />
299+ </xsl : for-each >
285300 </xsl : function >
286301
287302 <xsl : function name =" ldh:block-object-apply" as =" item()" ixsl : updating =" yes" >
288303 <xsl : param name =" context" as =" map(*)" />
289304 <xsl : variable name =" obj-value-id" select =" $context('obj-value-id')" as =" xs:string" />
290305
291- <xsl : for-each select =" id($obj-value-id, ixsl:page())" >
292- <xsl : apply-templates mode =" ldh:RenderRow" />
293- </xsl : for-each >
294- </xsl : function >
295-
296- <xsl : function name =" ldh:hide-block-progress-bar" ixsl : updating =" yes" >
297- <xsl : param name =" container" as =" element()" />
298- <xsl : param name =" results" as =" array(*)" />
299- <xsl : message >ldh:hide-block-progress-bar</xsl : message >
306+ <xsl : message >ldh:block-object-apply $obj-value-id: <xsl : value-of select =" $obj-value-id" /></xsl : message >
300307
301- <!-- hide the progress bar -->
302- <xsl : for-each select =" $container/ancestor::div[contains-token(@class, 'span12')][contains-token(@class, 'progress')][contains-token(@class, 'active')]" >
303- <xsl : sequence select =" ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress', false() ])[current-date() lt xs:date('2000-01-01')]" />
304- <xsl : sequence select =" ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'progress-striped', false() ])[current-date() lt xs:date('2000-01-01')]" />
305- <xsl : sequence select =" ixsl:call(ixsl:get(., 'classList'), 'toggle', [ 'active', false() ])[current-date() lt xs:date('2000-01-01')]" />
306- </xsl : for-each >
308+ <xsl : apply-templates select =" id($obj-value-id, ixsl:page())" mode =" ldh:RenderRow" />
307309 </xsl : function >
308310
309311</xsl : stylesheet >
0 commit comments