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

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

xsl-template for documentHeading moved to document.xsl to remove complication of it useing bookswitch. Having the template in collectionConfig.xml means that even document-iiif-manifest.xsl needs to know about the xsl-variable

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