Commit d0d4d09d authored by Pierre-Yves Buard's avatar Pierre-Yves Buard Committed by Jerome Chauveau
Browse files

Pyb/mirador

parent 5cc41a96
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
    "install": "^0.12.1",
    "jquery": "^3.3.1",
    "mathjax": "^2.7.7",
    "mirador": "^3.1.1",
    "openseadragon": "^2.4.1",
    "popper.js": "^1.14.7",
    "readline": "^1.3.0",
+4 −0
Original line number Diff line number Diff line
.mirador-link {
  cursor:pointer;
  color:var(--ead-link-color);
}
 No newline at end of file
+83 −0
Original line number Diff line number Diff line

function    openInMirador(link) {
    var mirador = Mirador.viewer({
	"id": "mirador-viewer",
	"language":"fr",
	"selectedTheme": "dark",
	"window": { //global window defaults
	    "allowClose": false, // Configure if windows can be closed or not
	    "allowFullscreen": false, // Configure to show a "fullscreen" button in the WindowTopBar
	    "allowMaximize": true, // Configure if windows can be maximized or not
	    "allowTopMenuButton": true, // Configure if window view and thumbnail display menu are visible or not
	    "allowWindowSideBar": true, // Configure if side bar menu is visible or not
	    "authNewWindowCenter": 'parent', // Configure how to center a new window created by the authentication flow. Options: parent, screen
	    "sideBarPanel": 'info', // Configure which sidebar is selected by default. Options: info, attribution, canvas, annotations, search
	    "defaultSidebarPanelHeight": 201,  // Configure default sidebar height in pixels
	    "defaultSidebarPanelWidth": 235, // Configure default sidebar width in pixels
	    "defaultView": 'single',  // Configure which viewing mode (e.g. single, book, gallery) for windows to be opened in
	    "forceDrawAnnotations": false,
	    "hideWindowTitle": false, // Configure if the window title is shown in the window title bar or not
	    "highlightAllAnnotations": false, // Configure whether to display annotations on the canvas by default
	    "showLocalePicker": false, // Configure locale picker for multi-lingual metadata
	    "sideBarOpen": false, // Configure if the sidebar (and its content panel) is open by default
	    "switchCanvasOnSearch": false, // Configure if Mirador should automatically switch to the canvas of the first search result
	    "panels": { // Configure which panels are visible in WindowSideBarButtons
		"info": false,
		"attribution": false,
		"canvas": false,
		"annotations": false,
		"search": false,
		"layers": false,
	    }
	},
	"windows": [
	    {
		"loadedManifest": link,
		//"canvasIndex": 3,
		"thumbnailNavigationPosition": 'far-right'
	    }
	],
	"workspace": {
	    "draggingEnabled": true,
	    "allowNewWindows": true,
	    "id": "my-panel",
	    "isWorkspaceAddVisible": false, // Catalog/Workspace add window feature visible by default
	    "exposeModeOn": false, // unused?
	    "height": 5000, // height of the elastic mode's virtual canvas
	    "showZoomControls": true, // Configure if zoom controls should be displayed by default
	    "type": 'mosaic', // Which workspace type to load by default. Other possible values are "elastic". If "mosaic" or "elastic" are not selected no worksapce type will be used.
	    "viewportPosition": { // center coordinates for the elastic mode workspace
		"x": 0,
		"y": 0,
	    },
	    "width": 5000, // width of the elastic mode's virtual canvas
	},
	"workspaceControlPanel": {
	    "enabled": false, // Configure if the control panel should be rendered.  Useful if you want to lock the viewer down to only the configured manifests
	},
    });
}

//load thumbnails from IIIF server
document.addEventListener("DOMContentLoaded", function(event){
    var imgsIIIF = document.querySelectorAll('img.mirador-link'); //img with class mirador-link

    for (var e = 0, len = imgsIIIF.length; e < len; ++e) {
	var currentId = imgsIIIF[e].id
	getThumbnail(imgsIIIF[e].src).then((thumbnail) => {
	    var currentImg = document.getElementById(currentId)
	    currentImg.setAttribute("src",thumbnail)
	})
    }
})

async function getThumbnail(url) {
    const response = await fetch(url);
    let manifest = await response.json();
    let thumbnail = manifest.thumbnail["@id"]
    return thumbnail
}


