Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support section variable in manual url #8494

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,30 @@
if (gnGlobalSettings.lang !== "en") {
baseUrl = scope.helpBaseUrl.replace("{{lang}}", gnGlobalSettings.lang);
} else {
baseUrl = scope.helpBaseUrl.replace("/{{lang}}", "");
baseUrl = scope.helpBaseUrl.replace("{{lang}}", "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be "."

i.e. there are 2 urls.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think about it, it does not make sense to user "." either because someone could use ?lang={{lang}} and it would be odd to add "." and ?lang=. would not make sense!
So I guess "" is better in this case.
Maybe there could be another replace on the url after the replace to remove all the double "//"

As for why there is a odd case where lang = ""
What if it treated gnGlobalSettings.lang !== "en" as if gnGlobalSettings.lang = null?
Then {{lang?en}} could mean that if lang is null then default to en
So you could add another replacement for the following.
baseUrl = scope.helpBaseUrl.replace("{{lang?en}}", "");

So gn could use
https://docs.geonetwork-opensource.org/4.2/{{lang}}/api/search/
And other sites that always want to have a language value for language could use
https://example.com/{{lang?en}}/api/search/?lang={{lang?en}} and it would result to en value.
But this would still be odd logic.

}

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add the "/"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the default original code.

The default manual.json of each section contains was appended at the end of the url and they contain no such "/". So the Javascript has to add them

"creating-metadata": "user-guide/describing-information/creating-metadata/",

}

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;
}

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 @@ -632,7 +632,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.",
Expand Down