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