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

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

OCR'd txt now stored in each <div> as a data field

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