changeset 270:0040ce361d4c iiif

serving openseadragon
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Jul 2023 17:16:32 +0200
parents 30fb01ce97a3
children 45e3b5adf4ae
files ViewerPlugin/CMakeLists.txt ViewerPlugin/OrthancExplorer.js ViewerPlugin/Plugin.cpp ViewerPlugin/mirador.html ViewerPlugin/openseadragon.html
diffstat 5 files changed, 63 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ViewerPlugin/CMakeLists.txt	Mon Jul 10 16:23:46 2023 +0200
+++ b/ViewerPlugin/CMakeLists.txt	Mon Jul 10 17:16:32 2023 +0200
@@ -170,10 +170,11 @@
 
 EmbedResources(
   ${OPENLAYERS_RESOURCES}
-  ORTHANC_EXPLORER  ${CMAKE_SOURCE_DIR}/OrthancExplorer.js
-  VIEWER_HTML       ${CMAKE_SOURCE_DIR}/viewer.html
-  VIEWER_JS         ${CMAKE_SOURCE_DIR}/viewer.js
-  MIRADOR_HTML      ${CMAKE_SOURCE_DIR}/mirador.html
+  ORTHANC_EXPLORER     ${CMAKE_SOURCE_DIR}/OrthancExplorer.js
+  VIEWER_HTML          ${CMAKE_SOURCE_DIR}/viewer.html
+  VIEWER_JS            ${CMAKE_SOURCE_DIR}/viewer.js
+  MIRADOR_HTML         ${CMAKE_SOURCE_DIR}/mirador.html
+  OPEN_SEADRAGON_HTML  ${CMAKE_SOURCE_DIR}/openseadragon.html
   )
 
 
--- a/ViewerPlugin/OrthancExplorer.js	Mon Jul 10 16:23:46 2023 +0200
+++ b/ViewerPlugin/OrthancExplorer.js	Mon Jul 10 17:16:32 2023 +0200
@@ -24,6 +24,7 @@
   var seriesId = $.mobile.pageData.uuid;
 
   $('#mirador-button').remove();
+  $('#openseadragon-button').remove();
   $('#wsi-button').remove();
 
   $('#series-iiif-button').remove();
@@ -54,6 +55,23 @@
           }
         });
 
+        if (${SERVE_OPEN_SEADRAGON}) {
+          var b = $('<a>')
+              .attr('id', 'openseadragon-button')
+              .attr('data-role', 'button')
+              .attr('href', '#')
+              .attr('data-icon', 'search')
+              .attr('data-theme', 'e')
+              .text('Test IIIF in OpenSeadragon')
+              .button();
+
+          b.insertAfter($('#series-info'));
+          b.click(function() {
+            if ($.mobile.pageData) {
+              window.open('../wsi/app/openseadragon.html?image=../iiif/tiles/' + seriesId + '/info.json');
+            }
+          });
+        }
       }
 
       if (${SERVE_IIIF}) {
@@ -86,7 +104,7 @@
             .attr('href', '#')
             .attr('data-icon', 'search')
             .attr('data-theme', 'e')
-            .text('Open IIIF in Mirador')
+            .text('Test IIIF in Mirador')
             .button();
 
         b.insertAfter($('#series-info'));
--- a/ViewerPlugin/Plugin.cpp	Mon Jul 10 16:23:46 2023 +0200
+++ b/ViewerPlugin/Plugin.cpp	Mon Jul 10 17:16:32 2023 +0200
@@ -221,6 +221,11 @@
     resource = Orthanc::EmbeddedResources::MIRADOR_HTML;
     mime = "text/html";
   }
+  else if (f == "openseadragon.html")
+  {
+    resource = Orthanc::EmbeddedResources::OPEN_SEADRAGON_HTML;
+    mime = "text/html";
+  }
   else
   {
     throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource);
@@ -289,6 +294,7 @@
     OrthancPlugins::RegisterRestCallback<ServeTile>("/wsi/tiles/([0-9a-f-]+)/([0-9-]+)/([0-9-]+)/([0-9-]+)", true);
 
     bool serveMirador;
+    bool serveOpenSeadragon;
     bool serveIIIF = true;  // TODO => CONFIG
     std::string iiifPublicUrl;
 
@@ -306,15 +312,22 @@
       InitializeIIIF(iiifPublicUrl);
 
       serveMirador = true;  // TODO => CONFIG
+      serveOpenSeadragon = true;  // TODO => CONFIG
 
       if (serveMirador)
       {
         OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(mirador.html)", true);
       }
+
+      if (serveOpenSeadragon)
+      {
+        OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(openseadragon.html)", true);
+      }
     }
     else
     {
       serveMirador = false;
+      serveOpenSeadragon = false;
     }
 
     {
@@ -326,6 +339,7 @@
       std::map<std::string, std::string> dictionary;
       dictionary["SERVE_IIIF"] = (serveIIIF ? "true" : "false");
       dictionary["SERVE_MIRADOR"] = (serveMirador ? "true" : "false");
+      dictionary["SERVE_OPEN_SEADRAGON"] = (serveOpenSeadragon ? "true" : "false");
       dictionary["IIIF_PUBLIC_URL"] = iiifPublicUrl;
       explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary);
 
--- a/ViewerPlugin/mirador.html	Mon Jul 10 16:23:46 2023 +0200
+++ b/ViewerPlugin/mirador.html	Mon Jul 10 17:16:32 2023 +0200
@@ -20,7 +20,7 @@
       }
       var miradorInstance = Mirador.viewer({
         id: 'mirador',
-        windows: windows,
+        windows: windows
       });
     </script>
   </body>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ViewerPlugin/openseadragon.html	Mon Jul 10 17:16:32 2023 +0200
@@ -0,0 +1,24 @@
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+    <meta name="theme-color" content="#000000">
+    <title>OpenSeadragon</title>
+    <script src="https://unpkg.com/openseadragon@4.1.0/build/openseadragon/openseadragon.js"></script>
+  </head>
+
+  <body>
+    <div id="osd" style="width: 100%; height: 100%;"></div>
+    <script type="text/javascript">
+      var params = new URL(document.location).searchParams;
+      OpenSeadragon({
+      id:                 'osd',
+      prefixUrl:          'https://unpkg.com/openseadragon@4.1.0/build/openseadragon/images/',
+      preserveViewport:   true,
+      visibilityRatio:    1,
+      sequenceMode:       true,
+      tileSources:        [params.get('image')]
+      });
+    </script>
+  </body>
+</html>