Skip to content

Commit

Permalink
[Backport 4.2.x] Support section variable in manual url (#8494) (#8566)
Browse files Browse the repository at this point in the history
* support section variable in manual url (#8494)

* support section variable in manual url

* isoLang variable, help wording

* Revert "isoLang variable, help wording"

This reverts commit 0b000ce

* ignore path "/" for default language replacement

* Update web-ui/src/main/resources/catalog/locales/en-admin.json

Co-authored-by: Jose García <[email protected]>

* remove double slash

* remove double slash in error handler

---------

Co-authored-by: Jose García <[email protected]>

* support section variable in manual url (#8494)

* support section variable in manual url

* isoLang variable, help wording

* Revert "isoLang variable, help wording"

This reverts commit 0b000ce

* ignore path "/" for default language replacement

* Update web-ui/src/main/resources/catalog/locales/en-admin.json

Co-authored-by: Jose García <[email protected]>

* remove double slash

* remove double slash in error handler

---------

Co-authored-by: Jose García <[email protected]>

* Update NeedHelpDirective.js

prettier plugin reformating

---------

Co-authored-by: Jose García <[email protected]>
  • Loading branch information
wangf1122 and josegar74 authored Dec 16, 2024
1 parent 04eed35 commit ee95560
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion web-ui/src/main/resources/catalog/locales/en-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,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/publication": "Publication",
"system/publication/doi/doienabled": "Allow creation of Digital Object Identifier (DOI)",
"system/publication/doi/doipattern": "DOI pattern",
Expand Down

0 comments on commit ee95560

Please sign in to comment.