diff --git a/web-ui/src/main/resources/catalog/components/common/needhelp/NeedHelpDirective.js b/web-ui/src/main/resources/catalog/components/common/needhelp/NeedHelpDirective.js index 508d639231b..0ca87cb85c0 100644 --- a/web-ui/src/main/resources/catalog/components/common/needhelp/NeedHelpDirective.js +++ b/web-ui/src/main/resources/catalog/components/common/needhelp/NeedHelpDirective.js @@ -48,10 +48,20 @@ module.directive("gnNeedHelp", [ "gnGlobalSettings", "gnAlertService", + "gnConfigService", + "gnConfig", "$http", "$q", "$translate", - function (gnGlobalSettings, gnAlertService, $http, $q, $translate) { + function ( + gnGlobalSettings, + gnAlertService, + gnConfigService, + gnConfig, + $http, + $q, + $translate + ) { return { restrict: "A", replace: true, @@ -60,6 +70,21 @@ link: function (scope, element, attrs) { scope.iconOnly = attrs.iconOnly === "true"; scope.documentationLinks = null; + scope.applicationVersion = ""; + + scope.helpBaseUrl = + "https://docs.geonetwork-opensource.org/{{version}}/{{lang}}"; + + gnConfigService.load().then(function (c) { + var version = gnConfig["system.platform.version"]; + scope.applicationVersion = version.substring(0, version.lastIndexOf(".")); + + var docUrl = gnConfig["system.documentation.url"]; + + if (docUrl) { + scope.helpBaseUrl = docUrl; + } + }); scope.$watch("documentationLinks", function (n, o) { if (n !== o && n != null) { @@ -67,10 +92,6 @@ } }); - var helpBaseUrl = - gnGlobalSettings.docUrl || - "https://docs.geonetwork-opensource.org/latest/{lang}"; - /** * load the JSON file with all the documentation links and put the links in the scope */ @@ -129,17 +150,21 @@ var baseUrl; if (gnGlobalSettings.lang !== "en") { - baseUrl = helpBaseUrl.replace("{lang}", gnGlobalSettings.lang); + baseUrl = scope.helpBaseUrl.replace("{{lang}}", gnGlobalSettings.lang); } else { - baseUrl = helpBaseUrl.replace("/{lang}", ""); + baseUrl = scope.helpBaseUrl.replace("/{{lang}}", ""); } + baseUrl = baseUrl.replace("{{version}}", scope.applicationVersion); + var helpPageUrl = baseUrl + "/" + page; testAndOpen(helpPageUrl).then( function () {}, function () { - var baseUrl = helpBaseUrl.replace("/{lang}", ""); + var baseUrl = scope.helpBaseUrl + .replace("/{{lang}}", "") + .replace("{{version}}", scope.applicationVersion); var helpPageUrl = baseUrl + "/" + page; testAndOpen(helpPageUrl); diff --git a/web-ui/src/main/resources/catalog/locales/en-admin.json b/web-ui/src/main/resources/catalog/locales/en-admin.json index 25b88cf4545..619c95c45e0 100644 --- a/web-ui/src/main/resources/catalog/locales/en-admin.json +++ b/web-ui/src/main/resources/catalog/locales/en-admin.json @@ -625,6 +625,9 @@ "system/clickablehyperlinks": "Link in metadata records", "system/clickablehyperlinks/enable": "Clickable hyperlinks", "system/clickablehyperlinks/enable-help": "If set, GeoNetwork will display clickable hyperlinks in the metadata.", + "system/documentation": "Documentation configuration", + "system/documentation/url": "Base manual url", + "system/documentation/url-help": "Base application manual url. Defaults to the official manual page (https://docs.geonetwork-opensource.org/{version}/{lang}) and can be customised to use a self hosted documentation with a custom branding. The url can contain \\{\\{lang\\}\\} placeholder, to display the manual in different languages when available, and \\{\\{version\\}\\} placeholder to use the application version.", "system/publication": "Publication", "system/publication/doi/doienabled": "Allow creation of Digital Object Identifier (DOI)", "system/publication/doi/doipattern": "DOI pattern", diff --git a/web/src/main/webapp/WEB-INF/classes/setup/sql/data/data-db-default.sql b/web/src/main/webapp/WEB-INF/classes/setup/sql/data/data-db-default.sql index 0c743b7ad0c..d97f9de74e0 100644 --- a/web/src/main/webapp/WEB-INF/classes/setup/sql/data/data-db-default.sql +++ b/web/src/main/webapp/WEB-INF/classes/setup/sql/data/data-db-default.sql @@ -593,6 +593,7 @@ INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system INSERT INTO Settings (name, value, datatype, position, internal, encrypted) VALUES ('system/proxy/password', NULL, 0, 550, 'y', 'y'); INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/proxy/ignorehostlist', NULL, 0, 560, 'y'); INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/cors/allowedHosts', '*', 0, 561, 'y'); +INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/documentation/url', 'https://docs.geonetwork-opensource.org/{{version}}/{{lang}}', 0, 570, 'n'); INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/feedback/email', 'root@localhost', 0, 610, 'y'); INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/feedback/mailServer/host', '', 0, 630, 'y'); INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/feedback/mailServer/port', '25', 1, 640, 'y'); diff --git a/web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v443/migrate-default.sql b/web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v443/migrate-default.sql index d77fb7b3b44..5f7296a4f48 100644 --- a/web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v443/migrate-default.sql +++ b/web/src/main/webapp/WEB-INF/classes/setup/sql/migrate/v443/migrate-default.sql @@ -1,4 +1,7 @@ UPDATE Settings SET value='4.4.3' WHERE name='system/platform/version'; UPDATE Settings SET value='SNAPSHOT' WHERE name='system/platform/subVersion'; + +INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/documentation/url', 'https://docs.geonetwork-opensource.org/{{version}}/{{lang}}', 0, 570, 'n'); INSERT INTO Settings (name, value, datatype, position, internal) VALUES ('system/userFeedback/metadata/enable', 'false', 2, 1913, 'n'); +