changeset 2:cbc4be362700

added configuration option "RouterBasename"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 15 Jun 2023 16:37:05 +0200
parents cc0e9401b027
children fdb8c6c420d0
files Sources/Plugin.cpp Sources/app-config-system.js
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Sources/Plugin.cpp	Thu Jun 15 10:03:54 2023 +0200
+++ b/Sources/Plugin.cpp	Thu Jun 15 16:37:05 2023 +0200
@@ -26,6 +26,7 @@
 
 #include <Logging.h>
 #include <SystemToolbox.h>
+#include <Toolbox.h>
 
 #include <EmbeddedResources.h>
 
@@ -99,6 +100,7 @@
 
 
 static ResourcesCache cache_;
+static std::string    routerBasename_;
 
 void ServeFile(OrthancPluginRestOutput* output,
                const char* url,
@@ -120,6 +122,11 @@
     Orthanc::EmbeddedResources::GetFileResource(system, Orthanc::EmbeddedResources::APP_CONFIG_SYSTEM);
     Orthanc::EmbeddedResources::GetFileResource(user, Orthanc::EmbeddedResources::APP_CONFIG_USER);
     
+    std::map<std::string, std::string> dictionary;
+    dictionary["ROUTER_BASENAME"] = routerBasename_;
+
+    system = Orthanc::Toolbox::SubstituteVariables(system, dictionary);
+
     std::string s = (user + "\n" + system);
     OrthancPluginAnswerBuffer(context, output, s.c_str(), s.size(), "application/json");
   }
@@ -197,12 +204,21 @@
     Orthanc::Logging::Initialize(context);
 #endif
 
+    OrthancPlugins::OrthancConfiguration configuration;
+
+    {
+      OrthancPlugins::OrthancConfiguration globalConfiguration;
+      globalConfiguration.GetSection(configuration, "OHIF");
+    }
+
+    routerBasename_ = configuration.GetStringValue("RouterBasename", "/ohif");
+
     OrthancPluginSetDescription(context, "OHIF plugin for Orthanc.");
 
     OrthancPlugins::RegisterRestCallback<ServeFile>("/ohif/(.*)", true);
 
     OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback);
-    
+
     // Extend the default Orthanc Explorer with custom JavaScript for OHIF
     std::string explorer;
     Orthanc::EmbeddedResources::GetFileResource(explorer, Orthanc::EmbeddedResources::ORTHANC_EXPLORER);
--- a/Sources/app-config-system.js	Thu Jun 15 10:03:54 2023 +0200
+++ b/Sources/app-config-system.js	Thu Jun 15 16:37:05 2023 +0200
@@ -4,7 +4,7 @@
  * SPDX-License-Identifier: MIT
  */
 
-window.config.routerBasename = '/ohif';
+window.config.routerBasename = '${ROUTER_BASENAME}';
 
 window.config.dataSources = [
   {