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
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
erp5
Commits
5960d9fe
Commit
5960d9fe
authored
Apr 02, 2020
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: refactor web section create configuration manifest action
parent
6900195c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
145 additions
and
227 deletions
+145
-227
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSection_createAppConfigurationManifest.py
..._officejs_ui/WebSection_createAppConfigurationManifest.py
+59
-0
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSection_createAppConfigurationManifest.xml
...officejs_ui/WebSection_createAppConfigurationManifest.xml
+62
-0
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSection_getBase64ConfigurationUrlList.py
...b_officejs_ui/WebSection_getBase64ConfigurationUrlList.py
+18
-70
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSection_getBase64ConfigurationUrlList.xml
..._officejs_ui/WebSection_getBase64ConfigurationUrlList.xml
+1
-1
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSite_createAppConfigurationManifest.xml
...eb_officejs_ui/WebSite_createAppConfigurationManifest.xml
+5
-2
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSite_createAppConfigurationManifest/my_appcache_manifest.xml
...e_createAppConfigurationManifest/my_appcache_manifest.xml
+0
-154
No files found.
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSection_createAppConfigurationManifest.py
0 → 100644
View file @
5960d9fe
from
datetime
import
datetime
def
getElementFromContent
(
key
,
content
):
before_template
=
'"%s" type="text/x-renderjs-configuration">'
before
=
before_template
%
key
after
=
'</script>'
start
=
content
.
find
(
before
)
+
len
(
before
)
stop
=
content
.
find
(
after
,
start
)
result
=
content
[
start
:
stop
]
if
(
not
"<"
in
result
)
and
(
not
">"
in
result
)
and
(
result
!=
""
):
return
result
return
None
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
date
=
datetime
.
now
().
strftime
(
"%c"
)
try
:
router_file_reference
=
context
.
getLayoutProperty
(
"configuration_router_gadget_url"
,
default
=
""
)
if
router_file_reference
is
""
:
raise
ValueError
(
"Router Gadget Layout Property is missing"
)
router_file
=
portal_catalog
.
getResultValue
(
portal_type
=
'Web Page'
,
reference
=
router_file_reference
)
if
router_file
is
None
:
raise
ValueError
(
"Router web page '%s' not found"
%
router_file_reference
)
router_content
=
router_file
.
getTextContent
()
configuration_file_reference
=
getElementFromContent
(
"configuration_manifest"
,
router_content
)
if
configuration_file_reference
is
None
or
configuration_file_reference
is
""
:
raise
ValueError
(
"configuration_manifest router setting is missing"
)
configuration_manifest
=
portal_catalog
.
getResultValue
(
portal_type
=
'Web Manifest'
,
reference
=
configuration_file_reference
)
if
configuration_manifest
is
None
:
module
=
portal
.
getDefaultModule
(
'Web Page'
)
configuration_manifest
=
module
.
newContent
(
portal_type
=
'Web Manifest'
,
reference
=
configuration_file_reference
)
configuration_manifest
.
publish
()
url_list
=
context
.
WebSection_getBase64ConfigurationUrlList
(
batch_mode
=
"0"
)
configuration_element_lines_string
=
""
for
path
in
url_list
:
configuration_element_lines_string
+=
path
+
"
\
n
"
content
=
"CONFIGURATION MANIFEST
\
n
# generated on %s
\
n
CACHE:
\
n
\
n
"
%
date
content
+=
configuration_element_lines_string
content
+=
"
\
n
NETWORK:
\
n
*"
configuration_manifest
.
setTextContent
(
content
)
except
(
ValueError
,
KeyError
,
SyntaxError
,
AttributeError
)
as
e
:
if
batch_mode
:
return
'ERROR: '
+
str
(
e
)
return
context
.
Base_redirect
(
'view'
,
keep_items
=
dict
(
portal_status_message
=
'ERROR creating configuration manifest: '
+
str
(
e
)))
if
batch_mode
:
return
'done'
return
context
.
Base_redirect
(
'view'
,
keep_items
=
dict
(
portal_status_message
=
"Configuration manifest created: "
+
configuration_file_reference
))
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSection_createAppConfigurationManifest.xml
0 → 100644
View file @
5960d9fe
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
batch_mode=0
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
WebSection_createAppConfigurationManifest
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/
Base_createAppConfigurationManife
st.py
→
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/
WebSection_getBase64ConfigurationUrlLi
st.py
View file @
5960d9fe
import
json
import
json
import
base64
import
base64
from
datetime
import
datetime
from
Products.ERP5Type.Log
import
log
def
getElementFromContent
(
key
,
content
):
def
getElementFromContent
(
key
,
content
):
before_template
=
'"%s" type="text/x-renderjs-configuration">'
before_template
=
'"%s" type="text/x-renderjs-configuration">'
...
@@ -19,48 +19,27 @@ portal_catalog = portal.portal_catalog
...
@@ -19,48 +19,27 @@ portal_catalog = portal.portal_catalog
try
:
try
:
hateoas_appcache
=
context
.
getLayoutProperty
(
"hateoas_appcache"
,
default
=
"hateoas_appcache"
)
hateoas_appcache
=
context
.
getLayoutProperty
(
"hateoas_appcache"
,
default
=
"hateoas_appcache"
)
router_file_reference
=
context
.
getLayoutProperty
(
"configuration_router_gadget_url"
,
default
=
""
)
router_file_reference
=
context
.
getLayoutProperty
(
"configuration_router_gadget_url"
,
default
=
""
)
if
router_file_reference
is
""
:
if
router_file_reference
is
""
:
raise
ValueError
(
"Router Gadget Layout Property is missing"
)
raise
ValueError
(
"Router Gadget Layout Property is missing"
)
appcache_file_reference
=
context
.
getLayoutProperty
(
"configuration_manifest_url"
,
default
=
""
)
result_list
=
portal_catalog
.
getDocumentValueList
(
if
appcache_file_reference
is
""
:
portal_type
=
'Web Page'
,
raise
ValueError
(
"Manifest URL Layout Property is missing"
)
reference
=
router_file_reference
,
validation_state
=
'published%'
)
router_file
=
portal_catalog
.
getResultValue
(
if
len
(
result_list
)
==
0
:
portal_type
=
'Web Page'
,
reference
=
router_file_reference
)
if
router_file
is
None
:
raise
ValueError
(
"Router web page '%s' not found"
%
router_file_reference
)
raise
ValueError
(
"Router web page '%s' not found"
%
router_file_reference
)
router_content
=
result_list
[
0
].
getTextContent
()
appcache_manifest
=
portal_catalog
.
getResultValue
(
portal_type
=
'Web Manifest'
,
reference
=
appcache_file_reference
)
if
appcache_manifest
is
None
:
raise
ValueError
(
"Appcache manifest '%s' not found"
%
appcache_file_reference
)
router_content
=
router_file
.
getTextContent
()
configuration_file_reference
=
getElementFromContent
(
"configuration_manifest"
,
router_content
)
if
configuration_file_reference
is
None
or
configuration_file_reference
is
""
:
raise
ValueError
(
"configuration_manifest router setting is missing"
)
configuration_manifest
=
portal_catalog
.
getResultValue
(
portal_type
=
'Web Manifest'
,
reference
=
configuration_file_reference
)
if
configuration_manifest
is
None
:
module
=
portal
.
getDefaultModule
(
'Web Page'
)
configuration_manifest
=
module
.
newContent
(
portal_type
=
'Web Manifest'
,
reference
=
configuration_file_reference
)
configuration_manifest
.
publish
()
portal_skin
=
getElementFromContent
(
"portal_skin_folder"
,
router_content
)
portal_skin
=
getElementFromContent
(
"portal_skin_folder"
,
router_content
)
if
portal_skin
is
None
:
if
portal_skin
is
None
:
raise
KeyError
(
"portal_skin_folder setting not found in router"
)
raise
KeyError
(
"portal_skin_folder setting not found in router"
)
app_action_string
=
getElementFromContent
(
"app_actions"
,
router_content
)
app_action_string
=
getElementFromContent
(
"app_actions"
,
router_content
)
if
app_action_string
is
None
:
if
app_action_string
is
None
:
raise
KeyError
(
"app_actions setting not found in router"
)
raise
KeyError
(
"app_actions setting not found in router"
)
date
=
datetime
.
now
().
strftime
(
"%c"
)
app_action_list
=
[]
app_action_list
=
[]
app_action_string
=
app_action_string
.
replace
(
'('
,
'['
).
replace
(
')'
,
']'
).
replace
(
',]'
,
']'
).
replace
(
"'"
,
'"'
)
app_action_string
=
app_action_string
.
replace
(
'('
,
'['
).
replace
(
')'
,
']'
).
replace
(
',]'
,
']'
).
replace
(
"'"
,
'"'
)
app_action_raw_list
=
json
.
loads
(
app_action_string
)
app_action_raw_list
=
json
.
loads
(
app_action_string
)
for
app_action
in
app_action_raw_list
:
for
app_action
in
app_action_raw_list
:
...
@@ -88,7 +67,6 @@ try:
...
@@ -88,7 +67,6 @@ try:
new_dialog_form_list
.
append
(
str
(
portal_type_dict
[
"new_content_dialog_form"
]))
new_dialog_form_list
.
append
(
str
(
portal_type_dict
[
"new_content_dialog_form"
]))
configuration_path_list
=
[]
configuration_path_list
=
[]
for
key
in
portal_actions_dict
:
for
key
in
portal_actions_dict
:
path
=
"portal_types/%s"
%
key
path
=
"portal_types/%s"
%
key
configuration_path_list
.
append
(
base64
.
b64encode
(
path
))
configuration_path_list
.
append
(
base64
.
b64encode
(
path
))
...
@@ -108,44 +86,14 @@ try:
...
@@ -108,44 +86,14 @@ try:
path
=
"portal_skins/%s/%s"
%
(
portal_skin
,
form
)
path
=
"portal_skins/%s/%s"
%
(
portal_skin
,
form
)
configuration_path_list
.
append
(
base64
.
b64encode
(
path
))
configuration_path_list
.
append
(
base64
.
b64encode
(
path
))
configuration_element_lines
=
""
url_list
=
[]
for
path
in
configuration_path_list
:
for
path
in
configuration_path_list
:
configuration_element_lines
+=
hateoas_appcache
+
"/definition_view/"
+
path
+
"
\
n
"
url_list
.
append
(
hateoas_appcache
+
"/definition_view/"
+
path
)
content
=
"CONFIGURATION MANIFEST
\
n
# generated on %s
\
n
CACHE:
\
n
\
n
"
%
date
content
+=
configuration_element_lines
content
+=
"
\
n
NETWORK:
\
n
*"
configuration_manifest
.
setTextContent
(
content
)
appcache_configuration_elements
=
"#app_configuration_resources
\
n
"
appcache_configuration_elements
+=
"#CONFIGURATION ELEMENTS generated on %s. Same as in configuration manifest
\
n
"
%
date
appcache_configuration_elements
+=
configuration_element_lines
appcache_configuration_elements
+=
"#/app_configuration_resources
\
n
\
n
"
token_found
=
False
configuration_added
=
False
appcache_content
=
""
appcache_line_list
=
appcache_manifest
.
getTextContent
().
split
(
'
\
n
'
)
for
line
in
appcache_line_list
:
if
"#app_configuration_resources"
in
line
:
token_found
=
True
if
"NETWORK:"
in
line
and
not
configuration_added
:
appcache_content
+=
appcache_configuration_elements
configuration_added
=
True
if
"#/app_configuration_resources"
in
line
:
appcache_content
+=
appcache_configuration_elements
configuration_added
=
True
token_found
=
False
if
not
token_found
:
if
not
"#/app_configuration_resources"
in
line
:
appcache_content
+=
line
+
'
\
n
'
appcache_manifest
.
setTextContent
(
appcache_content
)
except
(
ValueError
,
KeyError
,
SyntaxError
)
as
e
:
return
url_list
if
batch_mode
:
return
'ERROR: '
+
str
(
e
)
return
context
.
Base_redirect
(
'view'
,
keep_items
=
dict
(
portal_status_message
=
'ERROR creating configuration manifest: '
+
str
(
e
)))
if
batch_mode
:
except
(
ValueError
,
KeyError
,
SyntaxError
,
AttributeError
)
as
e
:
return
'done'
if
batch_mode
==
"0"
:
return
context
.
Base_redirect
(
'view'
,
keep_items
=
dict
(
portal_status_message
=
"Configuration manifest created: "
+
configuration_file_reference
))
raise
e
log
(
'ERROR generating Base64 configuration url list: '
+
str
(
e
))
return
[]
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/
Base_createAppConfigurationManife
st.xml
→
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/
WebSection_getBase64ConfigurationUrlLi
st.xml
View file @
5960d9fe
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
id
</string>
</key>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_createAppConfigurationManife
st
</string>
</value>
<value>
<string>
WebSection_getBase64ConfigurationUrlLi
st
</string>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
...
...
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSite_createAppConfigurationManifest.xml
View file @
5960d9fe
...
@@ -14,7 +14,11 @@
...
@@ -14,7 +14,11 @@
</item>
</item>
<item>
<item>
<key>
<string>
action
</string>
</key>
<key>
<string>
action
</string>
</key>
<value>
<string>
Base_createAppConfigurationManifest
</string>
</value>
<value>
<string>
WebSection_createAppConfigurationManifest
</string>
</value>
</item>
<item>
<key>
<string>
action_title
</string>
</key>
<value>
<string></string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
description
</string>
</key>
<key>
<string>
description
</string>
</key>
...
@@ -74,7 +78,6 @@
...
@@ -74,7 +78,6 @@
<key>
<string>
left
</string>
</key>
<key>
<string>
left
</string>
</key>
<value>
<value>
<list>
<list>
<string>
my_appcache_manifest
</string>
<string>
my_router_gadget
</string>
<string>
my_router_gadget
</string>
</list>
</list>
</value>
</value>
...
...
bt5/erp5_officejs/SkinTemplateItem/portal_skins/erp5_web_officejs_ui/WebSite_createAppConfigurationManifest/my_appcache_manifest.xml
deleted
100644 → 0
View file @
6900195c
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"LabelField"
module=
"Products.Formulator.StandardFields"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
my_appcache_manifest
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary/>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
css_class
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
editable
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
extra
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
hidden
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
css_class
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
default
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
editable
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
extra
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
hidden
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
css_class
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
editable
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
enabled
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
extra
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
hidden
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Manifest URL:
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"TALESMethod"
module=
"Products.Formulator.TALESField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_text
</string>
</key>
<value>
<string>
python: here.getLayoutProperty("configuration_manifest_url")
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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