Skip to content

Commit

Permalink
System setting for documentation url (#7782)
Browse files Browse the repository at this point in the history
* System setting for documentation url

* System setting for documentation url - version placeholder
  • Loading branch information
josegar74 authored Feb 22, 2024
1 parent 63f1649 commit 761e167
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -60,17 +70,28 @@
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) {
scope.checkUrl();
}
});

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
*/
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions web-ui/src/main/resources/catalog/locales/en-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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');

0 comments on commit 761e167

Please sign in to comment.