source: gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes-and-performers/transform/pages/document.xsl@ 37126

Last change on this file since 37126 was 37126, checked in by davidb, 16 months ago

Changes related to merging the performers collection config settings into the programme one

File size: 15.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 <xsl:variable name="httpDocument">
13 <xsl:value-of select="$library_name"/>
14 <xsl:text>/collection/</xsl:text>
15 <xsl:value-of select="/page/pageResponse/collection/@name"/>
16 <xsl:text>/document/</xsl:text>
17 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 'd']/@value"/> <!-- or use $docID from default/transform/pages/document.xsl ???? -->
18 </xsl:variable>
19
20
21 <xsl:template name="iiif-links">
22 <xsl:param name="identifier"/>
23
24 <gsf:variable name="iiifImageRootIdentifier">
25 <xsl:text>/gs-cantaloupe/iiif/2/</xsl:text><xsl:value-of select="$site_name"/>:<xsl:value-of select="$collNameChecked"/>:<xsl:value-of select="$identifier"/>
26 </gsf:variable>
27
28 <!--
29 <gsf:variable name="iiifPresentationRootIdentifier"><xsl:value-of select="$docID"/></gsf:variable>
30 -->
31
32 <gsf:variable name="iiifPresentationRootIdentifier">http-greenstone://<xsl:value-of select="$site_name"/>/<xsl:value-of select="$collNameChecked"/>/<xsl:value-of select="$docID"/></gsf:variable>
33
34 <gsf:script>
35 var chosen_title = "untitled";
36
37 if (gs.variables.chosenTitle &amp;&amp; !gs.variables.docNodeID) {
38 // simple doc
39 chosen_title = gs.variables.chosenTitle;
40 }
41 else {
42 var docNodeID = gs.variables.docNodeID;
43 var page_pos = docNodeID.indexOf('.');
44 chosen_title = (page_pos>=0) ? "page " + docNodeID.substring(page_pos+1) : docNodeID;
45 }
46
47 var iiif_doc_image = {
48 "id": document.location.origin + gs.variables.iiifImageRootIdentifier,
49 //"format": mime_type, // ???? or is it OK to always have this as image/jpeg and rely on IIIF Image Server coverting as/when needed???
50 //"chosen_title": gs.variables.chosenTitle,
51 "chosen_title": chosen_title,
52 "x_dim": gs.variables.imageWidth,
53 "y_dim": gs.variables.imageHeight,
54 };
55
56 IIIF_Doc_Images.push(iiif_doc_image);
57
58 </gsf:script>
59
60 </xsl:template>
61
62
63 <xsl:template name="opt-googlevision-ocr-json">
64 <xsl:param name="assocfilepath"/>
65
66 <gsf:variable name="GVDocumentOCRJSON"><gsf:metadata name="GVDocumentOCRJSON"/></gsf:variable>
67 <gsf:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')"/></gsf:variable>
68
69 <gsf:switch>
70 <gsf:metadata name="HasGoogleVisionDocumentOCRJSON"/>
71 <gsf:when test='equals' test-value="1">
72
73 <gsf:script>
74 // Load in the Google Vision OCR JSON file and display bounding boxes for this document (docType=simple) or page (docType=paged)
75 load_gv_dococr_json(gs.variables.GVDocumentOCRJSON,gs.variables.docSectionID,display_gv_ocr_bounding_boxes);
76 </gsf:script>
77 </gsf:when>
78 </gsf:switch>
79
80 </xsl:template>
81
82
83 <xsl:template name="wrappedSectionPost">
84
85 <!-- add in IIIF Server link for section image -->
86 <xsl:variable name="nodeID" select="@nodeID"/>
87 <xsl:call-template name="iiif-links">
88 <xsl:with-param name="identifier" select="$nodeID" />
89 </xsl:call-template>
90
91 <!-- add in Google Vision OCR JSON link for section image -->
92 <xsl:call-template name="opt-googlevision-ocr-json">
93 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" select="root"/></xsl:with-param>
94 </xsl:call-template>
95
96 </xsl:template>
97
98 <xsl:template name="sectionImage">
99 <xsl:if test="$bookswitch != 'mirador'">
100 <gsf:image type="screen"/>
101 </xsl:if>
102 </xsl:template>
103
104 <xsl:template name="sectionContent">
105
106 <xsl:choose>
107 <xsl:when test="$bookswitch = 'mirador'">
108 <gsf:variable name="screenImageWidth"><gsf:metadata name="ScreenWidth"/></gsf:variable>
109 <gsf:variable name="screenImageHeight"><gsf:metadata name="ScreenHeight"/></gsf:variable>
110 <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>
111 <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>
112 <gsf:variable name="docNodeID"><xsl:value-of select="@nodeID"/></gsf:variable> <!-- used to make each 'tidyDiv' unique -->
113 </xsl:when>
114
115 <xsl:otherwise>
116 <xsl:call-template name="wrappedSectionImage"/>
117
118 <div style="padding: 10px 0px 10px 0px">Ocr'd Text:</div>
119 <i>
120 <xsl:call-template name="wrappedSectionText"/>
121 </i>
122 </xsl:otherwise>
123 </xsl:choose>
124
125 <xsl:call-template name="wrappedSectionPost"/>
126 </xsl:template>
127
128 <xsl:template name="sectionContentForEditing">
129 <xsl:call-template name="wrappedSectionImage"/>
130 <xsl:call-template name="wrappedSectionTextForEditing"/>
131 </xsl:template>
132
133 <xsl:template name="documentHeadingOLD">
134 <xsl:if test="$bookswitch != 'mirador'">
135 <span style="font-weight:bold; font-size: 120%;">
136 <xsl:call-template name="choose-title"/>
137 </span>
138 </xsl:if>
139
140 <gsf:metadata-table>
141 <gsf:metadata name="ex.im.No">Catalogue No:</gsf:metadata>
142 <gsf:metadata name="ex.im.Work">Work:</gsf:metadata>
143 <gsf:metadata name="ex.im.Artist">Artist(s):</gsf:metadata>
144 <gsf:metadata name="ex.im.Venue">Venue:</gsf:metadata>
145 <gsf:metadata name="ex.im.Composer">Composer:</gsf:metadata>
146 </gsf:metadata-table>
147
148 </xsl:template>
149
150
151 <xsl:template name="documentPre">
152 <xsl:variable name="httpCollection">library/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:variable>
153
154 <gsf:variable name="optionIncludeFileAssocOpenAnnotations">
155 <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeFileAssocOpenAnnotations']/@value"/>
156 </gsf:variable>
157 <gsf:variable name="optionIncludeEditableOpenAnnotations">
158 <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@value"/>
159 </gsf:variable>
160 <gsf:variable name="optionIncludeEditableOpenAnnotationsEndpointURL">
161 <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@endpointURL"/>
162 </gsf:variable>
163
164
165 <gsf:variable name="chosenTitle"><xsl:call-template name="choose-title"/></gsf:variable>
166 <!-- <gsf:variable name="toplevelTitle"><gsf:metadata name="Title" select="root"/></gsf:variable> -->
167 <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>
168 <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>
169
170 <gsf:script>
171 console.log("**** chosenTitle = " + gs.variables.chosenTitle);
172 </gsf:script>
173
174 <!--
175 <gsf:script src="{$httpCollection}/js/document_viewer.js"/>
176 -->
177
178 <gsf:script src="ext/structured-image/js/document_extra.js"/>
179 <style>
180 div.ocr-boundingbox-overlay {
181 position: absolute;
182 left: 0;
183 top: 0;
184 }
185
186 div.ocr-boundingbox {
187 position: absolute;
188 border: solid black 1px;
189 }
190
191 </style>
192
193 <xsl:if test="$bookswitch = 'mirador'">
194 <gsf:script src="ext/structured-image/mirador3/dist/mirador-with-annotations.js"/>
195 <!-- Mirador, by default, uses Roboto font, so load it in -->
196 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
197 </xsl:if>
198
199 <gsf:script>
200 var IIIF_Doc_Images = [];
201 </gsf:script>
202
203 </xsl:template>
204
205 <xsl:template name="documentNodeText">
206 <xsl:param name="force">0</xsl:param>
207 <xsl:variable name="im_programme"><gsf:metadata name="im.Programme" select="root"/></xsl:variable>
208 im_programme = <xsl:value-of select="$im_programme"/><br/>
209 <xsl:choose>
210 <xsl:when test="$im_programme != 'true'">
211 <gsf:switch>
212 <gsf:metadata name="ex.im.GSFriendlyProg"/>
213 <gsf:when test="exists">
214
215 <xsl:variable name="im_prognum"><gsf:metadata name="ex.im.GSFriendlyProg"/></xsl:variable>
216 <xsl:variable name="im_pagenum"><gsf:metadata name="ex.im.GSFriendlyPage"/></xsl:variable>
217 <style>
218 div.progandpage {
219 padding-top: 8px;
220 padding-bottom: 8px;
221 }
222 </style>
223 <div class="progandpage">
224 <span style="display: inline-block; width: 160px;">Greenstone Viewer:</span>
225 <a href="https://intermuse.sowemustthink.space/greenstone3/library/collection/{$collNameChecked}/document/HMS_{$im_prognum}.{$im_pagenum}">
226 Programme HMS#<xsl:value-of select="$im_prognum"/>, Page <xsl:value-of select="$im_pagenum"/>
227 </a>
228 </div>
229 <div class="progandpage">
230 <span style="display: inline-block; width: 160px;">Mirador Viewer:</span>
231 <a href="https://intermuse.sowemustthink.space/greenstone3/library/collection/{$collNameChecked}/document/HMS_{$im_prognum}?book=mirador&amp;ed=1&amp;gotoPage={$im_pagenum}">
232 Programme HMS#<xsl:value-of select="$im_prognum"/>, Page <xsl:value-of select="$im_pagenum"/>
233 </a>
234 </div>
235 </gsf:when>
236 </gsf:switch>
237
238 </xsl:when>
239 <xsl:otherwise>
240 <!-- The following is directly from default/transform/page/document.xsl -->
241 <!-- **** consider replacing with <gsf:text> ???? ... or change the name of this outer template so it can still call the default inner one -->
242
243 <!-- Hides the "This document has no text." message -->
244 <xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable>
245 <xsl:choose>
246 <xsl:when test="$force = '1' or not($noText = '1')">
247
248 <!-- Section text -->
249 <xsl:for-each select="nodeContent">
250 <xsl:call-template name="displayMarkedUpTextAndAnnotations"/>
251 </xsl:for-each>
252 </xsl:when>
253 <xsl:when test="$noText = '1' and not(metadataList/metadata[@name='ImageType'])">
254 <gsf:link type="source"><gsf:metadata name="Source"/></gsf:link>
255 </xsl:when>
256 </xsl:choose>
257 <xsl:text> </xsl:text>
258
259 </xsl:otherwise>
260 </xsl:choose>
261 </xsl:template>
262
263
264 <xsl:template name="documentContentMirador3">
265 <xsl:if test="@docType='simple'">
266 <gsf:script>$('#tocLoadingImage').hide()</gsf:script>
267 <!-- add in IIIF Server link for simple page image -->
268 <xsl:call-template name="iiif-links">
269 <xsl:with-param name="identifier" select="$docID" />
270 </xsl:call-template>
271 </xsl:if>
272 </xsl:template>
273
274 <xsl:template name="documentContent">
275 <!-- The way document.xsl tempaltes are structured, only get to here is if @docType = 'simple' -->
276 <!-- A 'paged' (or 'hierarical') document goes throgh 'wrappedContent' -->
277
278 <div id="gs-document">
279
280 <xsl:choose>
281 <xsl:when test="$bookswitch = 'mirador'">
282 <xsl:call-template name="documentPre"/>
283 <xsl:call-template name="documentContentMirador3"/>
284 <xsl:call-template name="documentPost"/>
285 <xsl:call-template name="documentPostMirador3"/>
286 </xsl:when>
287
288 <xsl:otherwise>
289 <xsl:call-template name="documentPre"/>
290 <xsl:call-template name="wrappedSectionImage"/>
291 <div id="gs-document-text">
292 <xsl:call-template name="documentNodeText"/>
293 </div>
294 <xsl:call-template name="documentPost"/>
295 </xsl:otherwise>
296
297 </xsl:choose>
298 </div>
299
300 </xsl:template>
301
302
303 <xsl:template name="documentPost">
304
305 <xsl:if test="@docType='simple'">
306 <xsl:call-template name="opt-googlevision-ocr-json">
307 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
308 </xsl:call-template>
309 </xsl:if>
310 </xsl:template>
311
312 <xsl:template name="documentPostMirador3">
313
314 <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->
315 <div style="position: relative; width: 100%; height: 800px;">
316 <div id="mirador3-viewer"><xsl:comment>filler</xsl:comment></div>
317 </div>
318
319 <!--
320 <gsf:variable name="endpointURL">
321 <xsl:choose>
322 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@value='true'">
323 <xsl:choose>
324 <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@endpointURL">
325 <xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='includeEditableOpenAnnotations']/@endpointURL"/>
326 </xsl:when>
327 <xsl:otherwise>
328 <xsl:text>localStorage</xsl:text> < ! - - default - - >
329 </xsl:otherwise>
330 </xsl:choose>
331 </xsl:when>
332 <xsl:otherwise></xsl:otherwise>
333 </xsl:choose>
334 </gsf:variable>
335 -->
336
337 <gsf:script>
338 var iiifpres_root_id = gs.variables.iiifPresentationRootIdentifier;
339 console.log(gs);
340 var iiifpres_label = (gs.variables.toplevelTitle) ? gs.variables.toplevelTitle : gs.variables.chosenTitle;
341
342 var iiif_manifest = initIIIFManifest(iiifpres_root_id,iiifpres_label, IIIF_Doc_Images);
343
344 var mirador3 = createMirador3Viewer();
345 </gsf:script>
346
347 </xsl:template>
348
349 <xsl:template name="wrappedDocumentTopLevel">
350 <gsf:variable name="toplevelTitle"><xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']" /></gsf:variable>
351 <xsl:choose>
352 <xsl:when test="$bookswitch = 'mirador'">
353 <!-- <xsl:call-template name="documentPre"/> -->
354 <div style="display:none;">
355 <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
356 </div>
357 <!-- <xsl:call-template name="documentPost"/> -->
358 <xsl:call-template name="documentPostMirador3"/>
359 </xsl:when>
360 <xsl:otherwise>
361 <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
362 </xsl:otherwise>
363 </xsl:choose>
364 </xsl:template>
365
366
367 <!-- content of a simple document. Will not be used for editing mode -->
368 <xsl:template name="documentPostInProgress">
369
370
371 <!--
372 canDoEditing = <xsl:value-of select="$canDoEditing"/> <br />
373 editingTurnedOn = <xsl:value-of select="$editingTurnedOn"/>
374 -->
375
376 <!--
377
378 <xsl:choose>
379 <xsl:when test="$canDoEditing = 'true' and $editingTurnedOn = 'true'">
380
381 <xsl:when test="$canDoEditing = 'true'">
382-->
383 <gsf:script src="https://unpkg.com/mirador@latest/dist/mirador.min.js"/>
384
385
386 <!-- By default uses Roboto font. Be sure to load this or change the font -->
387 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
388 <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->
389
390 <div style="position: relative; width: 100%; height: 800px;">
391 <div id="my-mirador"> <xsl:comment>filler</xsl:comment></div>
392 </div>
393
394 <gsf:script>
395
396var mirador = Mirador.viewer({
397 "id": "my-mirador",
398 "manifests": {
399 "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json": {
400 "provider": "IntermusE"
401 }
402 },
403 "window" : { "panels" : { "annotations": true, "attribution": false } },
404 "annotations": {
405 "htmlSanitizationRuleSet": 'iiif', // See src/lib/htmlRules.js for acceptable values
406 "filteredMotivations": ['oa:commenting', 'oa:tagging', 'sc:painting', 'commenting', 'tagging'],
407 },
408 "windows": [
409 {
410 "loadedManifest": "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json",
411 "canvasIndex": 1,
412 "thumbnailNavigationPosition": 'far-bottom'
413 }
414 ]
415});
416 </gsf:script>
417
418 <!--
419 </xsl:when>
420 </xsl:choose>
421-->
422
423 </xsl:template>
424
425
426</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.