Changeset 37085 for gs3-installations
- Timestamp:
- 2023-01-02T00:26:55+13:00 (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-installations/intermuse/trunk/sites/intermuse/collect/programmes/transform/pages/document-iiif-manifest.xsl
r37082 r37085 9 9 exclude-result-prefixes="java util gsf"> 10 10 11 12 <!-- Inherit from document, but modified to drastically cut things down to what is needed: 11 <!-- 12 Key goal: generate a IIIF v2 compliant manifest file in JSON format based on the document 13 --> 14 15 <!-- Similar in spirit to document.xsl (catering for 'simple' and complex document structures such as 'pages'), 16 but considerably tailored down to produce the raw IIIF-manifest JSON format: 13 17 (i) focus on just the (potientailly hierachically nested) pages 14 18 (ii) so a bit like ed=1, but implied rather than needing to be set 15 16 Key goal: generate a IIIF v2 compliant manifest file in JSON format based on the document17 -->18 19 <!--20 <xsl:import href="pages/document.xsl"/>21 19 --> 22 20 … … 33 31 --> 34 32 35 <!-- If the c parameter is empty then use the p.c parameter for the collection name--> 36 <xsl:variable name="collNameChecked"> 37 <xsl:choose> 38 <xsl:when test="$collName = '' and /page/pageRequest/paramList/param[@name='p.c']/@value"> 39 <xsl:value-of select="/page/pageRequest/paramList/param[@name='p.c']/@value"/> 40 </xsl:when> 41 <xsl:otherwise> 42 <xsl:value-of select="$collName"/> 43 </xsl:otherwise> 44 </xsl:choose> 45 </xsl:variable> 46 47 33 <!-- **** is this variable used anymore in thie file???? --> 48 34 <xsl:variable name="httpDocument"> 49 35 <xsl:value-of select="$library_name"/> … … 53 39 <xsl:value-of select="/page/pageRequest/paramList/param[@name = 'd']/@value"/> <!-- or use $docID from default/transform/pages/document.xsl ???? --> 54 40 </xsl:variable> 55 41 42 56 43 <xsl:variable name="iiifPresentationRootIdentifier">http-greenstone://<xsl:value-of select="$site_name"/>/<xsl:value-of select="$collNameChecked"/>/<xsl:value-of select="$docID"/></xsl:variable> 57 44 … … 87 74 <xsl:text>/gs-cantaloupe/iiif/2/</xsl:text><xsl:value-of select="$site_name"/>:<xsl:value-of select="$collNameChecked"/>:<xsl:value-of select="$identifier"/> 88 75 </xsl:variable> 89 90 91 <!--92 var chosen_title = "untitled";93 94 if (gs.variables.chosenTitle && !gs.variables.docNodeID) {95 // simple doc96 chosen_title = gs.variables.chosenTitle;97 }98 else {99 var docNodeID = gs.variables.docNodeID;100 var page_pos = docNodeID.indexOf('.');101 chosen_title = (page_pos>=0) ? "page " + docNodeID.substring(page_pos+1) : docNodeID;102 }103 104 -->105 106 107 76 108 77 <!-- page/pageRequest[@baseURL]="//intermuse.sowemustthink.space/greenstone3/ --> … … 131 100 </xsl:variable> 132 101 102 <!-- The following is useful for debugging, nested in 'pre' tags --> 133 103 <!-- 134 104 docType = <xsl:value-of select="$docType"/> … … 145 115 <!-- an array entry in 'canvases': { @content, @id, @type, label, width, height, images[{}], thumbnail {@id,@type} } --> 146 116 <pre> 117 <!-- add a comma first, if it is not the first canvas element in the array --> 147 118 <xsl:if test="$section > 1"> 148 119 , … … 191 162 192 163 193 <xsl:template name="googlevision-ocr-jsonOLD">194 <xsl:param name="assocfilepath"/>195 196 <xsl:variable name="GVDocumentOCRJSON"><gsf:metadata name="GVDocumentOCRJSON"/></xsl:variable>197 <xsl:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')"/></xsl:variable>198 <!--199 <gsf:variable name="GVDocumentOCRJSON"><gsf:metadata name="GVDocumentOCRJSON"/></gsf:variable>200 <gsf:variable name="docSectionID"><xsl:value-of select="util:replace(@nodeID, '.', '_')"/></gsf:variable>201 -->202 203 <!--204 <gsf:script>205 load_gv_dococr_json(gs.variables.GVDocumentOCRJSON,gs.variables.docSectionID,display_gv_ocr_bounding_boxes);206 </gsf:script>207 -->208 209 </xsl:template>210 211 212 164 <xsl:template name="wrappedSectionPost"> 213 165 166 <!-- **** improve name !!!! --> 214 167 <!-- add in IIIF Server link for section image --> 215 168 <xsl:variable name="nodeID" select="@nodeID"/> … … 218 171 <xsl:with-param name="docType" select="@docType" /> 219 172 </xsl:call-template> 220 221 <!-- add in Google Vision OCR JSON link for section image -->222 <!--223 <xsl:call-template name="googlevision-ocr-json">224 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" select="root"/></xsl:with-param>225 </xsl:call-template>226 -->227 228 173 </xsl:template> 229 174 … … 240 185 </xsl:template> 241 186 242 <xsl:template name="sectionContentOLD">243 244 <xsl:choose>245 <xsl:when test="$bookswitch = 'mirador'">246 <gsf:variable name="screenImageWidth"><gsf:metadata name="ScreenWidth"/></gsf:variable>247 <gsf:variable name="screenImageHeight"><gsf:metadata name="ScreenHeight"/></gsf:variable>248 <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>249 <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>250 <gsf:variable name="docNodeID"><xsl:value-of select="@nodeID"/></gsf:variable> <!-- used to make each 'tidyDiv' unique -->251 </xsl:when>252 253 <!-- OBSOLETE when removing forced bookswith = mirador -->254 <xsl:otherwise>255 <xsl:call-template name="wrappedSectionImage"/>256 257 <div style="padding: 10px 0px 10px 0px">Ocr'd Text:</div>258 <i>259 <xsl:call-template name="wrappedSectionText"/>260 </i>261 </xsl:otherwise>262 </xsl:choose>263 264 <xsl:call-template name="wrappedSectionPost"/>265 </xsl:template>266 187 267 188 <xsl:template name="documentPre"> … … 279 200 </xsl:variable> 280 201 281 <!-- <gsf:variable name="chosenTitle"><xsl:call-template name="choose-title"/></gsf:variable> --> 282 <!-- <gsf:variable name="toplevelTitle"><gsf:metadata name="Title" select="root"/></gsf:variable> --> 283 <!-- <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable> --> 284 <!-- <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable> --> 285 286 287 <!-- iiif_manifest: --> 202 <!-- start of iiif_manifest: --> 288 203 <pre> 289 204 { … … 307 222 </pre> 308 223 309 <!-- 310 <gsf:script> 311 console.log("**** sa=iiif-manifest: chosenTitle = " + gs.variables.chosenTitle); 312 </gsf:script> 313 <gsf:script src="{$httpCollection}/js/document_viewer.js"/> 314 <style> 315 div.ocr-boundingbox-overlay { 316 position: absolute; 317 left: 0; 318 top: 0; 319 } 320 321 div.ocr-boundingbox { 322 position: absolute; 323 border: solid black 1px; 324 } 325 326 </style> 327 --> 328 329 <!-- OBSOLETE when removing forced bookswith = mirador --> 330 <!-- the following is not needed, if only generating the required JSON IIIF Manifest file --> 331 <!-- 332 <xsl:if test="$bookswitch = 'mirador'"> 333 <gsf:script src="ext/structured-image/mirador3/dist/mirador-with-annotations.js"/> 334 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" /> 335 </xsl:if> 336 --> 337 338 <!-- 339 <gsf:script> 340 var IIIF_Doc_Images = []; 341 </gsf:script> 342 --> 343 </xsl:template> 344 345 346 <!-- 347 { 348 "@context": "http://iiif.io/api/presentation/2/context.json", 349 "@id": "http-greenstone://intermuse/programmes/HMS_1/canvas/1", 350 "@type": "sc:Canvas", 351 "width": "3670", 352 "height": "4641", 353 "label": "page 1", 354 "images": [ 355 { 356 "@context": "http://iiif.io/api/image/2/context.json", 357 "@id": "http-greenstone://intermuse/programmes/HMS_1/annotation/1", 358 "@type": "oa:Annotation", 359 "motivation": "sc:painting", 360 "on": "http-greenstone://intermuse/programmes/HMS_1/canvas", 361 "resource": { 362 "@id": "https://intermuse.sowemustthink.space/gs-cantaloupe/iiif/2/intermuse:programmes:HMS_1.1/full/full/0/default.jpg", 363 "@type": "dctypes:Image", 364 "format": "image/jpeg", 365 "width": "3670", 366 "height": "4641", 367 "service": { 368 "@context": "http://iiif.io/api/image/2/context.json", 369 "@id": "https://intermuse.sowemustthink.space/gs-cantaloupe/iiif/2/intermuse:programmes:HMS_1.1", 370 "profile": "https://iiif.io/api/image/2/profiles/level2.json" 371 } 372 } 373 } 374 ], 375 "thumbnail": { 376 "@id": "https://intermuse.sowemustthink.space/gs-cantaloupe/iiif/2/intermuse:programmes:HMS_1.1/full/,150/0/default.jpg", 377 "@type": "dctypes:Image" 378 } 379 } 380 --> 224 </xsl:template> 225 381 226 382 227 <xsl:template name="documentContentSimpleIIIFImage"> … … 397 242 398 243 <xsl:template name="documentPost"> 399 <!-- close of canvases --> 244 <!-- end of iiif_manifest: --> 245 <!-- close of canvases, then close higher level blocks to complete the JSON file --> 400 246 <pre> 401 247 ] … … 406 252 </xsl:template> 407 253 408 <xsl:template name="documentPostOLD"> 409 <xsl:if test="@docType='simple'"> 410 <!-- add in Google Vision OCR JSON link for simple page image --> 411 <xsl:call-template name="googlevision-ocr-jsonOLD"> 412 <xsl:with-param name="assocfilepath"><gsf:metadata name="assocfilepath" pos="first"/></xsl:with-param> 413 </xsl:call-template> 414 </xsl:if> 415 </xsl:template> 416 254 255 <!-- **** improve name !!!! --> 417 256 <xsl:template name="documentPostMirador3"> 418 257 … … 421 260 <div id="mirador3-viewer"> <xsl:comment>filler</xsl:comment></div> 422 261 </div> 423 424 <!--425 <gsf:script>426 var iiifpres_root_id = gs.variables.iiifPresentationRootIdentifier;427 console.log(gs);428 var iiifpres_label = (gs.variables.toplevelTitle) ? gs.variables.toplevelTitle : gs.variables.chosenTitle;429 430 var iiif_manifest = initIIIFManifest(iiifpres_root_id,iiifpres_label, IIIF_Doc_Images);431 432 var mirador3 = createMirador3Viewer();433 </gsf:script>434 -->435 262 436 263 </xsl:template> … … 456 283 </xsl:template> 457 284 458 285 286 <!-- **** see about eliminating the following => shouldn't be needed! !!!! --> 459 287 <!-- content of a simple document. Will not be used for editing mode --> 460 288 <xsl:template name="documentPostInProgress"> … … 519 347 </xsl:template> 520 348 521 <!-- Used to make sure that regardless what the collection designer uses for the title and content we can wrap it properly -->522 <!-- If editing, be aware that the Document Basket looks for specific classes that this template bakes in (key points marked with ***) -->523 <xsl:template name="wrapDocumentNodesOLD">524 <xsl:variable name="nodeID" select="@nodeID"/>525 <a name="{@nodeID}"><xsl:text> </xsl:text></a>526 527 <!-- Section header -->528 <table class="sectionHeader"><tr>529 530 <!-- Title -->531 <td id="header{@nodeID}" class="headerTD sectionTitle"><!-- *** -->532 <p>533 <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>534 535 <xsl:if test="util:hashToSectionId(@nodeID)">536 <span class="sectionNumberSpan">537 <xsl:value-of select="util:hashToSectionId(@nodeID)"/>538 <xsl:text> </xsl:text>539 </span>540 </xsl:if>541 <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->542 <span><xsl:call-template name="sectionHeading"/></span>543 </p>544 </td>545 546 </tr></table>547 548 <div id="doc{@nodeID}"><!-- *** -->549 550 <xsl:choose>551 <xsl:when test="../../document">552 <xsl:call-template name="topLevelSectionContent"/>553 </xsl:when>554 <xsl:otherwise>555 <xsl:call-template name="sectionContent"/>556 </xsl:otherwise>557 </xsl:choose>558 559 <xsl:if test="documentNode">560 <xsl:for-each select="documentNode">561 <xsl:call-template name="wrapDocumentNodes"/>562 </xsl:for-each>563 </xsl:if>564 </div>565 </xsl:template>566 567 568 349 569 350 … … 641 422 642 423 643 424 <!-- **** SIMPLIFY !!!! --> 644 425 645 426 <xsl:template name="wrappedDocument">
Note:
See TracChangeset
for help on using the changeset viewer.