collective.documentgenerator 4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- collective/documentgenerator/DX_renderer.py +51 -0
- collective/documentgenerator/__init__.py +11 -0
- collective/documentgenerator/adapters.py +30 -0
- collective/documentgenerator/browser/__init__.py +0 -0
- collective/documentgenerator/browser/actionspanel.py +19 -0
- collective/documentgenerator/browser/check_pod_templates.pt +86 -0
- collective/documentgenerator/browser/children_pod_template.pt +27 -0
- collective/documentgenerator/browser/configure.zcml +217 -0
- collective/documentgenerator/browser/controlpanel.py +165 -0
- collective/documentgenerator/browser/generation_view.py +613 -0
- collective/documentgenerator/browser/overrides.py +9 -0
- collective/documentgenerator/browser/resources/css/documentgenerator.css +133 -0
- collective/documentgenerator/browser/static/.gitkeep +0 -0
- collective/documentgenerator/browser/static/configurable.svg +1232 -0
- collective/documentgenerator/browser/static/csv.svg +521 -0
- collective/documentgenerator/browser/static/doc.svg +23 -0
- collective/documentgenerator/browser/static/docx.svg +20 -0
- collective/documentgenerator/browser/static/download_icon.svg +54 -0
- collective/documentgenerator/browser/static/libreoffice-blanck.svg +481 -0
- collective/documentgenerator/browser/static/mailinglooptemplate.svg +1207 -0
- collective/documentgenerator/browser/static/missing_use.svg +42 -0
- collective/documentgenerator/browser/static/nok.svg +38 -0
- collective/documentgenerator/browser/static/nok_use.svg +38 -0
- collective/documentgenerator/browser/static/nok_used.svg +38 -0
- collective/documentgenerator/browser/static/odp.svg +1264 -0
- collective/documentgenerator/browser/static/ods.svg +1354 -0
- collective/documentgenerator/browser/static/odt.svg +1347 -0
- collective/documentgenerator/browser/static/ok.svg +38 -0
- collective/documentgenerator/browser/static/ok_use.svg +38 -0
- collective/documentgenerator/browser/static/ok_used.svg +38 -0
- collective/documentgenerator/browser/static/pdf.svg +557 -0
- collective/documentgenerator/browser/static/podtemplate.svg +1197 -0
- collective/documentgenerator/browser/static/rtf.svg +521 -0
- collective/documentgenerator/browser/static/style.svg +1207 -0
- collective/documentgenerator/browser/static/subtemplate.svg +1232 -0
- collective/documentgenerator/browser/static/xls.svg +159 -0
- collective/documentgenerator/browser/static/xlsx.svg +48 -0
- collective/documentgenerator/browser/table.py +326 -0
- collective/documentgenerator/browser/templates_listing.pt +29 -0
- collective/documentgenerator/browser/views.py +366 -0
- collective/documentgenerator/config.py +174 -0
- collective/documentgenerator/configure.zcml +51 -0
- collective/documentgenerator/content/__init__.py +0 -0
- collective/documentgenerator/content/condition.py +66 -0
- collective/documentgenerator/content/conditions.zcml +30 -0
- collective/documentgenerator/content/configure.zcml +18 -0
- collective/documentgenerator/content/document_factory.py +73 -0
- collective/documentgenerator/content/file_representation.py +70 -0
- collective/documentgenerator/content/file_representation.zcml +29 -0
- collective/documentgenerator/content/merge_templates.py +15 -0
- collective/documentgenerator/content/merge_templates.zcml +11 -0
- collective/documentgenerator/content/pod_template.py +601 -0
- collective/documentgenerator/content/style_template.py +54 -0
- collective/documentgenerator/content/vocabulary.py +344 -0
- collective/documentgenerator/content/vocabulary.zcml +105 -0
- collective/documentgenerator/demo/__init__.py +0 -0
- collective/documentgenerator/demo/configure.zcml +18 -0
- collective/documentgenerator/demo/helper.py +170 -0
- collective/documentgenerator/events/__init__.py +0 -0
- collective/documentgenerator/events/configure.zcml +44 -0
- collective/documentgenerator/events/pod_templates_events.py +66 -0
- collective/documentgenerator/events/styles_events.py +151 -0
- collective/documentgenerator/helper/__init__.py +7 -0
- collective/documentgenerator/helper/base.py +334 -0
- collective/documentgenerator/helper/configure.zcml +34 -0
- collective/documentgenerator/helper/dexterity.py +178 -0
- collective/documentgenerator/interfaces.py +166 -0
- collective/documentgenerator/locales/collective.documentgenerator.pot +564 -0
- collective/documentgenerator/locales/es/LC_MESSAGES/collective.documentgenerator.po +572 -0
- collective/documentgenerator/locales/es/LC_MESSAGES/plone.po +32 -0
- collective/documentgenerator/locales/fr/LC_MESSAGES/collective.documentgenerator.po +566 -0
- collective/documentgenerator/locales/fr/LC_MESSAGES/plone.po +27 -0
- collective/documentgenerator/locales/manual.pot +30 -0
- collective/documentgenerator/locales/plone-manual.pot +22 -0
- collective/documentgenerator/locales/plone.pot +30 -0
- collective/documentgenerator/locales/update.sh +22 -0
- collective/documentgenerator/migrations/__init__.py +0 -0
- collective/documentgenerator/migrations/migrate_to_11.py +52 -0
- collective/documentgenerator/migrations/migrate_to_12.py +32 -0
- collective/documentgenerator/migrations/migrate_to_13.py +35 -0
- collective/documentgenerator/migrations/migrate_to_3.py +36 -0
- collective/documentgenerator/migrations/migrate_to_5.py +30 -0
- collective/documentgenerator/migrations/migrate_to_6.py +27 -0
- collective/documentgenerator/migrations/migrate_to_7.py +34 -0
- collective/documentgenerator/migrations/migrate_to_8.py +36 -0
- collective/documentgenerator/migrations/migrate_to_9.py +50 -0
- collective/documentgenerator/profiles/base/browserlayer.xml +6 -0
- collective/documentgenerator/profiles/base/controlpanel.xml +21 -0
- collective/documentgenerator/profiles/base/metadata.xml +8 -0
- collective/documentgenerator/profiles/base/registry.xml +48 -0
- collective/documentgenerator/profiles/base/types/ConfigurablePODTemplate.xml +69 -0
- collective/documentgenerator/profiles/base/types/MailingLoopTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types/PODTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types/StyleTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types/SubTemplate.xml +68 -0
- collective/documentgenerator/profiles/base/types.xml +22 -0
- collective/documentgenerator/profiles/base/viewlets.xml +10 -0
- collective/documentgenerator/profiles/demo/browserlayer.xml +6 -0
- collective/documentgenerator/profiles/demo/collectivedocumentgenerator_demo_marker.txt +0 -0
- collective/documentgenerator/profiles/demo/import_steps.xml +11 -0
- collective/documentgenerator/profiles/demo/metadata.xml +7 -0
- collective/documentgenerator/profiles/demo/registry.xml +14 -0
- collective/documentgenerator/profiles/demo/templates/mailing.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/modele_general.ods +0 -0
- collective/documentgenerator/profiles/demo/templates/modele_general.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/mod/303/250le_collection.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/possibly_mailed_model.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/styles.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/styles_2.odt +0 -0
- collective/documentgenerator/profiles/demo/templates/sub_template.odt +0 -0
- collective/documentgenerator/profiles/demo/viewlets.xml +3 -0
- collective/documentgenerator/profiles/testing/metadata.xml +7 -0
- collective/documentgenerator/profiles/testing/types/member.xml +114 -0
- collective/documentgenerator/profiles/testing/types.xml +9 -0
- collective/documentgenerator/profiles/uninstall/browserlayer.xml +7 -0
- collective/documentgenerator/profiles/uninstall/controlpanel.xml +21 -0
- collective/documentgenerator/profiles/uninstall/metadata.xml +4 -0
- collective/documentgenerator/profiles/uninstall/registry.xml +14 -0
- collective/documentgenerator/profiles/uninstall/types.xml +27 -0
- collective/documentgenerator/profiles/uninstall/viewlets.xml +8 -0
- collective/documentgenerator/profiles.zcml +209 -0
- collective/documentgenerator/renderer.zcml +36 -0
- collective/documentgenerator/search_replace/__init__.py +0 -0
- collective/documentgenerator/search_replace/configure.zcml +21 -0
- collective/documentgenerator/search_replace/pod_template.py +161 -0
- collective/documentgenerator/search_replace/search_result_form.pt +76 -0
- collective/documentgenerator/search_replace/searchreplace_panel.pt +31 -0
- collective/documentgenerator/search_replace/searchreplace_panel.py +274 -0
- collective/documentgenerator/setuphandlers.py +297 -0
- collective/documentgenerator/testing.py +278 -0
- collective/documentgenerator/testing.zcml +17 -0
- collective/documentgenerator/tests/__init__.py +0 -0
- collective/documentgenerator/tests/failing_template.odt +0 -0
- collective/documentgenerator/tests/robot/.gitkeep +0 -0
- collective/documentgenerator/tests/template_to_clean.odt +0 -0
- collective/documentgenerator/tests/template_without_style_page.odt +0 -0
- collective/documentgenerator/tests/test_DX_helper_view.py +398 -0
- collective/documentgenerator/tests/test_base_helper_view.py +216 -0
- collective/documentgenerator/tests/test_check_podtemplates_view.py +138 -0
- collective/documentgenerator/tests/test_config.py +119 -0
- collective/documentgenerator/tests/test_configurable_pod_template.py +467 -0
- collective/documentgenerator/tests/test_demo_profile.py +121 -0
- collective/documentgenerator/tests/test_events.py +187 -0
- collective/documentgenerator/tests/test_generation_view.py +680 -0
- collective/documentgenerator/tests/test_mailing_loop_template.py +48 -0
- collective/documentgenerator/tests/test_pod_template.py +190 -0
- collective/documentgenerator/tests/test_robot.py +26 -0
- collective/documentgenerator/tests/test_search_replace.py +485 -0
- collective/documentgenerator/tests/test_setup.py +77 -0
- collective/documentgenerator/tests/test_style_template.py +19 -0
- collective/documentgenerator/tests/test_sub_template.py +49 -0
- collective/documentgenerator/tests/test_templates_listing_view.py +120 -0
- collective/documentgenerator/tests/test_utils.py +205 -0
- collective/documentgenerator/tests/test_vocabulary.py +169 -0
- collective/documentgenerator/utils.py +245 -0
- collective/documentgenerator/viewlets/__init__.py +0 -0
- collective/documentgenerator/viewlets/batchactions.py +14 -0
- collective/documentgenerator/viewlets/configure.zcml +17 -0
- collective/documentgenerator/viewlets/generationlinks.pt +46 -0
- collective/documentgenerator/viewlets/generationlinks.py +67 -0
- collective.documentgenerator-4.0-py3.12-nspkg.pth +1 -0
- collective_documentgenerator-4.0.dist-info/METADATA +1136 -0
- collective_documentgenerator-4.0.dist-info/RECORD +167 -0
- collective_documentgenerator-4.0.dist-info/WHEEL +5 -0
- collective_documentgenerator-4.0.dist-info/entry_points.txt +2 -0
- collective_documentgenerator-4.0.dist-info/namespace_packages.txt +1 -0
- collective_documentgenerator-4.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<configure
|
|
2
|
+
xmlns="http://namespaces.zope.org/zope"
|
|
3
|
+
xmlns:five="http://namespaces.zope.org/five"
|
|
4
|
+
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
|
|
5
|
+
xmlns:i18n="http://namespaces.zope.org/i18n"
|
|
6
|
+
xmlns:zcml="http://namespaces.zope.org/zcml"
|
|
7
|
+
i18n_domain="collective.documentgenerator"
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
<genericsetup:registerProfile
|
|
11
|
+
name="default"
|
|
12
|
+
title="collective.documentgenerator"
|
|
13
|
+
description="Installs the collective.documentgenerator add-on."
|
|
14
|
+
provides="Products.GenericSetup.interfaces.EXTENSION"
|
|
15
|
+
directory="profiles/base"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<genericsetup:registerProfile
|
|
19
|
+
name="uninstall"
|
|
20
|
+
title="collective.documentgenerator uninstall"
|
|
21
|
+
description="Uninstalls the collective.documentgenerator add-on."
|
|
22
|
+
provides="Products.GenericSetup.interfaces.EXTENSION"
|
|
23
|
+
directory="profiles/uninstall"
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<genericsetup:registerProfile
|
|
27
|
+
name="demo"
|
|
28
|
+
title="collective.documentgenerator demo"
|
|
29
|
+
description="Installs the collective.documentgenerator demo profile."
|
|
30
|
+
provides="Products.GenericSetup.interfaces.EXTENSION"
|
|
31
|
+
directory="profiles/demo"
|
|
32
|
+
/>
|
|
33
|
+
|
|
34
|
+
<genericsetup:importStep
|
|
35
|
+
name="collectivedocumentgenerator-postInstall"
|
|
36
|
+
title="collective.documentgenerator post_install import step"
|
|
37
|
+
description="Post install import step from collective.documentgenerator"
|
|
38
|
+
handler=".setuphandlers.post_install"
|
|
39
|
+
>
|
|
40
|
+
</genericsetup:importStep>
|
|
41
|
+
|
|
42
|
+
<genericsetup:upgradeSteps
|
|
43
|
+
profile="collective.documentgenerator:default"
|
|
44
|
+
source="1"
|
|
45
|
+
destination="2"
|
|
46
|
+
>
|
|
47
|
+
<genericsetup:upgradeDepends
|
|
48
|
+
title="Reapply registry.xml"
|
|
49
|
+
description="This will add new parameter 'optimize_tables'"
|
|
50
|
+
import_steps="plone.app.registry"
|
|
51
|
+
/>
|
|
52
|
+
<genericsetup:upgradeDepends
|
|
53
|
+
title="Reapply controlpanel"
|
|
54
|
+
description="This will update title and icon that changed"
|
|
55
|
+
import_steps="controlpanel"
|
|
56
|
+
/>
|
|
57
|
+
</genericsetup:upgradeSteps>
|
|
58
|
+
|
|
59
|
+
<genericsetup:upgradeStep
|
|
60
|
+
title="collective.documentgenerator: upgrade to 3"
|
|
61
|
+
profile="collective.documentgenerator:default"
|
|
62
|
+
source="2"
|
|
63
|
+
destination="3"
|
|
64
|
+
handler="collective.documentgenerator.migrations.migrate_to_3.migrate"
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
<genericsetup:upgradeSteps
|
|
68
|
+
profile="collective.documentgenerator:default"
|
|
69
|
+
source="3"
|
|
70
|
+
destination="4"
|
|
71
|
+
>
|
|
72
|
+
<genericsetup:upgradeDepends
|
|
73
|
+
title="Reapply registry.xml"
|
|
74
|
+
description="This will add new parameter 'enable_raiseOnError_for_non_managers'"
|
|
75
|
+
import_steps="plone.app.registry"
|
|
76
|
+
/>
|
|
77
|
+
</genericsetup:upgradeSteps>
|
|
78
|
+
|
|
79
|
+
<genericsetup:upgradeStep
|
|
80
|
+
title="collective.documentgenerator: upgrade to 5"
|
|
81
|
+
profile="collective.documentgenerator:default"
|
|
82
|
+
source="4"
|
|
83
|
+
destination="5"
|
|
84
|
+
handler="collective.documentgenerator.migrations.migrate_to_5.migrate"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<genericsetup:upgradeStep
|
|
88
|
+
title="collective.documentgenerator: upgrade to 6"
|
|
89
|
+
profile="collective.documentgenerator:default"
|
|
90
|
+
source="5"
|
|
91
|
+
destination="6"
|
|
92
|
+
handler="collective.documentgenerator.migrations.migrate_to_6.migrate"
|
|
93
|
+
/>
|
|
94
|
+
|
|
95
|
+
<genericsetup:upgradeStep
|
|
96
|
+
title="collective.documentgenerator: upgrade to 7"
|
|
97
|
+
profile="collective.documentgenerator:default"
|
|
98
|
+
source="6"
|
|
99
|
+
destination="7"
|
|
100
|
+
handler="collective.documentgenerator.migrations.migrate_to_7.migrate"
|
|
101
|
+
/>
|
|
102
|
+
|
|
103
|
+
<genericsetup:upgradeStep
|
|
104
|
+
title="collective.documentgenerator: upgrade to 8"
|
|
105
|
+
profile="collective.documentgenerator:default"
|
|
106
|
+
source="7"
|
|
107
|
+
destination="8"
|
|
108
|
+
handler="collective.documentgenerator.migrations.migrate_to_8.migrate"
|
|
109
|
+
/>
|
|
110
|
+
|
|
111
|
+
<genericsetup:upgradeSteps
|
|
112
|
+
profile="collective.documentgenerator:default"
|
|
113
|
+
source="8"
|
|
114
|
+
destination="9"
|
|
115
|
+
>
|
|
116
|
+
<genericsetup:upgradeDepends
|
|
117
|
+
title="Reapply registry.xml"
|
|
118
|
+
description="This will add new parameter 'column_modifier'"
|
|
119
|
+
import_steps="plone.app.registry"
|
|
120
|
+
/>
|
|
121
|
+
<genericsetup:upgradeStep
|
|
122
|
+
title="collective.documentgenerator: upgrade to 9"
|
|
123
|
+
description="This will migrate old parameter 'optimize_tables' to new parameter 'column_modifier'"
|
|
124
|
+
handler="collective.documentgenerator.migrations.migrate_to_9.migrate"
|
|
125
|
+
/>
|
|
126
|
+
</genericsetup:upgradeSteps>
|
|
127
|
+
|
|
128
|
+
<genericsetup:upgradeSteps
|
|
129
|
+
profile="collective.documentgenerator:default"
|
|
130
|
+
source="9"
|
|
131
|
+
destination="10"
|
|
132
|
+
>
|
|
133
|
+
<genericsetup:upgradeDepends
|
|
134
|
+
title="Reapply registry.xml"
|
|
135
|
+
description="This will add new parameter 'oo_server' and 'use_stream'"
|
|
136
|
+
import_steps="plone.app.registry"
|
|
137
|
+
/>
|
|
138
|
+
</genericsetup:upgradeSteps>
|
|
139
|
+
|
|
140
|
+
<genericsetup:upgradeSteps
|
|
141
|
+
profile="collective.documentgenerator:default"
|
|
142
|
+
source="10"
|
|
143
|
+
destination="11"
|
|
144
|
+
>
|
|
145
|
+
<genericsetup:upgradeStep
|
|
146
|
+
title="collective.documentgenerator: upgrade to 11"
|
|
147
|
+
description="This will migrate the use_stream parameter"
|
|
148
|
+
handler="collective.documentgenerator.migrations.migrate_to_11.migrate"
|
|
149
|
+
/>
|
|
150
|
+
</genericsetup:upgradeSteps>
|
|
151
|
+
|
|
152
|
+
<genericsetup:upgradeSteps
|
|
153
|
+
profile="collective.documentgenerator:default"
|
|
154
|
+
source="11"
|
|
155
|
+
destination="12"
|
|
156
|
+
>
|
|
157
|
+
<genericsetup:upgradeStep
|
|
158
|
+
title="collective.documentgenerator: upgrade to 12"
|
|
159
|
+
description="This apply new svg icons"
|
|
160
|
+
handler="collective.documentgenerator.migrations.migrate_to_12.migrate"
|
|
161
|
+
/>
|
|
162
|
+
</genericsetup:upgradeSteps>
|
|
163
|
+
|
|
164
|
+
<genericsetup:upgradeSteps
|
|
165
|
+
profile="collective.documentgenerator:default"
|
|
166
|
+
source="12"
|
|
167
|
+
destination="13"
|
|
168
|
+
>
|
|
169
|
+
<genericsetup:upgradeStep
|
|
170
|
+
title="collective.documentgenerator: upgrade to 13"
|
|
171
|
+
description="Apply clean_notes on every existing POD templates"
|
|
172
|
+
handler="collective.documentgenerator.migrations.migrate_to_13.migrate"
|
|
173
|
+
/>
|
|
174
|
+
</genericsetup:upgradeSteps>
|
|
175
|
+
|
|
176
|
+
<genericsetup:upgradeSteps
|
|
177
|
+
profile="collective.documentgenerator:default"
|
|
178
|
+
source="13"
|
|
179
|
+
destination="14"
|
|
180
|
+
>
|
|
181
|
+
<genericsetup:upgradeDepends
|
|
182
|
+
title="Reapply registry.xml"
|
|
183
|
+
description="This will add new parameter 'oo_port_list'"
|
|
184
|
+
import_steps="plone.app.registry"
|
|
185
|
+
/>
|
|
186
|
+
</genericsetup:upgradeSteps>
|
|
187
|
+
|
|
188
|
+
<genericsetup:upgradeSteps
|
|
189
|
+
profile="collective.documentgenerator:default"
|
|
190
|
+
source="14"
|
|
191
|
+
destination="15"
|
|
192
|
+
>
|
|
193
|
+
<genericsetup:upgradeDepends
|
|
194
|
+
title="Reapply registry.xml"
|
|
195
|
+
description="This will add new parameter 'force_default_page_style_for_mailing'"
|
|
196
|
+
import_steps="plone.app.registry"
|
|
197
|
+
/>
|
|
198
|
+
</genericsetup:upgradeSteps>
|
|
199
|
+
|
|
200
|
+
<utility
|
|
201
|
+
factory=".setuphandlers.HiddenProfiles"
|
|
202
|
+
name="collective.documentgenerator"
|
|
203
|
+
/>
|
|
204
|
+
<utility
|
|
205
|
+
factory=".setuphandlers.HiddenProducts"
|
|
206
|
+
name="collective.documentgenerator"
|
|
207
|
+
/>
|
|
208
|
+
|
|
209
|
+
</configure>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<configure
|
|
2
|
+
xmlns="http://namespaces.zope.org/zope"
|
|
3
|
+
xmlns:i18n="http://namespaces.zope.org/i18n"
|
|
4
|
+
xmlns:zcml="http://namespaces.zope.org/zcml"
|
|
5
|
+
i18n_domain="collective.documentgenerator"
|
|
6
|
+
>
|
|
7
|
+
|
|
8
|
+
<!-- Dexterity -->
|
|
9
|
+
<adapter
|
|
10
|
+
factory="collective.documentgenerator.DX_renderer.DexterityExportableAdapter"
|
|
11
|
+
provides="collective.documentgenerator.interfaces.IFieldRendererForDocument"
|
|
12
|
+
for="zope.schema.interfaces.IField
|
|
13
|
+
zope.interface.Interface
|
|
14
|
+
zope.interface.Interface"
|
|
15
|
+
permission="zope2.View"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<adapter
|
|
19
|
+
factory="collective.documentgenerator.DX_renderer.DexterityDateExportableAdapter"
|
|
20
|
+
provides="collective.documentgenerator.interfaces.IFieldRendererForDocument"
|
|
21
|
+
for="zope.schema.interfaces.IDate
|
|
22
|
+
zope.interface.Interface
|
|
23
|
+
zope.interface.Interface"
|
|
24
|
+
permission="zope2.View"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
<adapter
|
|
28
|
+
factory="collective.documentgenerator.DX_renderer.DexterityDatetimeExportableAdapter"
|
|
29
|
+
provides="collective.documentgenerator.interfaces.IFieldRendererForDocument"
|
|
30
|
+
for="zope.schema.interfaces.IDatetime
|
|
31
|
+
zope.interface.Interface
|
|
32
|
+
zope.interface.Interface"
|
|
33
|
+
permission="zope2.View"
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
</configure>
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<configure
|
|
2
|
+
xmlns="http://namespaces.zope.org/zope"
|
|
3
|
+
xmlns:browser="http://namespaces.zope.org/browser"
|
|
4
|
+
xmlns:i18n="http://namespaces.zope.org/i18n"
|
|
5
|
+
xmlns:zcml="http://namespaces.zope.org/zcml"
|
|
6
|
+
i18n_domain="collective.documentgenerator"
|
|
7
|
+
>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<browser:page
|
|
11
|
+
name="collective.documentgenerator-searchreplacepanel"
|
|
12
|
+
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
|
|
13
|
+
class="collective.documentgenerator.search_replace.searchreplace_panel.DocumentGeneratorSearchReplace"
|
|
14
|
+
template="searchreplace_panel.pt"
|
|
15
|
+
permission="cmf.ManagePortal"
|
|
16
|
+
layer="..interfaces.ICollectiveDocumentGeneratorLayer"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<adapter factory=".searchreplace_panel.DocumentGeneratorSearchReplacePanelAdapter" />
|
|
20
|
+
|
|
21
|
+
</configure>
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
from appy.bin.ogrep import Grep
|
|
2
|
+
from collective.documentgenerator.browser.generation_view import HAS_FINGERPOINTING
|
|
3
|
+
from collective.documentgenerator.utils import get_site_root_relative_path
|
|
4
|
+
from collective.documentgenerator.utils import temporary_file_name
|
|
5
|
+
from plone.namedfile import NamedBlobFile
|
|
6
|
+
from Products.CMFPlone.utils import safe_unicode
|
|
7
|
+
|
|
8
|
+
import collections
|
|
9
|
+
import mimetypes
|
|
10
|
+
import os
|
|
11
|
+
import shutil
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
SearchReplaceResult = collections.namedtuple(
|
|
15
|
+
"SearchReplaceResult",
|
|
16
|
+
["pod_expr", "match_start", "match_end", "match", "node_type", "new_pod_expr"],
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SearchAndReplacePODTemplates:
|
|
21
|
+
"""
|
|
22
|
+
Search and replace POD expression among PODTemplates.
|
|
23
|
+
Use it like this:
|
|
24
|
+
with SearchAndReplacePODTemplates(podtemplate_obj) as search_replace:
|
|
25
|
+
search_results = search_replace.search('WhatISearch')
|
|
26
|
+
replace_results = search_replace.replace('^WillBeReplaced$', 'ByThis', is_regex=True)
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(self, podtemplates):
|
|
30
|
+
"""
|
|
31
|
+
:param podtemplates: List of PODTemplate objects
|
|
32
|
+
"""
|
|
33
|
+
self.podtemplates = podtemplates
|
|
34
|
+
self.templates_by_filename = {}
|
|
35
|
+
self.tmp_dir = temporary_file_name(suffix="search_replace")
|
|
36
|
+
self.changed_files = set()
|
|
37
|
+
|
|
38
|
+
# compute the (future) file system path of the plone pod templates
|
|
39
|
+
for podtemplate in podtemplates:
|
|
40
|
+
if not podtemplate.odt_file or not podtemplate.odt_file.filename:
|
|
41
|
+
continue # ignore templates referring another pod template.
|
|
42
|
+
file_extension = podtemplate.odt_file.filename.split(".")[-1].lower()
|
|
43
|
+
template_path = get_site_root_relative_path(podtemplate)
|
|
44
|
+
fs_filename = "{}/{}.{}".format(
|
|
45
|
+
self.tmp_dir, template_path.replace("/", "_"), file_extension
|
|
46
|
+
)
|
|
47
|
+
self.templates_by_filename[fs_filename] = {
|
|
48
|
+
"obj": podtemplate,
|
|
49
|
+
"path": template_path,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
def __enter__(self):
|
|
53
|
+
"""
|
|
54
|
+
copy the plone pod template content on the file system
|
|
55
|
+
"""
|
|
56
|
+
os.mkdir(self.tmp_dir)
|
|
57
|
+
for filename in self.templates_by_filename.keys():
|
|
58
|
+
# clean old files
|
|
59
|
+
if os.path.isfile(filename):
|
|
60
|
+
os.remove(filename)
|
|
61
|
+
# copy the pod templates on the file system.
|
|
62
|
+
with open(filename, "wb") as template_file:
|
|
63
|
+
plone_template = self.templates_by_filename[filename]["obj"]
|
|
64
|
+
template_file.write(plone_template.odt_file.data)
|
|
65
|
+
return self
|
|
66
|
+
|
|
67
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
68
|
+
# push the result back into the site pod templates
|
|
69
|
+
for filename in self.changed_files:
|
|
70
|
+
with open(filename, "rb") as replaced_file:
|
|
71
|
+
podtemplate = self.templates_by_filename[filename]["obj"]
|
|
72
|
+
result = NamedBlobFile(
|
|
73
|
+
data=replaced_file.read(),
|
|
74
|
+
contentType=podtemplate.odt_file.contentType
|
|
75
|
+
or mimetypes.guess_type(filename)[0],
|
|
76
|
+
filename=podtemplate.odt_file.filename,
|
|
77
|
+
)
|
|
78
|
+
podtemplate.odt_file = result
|
|
79
|
+
# delete tmp directory
|
|
80
|
+
shutil.rmtree(self.tmp_dir)
|
|
81
|
+
|
|
82
|
+
def search(self, find_expr, is_regex=False):
|
|
83
|
+
"""
|
|
84
|
+
Search find_expr in self.podtemplates
|
|
85
|
+
:param find_expr: A regex str or simple string
|
|
86
|
+
:param is_regex: use is_regex=False if find_expr is not a regex
|
|
87
|
+
:return: a dict with podtemplate uid as key and list of SearchReplaceResult as value
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
grepper = Grep(
|
|
91
|
+
keyword=find_expr,
|
|
92
|
+
repl=None,
|
|
93
|
+
path=self.tmp_dir,
|
|
94
|
+
asString=not is_regex,
|
|
95
|
+
inContent=False,
|
|
96
|
+
dryRun=False,
|
|
97
|
+
verbose=0,
|
|
98
|
+
vverbose=0,
|
|
99
|
+
nice=0,
|
|
100
|
+
)
|
|
101
|
+
grepper.run()
|
|
102
|
+
results = self._prepare_results_output(grepper.matches, is_replacing=False)
|
|
103
|
+
return results
|
|
104
|
+
|
|
105
|
+
def replace(self, find_expr, replace_expr, is_regex=False, dry_run=False):
|
|
106
|
+
"""
|
|
107
|
+
Replace find_expr match with replace_expr in self.podtemplates
|
|
108
|
+
:param find_expr: A regex str or simple str
|
|
109
|
+
:param replace_expr: A str that will replace find_expr match
|
|
110
|
+
:param is_regex: Use is_regex=False if find_expr is not a regex
|
|
111
|
+
:param dry_run: Perform a dry run and not the actual replacement(s).
|
|
112
|
+
This will not modify the template(s) and can be used safely.
|
|
113
|
+
:return: a dict with podtemplate uid as key and list of SearchReplaceResult as value
|
|
114
|
+
"""
|
|
115
|
+
grepper = Grep(
|
|
116
|
+
keyword=find_expr,
|
|
117
|
+
path=self.tmp_dir,
|
|
118
|
+
repl=replace_expr,
|
|
119
|
+
asString=not is_regex,
|
|
120
|
+
inContent=False,
|
|
121
|
+
dryRun=dry_run,
|
|
122
|
+
verbose=0,
|
|
123
|
+
vverbose=0,
|
|
124
|
+
nice=0,
|
|
125
|
+
)
|
|
126
|
+
grepper.run()
|
|
127
|
+
results = self._prepare_results_output(grepper.matches, is_replacing=False)
|
|
128
|
+
|
|
129
|
+
for filename in grepper.matches.keys():
|
|
130
|
+
self.changed_files.add(filename)
|
|
131
|
+
|
|
132
|
+
return results
|
|
133
|
+
|
|
134
|
+
def _prepare_results_output(self, matches, replace_expr="", is_replacing=True):
|
|
135
|
+
"""Prepare results output so we have a nice feedback when searching and replacing"""
|
|
136
|
+
results = {}
|
|
137
|
+
for file_path, file_results in matches.items():
|
|
138
|
+
template = self.templates_by_filename[file_path]["obj"]
|
|
139
|
+
template_uid = template.UID()
|
|
140
|
+
results[template_uid] = file_results
|
|
141
|
+
return results
|
|
142
|
+
|
|
143
|
+
@staticmethod
|
|
144
|
+
def _log_replace(template, match, replaced_by, old_pod_expr, new_pod_expr):
|
|
145
|
+
"""Log replacements if fingerpointing installed"""
|
|
146
|
+
if HAS_FINGERPOINTING:
|
|
147
|
+
from collective.fingerpointing.config import AUDIT_MESSAGE
|
|
148
|
+
from collective.fingerpointing.logger import log_info
|
|
149
|
+
from collective.fingerpointing.utils import get_request_information
|
|
150
|
+
|
|
151
|
+
# add logging message to fingerpointing log
|
|
152
|
+
user, ip = get_request_information()
|
|
153
|
+
action = "replace_in_template"
|
|
154
|
+
extras = u"podtemplate={0} match={1} replaced_by={2} old_pod_expr={3} new_pod_expr={4}".format(
|
|
155
|
+
"/".join(template.getPhysicalPath()),
|
|
156
|
+
match,
|
|
157
|
+
replaced_by,
|
|
158
|
+
old_pod_expr,
|
|
159
|
+
new_pod_expr,
|
|
160
|
+
)
|
|
161
|
+
log_info(safe_unicode(AUDIT_MESSAGE).format(user, ip, action, extras))
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
|
|
2
|
+
<div tal:condition="python: bool(view.get_results_table())"
|
|
3
|
+
i18n:domain="collective.documentgenerator"
|
|
4
|
+
>
|
|
5
|
+
<table class="datagridwidget-table-view search-replace-results"
|
|
6
|
+
style="margin-top: 0.5em"
|
|
7
|
+
tal:define="
|
|
8
|
+
templates python:view.get_results_table().items();
|
|
9
|
+
"
|
|
10
|
+
>
|
|
11
|
+
<thead>
|
|
12
|
+
<tr>
|
|
13
|
+
<th class="header"
|
|
14
|
+
i18n:translate=""
|
|
15
|
+
>
|
|
16
|
+
POD expression
|
|
17
|
+
</th>
|
|
18
|
+
<th class="header selected-header"
|
|
19
|
+
tal:condition="view/is_previewing"
|
|
20
|
+
i18n:translate=""
|
|
21
|
+
>
|
|
22
|
+
Selected
|
|
23
|
+
</th>
|
|
24
|
+
</tr>
|
|
25
|
+
</thead>
|
|
26
|
+
<tbody class="datagridwidget-tbody">
|
|
27
|
+
<tal:block repeat="template templates">
|
|
28
|
+
<tr class="header">
|
|
29
|
+
<td>
|
|
30
|
+
<div class="search-group"
|
|
31
|
+
tal:define="
|
|
32
|
+
template_url python:view.get_template_link(template[0]);
|
|
33
|
+
template_title python:view.get_template_breadcrumb(template[0]);
|
|
34
|
+
"
|
|
35
|
+
>
|
|
36
|
+
<a tal:content="template_title"
|
|
37
|
+
tal:attributes="
|
|
38
|
+
href template_url;
|
|
39
|
+
"
|
|
40
|
+
></a>
|
|
41
|
+
</div>
|
|
42
|
+
</td>
|
|
43
|
+
<td class="search-group"
|
|
44
|
+
tal:condition="view/is_previewing"
|
|
45
|
+
>
|
|
46
|
+
<input checked
|
|
47
|
+
name="selected_templates"
|
|
48
|
+
type="checkbox"
|
|
49
|
+
tal:attributes="
|
|
50
|
+
value python: template[0];
|
|
51
|
+
"
|
|
52
|
+
/>
|
|
53
|
+
</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tal:block repeat="result python:template[1]">
|
|
56
|
+
<tr>
|
|
57
|
+
<td colspan="2"
|
|
58
|
+
tal:condition="python:view.is_previewing()"
|
|
59
|
+
>
|
|
60
|
+
<span class="search-cell"
|
|
61
|
+
tal:content="structure python:result.content"
|
|
62
|
+
></span>
|
|
63
|
+
</td>
|
|
64
|
+
<td colspan="2"
|
|
65
|
+
tal:condition="python:not view.is_previewing()"
|
|
66
|
+
>
|
|
67
|
+
<span class="search-cell"
|
|
68
|
+
tal:content="structure python:view.display_diff(result)"
|
|
69
|
+
></span>
|
|
70
|
+
</td>
|
|
71
|
+
</tr>
|
|
72
|
+
</tal:block>
|
|
73
|
+
</tal:block>
|
|
74
|
+
</tbody>
|
|
75
|
+
</table>
|
|
76
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
|
2
|
+
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
|
3
|
+
xmlns:metal="http://xml.zope.org/namespaces/metal"
|
|
4
|
+
xmlns:tal="http://xml.zope.org/namespaces/tal"
|
|
5
|
+
lang="en"
|
|
6
|
+
metal:use-macro="here/prefs_main_template/macros/master"
|
|
7
|
+
xml:lang="en"
|
|
8
|
+
i18n:domain="collective.documentgenerator"
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
<metal:block fill-slot="top_slot"
|
|
12
|
+
tal:define="
|
|
13
|
+
dummy python:request.set('disable_border',1);
|
|
14
|
+
"
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
<body>
|
|
18
|
+
<div id="content"
|
|
19
|
+
metal:fill-slot="prefs_configlet_content"
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
<h1 class="documentFirstHeading"
|
|
23
|
+
tal:content="view/label"
|
|
24
|
+
>View Title</h1>
|
|
25
|
+
|
|
26
|
+
<div id="layout-contents">
|
|
27
|
+
<span tal:replace="structure view/contents"></span>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|