diff options
author | Jan Holesovsky <kendy@collabora.com> | 2018-08-14 16:34:25 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-08-16 09:13:39 +0200 |
commit | 73023bcc0dba68f6677bc02cdad75145180e2b11 (patch) | |
tree | 66fa7eb6279cd0752e012e286c422b1162d96cea | |
parent | 0d068dc8d5cd64f89c8a8e3d0a6bef6ed9e1ee87 (diff) |
Limit the online help only to the built languages.
Change-Id: Ib81dbd9a4047d9bb63761a43ef0b183a450b03f1
Reviewed-on: https://gerrit.libreoffice.org/59047
Tested-by: Jenkins
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r-- | CustomTarget_html.mk | 9 | ||||
-rw-r--r-- | Package_html_dynamic.mk | 1 | ||||
-rw-r--r-- | help3xsl/help2.js | 17 | ||||
-rw-r--r-- | help3xsl/index2.html | 9 |
4 files changed, 30 insertions, 6 deletions
diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk index 58f7b7aaf2..ad383a0085 100644 --- a/CustomTarget_html.mk +++ b/CustomTarget_html.mk @@ -16,6 +16,7 @@ html_BMARK_MODULES := swriter:WRITER scalc:CALC simpress:IMPRESS sdraw:DRAW shar $(eval $(call gb_CustomTarget_register_targets,helpcontent2/help3xsl,\ hid2file.js \ + languages.js \ $(foreach lang,$(gb_HELP_LANGS),\ $(lang)/bookmarks.js \ $(lang)/contents.js \ @@ -46,6 +47,14 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/hid2file.js : \ ) > $@ \ ) +$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/languages.js : \ + $(SRCDIR)/helpcontent2/CustomTarget_html.mk + ( \ + echo -n 'var languagesSet = new Set([' ; \ + for lang in $(gb_HELP_LANGS) ; do echo -n "'$$lang', " ; done | sed 's/, $$//' ; \ + echo ']);' \ + ) > $@ + define html_gen_contents_html_dep $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/contents.part : $(call gb_HelpTarget__get_treefile,$(1),$(3)) $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/contents.part : TREE_FILE := $(call gb_HelpTarget__get_treefile,$(1),$(3)) diff --git a/Package_html_dynamic.mk b/Package_html_dynamic.mk index 7af53ecb8d..8c0c2fe5b4 100644 --- a/Package_html_dynamic.mk +++ b/Package_html_dynamic.mk @@ -13,6 +13,7 @@ $(eval $(call gb_Package_use_customtarget,helpcontent2_html_dynamic,helpcontent2 $(eval $(call gb_Package_add_files,helpcontent2_html_dynamic,$(LIBO_SHARE_HELP_FOLDER)$(if $(HELP_ONLINE),/$(PRODUCTVERSION)), \ hid2file.js \ + languages.js \ )) # vim: set noet sw=4 ts=4: diff --git a/help3xsl/help2.js b/help3xsl/help2.js index 0e7b9d3325..aed610371b 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -120,4 +120,21 @@ function getParameterByName(name, url) { } return decodeURIComponent(results[2].replace(/\+/g, " ")); } + +function existingLang(lang) { + if (lang === undefined) { + return 'en-US'; + } + + if (languagesSet.has(lang)) { + return lang; + } + + lang = lang.replace(/[-_].*/, ''); + if (languagesSet.has(lang)) { + return lang; + } + + return 'en-US'; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/help3xsl/index2.html b/help3xsl/index2.html index 6a9a1a6c8e..ad12320433 100644 --- a/help3xsl/index2.html +++ b/help3xsl/index2.html @@ -11,6 +11,7 @@ <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval' piwik.documentfoundation.org *.google.com *.googleapis.com"/> <script type="text/javascript" src="help2.js"></script> <script type="text/javascript" src="hid2file.js"></script> + <script type="text/javascript" src="languages.js"></script> </head> <body> <script type="text/javascript"> @@ -20,7 +21,7 @@ // the URL came from LibreOffice help (F1) var target = getParameterByName("Target",url); var version = getParameterByName("Version",url); - var lang = getParameterByName("Language",url); + var lang = existingLang(getParameterByName("Language", url)); var system = getParameterByName("System",url); var module; var defaultFile; @@ -54,11 +55,7 @@ window.location.href = newURL; } else { // URL came from elsewhere, direct access to webroot, we redirect to main Help page - var userLang = navigator.language; - if (userLang === undefined) { - userlang="en-US"; - } - window.location.href = userLang + '/text/shared/main0108.html?&DbPAR=WRITER&System=WIN'; + window.location.href = existingLang(navigator.language) + '/text/shared/main0108.html?&DbPAR=WRITER&System=WIN'; } </script> </body> |