//MAX.addPlugin(new MiradorViewer('mirador_viewer'));
+31 −0
Original line number Diff line number Diff line
(: For conditions of distribution and use, see the accompanying legal.txt file. :)

module namespace max.plugin.mirador = 'pddn/max/plugin/mirador';
import module namespace max.config = 'pddn/max/config' at '../../rxq/config.xqm';

declare variable $max.plugin.mirador:PLUGIN_ID := "mirador_viewer";

(:
returns html page with mirador loaded
:)

declare
%rest:GET
%output:method("html")
%rest:query-param("link", "{$link}")
%rest:path("/{$project}/mirador")
function max.plugin.mirador:loadViewer($project,$link){
let $publicjs := max.config:getBaseURI() || "plugins/" || $max.plugin.mirador:PLUGIN_ID || '/' || $max.plugin.mirador:PLUGIN_ID || '.js'
let $libJs := max.config:getBaseURI() || 'core/ui/lib/mirador.min.js'
  let $htmlPage := <html>
  <head>
</head>
<body onload='openInMirador("{$link}")'>
  <div id='mirador-viewer'/>
  <script type='text/javascript' src='{$libJs}'></script>
  <script type='text/javascript' src='{$publicjs}'></script>
</body>
</html>

return $htmlPage
  };
 No newline at end of file
+70 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8" ?>
<!--
 For conditions of distribution and use, see the accompanying legal.txt file.
-->
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:tei="http://www.tei-c.org/ns/1.0"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:ead="urn:isbn:1-931666-22-9" 
  exclude-result-prefixes="tei xsl ead xlink">



  <!-- ead -->
  <!-- lien (sans imagette) -->
  <!-- Ugly template for alpha tests-->
  <xsl:template match="ead:extref[contains(@xlink:href,'/manifest')]">
    <xsl:variable name="iiifLink">
      <xsl:choose>
        <xsl:when test="@entityref='iiif_manifest'">
          <xsl:value-of select="$baseuri"/><xsl:value-of select="$project"/><xsl:text>/mirador/?link=</xsl:text><xsl:value-of select="@xlink:href"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$baseuri"/><xsl:value-of select="$project"/><xsl:text>/mirador/?link=https</xsl:text><xsl:value-of select="substring-after(@xlink:href,'=http')"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <span onclick="window.open('{$iiifLink}','Mirador Viewer','width=800,height=600,location=no')" class="mirador-link"><xsl:value-of select="."/></span>
  </xsl:template>

  <!-- dao avec imagette -->
  <xsl:template match="ead:dao[@entityref='iiif_manifest']">
    <xsl:variable name="iiifLink">
      <xsl:value-of select="$baseuri"/>
      <xsl:value-of select="$project"/>
      <xsl:text>/mirador/?link=</xsl:text>
      <xsl:value-of select="@xlink:href"/>
    </xsl:variable>
    
    <xsl:variable name="imgId">
      <xsl:text>thumbnail</xsl:text><xsl:value-of select="count(preceding::*:dao[@entityref='iiif_manifest'])+1"/>
    </xsl:variable>
    <span onclick="window.open('{$iiifLink}','Mirador Viewer','width=800,height=600,location=no')" class="mirador-link"><xsl:value-of select="."/></span>
    <figure>
      <img id="{$imgId}" src="{@xlink:href}" onclick="window.open('{$iiifLink}','Mirador Viewer','width=800,height=600,location=no')" class="mirador-link">      
      </img>
    </figure>
  </xsl:template>
  
  <!-- tei -->
  <xsl:template match="tei:pb[@tei:rend='iiif_manifest']">
    <xsl:variable name="iiifLink">
      <xsl:value-of select="$baseuri"/>
      <xsl:value-of select="$project"/>
      <xsl:text>/mirador/?link=</xsl:text>
      <xsl:value-of select="@tei:n"/>
    </xsl:variable>

    <span onclick="window.open('{$iiifLink}','Mirador Viewer','width=800,height=600,location=no')">
      <xsl:attribute name="class">pb mirador-link</xsl:attribute>
      <xsl:attribute name="name">
        <xsl:value-of select="@xml:id"/>
      </xsl:attribute>
      <xsl:value-of select="@tei:n"/>
    </span>

    
  </xsl:template>

</xsl:stylesheet>                
Loading