# HG changeset patch # User Sebastien Jodogne # Date 1688975068 -7200 # Node ID 14f182958ca79265a27e566cbc354721003e5ba8 # Parent b9eab260a37241f14c157816993b73bdbda66f97 added button to access IIIF manifest of series diff -r b9eab260a372 -r 14f182958ca7 ViewerPlugin/OrthancExplorer.js --- 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 = $('') + .attr('id', 'series-iiif-button') + .attr('data-role', 'button') + .attr('href', '#') + .text('Copy link to IIIF manifest'); + + var 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 = $('') .attr('id', 'mirador-button') diff -r b9eab260a372 -r 14f182958ca7 ViewerPlugin/Plugin.cpp --- 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("/wsi/pyramids/([0-9a-f-]+)", true); OrthancPlugins::RegisterRestCallback("/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("/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("/wsi/app/(mirador.html)", true); + } + } + else + { + serveMirador = false; } { @@ -315,7 +324,9 @@ Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); std::map 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());