imio.smartweb.core 1.2.34__py3-none-any.whl → 1.2.37__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.
- imio/smartweb/core/browser/sitemap.py +52 -46
- imio/smartweb/core/contents/rest/utils.py +99 -0
- imio/smartweb/core/contents/sections/external_content/configure.zcml +29 -0
- imio/smartweb/core/contents/sections/external_content/view.pt +25 -7
- imio/smartweb/core/contents/sections/external_content/view_idelux_waste.pt +50 -0
- imio/smartweb/core/contents/sections/external_content/view_inbw_containers_affluence.pt +91 -0
- imio/smartweb/core/contents/sections/external_content/view_odwb_widget.pt +20 -0
- imio/smartweb/core/contents/sections/external_content/views.py +303 -124
- imio/smartweb/core/contents/sections/text/view.pt +1 -1
- imio/smartweb/core/interfaces.py +7 -0
- imio/smartweb/core/profiles/default/metadata.xml +1 -1
- imio/smartweb/core/profiles/default/registry/plone.xml +21 -4
- imio/smartweb/core/profiles/default/types/Collection.xml +13 -0
- imio/smartweb/core/profiles/default/types/File.xml +13 -0
- imio/smartweb/core/profiles/default/types/Image.xml +13 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.BlockLink.xml +5 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.CirkwiView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.DirectoryView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.EventsView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.Folder.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.NewsView.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.Page.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.PortalPage.xml +1 -0
- imio/smartweb/core/profiles/default/types/imio.smartweb.Procedure.xml +1 -0
- imio/smartweb/core/tests/test_section_external_content.py +23 -23
- imio/smartweb/core/tests/test_sections.py +3 -15
- imio/smartweb/core/tests/test_sitemap.py +41 -22
- imio/smartweb/core/upgrades/configure.zcml +36 -0
- imio/smartweb/core/upgrades/profiles/1053_to_1054/registry.xml +39 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/Collection.xml +13 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/File.xml +13 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/Image.xml +13 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.BlockLink.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.CirkwiView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.DirectoryView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.EventsView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Folder.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.NewsView.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Page.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.PortalPage.xml +12 -0
- imio/smartweb/core/upgrades/profiles/1054_to_1055/types/imio.smartweb.Procedure.xml +12 -0
- imio/smartweb/core/viewlets/configure.zcml +10 -0
- imio/smartweb/core/viewlets/external_content.py +13 -5
- imio/smartweb/core/viewlets/odwb_widget_header.pt +19 -0
- imio/smartweb/core/webcomponents/build/css/373.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/486.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/686.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/919.smartweb-webcomponents-compiled.css +1 -0
- imio/smartweb/core/webcomponents/build/css/smartweb-webcomponents-compiled.css +1 -1
- imio/smartweb/core/webcomponents/build/js/209.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/218.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/373.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/486.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/568.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/568.smartweb-webcomponents-compiled.js.LICENSE.txt +14 -0
- imio/smartweb/core/webcomponents/build/js/674.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/686.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/799.smartweb-webcomponents-compiled.js +2 -0
- imio/smartweb/core/webcomponents/build/js/804.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/919.smartweb-webcomponents-compiled.js +1 -0
- imio/smartweb/core/webcomponents/build/js/smartweb-webcomponents-compiled.js +1 -1
- imio/smartweb/core/webcomponents/src/utils/translation.js +2 -2
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/METADATA +28 -1
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/RECORD +74 -56
- imio/smartweb/core/webcomponents/build/css/323.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/css/392.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/css/528.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/css/647.smartweb-webcomponents-compiled.css +0 -1
- imio/smartweb/core/webcomponents/build/js/143.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/144.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/323.smartweb-webcomponents-compiled.js +0 -1
- imio/smartweb/core/webcomponents/build/js/392.smartweb-webcomponents-compiled.js +0 -1
- imio/smartweb/core/webcomponents/build/js/493.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/528.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/528.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -1
- imio/smartweb/core/webcomponents/build/js/647.smartweb-webcomponents-compiled.js +0 -1
- imio/smartweb/core/webcomponents/build/js/729.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/729.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -1
- imio/smartweb/core/webcomponents/build/js/9.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/969.smartweb-webcomponents-compiled.js +0 -2
- imio/smartweb/core/webcomponents/build/js/969.smartweb-webcomponents-compiled.js.LICENSE.txt +0 -642
- imio/smartweb/core/webcomponents/build/js/979.smartweb-webcomponents-compiled.js +0 -1
- /imio/smartweb/core/webcomponents/build/js/{9.smartweb-webcomponents-compiled.js.LICENSE.txt → 209.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio/smartweb/core/webcomponents/build/js/{143.smartweb-webcomponents-compiled.js.LICENSE.txt → 218.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio/smartweb/core/webcomponents/build/js/{493.smartweb-webcomponents-compiled.js.LICENSE.txt → 674.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio/smartweb/core/webcomponents/build/js/{144.smartweb-webcomponents-compiled.js.LICENSE.txt → 799.smartweb-webcomponents-compiled.js.LICENSE.txt} +0 -0
- /imio.smartweb.core-1.2.34-py3.10-nspkg.pth → /imio.smartweb.core-1.2.37-py3.10-nspkg.pth +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/LICENSE.GPL +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/LICENSE.rst +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/WHEEL +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/namespace_packages.txt +0 -0
- {imio.smartweb.core-1.2.34.dist-info → imio.smartweb.core-1.2.37.dist-info}/top_level.txt +0 -0
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
from embeddify import Embedder
|
4
4
|
from embeddify import Plugin
|
5
|
+
|
6
|
+
from imio.smartweb.core.interfaces import IOdwbViewUtils
|
5
7
|
from imio.smartweb.core.contents.sections.views import SectionView
|
6
8
|
from imio.smartweb.core.interfaces import IArcgisViewUtils
|
7
9
|
from imio.smartweb.locales import SmartwebMessageFactory as _
|
@@ -11,12 +13,22 @@ from plone.app.contenttypes.behaviors.leadimage import ILeadImage
|
|
11
13
|
from Products.Five.browser import BrowserView
|
12
14
|
from zope.i18n import translate
|
13
15
|
from zope.interface import implementer
|
16
|
+
from zope.interface import Interface
|
17
|
+
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
|
14
18
|
|
15
19
|
import json
|
20
|
+
import logging
|
21
|
+
import requests
|
22
|
+
|
23
|
+
logger = logging.getLogger("imio.smartweb.core")
|
16
24
|
|
17
25
|
|
18
26
|
class ExternalContentView(SectionView):
|
19
|
-
|
27
|
+
|
28
|
+
plugin_config = {}
|
29
|
+
|
30
|
+
def __init__(self, context, request):
|
31
|
+
width = "100%"
|
20
32
|
current_lang = api.portal.get_current_language()[:2]
|
21
33
|
plugins = [
|
22
34
|
EaglebePlugin(),
|
@@ -24,10 +36,13 @@ class ExternalContentView(SectionView):
|
|
24
36
|
CognitoformPlugin(),
|
25
37
|
ArcgisPlugin(),
|
26
38
|
GiveADayPlugin(),
|
39
|
+
IdeluxWastePlugin(),
|
40
|
+
InbwContainersAffluencePlugin(),
|
41
|
+
OdwbWidgetPlugin(),
|
27
42
|
UnknowServicePlugin(),
|
28
43
|
]
|
29
|
-
extra_params =
|
30
|
-
plugin_config = {
|
44
|
+
extra_params = context.external_content_params
|
45
|
+
self.plugin_config = {
|
31
46
|
"eaglebeplugin": {"width": width},
|
32
47
|
"ellohaplugin": {
|
33
48
|
"width": width,
|
@@ -41,16 +56,39 @@ class ExternalContentView(SectionView):
|
|
41
56
|
},
|
42
57
|
"arcgisplugin": {
|
43
58
|
"width": width,
|
44
|
-
"url":
|
59
|
+
"url": context.absolute_url(),
|
45
60
|
"current_lang": current_lang,
|
46
61
|
"extra_params": extra_params,
|
47
62
|
},
|
48
63
|
"giveadayplugin": {},
|
64
|
+
"ideluxwasteplugin": {
|
65
|
+
"url": context.absolute_url(),
|
66
|
+
"extra_params": extra_params,
|
67
|
+
},
|
68
|
+
"inbwcontainersaffluenceplugin": {
|
69
|
+
"url": context.absolute_url(),
|
70
|
+
"extra_params": extra_params,
|
71
|
+
},
|
72
|
+
"odwbwidgetplugin": {
|
73
|
+
"url": context.absolute_url(),
|
74
|
+
"extra_params": extra_params,
|
75
|
+
},
|
49
76
|
"unknowserviceplugin": {"width": width, "current_lang": current_lang},
|
50
77
|
}
|
51
|
-
embedder = Embedder(plugins=plugins, plugin_config=plugin_config)
|
52
|
-
url =
|
53
|
-
|
78
|
+
embedder = Embedder(plugins=plugins, plugin_config=self.plugin_config)
|
79
|
+
url = context.external_content_url
|
80
|
+
self.plugin = embedder(url, config={"width": width})
|
81
|
+
super(ExternalContentView, self).__init__(context, request)
|
82
|
+
|
83
|
+
@property
|
84
|
+
def contents(self):
|
85
|
+
return self.plugin.contents
|
86
|
+
|
87
|
+
def display_odwb_widget_viewlet(self):
|
88
|
+
return self.plugin.is_odwb_widget_plugins
|
89
|
+
|
90
|
+
def render_viewlet(self):
|
91
|
+
return self.index()
|
54
92
|
|
55
93
|
def has_leadimage(self):
|
56
94
|
if ILeadImage.providedBy(self.context) and getattr(
|
@@ -59,161 +97,279 @@ class ExternalContentView(SectionView):
|
|
59
97
|
return True
|
60
98
|
return False
|
61
99
|
|
100
|
+
def get_plugin(self):
|
101
|
+
return self.plugin
|
102
|
+
|
103
|
+
def which_plugin(self):
|
104
|
+
if IOdwbWidgetPlugin.providedBy(self.plugin):
|
105
|
+
return "odwbwidgetplugin"
|
106
|
+
elif IIdeluxWastePlugin.providedBy(self.plugin):
|
107
|
+
return "ideluxwasteplugin"
|
108
|
+
elif IInbwContainersAffluencePlugin.providedBy(self.plugin):
|
109
|
+
return "inbwcontainersaffluenceplugin"
|
110
|
+
else:
|
111
|
+
return None
|
112
|
+
|
62
113
|
def image(self):
|
63
114
|
return f"{self.context.absolute_url()}/@@download/image"
|
64
115
|
|
65
116
|
|
66
|
-
class
|
117
|
+
class BasePlugin(Plugin):
|
118
|
+
""" """
|
119
|
+
|
120
|
+
is_odwb_widget_plugins = False
|
121
|
+
|
122
|
+
@property
|
123
|
+
def contents(self):
|
124
|
+
return ""
|
125
|
+
|
126
|
+
|
127
|
+
class EaglebePlugin(BasePlugin):
|
67
128
|
def __call__(self, parts, config={}):
|
129
|
+
self.parts = parts
|
130
|
+
self.config = config
|
68
131
|
if "app.eaglebe.com" in parts.netloc:
|
69
|
-
return
|
70
|
-
#
|
132
|
+
return self
|
71
133
|
return None
|
72
134
|
|
135
|
+
@property
|
136
|
+
def contents(self):
|
137
|
+
return f'<iframe class="eaglebe" src="{self.parts.geturl()}" scrolling="no" width="{self.config["width"]}">'
|
138
|
+
|
73
139
|
|
74
|
-
class EllohaPlugin(
|
140
|
+
class EllohaPlugin(BasePlugin):
|
75
141
|
def __call__(self, parts, config={}):
|
76
142
|
if "reservation.elloha.com" in parts.netloc:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
143
|
+
self.parts = parts
|
144
|
+
self.config = config
|
145
|
+
return self
|
146
|
+
return None
|
147
|
+
|
148
|
+
@property
|
149
|
+
def contents(self):
|
150
|
+
# sample :
|
151
|
+
# {
|
152
|
+
# "ConstellationWidgetContainer": "917c4c52-c997-4077-9135-873a0b2e0c85",
|
153
|
+
# "Idoi": "195ea849-1732-4a69-a051-e7911001cd09"
|
154
|
+
# }
|
155
|
+
current_lang = self.config["current_lang"]
|
156
|
+
extra_params = self.config["extra_params"]
|
157
|
+
error_message = _(
|
158
|
+
"With an elloha plugin, extra params must contain a dictionary with two keys : ConstellationWidgetContainer, Idoi"
|
159
|
+
)
|
160
|
+
error_message = translate(error_message, target_language=current_lang)
|
161
|
+
error_message = f'<div class="elloha elloha_error">{error_message}</div>'
|
162
|
+
|
163
|
+
if extra_params is None or extra_params[0] != "{" or extra_params[-1] != "}":
|
164
|
+
return error_message
|
165
|
+
try:
|
166
|
+
res = json.loads(extra_params.lower())
|
167
|
+
except JSONDecodeError:
|
168
|
+
return error_message
|
169
|
+
|
170
|
+
if res.get("constellationwidgetcontainer") is None or res.get("idoi") is None:
|
171
|
+
return error_message
|
172
|
+
|
173
|
+
cw1 = res.get("constellationwidgetcontainer")
|
174
|
+
cw2 = cw1.replace("-", "")
|
175
|
+
idoi = res.get("idoi")
|
176
|
+
return (
|
177
|
+
f'<div class="elloha">'
|
178
|
+
f'<div id="ConstellationWidgetContainer{cw1}" '
|
179
|
+
f'style="width:100%" data-id-projet="{cw2}">...</div></div>'
|
180
|
+
f'<script type="text/javascript" src="{self.parts.geturl()}/Scripts/widget-loader.min.js?v=42"></script>'
|
181
|
+
f'<script type="text/javascript">var constellationWidgetUrl{cw2}, '
|
182
|
+
f"constellationTypeModule{cw2};"
|
183
|
+
f'constellationWidgetUrl{cw2} = "https://reservation.elloha.com/Widget/BookingEngine/{cw1}?idoi={idoi}&culture=fr-FR";'
|
184
|
+
f'constellationTypeModule{cw2}=1; constellationWidgetLoad("ConstellationWidgetContainer{cw1}");'
|
185
|
+
f'constellationWidgetAddEvent(window, "resize", function () {{constellationWidgetSetAppearance("ConstellationWidgetContainer{cw1}");}});</script>'
|
186
|
+
)
|
187
|
+
|
188
|
+
|
189
|
+
class CognitoformPlugin(BasePlugin):
|
190
|
+
def __call__(self, parts, config={}):
|
191
|
+
if "cognitoforms" in parts.netloc:
|
192
|
+
self.parts = parts
|
193
|
+
self.config = config
|
194
|
+
return self
|
195
|
+
return None
|
196
|
+
|
197
|
+
@property
|
198
|
+
def contents(self):
|
199
|
+
current_lang = self.config["current_lang"]
|
200
|
+
extra_params = self.config["extra_params"]
|
201
|
+
|
202
|
+
error_message = _(
|
203
|
+
"With a cognitoform plugin, extra params can be void but if you complete it you must specify : scrolling:(yes/no) and overflow:(hidden/scroll/auto)"
|
204
|
+
)
|
205
|
+
error_message = translate(error_message, target_language=current_lang)
|
206
|
+
error_message = (
|
207
|
+
f'<div class="cognitoform cognitoform_error">{error_message}</div>'
|
208
|
+
)
|
209
|
+
|
210
|
+
if extra_params is None:
|
211
|
+
return f'<iframe src="{self.parts.geturl()}" style="border: 0px none; width: {self.config["width"]}%; overflow: auto;" scrolling="yes"></iframe>'
|
212
|
+
else:
|
213
|
+
if extra_params[0] != "{" or extra_params[-1] != "}":
|
96
214
|
return error_message
|
97
215
|
try:
|
98
216
|
res = json.loads(extra_params.lower())
|
99
217
|
except JSONDecodeError:
|
100
218
|
return error_message
|
101
219
|
|
102
|
-
if (
|
103
|
-
res.get("constellationwidgetcontainer") is None
|
104
|
-
or res.get("idoi") is None
|
105
|
-
):
|
220
|
+
if res.get("overflow") is None or res.get("scrolling") is None:
|
106
221
|
return error_message
|
107
222
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
return (
|
112
|
-
f'<div class="elloha">'
|
113
|
-
f'<div id="ConstellationWidgetContainer{cw1}" '
|
114
|
-
f'style="width:100%" data-id-projet="{cw2}">...</div></div>'
|
115
|
-
f'<script type="text/javascript" src="{parts.geturl()}/Scripts/widget-loader.min.js?v=42"></script>'
|
116
|
-
f'<script type="text/javascript">var constellationWidgetUrl{cw2}, '
|
117
|
-
f"constellationTypeModule{cw2};"
|
118
|
-
f'constellationWidgetUrl{cw2} = "https://reservation.elloha.com/Widget/BookingEngine/{cw1}?idoi={idoi}&culture=fr-FR";'
|
119
|
-
f'constellationTypeModule{cw2}=1; constellationWidgetLoad("ConstellationWidgetContainer{cw1}");'
|
120
|
-
f'constellationWidgetAddEvent(window, "resize", function () {{constellationWidgetSetAppearance("ConstellationWidgetContainer{cw1}");}});</script>'
|
121
|
-
)
|
122
|
-
#
|
123
|
-
return None
|
223
|
+
overflow = res.get("overflow")
|
224
|
+
scrolling = res.get("scrolling")
|
225
|
+
return f'<iframe src="{self.parts.geturl()}" style="border: 0px none; width: {self.config["width"]}%; overflow: {overflow};" scrolling="{scrolling}"></iframe>'
|
124
226
|
|
125
227
|
|
126
|
-
class
|
228
|
+
class ArcgisPlugin(BasePlugin):
|
127
229
|
def __call__(self, parts, config={}):
|
128
|
-
if "
|
129
|
-
|
130
|
-
|
230
|
+
if "arcgis" in parts.netloc:
|
231
|
+
self.parts = parts
|
232
|
+
self.config = config
|
233
|
+
return None
|
234
|
+
|
235
|
+
@property
|
236
|
+
def contents(self):
|
237
|
+
# url : https://developers.arcgis.com/
|
238
|
+
# extra_params : {"portal_item_id":"27a432b0835149e6acd3ac39d0e4349c"}
|
239
|
+
current_lang = self.config["current_lang"]
|
240
|
+
extra_params = self.config["extra_params"]
|
241
|
+
url = self.config["url"]
|
242
|
+
|
243
|
+
error_message = _(
|
244
|
+
"With arcgis plugin, extra params must contain a dictionary with one key : portal_item_id"
|
245
|
+
)
|
246
|
+
error_message = translate(error_message, target_language=current_lang)
|
247
|
+
error_message = f'<div class="arcgis arcgis_error">{error_message}</div>'
|
248
|
+
|
249
|
+
if extra_params is None or extra_params[0] != "{" or extra_params[-1] != "}":
|
250
|
+
return error_message
|
251
|
+
try:
|
252
|
+
res = json.loads(extra_params.lower())
|
253
|
+
except JSONDecodeError:
|
254
|
+
return error_message
|
255
|
+
if res.get("portal_item_id") is None:
|
256
|
+
return error_message
|
257
|
+
|
258
|
+
portal_item_id = res.get("portal_item_id")
|
259
|
+
msg = _("Consult the map")
|
260
|
+
msg = translate(msg, target_language=current_lang)
|
261
|
+
return f'<a href="{url}/view_arcgis?portal_item_id={portal_item_id}">{msg}</a>'
|
131
262
|
|
132
|
-
error_message = _(
|
133
|
-
"With a cognitoform plugin, extra params can be void but if you complete it you must specify : scrolling:(yes/no) and overflow:(hidden/scroll/auto)"
|
134
|
-
)
|
135
|
-
error_message = translate(error_message, target_language=current_lang)
|
136
|
-
error_message = (
|
137
|
-
f'<div class="cognitoform cognitoform_error">{error_message}</div>'
|
138
|
-
)
|
139
263
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
res = json.loads(extra_params.lower())
|
147
|
-
except JSONDecodeError:
|
148
|
-
return error_message
|
149
|
-
|
150
|
-
if res.get("overflow") is None or res.get("scrolling") is None:
|
151
|
-
return error_message
|
152
|
-
|
153
|
-
overflow = res.get("overflow")
|
154
|
-
scrolling = res.get("scrolling")
|
155
|
-
return f'<iframe src="{parts.geturl()}" style="border: 0px none; width: {config["width"]}%; overflow: {overflow};" scrolling="{scrolling}"></iframe>'
|
264
|
+
class GiveADayPlugin(BasePlugin):
|
265
|
+
def __call__(self, parts, config={}):
|
266
|
+
if "www.giveaday.be" in parts.netloc:
|
267
|
+
self.parts = parts
|
268
|
+
self.config = config
|
269
|
+
return self
|
156
270
|
#
|
157
271
|
return None
|
158
272
|
|
273
|
+
@property
|
274
|
+
def contents(self):
|
275
|
+
return (
|
276
|
+
'<div id="giveaday-widget"></div>'
|
277
|
+
"<script src=https://www.giveaday.be/assets/giveaday_v1.js></script>"
|
278
|
+
"<script>"
|
279
|
+
"function renderWidget() {"
|
280
|
+
'giveADayWidget.initialize("giveaday-widget", 2924, "organization", "large", "fr","#34B78F");}'
|
281
|
+
"renderWidget();"
|
282
|
+
"</script>"
|
283
|
+
)
|
284
|
+
|
285
|
+
|
286
|
+
class IIdeluxWastePlugin(Interface):
|
287
|
+
""""""
|
159
288
|
|
160
|
-
|
289
|
+
|
290
|
+
@implementer(IIdeluxWastePlugin)
|
291
|
+
class IdeluxWastePlugin(BasePlugin):
|
161
292
|
def __call__(self, parts, config={}):
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
error_message = _(
|
170
|
-
"With arcgis plugin, extra params must contain a dictionary with one key : portal_item_id"
|
171
|
-
)
|
172
|
-
error_message = translate(error_message, target_language=current_lang)
|
173
|
-
error_message = f'<div class="arcgis arcgis_error">{error_message}</div>'
|
174
|
-
|
175
|
-
if (
|
176
|
-
extra_params is None
|
177
|
-
or extra_params[0] != "{"
|
178
|
-
or extra_params[-1] != "}"
|
179
|
-
):
|
180
|
-
return error_message
|
181
|
-
try:
|
182
|
-
res = json.loads(extra_params.lower())
|
183
|
-
except JSONDecodeError:
|
184
|
-
return error_message
|
185
|
-
if res.get("portal_item_id") is None:
|
186
|
-
return error_message
|
293
|
+
# https://www.odwb.be/api/explore/v2.1/catalog/datasets/guide-de-tri1/records
|
294
|
+
if "www.odwb.be" in parts.netloc and "guide-de-tri1" in parts.path:
|
295
|
+
self.parts = parts
|
296
|
+
self.config = config
|
297
|
+
return self
|
298
|
+
return None
|
187
299
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
300
|
+
# url = config["url"]
|
301
|
+
# return (f'<a href="{url}/view_idelux_waste?portal_item_id={portal_item_id}">{msg}</a>')
|
302
|
+
@property
|
303
|
+
def contents(self):
|
304
|
+
headers = {"Accept": "application/json"}
|
305
|
+
try:
|
306
|
+
# ?limit=-1 to get all records from an odwb table.
|
307
|
+
response = requests.get(
|
308
|
+
f"{self.parts.geturl()}?limit=-1", headers=headers, timeout=5
|
193
309
|
)
|
194
|
-
|
195
|
-
|
310
|
+
self.config["extra_params"] = response.json()
|
311
|
+
return self.config["extra_params"]
|
312
|
+
|
313
|
+
except requests.exceptions.Timeout:
|
314
|
+
logger.warning(f"Timeout raised for requests : {self.url}")
|
315
|
+
return None
|
316
|
+
|
196
317
|
|
318
|
+
class IInbwContainersAffluencePlugin(Interface):
|
319
|
+
""""""
|
197
320
|
|
198
|
-
|
321
|
+
|
322
|
+
@implementer(IInbwContainersAffluencePlugin)
|
323
|
+
class InbwContainersAffluencePlugin(BasePlugin):
|
199
324
|
def __call__(self, parts, config={}):
|
200
|
-
if "www.
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
"<script>"
|
205
|
-
"function renderWidget() {"
|
206
|
-
'giveADayWidget.initialize("giveaday-widget", 2924, "organization", "large", "fr","#34B78F");}'
|
207
|
-
"renderWidget();"
|
208
|
-
"</script>"
|
209
|
-
)
|
210
|
-
#
|
325
|
+
if "www.odwb.be" in parts.netloc and "affluence" in parts.path:
|
326
|
+
self.parts = parts
|
327
|
+
self.config = config
|
328
|
+
return self
|
211
329
|
return None
|
212
330
|
|
331
|
+
@property
|
332
|
+
def contents(self):
|
333
|
+
headers = {"Accept": "application/json"}
|
334
|
+
try:
|
335
|
+
response = requests.get(
|
336
|
+
f"{self.parts.geturl()}&limit=-1", headers=headers, timeout=5
|
337
|
+
)
|
338
|
+
self.config["extra_params"] = json.dumps(response.json())
|
339
|
+
return self.config["extra_params"]
|
340
|
+
except requests.exceptions.Timeout:
|
341
|
+
logger.warning(f"Timeout raised for requests : {self.url}")
|
342
|
+
return None
|
343
|
+
|
344
|
+
|
345
|
+
class IOdwbWidgetPlugin(Interface):
|
346
|
+
""""""
|
213
347
|
|
214
|
-
|
348
|
+
|
349
|
+
@implementer(IOdwbWidgetPlugin)
|
350
|
+
class OdwbWidgetPlugin(BasePlugin):
|
215
351
|
def __call__(self, parts, config={}):
|
216
|
-
|
352
|
+
# https://static.opendatasoft.com/ods-widgets
|
353
|
+
if "static.opendatasoft.com" in parts.netloc:
|
354
|
+
self.is_odwb_widget_plugins = True
|
355
|
+
self.parts = parts
|
356
|
+
self.config = config
|
357
|
+
return self
|
358
|
+
|
359
|
+
@property
|
360
|
+
def contents(self):
|
361
|
+
return self.config["extra_params"]
|
362
|
+
|
363
|
+
|
364
|
+
class UnknowServicePlugin(BasePlugin):
|
365
|
+
def __call__(self, parts, config={}):
|
366
|
+
self.parts = parts
|
367
|
+
self.config = config
|
368
|
+
return self
|
369
|
+
|
370
|
+
@property
|
371
|
+
def contents(self):
|
372
|
+
current_lang = self.config["current_lang"]
|
217
373
|
msg = _("Unknow service")
|
218
374
|
msg = translate(msg, target_language=current_lang)
|
219
375
|
return f'<p class="unknow_service">{msg}</p>'
|
@@ -226,3 +382,26 @@ class ArcgisView(BrowserView):
|
|
226
382
|
@property
|
227
383
|
def get_portal_item_id(self):
|
228
384
|
return self.request.portal_item_id
|
385
|
+
|
386
|
+
|
387
|
+
class IdeluxWasteView(BrowserView):
|
388
|
+
|
389
|
+
def __init__(self, context, request):
|
390
|
+
""" """
|
391
|
+
|
392
|
+
|
393
|
+
class InbwContainersAffluenceView(BrowserView):
|
394
|
+
|
395
|
+
def __init__(self, context, request):
|
396
|
+
""" """
|
397
|
+
|
398
|
+
|
399
|
+
class IOdwbWidgetLayer(IDefaultBrowserLayer):
|
400
|
+
""" """
|
401
|
+
|
402
|
+
|
403
|
+
@implementer(IOdwbViewUtils, IOdwbWidgetLayer)
|
404
|
+
class OdwbWidgetView(BrowserView):
|
405
|
+
|
406
|
+
def __init__(self, context, request):
|
407
|
+
""" """
|
@@ -22,7 +22,7 @@
|
|
22
22
|
id string:body-section-${context/id}">
|
23
23
|
<tal:cond condition="image">
|
24
24
|
<figure>
|
25
|
-
<img
|
25
|
+
<img tal:attributes="src python:view.get_scale_url(context); alt python:context.image_caption if context.image_caption else ''" />
|
26
26
|
<figcaption tal:condition="context/image_caption" tal:content="context/image_caption"></figcaption>
|
27
27
|
</figure>
|
28
28
|
</tal:cond>
|
imio/smartweb/core/interfaces.py
CHANGED
@@ -19,17 +19,34 @@
|
|
19
19
|
interface="Products.CMFPlone.interfaces.controlpanel.ISearchSchema"
|
20
20
|
field="types_not_searched">
|
21
21
|
<value purge="false">
|
22
|
+
<element>News Item</element>
|
23
|
+
<element>imio.smartweb.HeroBanner</element>
|
24
|
+
<element>Discussion Item</element>
|
25
|
+
<element>MessagesConfig</element>
|
26
|
+
<element>Folder</element>
|
22
27
|
<element>imio.smartweb.BlockLink</element>
|
28
|
+
<element>Message</element>
|
29
|
+
<element>Document</element>
|
23
30
|
<element>imio.smartweb.Footer</element>
|
24
|
-
<element>imio.smartweb.
|
31
|
+
<element>imio.smartweb.SectionHTML</element>
|
32
|
+
<element>imio.smartweb.SectionSendinblue</element>
|
33
|
+
<element>imio.smartweb.SectionNews</element>
|
34
|
+
<element>imio.smartweb.SectionCollection</element>
|
25
35
|
<element>imio.smartweb.SectionContact</element>
|
36
|
+
<element>imio.smartweb.SectionExternalContent</element>
|
37
|
+
<element>imio.smartweb.SectionSelections</element>
|
26
38
|
<element>imio.smartweb.SectionFiles</element>
|
27
|
-
<element>imio.smartweb.SectionGallery</element>
|
28
39
|
<element>imio.smartweb.SectionLinks</element>
|
29
|
-
<element>imio.smartweb.SectionSelections</element>
|
30
|
-
<element>imio.smartweb.SectionSlide</element>
|
31
40
|
<element>imio.smartweb.SectionText</element>
|
41
|
+
<element>imio.smartweb.SectionGallery</element>
|
42
|
+
<element>imio.smartweb.SectionMap</element>
|
43
|
+
<element>imio.smartweb.SectionPostit</element>
|
44
|
+
<element>imio.smartweb.SectionSlide</element>
|
32
45
|
<element>imio.smartweb.SectionVideo</element>
|
46
|
+
<element>imio.smartweb.SectionEvents</element>
|
47
|
+
<element>Plone Site</element>
|
48
|
+
<element>TempFolder</element>
|
49
|
+
<element>Event</element>
|
33
50
|
</value>
|
34
51
|
</record>
|
35
52
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
3
|
+
meta_type="Dexterity FTI"
|
4
|
+
name="Collection"
|
5
|
+
i18n:domain="plone"
|
6
|
+
>
|
7
|
+
|
8
|
+
<!-- Enabled behaviors -->
|
9
|
+
<property name="behaviors" purge="false">
|
10
|
+
<element value="solr.fields" />
|
11
|
+
</property>
|
12
|
+
|
13
|
+
</object>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
3
|
+
meta_type="Dexterity FTI"
|
4
|
+
name="File"
|
5
|
+
i18n:domain="plone"
|
6
|
+
>
|
7
|
+
|
8
|
+
<!-- Enabled behaviors -->
|
9
|
+
<property name="behaviors" purge="false">
|
10
|
+
<element value="solr.fields" />
|
11
|
+
</property>
|
12
|
+
|
13
|
+
</object>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
|
3
|
+
meta_type="Dexterity FTI"
|
4
|
+
name="Image"
|
5
|
+
i18n:domain="plone"
|
6
|
+
>
|
7
|
+
|
8
|
+
<!-- Enabled behaviors -->
|
9
|
+
<property name="behaviors" purge="false">
|
10
|
+
<element value="solr.fields" />
|
11
|
+
</property>
|
12
|
+
|
13
|
+
</object>
|