8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
10 # FOR A PARTICULAR PURPOSE. |
10 # FOR A PARTICULAR PURPOSE. |
11 # |
11 # |
12 |
12 |
13 __docformat__ = 'restructuredtext' |
|
14 |
|
15 from itertools import islice |
13 from itertools import islice |
16 |
14 |
17 from persistent import Persistent |
15 from persistent import Persistent |
18 from zope.location import Location |
16 from zope.location import Location |
19 from zope.schema.fieldproperty import FieldProperty |
17 from zope.schema.fieldproperty import FieldProperty |
20 |
18 |
21 from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationInfo, \ |
19 from pyams_content.component.association.interfaces import IAssociationContainer, \ |
22 IAssociationParagraph |
20 IAssociationInfo, IAssociationParagraph |
23 from pyams_content.component.extfile import IExtFile |
21 from pyams_content.component.extfile import IExtFile |
24 from pyams_content.component.links.interfaces import IBaseLink, IInternalLink |
22 from pyams_content.component.links.interfaces import IBaseLink, IInternalLink |
25 from pyams_content.component.paragraph.interfaces import IParagraphContainer, IParagraphContainerTarget |
23 from pyams_content.component.paragraph.interfaces import IParagraphContainer, \ |
|
24 IParagraphContainerTarget |
26 from pyams_content.features.renderer.interfaces import IContentRenderer |
25 from pyams_content.features.renderer.interfaces import IContentRenderer |
27 from pyams_default_theme import _ |
26 from pyams_default_theme.component.association.interfaces import \ |
28 from pyams_default_theme.component.association.interfaces import IAssociationParagraphDefaultRendererSettings, \ |
27 IAssociationParagraphDefaultRendererSettings, \ |
29 IAssociationParagraphRemoteContentRendererSettings, IAssociationParagraphSlicedRemoteContentRendererSettings |
28 IAssociationParagraphRemoteContentRendererSettings, \ |
|
29 IAssociationParagraphSlicedRemoteContentRendererSettings |
30 from pyams_default_theme.features.renderer import BaseContentRenderer |
30 from pyams_default_theme.features.renderer import BaseContentRenderer |
31 from pyams_skin.layer import IPyAMSLayer |
31 from pyams_skin.layer import IPyAMSLayer |
32 from pyams_template.template import template_config |
32 from pyams_template.template import template_config |
33 from pyams_utils.adapter import adapter_config, get_annotation_adapter |
33 from pyams_utils.adapter import adapter_config, get_annotation_adapter |
34 from pyams_utils.factory import factory_config |
34 from pyams_utils.factory import factory_config |
35 |
35 |
36 |
36 |
|
37 __docformat__ = 'restructuredtext' |
|
38 |
|
39 from pyams_default_theme import _ |
|
40 |
|
41 |
37 # |
42 # |
38 # Associations paragraph default renderer |
43 # Associations paragraph default renderer |
39 # |
44 # |
40 |
45 |
41 ASSOCIATION_PARAGRAPH_DEFAULT_RENDERER_SETTINGS_KEY = 'pyams_content.association.renderer:default' |
46 ASSOCIATION_PARAGRAPH_DEFAULT_RENDERER_SETTINGS_KEY = 'pyams_content.association.renderer:default' |
46 """Association paragraph default renderer settings""" |
51 """Association paragraph default renderer settings""" |
47 |
52 |
48 description_format = FieldProperty(IAssociationParagraphDefaultRendererSettings['description_format']) |
53 description_format = FieldProperty(IAssociationParagraphDefaultRendererSettings['description_format']) |
49 |
54 |
50 |
55 |
51 @adapter_config(context=IAssociationParagraph, provides=IAssociationParagraphDefaultRendererSettings) |
56 @adapter_config(context=IAssociationParagraph, |
|
57 provides=IAssociationParagraphDefaultRendererSettings) |
52 def association_paragraph_default_renderer_settings_factory(context): |
58 def association_paragraph_default_renderer_settings_factory(context): |
53 """Associations paragraph default renderer settings factory""" |
59 """Associations paragraph default renderer settings factory""" |
54 return get_annotation_adapter(context, ASSOCIATION_PARAGRAPH_DEFAULT_RENDERER_SETTINGS_KEY, |
60 return get_annotation_adapter(context, ASSOCIATION_PARAGRAPH_DEFAULT_RENDERER_SETTINGS_KEY, |
55 IAssociationParagraphDefaultRendererSettings) |
61 IAssociationParagraphDefaultRendererSettings) |
56 |
62 |
57 |
63 |
58 @adapter_config(name='default', context=(IAssociationParagraph, IPyAMSLayer), provides=IContentRenderer) |
64 @adapter_config(name='default', |
59 @template_config(template='templates/association-default.pt', layer=IPyAMSLayer) |
65 context=(IAssociationParagraph, IPyAMSLayer), |
|
66 provides=IContentRenderer) |
|
67 @template_config(template='templates/association-default.pt', |
|
68 layer=IPyAMSLayer) |
60 class AssociationParagraphDefaultRenderer(BaseContentRenderer): |
69 class AssociationParagraphDefaultRenderer(BaseContentRenderer): |
61 """Associations paragraph default renderer""" |
70 """Associations paragraph default renderer""" |
62 |
71 |
63 label = _("Default associations renderer") |
72 label = _("Default associations renderer") |
64 i18n_context_attrs = ('title',) |
73 i18n_context_attrs = ('title',) |
103 display_title = FieldProperty(IAssociationParagraphSlicedRemoteContentRendererSettings['display_title']) |
112 display_title = FieldProperty(IAssociationParagraphSlicedRemoteContentRendererSettings['display_title']) |
104 display_header = FieldProperty(IAssociationParagraphSlicedRemoteContentRendererSettings['display_header']) |
113 display_header = FieldProperty(IAssociationParagraphSlicedRemoteContentRendererSettings['display_header']) |
105 paragraphs_count = FieldProperty(IAssociationParagraphSlicedRemoteContentRendererSettings['paragraphs_count']) |
114 paragraphs_count = FieldProperty(IAssociationParagraphSlicedRemoteContentRendererSettings['paragraphs_count']) |
106 |
115 |
107 |
116 |
108 @adapter_config(context=IAssociationParagraph, provides=IAssociationParagraphSlicedRemoteContentRendererSettings) |
117 @adapter_config(context=IAssociationParagraph, |
|
118 provides=IAssociationParagraphSlicedRemoteContentRendererSettings) |
109 def association_paragraph_sliced_remote_content_renderer_settings_factory(context): |
119 def association_paragraph_sliced_remote_content_renderer_settings_factory(context): |
110 """Associations paragraph sliced remote content renderer settings factory""" |
120 """Associations paragraph sliced remote content renderer settings factory""" |
111 return get_annotation_adapter(context, ASSOCIATION_PARAGRAPH_SLICED_REMOTE_CONTENT_RENDERER_SETTINGS_KEY, |
121 return get_annotation_adapter(context, ASSOCIATION_PARAGRAPH_SLICED_REMOTE_CONTENT_RENDERER_SETTINGS_KEY, |
112 IAssociationParagraphSlicedRemoteContentRendererSettings) |
122 IAssociationParagraphSlicedRemoteContentRendererSettings) |
113 |
123 |
114 |
124 |
115 @adapter_config(name='reportage', context=(IAssociationParagraph, IPyAMSLayer), provides=IContentRenderer) |
125 @adapter_config(name='reportage', |
116 @template_config(template='templates/association-remote-content.pt', layer=IPyAMSLayer) |
126 context=(IAssociationParagraph, IPyAMSLayer), |
|
127 provides=IContentRenderer) |
|
128 @template_config(template='templates/association-remote-content.pt', |
|
129 layer=IPyAMSLayer) |
117 class AssociationParagraphSlicedRemoteContentRenderer(BaseContentRenderer): |
130 class AssociationParagraphSlicedRemoteContentRenderer(BaseContentRenderer): |
118 """Associations container sliced remote content renderer""" |
131 """Associations container sliced remote content renderer""" |
119 |
132 |
120 label = _("Include first remote content paragraphs") |
133 label = _("Include first remote content paragraphs") |
121 weight = 10 |
134 weight = 10 |
149 display_header = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['display_header']) |
162 display_header = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['display_header']) |
150 factories = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['factories']) |
163 factories = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['factories']) |
151 anchors_only = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['anchors_only']) |
164 anchors_only = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['anchors_only']) |
152 |
165 |
153 |
166 |
154 @adapter_config(context=IAssociationParagraph, provides=IAssociationParagraphRemoteContentRendererSettings) |
167 @adapter_config(context=IAssociationParagraph, |
|
168 provides=IAssociationParagraphRemoteContentRendererSettings) |
155 def association_paragraph_remote_content_renderer_settings_factory(context): |
169 def association_paragraph_remote_content_renderer_settings_factory(context): |
156 """Associations paragraph remote content renderer settings factory""" |
170 """Associations paragraph remote content renderer settings factory""" |
157 return get_annotation_adapter(context, ASSOCIATION_PARAGRAPH_REMOTE_CONTENT_RENDERER_SETTINGS_KEY, |
171 return get_annotation_adapter(context, ASSOCIATION_PARAGRAPH_REMOTE_CONTENT_RENDERER_SETTINGS_KEY, |
158 IAssociationParagraphRemoteContentRendererSettings) |
172 IAssociationParagraphRemoteContentRendererSettings) |
159 |
173 |
160 |
174 |
161 @adapter_config(name='remote-content', context=(IAssociationParagraph, IPyAMSLayer), provides=IContentRenderer) |
175 @adapter_config(name='remote-content', |
162 @template_config(template='templates/association-remote-content.pt', layer=IPyAMSLayer) |
176 context=(IAssociationParagraph, IPyAMSLayer), |
|
177 provides=IContentRenderer) |
|
178 @template_config(template='templates/association-remote-content.pt', |
|
179 layer=IPyAMSLayer) |
163 class AssociationParagraphRemoteContentRenderer(BaseContentRenderer): |
180 class AssociationParagraphRemoteContentRenderer(BaseContentRenderer): |
164 """Associations container remote content renderer""" |
181 """Associations container remote content renderer""" |
165 |
182 |
166 label = _("Include remote content paragraphs") |
183 label = _("Include remote content paragraphs") |
167 weight = 11 |
184 weight = 11 |