source: gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/transform/pages/document-iiif-manifest.xsl@ 37082

Last change on this file since 37082 was 37082, checked in by davidb, 18 months ago

A very rough-cut XSL to generate an IIIF-Manifest compliant JSON file. Needs the interfaceConfig.xml file to be updated with document-iiif-manifest.xsl as a 'sa' argument; also currently relies on a common section of document.xsl to be carved out as document-core.xsl so it can also be used in document-iiiif-manifest.xsl (as inheritance/xsl-import was not the appropriate route to do this)

File size: 26.6 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util gsf">
10
11
12 <!-- Inherit from document, but modified to drastically cut things down to what is needed:
13 (i) focus on just the (potientailly hierachically nested) pages
14 (ii) so a bit like ed=1, but implied rather than needing to be set
15
16 Key goal: generate a IIIF v2 compliant manifest file in JSON format based on the document
17 -->
18
19 <!--
20 <xsl:import href="pages/document.xsl"/>
21 -->
22
23 <xsl:include href="layouts/header-core.xsl"/>
24
25 <xsl:include href="pages/document-shared.xsl" />
26 <xsl:include href="pages/document-core.xsl" />
27
28 <xsl:output method="html" version="1.0" encoding="utf-8"/>
29
30 <!--
31 <xsl:output method="text" version="1.0" encoding="utf-8" omit-xml-declaration="yes"/>
32 <xsl:strip-space elements="*"/>
33 -->
34
35 <!-- If the c parameter is empty then use the p.c parameter for the collection name-->
36 <xsl:variable name="collNameChecked">
37 <xsl:choose>
38 <xsl:when test="$collName = '' and /page/pageRequest/paramList/param[@name='p.c']/@value">
39 <xsl:value-of select="/page/pageRequest/paramList/param[@name='p.c']/@value"/>
40 </xsl:when>
41 <xsl:otherwise>
42 <xsl:value-of select="$collName"/>
43 </xsl:otherwise>
44 </xsl:choose>
45 </xsl:variable>
46
47
48 <xsl:variable name="httpDocument">
49 <xsl:value-of select="$library_name"/>
50 <xsl:text>/collection/</xsl:text>
51 <xsl:value-of select="/page/pageResponse/collection/@name"/>
52 <xsl:text>/document/</xsl:text>
53 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 'd']/@value"/> <!-- or use $docID from default/transform/pages/document.xsl ???? -->
54 </xsl:variable>
55
56 <xsl:variable name="iiifPresentationRootIdentifier">http-greenstone://<xsl:value-of select="$site_name"/>/<xsl:value-of select="$collNameChecked"/>/<xsl:value-of select="$docID"/></xsl:variable>
57
58 <xsl:variable name="bookswitch">mirador</xsl:variable>
59
60 <xsl:template match="/">
61 <html>
62 <body>
63 <xsl:apply-templates select="/page/pageResponse/document" />
64 </body>
65 </html>
66
67 </xsl:template>
68
69
70 <xsl:template name="iiif-other-content">
71 <xsl:param name="optSection"/>
72
73 <xsl:variable name="baseURL">https:<xsl:value-of select="/page/pageRequest/@baseURL"/></xsl:variable> <!-- **** had to hardwire https: -->
74 <!-- **** test for a gsf-option before include !!!! -->
75 "otherContent": [{
76 "@id": "<xsl:value-of select="$baseURL"/><xsl:value-of select="$library_name"/>/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="$collNameChecked"/>/index/assoc/<gsf:metadata name="assocfilepath" select="root"/>/openannotation-list<xsl:value-of select="$optSection"/>.json",
77 "@type": "sc:AnnotationList"
78 }],
79 </xsl:template>
80
81
82 <xsl:template name="iiif-links">
83 <xsl:param name="identifier"/>
84 <xsl:param name="docType"/>
85
86 <xsl:variable name="iiifImageRootIdentifier">
87 <xsl:text>/gs-cantaloupe/iiif/2/</xsl:text><xsl:value-of select="$site_name"/>:<xsl:value-of select="$collNameChecked"/>:<xsl:value-of select="$identifier"/>
88 </xsl:variable>
89
90
91 <!--
92 var chosen_title = "untitled";
93
94 if (gs.variables.chosenTitle &amp;&amp; !gs.variables.docNodeID) {
95 // simple doc
96 chosen_title = gs.variables.chosenTitle;
97 }
98 else {
99 var docNodeID = gs.variables.docNodeID;
100 var page_pos = docNodeID.indexOf('.');
101 chosen_title = (page_pos>=0) ? "page " + docNodeID.substring(page_pos+1) : docNodeID;
102 }
103
104 -->
105
106
107
108 <!-- page/pageRequest[@baseURL]="//intermuse.sowemustthink.space/greenstone3/ -->
109 <!-- page/pageRequest[@fullURL]="//intermuse.sowemustthink.space/greenstone3/library?a=d.... -->
110
111 <!-- ***** need to work out from raw XML message, say processing something from the above -->
112
113 <xsl:variable name="document-location-origin">https://intermuse.sowemustthink.space</xsl:variable>
114
115 <xsl:variable name="section"><xsl:value-of select="position()" /></xsl:variable>
116 <xsl:variable name="optSection">
117 <xsl:choose>
118 <xsl:when test="$docType = 'simple'"></xsl:when><!-- i.e. empty -->
119 <xsl:otherwise><xsl:value-of select="position()" /></xsl:otherwise>
120 </xsl:choose>
121 </xsl:variable>
122
123
124 <xsl:variable name="chosenTitle">
125 <xsl:choose>
126 <xsl:when test="$docType = 'simple'">
127 <xsl:call-template name="choose-title"/>
128 </xsl:when>
129 <xsl:otherwise>page <xsl:value-of select="$section"/></xsl:otherwise>
130 </xsl:choose>
131 </xsl:variable>
132
133 <!--
134 docType = <xsl:value-of select="$docType"/>
135 docID = <xsl:value-of select="$docID"/>
136 position = <xsl:value-of select="position()" />
137
138 identifer = <xsl:value-of select="$identifier"/>
139 section = <xsl:value-of select="$section"/>
140 optSection = <xsl:value-of select="$optSection"/>
141
142 iiifPresRootIdentifier = <xsl:value-of select="$iiifPresentationRootIdentifier" />
143 iiifImageRootIdentifier = <xsl:value-of select="$iiifImageRootIdentifier" />
144 -->
145 <!-- an array entry in 'canvases': { @content, @id, @type, label, width, height, images[{}], thumbnail {@id,@type} } -->
146 <pre>
147 <xsl:if test="$section &gt; 1">
148 ,
149 </xsl:if>
150 {
151 "@context": "http://iiif.io/api/presentation/2/context.json",
152 "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier" />/canvas/<xsl:value-of select="$section"/>",
153 "@type": "sc:Canvas",
154 "label": "<xsl:value-of select="$chosenTitle"/>",
155 <xsl:call-template name="iiif-other-content">
156 <xsl:with-param name="optSection"><xsl:value-of select="$optSection"/></xsl:with-param>
157 </xsl:call-template>
158 &quot;width&quot;: <gsf:metadata name="ImageWidth"/>,
159 &quot;height&quot;: <gsf:metadata name="ImageHeight"/>,
160
161 "images": [{
162 "image": {
163 "@context": "http://iiif.io/api/image/2/context.json",
164 "@type": "oa:Annotation",
165 "motivation": "sc:painting",
166 "on": "<xsl:value-of select="$iiifPresentationRootIdentifier" />/annotation/<xsl:value-of select="$section"/>",
167
168 "resource": {
169 "@id": "<xsl:value-of select="$document-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/full/0/default.jpg",
170 "@type": "dctypes:Image",
171 "format": "image/jpeg",
172 "width": <gsf:metadata name="ImageWidth"/>,
173 "hieght": <gsf:metadata name="ImageHeight"/>,
174 "service": {
175 "@context": "http://iiif.io/api/image/2/context.json",
176 "@id": "<xsl:value-of select="$document-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />",
177 "profile": "https://iiif.io/api/image/2/profiles/level2.json"
178 }
179 }
180 }
181 }],
182 "thumbnail": {
183 "@id": "<xsl:value-of select="$document-location-origin" /><xsl:value-of select="$iiifImageRootIdentifier" />/full/,150/0/default.jpg",
184 "@type": "dctypes:Image"
185 }
186 }
187 </pre>
188 <!-- Another field to consider in the above JSON is: -->
189 <!-- "format": mime_type, // ???? or is it OK to always have this as image/jpeg and rely on IIIF Image Server coverting as/when needed??? -->
190 </xsl:template>
191
192
193 <xsl:template name="googlevision-ocr-jsonOLD">
194 <xsl:param name="assocfilepath"/>
195
196 <xsl:variable name="GVDocumentOCRJSON"><gsf:metadata name="GVDocumentOCRJSON"/></xsl:variable>
197 <xsl:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')"/></xsl:variable>
198<!--
199 <gsf:variable name="GVDocumentOCRJSON"><gsf:metadata name="GVDocumentOCRJSON"/></gsf:variable>
200 <gsf:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')"/></gsf:variable>
201-->
202
203<!--
204 <gsf:script>
205 load_gv_dococr_json(gs.variables.GVDocumentOCRJSON,gs.variables.docSectionID,display_gv_ocr_bounding_boxes);
206 </gsf:script>
207-->
208
209 </xsl:template>
210
211
212 <xsl:template name="wrappedSectionPost">
213
214 <!-- add in IIIF Server link for section image -->
215 <xsl:variable name="nodeID" select="@nodeID"/>
216 <xsl:call-template name="iiif-links">
217 <xsl:with-param name="identifier" select="$nodeID" />
218 <xsl:with-param name="docType" select="@docType" />
219 </xsl:call-template>
220
221 <!-- add in Google Vision OCR JSON link for section image -->
222 <!--
223 <xsl:call-template name="googlevision-ocr-json">
224 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" select="root"/></xsl:with-param>
225 </xsl:call-template>
226 -->
227
228 </xsl:template>
229
230 <xsl:template name="sectionImage">
231 <!-- OBSOLETE when removing forced bookswith = mirador -->
232 <!-- make it do nothing !! -->
233 <xsl:if test="$bookswitch != 'mirador'">
234 <gsf:image type="screen"/>
235 </xsl:if>
236 </xsl:template>
237
238 <xsl:template name="sectionContent">
239 <xsl:call-template name="wrappedSectionPost"/>
240 </xsl:template>
241
242 <xsl:template name="sectionContentOLD">
243
244 <xsl:choose>
245 <xsl:when test="$bookswitch = 'mirador'">
246 <gsf:variable name="screenImageWidth"><gsf:metadata name="ScreenWidth"/></gsf:variable>
247 <gsf:variable name="screenImageHeight"><gsf:metadata name="ScreenHeight"/></gsf:variable>
248 <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>
249 <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>
250 <gsf:variable name="docNodeID"><xsl:value-of select="@nodeID"/></gsf:variable> <!-- used to make each 'tidyDiv' unique -->
251 </xsl:when>
252
253 <!-- OBSOLETE when removing forced bookswith = mirador -->
254 <xsl:otherwise>
255 <xsl:call-template name="wrappedSectionImage"/>
256
257 <div style="padding: 10px 0px 10px 0px">Ocr'd Text:</div>
258 <i>
259 <xsl:call-template name="wrappedSectionText"/>
260 </i>
261 </xsl:otherwise>
262 </xsl:choose>
263
264 <xsl:call-template name="wrappedSectionPost"/>
265 </xsl:template>
266
267 <xsl:template name="documentPre">
268 <xsl:variable name="httpCollection">library/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:variable>
269
270 <xsl:variable name="chosenTitle">
271 <xsl:choose>
272 <xsl:when test="@docType='simple'">
273 <xsl:call-template name="choose-title"/>
274 </xsl:when>
275 <xsl:otherwise>
276 <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']" />
277 </xsl:otherwise>
278 </xsl:choose>
279 </xsl:variable>
280
281 <!-- <gsf:variable name="chosenTitle"><xsl:call-template name="choose-title"/></gsf:variable> -->
282 <!-- <gsf:variable name="toplevelTitle"><gsf:metadata name="Title" select="root"/></gsf:variable> -->
283 <!-- <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable> -->
284 <!-- <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable> -->
285
286
287 <!-- iiif_manifest: -->
288 <pre>
289 {
290 "@context": "http://iiif.io/api/presentation/2/context.json",
291 "@type": "sc:Manifest",
292 "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/manifest",
293 "label": "<xsl:value-of select="$chosenTitle"/>",
294 "attribution": "The Internet of Musical Events (InterMusE): Digital Scholarship, Community, and the Archiving of Performance",
295 "license": "https://**** To Be Determined ****",
296 "logo": "https://intermuse.datatodata.org/wp-content/uploads/sites/4/2021/03/cropped-cropped-cropped-1.png",
297 "metadata": [
298 { "label": "creator", "value": ["aaa1","aaa2"] },
299 { "label": "title", "value": ["chosen-title"] }
300 ],
301 <!-- trival IIIF sequences => has one IIIF canvas in it -->
302 "sequences": [{
303 "@context": "http://iiif.io/api/image/2/context.json",
304 "@id": "<xsl:value-of select="$iiifPresentationRootIdentifier"/>/sequence/normal",
305 "@type": "sc:Sequence",
306 "canvases": [
307 </pre>
308
309 <!--
310 <gsf:script>
311 console.log("**** sa=iiif-manifest: chosenTitle = " + gs.variables.chosenTitle);
312 </gsf:script>
313 <gsf:script src="{$httpCollection}/js/document_viewer.js"/>
314 <style>
315 div.ocr-boundingbox-overlay {
316 position: absolute;
317 left: 0;
318 top: 0;
319 }
320
321 div.ocr-boundingbox {
322 position: absolute;
323 border: solid black 1px;
324 }
325
326 </style>
327 -->
328
329 <!-- OBSOLETE when removing forced bookswith = mirador -->
330 <!-- the following is not needed, if only generating the required JSON IIIF Manifest file -->
331 <!--
332 <xsl:if test="$bookswitch = 'mirador'">
333 <gsf:script src="ext/structured-image/mirador3/dist/mirador-with-annotations.js"/>
334 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
335 </xsl:if>
336 -->
337
338 <!--
339 <gsf:script>
340 var IIIF_Doc_Images = [];
341 </gsf:script>
342 -->
343 </xsl:template>
344
345
346 <!--
347{
348 "@context": "http://iiif.io/api/presentation/2/context.json",
349 "@id": "http-greenstone://intermuse/programmes/HMS_1/canvas/1",
350 "@type": "sc:Canvas",
351 "width": "3670",
352 "height": "4641",
353 "label": "page 1",
354 "images": [
355 {
356 "@context": "http://iiif.io/api/image/2/context.json",
357 "@id": "http-greenstone://intermuse/programmes/HMS_1/annotation/1",
358 "@type": "oa:Annotation",
359 "motivation": "sc:painting",
360 "on": "http-greenstone://intermuse/programmes/HMS_1/canvas",
361 "resource": {
362 "@id": "https://intermuse.sowemustthink.space/gs-cantaloupe/iiif/2/intermuse:programmes:HMS_1.1/full/full/0/default.jpg",
363 "@type": "dctypes:Image",
364 "format": "image/jpeg",
365 "width": "3670",
366 "height": "4641",
367 "service": {
368 "@context": "http://iiif.io/api/image/2/context.json",
369 "@id": "https://intermuse.sowemustthink.space/gs-cantaloupe/iiif/2/intermuse:programmes:HMS_1.1",
370 "profile": "https://iiif.io/api/image/2/profiles/level2.json"
371 }
372 }
373 }
374 ],
375 "thumbnail": {
376 "@id": "https://intermuse.sowemustthink.space/gs-cantaloupe/iiif/2/intermuse:programmes:HMS_1.1/full/,150/0/default.jpg",
377 "@type": "dctypes:Image"
378 }
379}
380 -->
381
382 <xsl:template name="documentContentSimpleIIIFImage">
383 <xsl:call-template name="iiif-links">
384 <xsl:with-param name="identifier" select="$docID" />
385 <xsl:with-param name="docType" select="@docType" />
386 </xsl:call-template>
387 </xsl:template>
388
389 <xsl:template name="documentContent">
390 <!-- The way document.xsl templates are structured, only get to here is if @docType = 'simple' -->
391 <!-- A 'paged' (or 'hierarical') document goes throgh 'wrappedContent' -->
392 <xsl:call-template name="documentPre"/>
393 <xsl:call-template name="documentContentSimpleIIIFImage"/>
394 <xsl:call-template name="documentPost"/>
395 <xsl:call-template name="documentPostMirador3"/>
396 </xsl:template>
397
398 <xsl:template name="documentPost">
399 <!-- close of canvases -->
400 <pre>
401 ]
402 }]
403 }
404 </pre>
405
406 </xsl:template>
407
408 <xsl:template name="documentPostOLD">
409 <xsl:if test="@docType='simple'">
410 <!-- add in Google Vision OCR JSON link for simple page image -->
411 <xsl:call-template name="googlevision-ocr-jsonOLD">
412 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
413 </xsl:call-template>
414 </xsl:if>
415 </xsl:template>
416
417 <xsl:template name="documentPostMirador3">
418
419 <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->
420 <div style="position: relative; width: 100%; height: 800px;">
421 <div id="mirador3-viewer"> <xsl:comment>filler</xsl:comment></div>
422 </div>
423
424 <!--
425 <gsf:script>
426 var iiifpres_root_id = gs.variables.iiifPresentationRootIdentifier;
427 console.log(gs);
428 var iiifpres_label = (gs.variables.toplevelTitle) ? gs.variables.toplevelTitle : gs.variables.chosenTitle;
429
430 var iiif_manifest = initIIIFManifest(iiifpres_root_id,iiifpres_label, IIIF_Doc_Images);
431
432 var mirador3 = createMirador3Viewer();
433 </gsf:script>
434 -->
435
436 </xsl:template>
437
438 <xsl:template name="wrappedDocumentTopLevel">
439
440 <xsl:choose>
441 <xsl:when test="$bookswitch = 'mirador'">
442 <!-- <xsl:call-template name="documentPre"/> -->
443 <div style="display:block;"> <!-- For embedded mirador3 viewer, used to be none **** -->
444 <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
445 </div>
446 <!-- <xsl:call-template name="documentPost"/> -->
447 <xsl:call-template name="documentPostMirador3"/>
448 </xsl:when>
449
450 <!-- OBSOLETE when removing forced bookswith = mirador -->
451 <xsl:otherwise>
452 <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
453 </xsl:otherwise>
454
455 </xsl:choose>
456 </xsl:template>
457
458
459 <!-- content of a simple document. Will not be used for editing mode -->
460 <xsl:template name="documentPostInProgress">
461
462
463 <gsf:script src="https://unpkg.com/mirador@latest/dist/mirador.min.js"/>
464
465
466 <!-- By default uses Roboto font. Be sure to load this or change the font -->
467 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
468 <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->
469
470 <div style="position: relative; width: 100%; height: 800px;">
471 <div id="my-mirador"> <xsl:comment>filler</xsl:comment></div>
472 </div>
473
474 <gsf:script>
475
476var mirador = Mirador.viewer({
477 "id": "my-mirador",
478 "manifests": {
479 "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json": {
480 "provider": "IntermusE"
481 }
482 },
483 "window" : { "panels" : { "annotations": true, "attribution": false } },
484 "annotations": {
485 "htmlSanitizationRuleSet": 'iiif', // See src/lib/htmlRules.js for acceptable values
486 "filteredMotivations": ['oa:commenting', 'oa:tagging', 'sc:painting', 'commenting', 'tagging'],
487 },
488 "windows": [
489 {
490 "loadedManifest": "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json",
491 "canvasIndex": 1,
492 "thumbnailNavigationPosition": 'far-bottom'
493 }
494 ]
495});
496 </gsf:script>
497
498
499 </xsl:template>
500
501
502
503 <xsl:template name="wrapDocumentNodes">
504
505 <xsl:choose>
506 <xsl:when test="../../document">
507 <xsl:call-template name="topLevelSectionContent"/>
508 </xsl:when>
509 <xsl:otherwise>
510 <xsl:call-template name="sectionContent"/>
511 </xsl:otherwise>
512 </xsl:choose>
513
514 <xsl:if test="documentNode">
515 <xsl:for-each select="documentNode">
516 <xsl:call-template name="wrapDocumentNodes"/>
517 </xsl:for-each>
518 </xsl:if>
519 </xsl:template>
520
521 <!-- Used to make sure that regardless what the collection designer uses for the title and content we can wrap it properly -->
522 <!-- If editing, be aware that the Document Basket looks for specific classes that this template bakes in (key points marked with ***) -->
523 <xsl:template name="wrapDocumentNodesOLD">
524 <xsl:variable name="nodeID" select="@nodeID"/>
525 <a name="{@nodeID}"><xsl:text> </xsl:text></a>
526
527 <!-- Section header -->
528 <table class="sectionHeader"><tr>
529
530 <!-- Title -->
531 <td id="header{@nodeID}" class="headerTD sectionTitle"><!-- *** -->
532 <p>
533 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
534
535 <xsl:if test="util:hashToSectionId(@nodeID)">
536 <span class="sectionNumberSpan">
537 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
538 <xsl:text> </xsl:text>
539 </span>
540 </xsl:if>
541 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
542 <span><xsl:call-template name="sectionHeading"/></span>
543 </p>
544 </td>
545
546 </tr></table>
547
548 <div id="doc{@nodeID}"><!-- *** -->
549
550 <xsl:choose>
551 <xsl:when test="../../document">
552 <xsl:call-template name="topLevelSectionContent"/>
553 </xsl:when>
554 <xsl:otherwise>
555 <xsl:call-template name="sectionContent"/>
556 </xsl:otherwise>
557 </xsl:choose>
558
559 <xsl:if test="documentNode">
560 <xsl:for-each select="documentNode">
561 <xsl:call-template name="wrapDocumentNodes"/>
562 </xsl:for-each>
563 </xsl:if>
564 </div>
565 </xsl:template>
566
567
568
569
570 <xsl:template name="wrappedSectionImage">
571 <xsl:variable name="screenImageWidth"><gsf:metadata name="ScreenWidth"/></xsl:variable>
572 <xsl:variable name="screenImageHeight"><gsf:metadata name="ScreenHeight"/></xsl:variable>
573 <xsl:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></xsl:variable>
574 <xsl:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></xsl:variable>
575 <xsl:variable name="docNodeID"><xsl:value-of select="@nodeID"/></xsl:variable> <!-- used to make each 'tidyDiv' unique -->
576
577 <gsf:div id="image{@nodeID}">
578 <xsl:attribute name="style">
579 <xsl:choose>
580 <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
581 <xsl:text>display:none;</xsl:text>
582 </xsl:when>
583 <xsl:otherwise>
584 <xsl:text>display:block;</xsl:text>
585 </xsl:otherwise>
586 </xsl:choose>
587 </xsl:attribute>
588 <xsl:call-template name="sectionImage"/><xsl:text> </xsl:text>
589 </gsf:div>
590
591
592 </xsl:template>
593
594 <!-- The default template for displaying the document node text -->
595 <!-- equivalent to gsf:text -->
596 <xsl:template name="documentNodeText">
597 <xsl:param name="force">0</xsl:param>
598 <!-- Hides the "This document has no text." message -->
599 <xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable>
600 <xsl:choose>
601 <xsl:when test="$force = '1' or not($noText = '1')">
602
603 <!-- Section text -->
604 <xsl:for-each select="nodeContent">
605 <xsl:call-template name="displayMarkedUpTextAndAnnotations"/>
606 </xsl:for-each>
607 </xsl:when>
608 <xsl:when test="$noText = '1' and not(metadataList/metadata[@name='ImageType'])">
609 <gsf:link type="source"><gsf:metadata name="Source"/></gsf:link>
610 </xsl:when>
611 </xsl:choose>
612 <xsl:text> </xsl:text>
613 </xsl:template>
614
615
616
617
618
619 <xsl:template match="/page/pageResponse/document">
620 <xsl:if test="$bookswitch = 'off' or ($bookswitch != 'on' and $bookswitch != 'flashxml')">
621 <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
622
623 <div id="float-anchor" style="width: 30%; min-width:180px; float:right; margin: 0 0 10px 20px;">
624
625 <!-- add in some text just in case nothing has been added to this div-->
626 <xsl:text> </xsl:text>
627 </div>
628 </xsl:if>
629
630 <!-- display the document -->
631 <xsl:choose>
632 <xsl:when test="@docType='simple'">
633 <xsl:call-template name="documentHeading"/><br/>
634 <xsl:call-template name="documentContentTopLevel"/>
635 </xsl:when>
636 <xsl:otherwise> <!-- display the standard greenstone document -->
637 <xsl:call-template name="wrappedDocumentTopLevel"/>
638 </xsl:otherwise>
639 </xsl:choose>
640 </xsl:template>
641
642
643
644
645 <xsl:template name="wrappedDocument">
646 <xsl:choose>
647 <!-- NOTE: alb = ajax load bypass -->
648 <!--
649 If we have asked for expanded document, then do this.
650 OR If the docType is hierarchy and we want to bypass the ajax load then do this
651 OR If the docType is hierarchy and we have asked for the top level document then do this
652 -->
653 <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or (/page/pageResponse/document/@docType = 'hierarchy' and (/page/pageRequest/paramList/param[@name = 'alb']/@value = '1' or (string-length(/page/pageRequest/paramList/param[@name = 'd']/@value) > 0 and not(util:contains(/page/pageResponse/document/@selectedNode, '.')))))">
654 <div id="gs-document">
655 <xsl:call-template name="documentPre"/>
656 <div id="gs-document-text" class="documenttext" collection="{/page/pageResponse/collection/@name}"><!-- *** -->
657 <xsl:for-each select="documentNode">
658 <xsl:call-template name="wrapDocumentNodes"/>
659 </xsl:for-each>
660 </div>
661 <xsl:call-template name="documentPost"/>
662 </div>
663 </xsl:when>
664 <xsl:when test="/page/pageResponse/document/@docType = 'paged' or /page/pageResponse/document/@docType = 'pagedhierarchy'">
665 <div id="gs-document">
666 <div id="tocLoadingImage" style="text-align:center;">
667 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
668 </div>
669 </div>
670 <script type="text/javascript">
671 <xsl:text disable-output-escaping="yes">
672 $(window).on("load", function()
673 {
674 var sectionID = gs.cgiParams.d;
675 var callbackFunction = null;
676 if(sectionID.indexOf(".") != -1)
677 {
678 callbackFunction = function()
679 {
680 focusSection(sectionID);
681 };
682 }
683 else {
684 callbackFunction = function()
685 {
686
687 expandAndExecute(sectionID+".1", null, null, null);
688 };
689 }
690 var docID = sectionID.replace(/([^.]*)\..*/, "$1");
691 var url = gs.xsltParams.library_name + "?a=d&amp;c=" + gs.cgiParams.c + "&amp;excerptid=gs-document&amp;dt=hierarchy&amp;d=" + docID;
692 if(gs.cgiParams.p_s) {
693 url += "&amp;p.s="+gs.cgiParams.p_s;
694 }
695 loadTopLevelPage(callbackFunction, url);
696 });
697 </xsl:text>
698 </script>
699 </xsl:when>
700 <xsl:otherwise>
701 <div id="gs-document">
702 <div id="tocLoadingImage" style="text-align:center;">
703 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
704 </div>
705 </div>
706 <script type="text/javascript">
707 <xsl:text disable-output-escaping="yes">
708 $(window).on("load", function()
709 {
710 loadTopLevelPage(function()
711 {
712 //Don't focus the section until the table of contents is loaded
713 var tocCheck = function()
714 {
715 if(gs.variables.tocLoaded)
716 {
717 focusSection("</xsl:text><xsl:value-of select="/page/pageResponse/document/@selectedNode"/><xsl:text disable-output-escaping="yes">");
718 }
719 else
720 {
721 setTimeout(tocCheck, 500);
722 }
723 }
724 tocCheck();
725 });
726 });
727 </xsl:text>
728 </script>
729 </xsl:otherwise>
730 </xsl:choose>
731
732 <div class="clear"><xsl:text> </xsl:text></div>
733 </xsl:template>
734
735
736
737
738</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.