From 91b82fa2bdb1900eb9ce6a821bbb6fc7343d6dac Mon Sep 17 00:00:00 2001 From: wangf1122 <74916635+wangf1122@users.noreply.github.com> Date: Sat, 14 Dec 2024 07:18:14 -0500 Subject: [PATCH] support section variable in manual url (#8494) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * support section variable in manual url * isoLang variable, help wording * Revert "isoLang variable, help wording" This reverts commit 0b000ce2 * ignore path "/" for default language replacement * Update web-ui/src/main/resources/catalog/locales/en-admin.json Co-authored-by: Jose García * remove double slash * remove double slash in error handler --------- Co-authored-by: Jose García --- .../common/needhelp/NeedHelpDirective.js | 34 ++++++++++++++++--- .../resources/catalog/locales/en-admin.json | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) 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 0ca87cb85c0..f47e68e93e6 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 @@ -140,6 +140,18 @@ return defer.promise; }; + /** + * Processes an URL removing // characters in the URL path. + * + * @param url + * @returns {string} + */ + var processUrl = function(url) { + var urlToProcess = new URL(url); + urlToProcess.pathname = urlToProcess.pathname.replace(/\/\//g, "/"); + return urlToProcess.toString(); + } + /** * Get the URL of the corresponding help page and open it in a new tab * @returns {boolean} @@ -152,20 +164,34 @@ if (gnGlobalSettings.lang !== "en") { baseUrl = scope.helpBaseUrl.replace("{{lang}}", gnGlobalSettings.lang); } else { - baseUrl = scope.helpBaseUrl.replace("/{{lang}}", ""); + baseUrl = scope.helpBaseUrl.replace("{{lang}}", ""); } baseUrl = baseUrl.replace("{{version}}", scope.applicationVersion); - var helpPageUrl = baseUrl + "/" + page; + var helpPageUrl; + if (baseUrl.includes("{{section}}")) { + helpPageUrl = baseUrl.replace("{{section}}", page); + } else { + helpPageUrl = baseUrl + "/" + page; + } + + helpPageUrl = processUrl(helpPageUrl); testAndOpen(helpPageUrl).then( function () {}, function () { var baseUrl = scope.helpBaseUrl - .replace("/{{lang}}", "") + .replace("{{lang}}", "") .replace("{{version}}", scope.applicationVersion); - var helpPageUrl = baseUrl + "/" + page; + var helpPageUrl; + if (baseUrl.includes("{{section}}")) { + helpPageUrl = baseUrl.replace("{{section}}", page); + } else { + helpPageUrl = baseUrl + "/" + page; + } + + helpPageUrl = processUrl(helpPageUrl); 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 8dce8d1887c..43e15b7548d 100644 --- a/web-ui/src/main/resources/catalog/locales/en-admin.json +++ b/web-ui/src/main/resources/catalog/locales/en-admin.json @@ -633,7 +633,7 @@ "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/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, \\{\\{version\\}\\} placeholder to use the application version, and \\{\\{section\\}\\} placeholder to parse sub section url from manual.json of the current page. When the \\{\\{section\\}\\} placeholder is not provided, the sub section value is automatically appended to the end of the url.", "system/csw": "Catalog Service for the Web (CSW)", "system/csw/capabilityRecordUuid": "Record to use for GetCapabilities", "system/csw/capabilityRecordUuid-help": "Choose the record to be used to build custom GetCapabilities document. If none exist, create a service metadata record (using ISO19139 or 19115-3 standards). To have a capabilities document with the main information required, set title, abstract, point of contact, keywords, constraints. If you need INSPIRE support also set properly the record main language and additional languages, INSPIRE themes and INSPIRE conformity.",