Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
b632fc1d
Commit
b632fc1d
authored
Oct 25, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_js_style: publish the page current language
parent
78cf1c94
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
76 additions
and
5 deletions
+76
-5
bt5/erp5_web_js_style/SkinTemplateItem/portal_skins/erp5_web_js_style_ui/dialog_main.zpt
...ateItem/portal_skins/erp5_web_js_style_ui/dialog_main.zpt
+1
-1
bt5/erp5_web_js_style/SkinTemplateItem/portal_skins/erp5_web_js_style_ui/jsstyle.js.js
...plateItem/portal_skins/erp5_web_js_style_ui/jsstyle.js.js
+7
-3
bt5/erp5_web_js_style/SkinTemplateItem/portal_skins/erp5_web_js_style_ui/view_main.zpt
...plateItem/portal_skins/erp5_web_js_style_ui/view_main.zpt
+1
-1
bt5/erp5_web_js_style_test/PathTemplateItem/portal_tests/js_style_zuite/testJsStyleWebSiteChangeLanguage.zpt
...tests/js_style_zuite/testJsStyleWebSiteChangeLanguage.zpt
+20
-0
bt5/erp5_web_js_style_test/PathTemplateItem/portal_tests/js_style_zuite/testJsStyleWebSiteChangeLanguageWithLanguageBaseUrl.zpt
...e/testJsStyleWebSiteChangeLanguageWithLanguageBaseUrl.zpt
+20
-0
bt5/erp5_web_js_style_test/PathTemplateItem/portal_tests/js_style_zuite/testJsStyleWebSiteChangeLanguageWithWebSiteBaseUrl.zpt
...te/testJsStyleWebSiteChangeLanguageWithWebSiteBaseUrl.zpt
+20
-0
bt5/erp5_web_js_style_test/SkinTemplateItem/portal_skins/erp5_web_js_style_test/jsstyle_demo.html.html
...ortal_skins/erp5_web_js_style_test/jsstyle_demo.html.html
+1
-0
bt5/erp5_web_js_style_test/SkinTemplateItem/portal_skins/erp5_web_js_style_test/jsstyle_demo.js.js
...em/portal_skins/erp5_web_js_style_test/jsstyle_demo.js.js
+6
-0
No files found.
bt5/erp5_web_js_style/SkinTemplateItem/portal_skins/erp5_web_js_style_ui/dialog_main.zpt
View file @
b632fc1d
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
current_language python: web_site.getPortalObject().Localizer.get_selected_language();
current_language python: web_site.getPortalObject().Localizer.get_selected_language();
global_definitions_macros here/global_definitions/macros;"
>
global_definitions_macros here/global_definitions/macros;"
>
<tal:block
metal:use-macro=
"global_definitions_macros/header_definitions"
/>
<tal:block
metal:use-macro=
"global_definitions_macros/header_definitions"
/>
<html>
<html
tal:attributes=
"lang current_language"
>
<head>
<head>
<base
tal:attributes=
"href python: '%s/' % web_section.absolute_url()"
/>
<base
tal:attributes=
"href python: '%s/' % web_section.absolute_url()"
/>
<meta
name=
"viewport"
content=
"width=device-width,height=device-height,initial-scale=1"
/>
<meta
name=
"viewport"
content=
"width=device-width,height=device-height,initial-scale=1"
/>
...
...
bt5/erp5_web_js_style/SkinTemplateItem/portal_skins/erp5_web_js_style_ui/jsstyle.js.js
View file @
b632fc1d
...
@@ -145,7 +145,7 @@
...
@@ -145,7 +145,7 @@
return
result
;
return
result
;
}
}
function
parsePageContent
(
body_element
,
base_uri
)
{
function
parsePageContent
(
body_element
,
language
,
base_uri
)
{
var
i
,
var
i
,
element
,
element
,
element_list
,
element_list
,
...
@@ -174,6 +174,7 @@
...
@@ -174,6 +174,7 @@
return
{
return
{
original_content
:
body_element
.
innerHTML
,
original_content
:
body_element
.
innerHTML
,
html_content
:
body_element
.
querySelector
(
'
main
'
).
innerHTML
,
html_content
:
body_element
.
querySelector
(
'
main
'
).
innerHTML
,
language
:
language
,
language_list
:
parseLanguageElement
(
language_list
:
parseLanguageElement
(
body_element
.
querySelector
(
'
nav#language
'
)
body_element
.
querySelector
(
'
nav#language
'
)
),
),
...
@@ -215,7 +216,9 @@
...
@@ -215,7 +216,9 @@
// consider this must be reloaded
// consider this must be reloaded
throw
new
Error
(
'
Trigger an error to force reload
'
);
throw
new
Error
(
'
Trigger an error to force reload
'
);
}
}
parsed_content
=
parsePageContent
(
dom_parser
.
body
,
dom_parser
.
baseURI
);
parsed_content
=
parsePageContent
(
dom_parser
.
body
,
dom_parser
.
documentElement
.
lang
,
dom_parser
.
baseURI
);
gadget
.
parsed_content
=
parsed_content
;
gadget
.
parsed_content
=
parsed_content
;
parsed_content
.
page_title
=
dom_parser
.
title
;
parsed_content
.
page_title
=
dom_parser
.
title
;
return
result_dict
.
style_gadget
.
render
(
parsed_content
.
html_content
,
return
result_dict
.
style_gadget
.
render
(
parsed_content
.
html_content
,
...
@@ -312,7 +315,8 @@
...
@@ -312,7 +315,8 @@
return
rJS
.
declareCSS
(
style_css_url
,
document
.
head
);
return
rJS
.
declareCSS
(
style_css_url
,
document
.
head
);
}
}
parsed_content
=
parsePageContent
(
gadget
.
element
);
parsed_content
=
parsePageContent
(
gadget
.
element
,
document
.
documentElement
.
lang
);
gadget
.
parsed_content
=
parsed_content
;
gadget
.
parsed_content
=
parsed_content
;
parsed_content
.
page_title
=
document
.
title
;
parsed_content
.
page_title
=
document
.
title
;
gadget
.
style_gadget_url
=
gadget
.
style_gadget_url
=
...
...
bt5/erp5_web_js_style/SkinTemplateItem/portal_skins/erp5_web_js_style_ui/view_main.zpt
View file @
b632fc1d
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
current_language python: web_site.getPortalObject().Localizer.get_selected_language();
current_language python: web_site.getPortalObject().Localizer.get_selected_language();
global_definitions_macros here/global_definitions/macros;"
>
global_definitions_macros here/global_definitions/macros;"
>
<tal:block
metal:use-macro=
"global_definitions_macros/header_definitions"
/>
<tal:block
metal:use-macro=
"global_definitions_macros/header_definitions"
/>
<html>
<html
tal:attributes=
"lang current_language"
>
<head>
<head>
<base
tal:attributes=
"href python: '%s/' % web_section.absolute_url()"
/>
<base
tal:attributes=
"href python: '%s/' % web_section.absolute_url()"
/>
<meta
name=
"viewport"
content=
"width=device-width,height=device-height,initial-scale=1"
/>
<meta
name=
"viewport"
content=
"width=device-width,height=device-height,initial-scale=1"
/>
...
...
bt5/erp5_web_js_style_test/PathTemplateItem/portal_tests/js_style_zuite/testJsStyleWebSiteChangeLanguage.zpt
View file @
b632fc1d
...
@@ -45,6 +45,11 @@
...
@@ -45,6 +45,11 @@
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'en')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
...
@@ -83,6 +88,11 @@
...
@@ -83,6 +88,11 @@
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'fr')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
...
@@ -121,6 +131,11 @@
...
@@ -121,6 +131,11 @@
<td>
//main//p[text()="主页内容"]
</td>
<td>
//main//p[text()="主页内容"]
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'zh')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()="主页内容"]
</td>
<td>
//main//p[text()="主页内容"]
</td>
...
@@ -159,6 +174,11 @@
...
@@ -159,6 +174,11 @@
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'en')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
...
...
bt5/erp5_web_js_style_test/PathTemplateItem/portal_tests/js_style_zuite/testJsStyleWebSiteChangeLanguageWithLanguageBaseUrl.zpt
View file @
b632fc1d
...
@@ -45,6 +45,11 @@
...
@@ -45,6 +45,11 @@
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'en')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
...
@@ -83,6 +88,11 @@
...
@@ -83,6 +88,11 @@
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'fr')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
...
@@ -121,6 +131,11 @@
...
@@ -121,6 +131,11 @@
<td>
//main//p[text()="主页内容"]
</td>
<td>
//main//p[text()="主页内容"]
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'zh')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()="主页内容"]
</td>
<td>
//main//p[text()="主页内容"]
</td>
...
@@ -159,6 +174,11 @@
...
@@ -159,6 +174,11 @@
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'en')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
...
...
bt5/erp5_web_js_style_test/PathTemplateItem/portal_tests/js_style_zuite/testJsStyleWebSiteChangeLanguageWithWebSiteBaseUrl.zpt
View file @
b632fc1d
...
@@ -45,6 +45,11 @@
...
@@ -45,6 +45,11 @@
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'en')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
...
@@ -78,6 +83,11 @@
...
@@ -78,6 +83,11 @@
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'fr')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
<td>
//main//p[text()="Contenu de la page d'accueil"]
</td>
...
@@ -111,6 +121,11 @@
...
@@ -111,6 +121,11 @@
<td>
//main//p[text()="主页内容"]
</td>
<td>
//main//p[text()="主页内容"]
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'zh')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()="主页内容"]
</td>
<td>
//main//p[text()="主页内容"]
</td>
...
@@ -144,6 +159,11 @@
...
@@ -144,6 +159,11 @@
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td></td>
<td></td>
</tr>
</tr>
<tr>
<td>
assertElementPresent
</td>
<td>
//p[@id='current_language'][contains(text(), 'en')]
</td>
<td></td>
</tr>
<tr>
<tr>
<td>
assertElementPresent
</td>
<td>
assertElementPresent
</td>
<td>
//main//p[text()='Frontpage content']
</td>
<td>
//main//p[text()='Frontpage content']
</td>
...
...
bt5/erp5_web_js_style_test/SkinTemplateItem/portal_skins/erp5_web_js_style_test/jsstyle_demo.html.html
View file @
b632fc1d
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
<p
id=
"gadget_style_url"
></p>
<p
id=
"gadget_style_url"
></p>
<p
id=
"render_count"
></p>
<p
id=
"render_count"
></p>
<p
id=
"portal_status_message"
></p>
<p
id=
"portal_status_message"
></p>
<p
id=
"current_language"
></p>
<nav
id=
"language"
></nav>
<nav
id=
"language"
></nav>
<nav
id=
"sitemap"
></nav>
<nav
id=
"sitemap"
></nav>
<aside
id=
"document_list"
></aside>
<aside
id=
"document_list"
></aside>
...
...
bt5/erp5_web_js_style_test/SkinTemplateItem/portal_skins/erp5_web_js_style_test/jsstyle_demo.js.js
View file @
b632fc1d
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
.
declareMethod
(
"
render
"
,
function
(
html_content
,
parsed_content
)
{
.
declareMethod
(
"
render
"
,
function
(
html_content
,
parsed_content
)
{
var
state
=
{
var
state
=
{
document_list
:
JSON
.
stringify
(
parsed_content
.
document_list
||
[]),
document_list
:
JSON
.
stringify
(
parsed_content
.
document_list
||
[]),
current_language
:
parsed_content
.
language
||
""
,
language_list
:
JSON
.
stringify
(
parsed_content
.
language_list
||
[]),
language_list
:
JSON
.
stringify
(
parsed_content
.
language_list
||
[]),
sitemap
:
JSON
.
stringify
(
parsed_content
.
sitemap
||
{}),
sitemap
:
JSON
.
stringify
(
parsed_content
.
sitemap
||
{}),
page_title
:
parsed_content
.
page_title
||
""
,
page_title
:
parsed_content
.
page_title
||
""
,
...
@@ -87,6 +88,11 @@
...
@@ -87,6 +88,11 @@
text
:
'
render count:
'
+
gadget
.
state
.
render_count
text
:
'
render count:
'
+
gadget
.
state
.
render_count
});
});
}
}
if
(
modification_dict
.
hasOwnProperty
(
'
current_language
'
))
{
domsugar
(
gadget
.
element
.
querySelector
(
'
p#current_language
'
),
{
text
:
gadget
.
state
.
current_language
});
}
if
(
modification_dict
.
hasOwnProperty
(
'
language_list
'
))
{
if
(
modification_dict
.
hasOwnProperty
(
'
language_list
'
))
{
language_list
=
JSON
.
parse
(
gadget
.
state
.
language_list
);
language_list
=
JSON
.
parse
(
gadget
.
state
.
language_list
);
child_list
=
[];
child_list
=
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment