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

Last change on this file since 37075 was 37075, checked in by davidb, 3 months ago

Changes that sync with the introduction of the SimpleAnnotationServer Storage backend

File size: 12.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 <!--
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="documentPre">
161 <xsl:variable name="httpCollection">library/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:variable>
162 <gsf:variable name="chosenTitle"><xsl:call-template name="choose-title"/></gsf:variable>
163 <!-- <gsf:variable name="toplevelTitle"><gsf:metadata name="Title" select="root"/></gsf:variable> -->
164 <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>
165 <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>
166
167 <gsf:script>
168 console.log("**** chosenTitle = " + gs.variables.chosenTitle);
169 </gsf:script>
170 <gsf:script src="{$httpCollection}/js/document_viewer.js"/>
171 <style>
172 div.ocr-boundingbox-overlay {
173 position: absolute;
174 left: 0;
175 top: 0;
176 }
177
178 div.ocr-boundingbox {
179 position: absolute;
180 border: solid black 1px;
181 }
182
183 </style>
184
185 <xsl:if test="$bookswitch = 'mirador'">
186 <!-- <gsf:script src="https://unpkg.com/mirador@latest/dist/mirador.min.js"/> -->
187
188 <gsf:script src="ext/structured-image/mirador3/dist/mirador-with-annotations.js"/>
189
190
191 <!-- Mirador, by default, uses Roboto font, so load it in -->
192 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
193 </xsl:if>
194
195 <gsf:script>
196 var IIIF_Doc_Images = [];
197 </gsf:script>
198
199 </xsl:template>
200
201
202 <xsl:template name="documentContentMirador3">
203 <xsl:if test="@docType='simple'">
204 <gsf:script>$('#tocLoadingImage').hide()</gsf:script>
205 <!-- add in IIIF Server link for simple page image -->
206 <xsl:call-template name="iiif-links">
207 <xsl:with-param name="identifier" select="$docID" />
208 </xsl:call-template>
209 </xsl:if>
210 </xsl:template>
211
212 <xsl:template name="documentContent">
213 <!-- The way document.xsl tempaltes are structured, only get to here is if @docType = 'simple' -->
214 <!-- A 'paged' (or 'hierarical') document goes throgh 'wrappedContent' -->
215
216 <div id="gs-document">
217
218 <xsl:choose>
219 <xsl:when test="$bookswitch = 'mirador'">
220 <xsl:call-template name="documentPre"/>
221 <xsl:call-template name="documentContentMirador3"/>
222 <xsl:call-template name="documentPost"/>
223 <xsl:call-template name="documentPostMirador3"/>
224 </xsl:when>
225
226 <xsl:otherwise>
227 <xsl:call-template name="documentPre"/>
228 <xsl:call-template name="wrappedSectionImage"/>
229 <div id="gs-document-text">
230 <xsl:call-template name="documentNodeText"/>
231 </div>
232 <xsl:call-template name="documentPost"/>
233 </xsl:otherwise>
234
235 </xsl:choose>
236 </div>
237
238 </xsl:template>
239
240
241 <xsl:template name="documentPost">
242
243 <xsl:if test="@docType='simple'">
244
245 <!--
246 <gsf:switch>
247 <gsf:metadata name='HasGoogleVisionDocumentOCRJSON";'/>
248 <gsf:when test='equals' test-value="1">
249 -->
250
251 <!-- add in Google Vision OCR JSON link for simple page image -->
252 <xsl:call-template name="googlevision-ocr-json">
253 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
254 </xsl:call-template>
255 <!--
256 </gsf:when>
257 </gsf:switch>
258-->
259
260 </xsl:if>
261 </xsl:template>
262
263 <xsl:template name="documentPostMirador3">
264
265 <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->
266 <div style="position: relative; width: 100%; height: 800px;">
267 <div id="mirador3-viewer"> <xsl:comment>filler</xsl:comment></div>
268 </div>
269
270 <gsf:script>
271 var iiifpres_root_id = gs.variables.iiifPresentationRootIdentifier;
272 console.log(gs);
273 var iiifpres_label = (gs.variables.toplevelTitle) ? gs.variables.toplevelTitle : gs.variables.chosenTitle;
274
275 var iiif_manifest = initIIIFManifest(iiifpres_root_id,iiifpres_label, IIIF_Doc_Images);
276
277 var mirador3 = createMirador3Viewer();
278 </gsf:script>
279
280 </xsl:template>
281
282 <xsl:template name="wrappedDocumentTopLevel">
283 <gsf:variable name="toplevelTitle"><xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode/metadataList/metadata[@name='Title']" /></gsf:variable>
284 <xsl:choose>
285 <xsl:when test="$bookswitch = 'mirador'">
286 <!-- <xsl:call-template name="documentPre"/> -->
287 <div style="display:none;">
288 <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
289 </div>
290 <!-- <xsl:call-template name="documentPost"/> -->
291 <xsl:call-template name="documentPostMirador3"/>
292 </xsl:when>
293 <xsl:otherwise>
294 <xsl:call-template name="wrappedDocument"/> <!-- without ed=1, this template misses the binds in of documentPre and documentPost -->
295 </xsl:otherwise>
296 </xsl:choose>
297 </xsl:template>
298
299
300 <!-- content of a simple document. Will not be used for editing mode -->
301 <xsl:template name="documentPostInProgress">
302
303
304 <!--
305 canDoEditing = <xsl:value-of select="$canDoEditing"/> <br />
306 editingTurnedOn = <xsl:value-of select="$editingTurnedOn"/>
307 -->
308
309 <!--
310
311 <xsl:choose>
312 <xsl:when test="$canDoEditing = 'true' and $editingTurnedOn = 'true'">
313
314 <xsl:when test="$canDoEditing = 'true'">
315-->
316 <gsf:script src="https://unpkg.com/mirador@latest/dist/mirador.min.js"/>
317
318
319 <!-- By default uses Roboto font. Be sure to load this or change the font -->
320 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
321 <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->
322
323 <div style="position: relative; width: 100%; height: 800px;">
324 <div id="my-mirador"> <xsl:comment>filler</xsl:comment></div>
325 </div>
326
327 <gsf:script>
328
329var mirador = Mirador.viewer({
330 "id": "my-mirador",
331 "manifests": {
332 "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json": {
333 "provider": "IntermusE"
334 }
335 },
336 "window" : { "panels" : { "annotations": true, "attribution": false } },
337 "annotations": {
338 "htmlSanitizationRuleSet": 'iiif', // See src/lib/htmlRules.js for acceptable values
339 "filteredMotivations": ['oa:commenting', 'oa:tagging', 'sc:painting', 'commenting', 'tagging'],
340 },
341 "windows": [
342 {
343 "loadedManifest": "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json",
344 "canvasIndex": 1,
345 "thumbnailNavigationPosition": 'far-bottom'
346 }
347 ]
348});
349 </gsf:script>
350
351 <!--
352 </xsl:when>
353 </xsl:choose>
354-->
355
356 </xsl:template>
357
358
359</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.