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

Last change on this file since 37011 was 37011, checked in by davidb, 15 months ago

Collection now correctly displays OCR bounding-boxes on each page of an Item file

File size: 6.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:template name="iiif-links">
13 <xsl:param name="identifier"/>
14
15 <div style="padding-top: 10px; padding-bottom: 10px;">
16 IIIF Server Info URL:
17 <a href="/gs-cantaloupe/iiif/2/{$site_name}:{$collNameChecked}:{$identifier}/info.json">
18 /gs-cantaloupe/iiif/2/<xsl:value-of select="$site_name"/>:<xsl:value-of select="$collNameChecked"/>:<xsl:value-of select="$identifier"/>/info.json
19 </a>
20 </div>
21
22 <div style="padding-top: 10px; padding-bottom: 10px;">
23 IIIF Server Image URL:
24 <a href="/gs-cantaloupe/iiif/2/{$site_name}:{$collNameChecked}:{$identifier}/full/full/0/default.jpg">
25 /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
26 </a> <br />
27 </div>
28
29 </xsl:template>
30
31
32 <xsl:template name="googlevision-ocr-json">
33 <xsl:param name="assocfilepath"/>
34
35 <div style="padding-top: 10px; padding-bottom: 10px;">
36 Google Vision OCR JSON:
37 <a>
38 <xsl:attribute name="href">
39 <xsl:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
40 <xsl:text>/index/assoc/</xsl:text><xsl:value-of disable-output-escaping="yes" select="$assocfilepath" /><xsl:text>/</xsl:text>gv_document_ocrgoogle-vision-output.json
41 </xsl:attribute>
42 gv_document_ocrgoogle-vision-output.json
43 </a>
44 </div>
45 <gsf:variable name="GVDocumentOCRJSON"><gsf:metadata name="GVDocumentOCRJSON"/></gsf:variable>
46 <gsf:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')}"/></gsf:variable>
47 <gsf:script>
48 load_gv_dococr_json(gs.variables.GVDocumentOCRJSON,gs.variables.docSectionID,display_gv_ocr_bounding_boxes);
49 </gsf:script>
50 </xsl:template>
51
52
53 <xsl:template name="wrappedSectionPost">
54
55 <!-- add in IIIF Server link for section image -->
56 <xsl:variable name="nodeID" select="@nodeID"/>
57 <xsl:call-template name="iiif-links">
58 <xsl:with-param name="identifier" select="$nodeID" />
59 </xsl:call-template>
60
61 <!-- add in Google Vision OCR JSON link for section image -->
62 <xsl:call-template name="googlevision-ocr-json">
63 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" select="root"/></xsl:with-param>
64 </xsl:call-template>
65
66 </xsl:template>
67
68
69 <xsl:template name="sectionContent">
70 <xsl:call-template name="wrappedSectionImage"/>
71 <div style="padding: 10px 0px 10px 0px">Ocr'd Text:</div>
72 <i>
73 <xsl:call-template name="wrappedSectionText"/>
74 </i>
75 <xsl:call-template name="wrappedSectionPost"/>
76 </xsl:template>
77
78 <xsl:template name="sectionContentForEditing">
79 <xsl:call-template name="wrappedSectionImage"/>
80 <xsl:call-template name="wrappedSectionTextForEditing"/>
81 </xsl:template>
82
83 <xsl:template name="documentPre">
84 <xsl:variable name="httpCollection">library/sites/<xsl:value-of select="$site_name"/>/collect/<xsl:value-of select="/page/pageResponse/collection/@name"/></xsl:variable>
85 <gsf:script src="{$httpCollection}/js/document_viewer.js"/>
86 <style>
87 div.ocr-boundingbox-overlay {
88 position: absolute;
89 left: 0;
90 top: 0;
91 }
92
93 div.ocr-boundingbox {
94 position: absolute;
95 border: solid black 1px;
96 }
97
98 </style>
99 </xsl:template>
100
101 <xsl:template name="documentPost">
102 <xsl:if test="@docType='simple'">
103 <!-- add in IIIF Server link for simple page image -->
104 <xsl:call-template name="iiif-links">
105 <xsl:with-param name="identifier" select="$docID" />
106 </xsl:call-template>
107
108 <!--
109 <gsf:switch>
110 <gsf:metadata name='HasGoogleVisionDocumentOCRJSON";'/>
111 <gsf:when test='equals' test-value="1">
112 -->
113
114 <!-- add in Google Vision OCR JSON link for simple page image -->
115 <xsl:call-template name="googlevision-ocr-json">
116 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param>
117 </xsl:call-template>
118 <!--
119 </gsf:when>
120 </gsf:switch>
121-->
122
123 </xsl:if>
124 </xsl:template>
125
126
127 <!-- content of a simple document. Will not be used for editing mode -->
128 <xsl:template name="documentPostInProgress">
129
130
131 <!--
132 canDoEditing = <xsl:value-of select="$canDoEditing"/> <br />
133 editingTurnedOn = <xsl:value-of select="$editingTurnedOn"/>
134 -->
135
136 <!--
137
138 <xsl:choose>
139 <xsl:when test="$canDoEditing = 'true' and $editingTurnedOn = 'true'">
140
141 <xsl:when test="$canDoEditing = 'true'">
142-->
143 <gsf:script src="https://unpkg.com/mirador@latest/dist/mirador.min.js"/>
144
145
146 <!-- By default uses Roboto font. Be sure to load this or change the font -->
147 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
148 <!-- Container element of Mirador whose id should be passed to the instantiating call as "id" -->
149
150 <div style="position: relative; width: 100%; height: 800px;">
151 <div id="my-mirador"> <xsl:comment>filler</xsl:comment></div>
152 </div>
153
154 <gsf:script>
155
156var mirador = Mirador.viewer({
157 "id": "my-mirador",
158 "manifests": {
159 "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json": {
160 "provider": "IntermusE"
161 }
162 },
163 "window" : { "panels" : { "annotations": true, "attribution": false } },
164 "annotations": {
165 "htmlSanitizationRuleSet": 'iiif', // See src/lib/htmlRules.js for acceptable values
166 "filteredMotivations": ['oa:commenting', 'oa:tagging', 'sc:painting', 'commenting', 'tagging'],
167 },
168 "windows": [
169 {
170 "loadedManifest": "https://intermuse.sowemustthink.space/greenstone3/sample-manifest.json",
171 "canvasIndex": 2,
172 "thumbnailNavigationPosition": 'far-bottom'
173 }
174 ]
175});
176 </gsf:script>
177
178 <!--
179 </xsl:when>
180 </xsl:choose>
181-->
182
183 </xsl:template>
184
185
186</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.