Mercurial > hg > orthanc-wsi
changeset 262:b9eab260a372 iiif
serving Mirador
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 10 Jul 2023 09:21:48 +0200 |
parents | c72fbdecdc38 |
children | 14f182958ca7 |
files | ViewerPlugin/CMakeLists.txt ViewerPlugin/OrthancExplorer.js ViewerPlugin/Plugin.cpp ViewerPlugin/mirador.html |
diffstat | 4 files changed, 71 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ViewerPlugin/CMakeLists.txt Mon Jul 10 08:59:40 2023 +0200 +++ b/ViewerPlugin/CMakeLists.txt Mon Jul 10 09:21:48 2023 +0200 @@ -173,6 +173,7 @@ 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 )
--- a/ViewerPlugin/OrthancExplorer.js Mon Jul 10 08:59:40 2023 +0200 +++ b/ViewerPlugin/OrthancExplorer.js Mon Jul 10 09:21:48 2023 +0200 @@ -24,6 +24,7 @@ var seriesId = $.mobile.pageData.uuid; $('#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 @@ -51,6 +52,24 @@ }); } + + if (${SERVE_MIRADOR}) { + var b = $('<a>') + .attr('id', 'mirador-button') + .attr('data-role', 'button') + .attr('href', '#') + .attr('data-icon', 'search') + .attr('data-theme', 'e') + .text('Open IIIF in Mirador') + .button(); + + b.insertAfter($('#series-info')); + b.click(function() { + if ($.mobile.pageData) { + window.open('../wsi/app/mirador.html?iiif-content=../iiif/' + seriesId + '/manifest.json'); + } + }); + } }); }); });
--- a/ViewerPlugin/Plugin.cpp Mon Jul 10 08:59:40 2023 +0200 +++ b/ViewerPlugin/Plugin.cpp Mon Jul 10 09:21:48 2023 +0200 @@ -216,6 +216,11 @@ resource = Orthanc::EmbeddedResources::OPENLAYERS_CSS; mime = "text/css"; } + else if (f == "mirador.html") + { + resource = Orthanc::EmbeddedResources::MIRADOR_HTML; + mime = "text/html"; + } else { throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); @@ -283,6 +288,13 @@ 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 + + if (serveMirador) + { + OrthancPlugins::RegisterRestCallback<ServeFile>("/wsi/app/(mirador.html)", true); + } + { // TODO => CONFIG std::string url = "http://localhost:8042/wsi/iiif"; @@ -296,10 +308,18 @@ InitializeIIIF(url); } - // Extend the default Orthanc Explorer with custom JavaScript for WSI - std::string explorer; - Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); - OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str()); + { + // Extend the default Orthanc Explorer with custom JavaScript for WSI + + std::string explorer; + Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER); + + std::map<std::string, std::string> dictionary; + dictionary["SERVE_MIRADOR"] = (serveMirador ? "true" : "false"); + explorer = Orthanc::Toolbox::SubstituteVariables(explorer, dictionary); + + OrthancPluginExtendOrthancExplorer(OrthancPlugins::GetGlobalContext(), explorer.c_str()); + } return 0; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ViewerPlugin/mirador.html Mon Jul 10 09:21:48 2023 +0200 @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> + <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>Mirador</title> + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> + <!--link rel="shortcut icon" type="image/svg" href="/img/mirador-logo.svg"/--> + </head> + <body> + <div id="mirador" style="position: absolute; top: 0; bottom: 0; left: 0; right: 0;"></div> + <script>document.write("<script type='text/javascript' src='https://unpkg.com/mirador@latest/dist/mirador.min.js'><\/script>");</script> + <script type="text/javascript"> + var params = new URL(document.location).searchParams; + var manifest = params.get('iiif-content') || params.get('manifest'); + var windows = []; + if (manifest) { + windows.push({ manifestId: manifest}); + } + var miradorInstance = Mirador.viewer({ + id: 'mirador', + windows: windows, + }); + </script> + </body> +</html>