changeset 263:14f182958ca7 iiif

added button to access IIIF manifest of series
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Jul 2023 09:44:28 +0200
parents b9eab260a372
children 75d933374805
files ViewerPlugin/OrthancExplorer.js ViewerPlugin/Plugin.cpp
diffstat 2 files changed, 47 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ViewerPlugin/OrthancExplorer.js	Mon Jul 10 09:21:48 2023 +0200
+++ b/ViewerPlugin/OrthancExplorer.js	Mon Jul 10 09:44:28 2023 +0200
@@ -23,8 +23,9 @@
 $('#series').live('pagebeforeshow', function() {
   var seriesId = $.mobile.pageData.uuid;
 
+  $('#mirador-button').remove();
+  $('#series-iiif').remove();
   $('#wsi-button').remove();
-  $('#mirador-button').remove();
 
   // Test whether this is a whole-slide image by check the SOP Class
   // UID of one instance of the series
@@ -53,6 +54,29 @@
 
       }
 
+      if (${SERVE_IIIF}) {
+        var b = $('<a>')
+            .attr('id', 'series-iiif-button')
+            .attr('data-role', 'button')
+            .attr('href', '#')
+            .text('Copy link to IIIF manifest');
+
+        var li = $('<li>')
+            .attr('data-icon', 'gear')
+            .append(b);
+
+        $('#series-access').append(li);
+
+        b.click(function(e) {
+          if ($.mobile.pageData) {
+            e.preventDefault();
+            var url = new URL('${IIIF_PUBLIC_URL}' + seriesId + '/manifest.json', window.location.href);
+            navigator.clipboard.writeText(url.href);
+            $(e.target).closest('li').buttonMarkup({ icon: 'check' });
+          }
+        });
+      }
+
       if (${SERVE_MIRADOR}) {
         var b = $('<a>')
             .attr('id', 'mirador-button')
--- a/ViewerPlugin/Plugin.cpp	Mon Jul 10 09:21:48 2023 +0200
+++ b/ViewerPlugin/Plugin.cpp	Mon Jul 10 09:44:28 2023 +0200
@@ -288,24 +288,33 @@
     OrthancPlugins::RegisterRestCallback<ServePyramid>("/wsi/pyramids/([0-9a-f-]+)", true);
     OrthancPlugins::RegisterRestCallback<ServeTile>("/wsi/tiles/([0-9a-f-]+)/([0-9-]+)/([0-9-]+)/([0-9-]+)", true);
 
-    bool serveMirador = true;  // TODO => CONFIG
+    bool serveMirador;
+    bool serveIIIF = true;  // TODO => CONFIG
+    std::string iiifPublicUrl;
 
-    if (serveMirador)
-    {
-      OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(mirador.html)", true);
-    }
-
+    if (serveIIIF)
     {
       // TODO => CONFIG
-      std::string url = "http://localhost:8042/wsi/iiif";
+      iiifPublicUrl = "http://localhost:8042/wsi/iiif";
 
-      if (url.empty() ||
-          url[url.size() - 1] != '/')
+      if (iiifPublicUrl.empty() ||
+          iiifPublicUrl[iiifPublicUrl.size() - 1] != '/')
       {
-        url += "/";
+        iiifPublicUrl += "/";
       }
 
-      InitializeIIIF(url);
+      InitializeIIIF(iiifPublicUrl);
+
+      serveMirador = true;  // TODO => CONFIG
+
+      if (serveMirador)
+      {
+        OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(mirador.html)", true);
+      }
+    }
+    else
+    {
+      serveMirador = false;
     }
 
     {
@@ -315,7 +324,9 @@
       Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER);
 
       std::map<std::string, std::string> dictionary;
+      dictionary["SERVE_IIIF"] = (serveIIIF ? "true" : "false");
       dictionary["SERVE_MIRADOR"] = (serveMirador ? "true" : "false");
+      dictionary["IIIF_PUBLIC_URL"] = iiifPublicUrl;
       explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary);
 
       OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str());