7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
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 from pyams_sequence.interfaces import ISequentialIntIds |
|
13 |
12 |
14 __docformat__ = 'restructuredtext' |
13 __docformat__ = 'restructuredtext' |
15 |
14 |
16 |
15 |
17 # import standard library |
16 # import standard library |
22 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget, IBaseExtFile |
21 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget, IBaseExtFile |
23 from pyams_content.component.illustration.interfaces import IIllustrationTarget |
22 from pyams_content.component.illustration.interfaces import IIllustrationTarget |
24 from pyams_content.component.links.interfaces import ILinkContainerTarget, IInternalLink, IExternalLink, IMailtoLink |
23 from pyams_content.component.links.interfaces import ILinkContainerTarget, IInternalLink, IExternalLink, IMailtoLink |
25 from pyams_content.component.paragraph.interfaces import IParagraphFactory |
24 from pyams_content.component.paragraph.interfaces import IParagraphFactory |
26 from pyams_content.component.paragraph.interfaces.html import RAW_PARAGRAPH_TYPE, IRawParagraph, HTML_PARAGRAPH_TYPE, \ |
25 from pyams_content.component.paragraph.interfaces.html import RAW_PARAGRAPH_TYPE, IRawParagraph, HTML_PARAGRAPH_TYPE, \ |
27 IHTMLParagraph |
26 IHTMLParagraph, RAW_PARAGRAPH_RENDERERS, HTML_PARAGRAPH_RENDERERS |
28 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE |
27 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE |
29 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator |
28 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator |
|
29 from pyams_sequence.interfaces import ISequentialIntIds |
30 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent |
30 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent |
31 |
31 |
32 # import packages |
32 # import packages |
33 from pyams_content.component.links import InternalLink, ExternalLink, MailtoLink |
33 from pyams_content.component.links import InternalLink, ExternalLink, MailtoLink |
34 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory |
34 from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory |
|
35 from pyams_content.features.renderer import RenderersVocabulary |
35 from pyams_utils.adapter import adapter_config |
36 from pyams_utils.adapter import adapter_config |
|
37 from pyams_utils.factory import factory_config |
36 from pyams_utils.registry import utility_config, get_utility |
38 from pyams_utils.registry import utility_config, get_utility |
37 from pyams_utils.request import check_request |
39 from pyams_utils.request import check_request |
38 from pyams_utils.traversing import get_parent |
40 from pyams_utils.traversing import get_parent |
39 from pyams_utils.url import absolute_url |
41 from pyams_utils.url import absolute_url |
|
42 from pyams_utils.vocabulary import vocabulary_config |
40 from pyquery import PyQuery |
43 from pyquery import PyQuery |
41 from pyramid.events import subscriber |
44 from pyramid.events import subscriber |
42 from pyramid.threadlocal import get_current_registry |
45 from pyramid.threadlocal import get_current_registry |
43 from zope.interface import implementer |
46 from zope.interface import implementer |
44 from zope.lifecycleevent import ObjectCreatedEvent |
47 from zope.lifecycleevent import ObjectCreatedEvent |
50 # |
53 # |
51 # Raw HTML paragraph |
54 # Raw HTML paragraph |
52 # |
55 # |
53 |
56 |
54 @implementer(IRawParagraph) |
57 @implementer(IRawParagraph) |
|
58 @factory_config(provided=IRawParagraph) |
55 class RawParagraph(BaseParagraph): |
59 class RawParagraph(BaseParagraph): |
56 """Raw HTML paragraph""" |
60 """Raw HTML paragraph""" |
57 |
61 |
58 icon_class = 'fa-code' |
62 icon_class = 'fa-code' |
59 icon_hint = _("Raw HTML ") |
63 icon_hint = _("Raw HTML ") |
60 |
64 |
61 body = FieldProperty(IRawParagraph['body']) |
65 body = FieldProperty(IRawParagraph['body']) |
|
66 renderer = FieldProperty(IRawParagraph['renderer']) |
62 |
67 |
63 |
68 |
64 @utility_config(name=RAW_PARAGRAPH_TYPE, provides=IParagraphFactory) |
69 @utility_config(name=RAW_PARAGRAPH_TYPE, provides=IParagraphFactory) |
65 class RawParagraphFactory(BaseParagraphFactory): |
70 class RawParagraphFactory(BaseParagraphFactory): |
66 """Raw paragraph factory""" |
71 """Raw paragraph factory""" |
92 else: |
97 else: |
93 output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang)) |
98 output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang)) |
94 return output |
99 return output |
95 |
100 |
96 |
101 |
|
102 @vocabulary_config(name=RAW_PARAGRAPH_RENDERERS) |
|
103 class RawParagraphRendererVocabulary(RenderersVocabulary): |
|
104 """Raw HTML paragraph renderers vocabulary""" |
|
105 |
|
106 content_interface = IRawParagraph |
|
107 |
|
108 |
97 # |
109 # |
98 # HTML paragraph |
110 # HTML paragraph |
99 # |
111 # |
100 |
112 |
101 @implementer(IHTMLParagraph, IIllustrationTarget, IExtFileContainerTarget, ILinkContainerTarget) |
113 @implementer(IHTMLParagraph, IIllustrationTarget, IExtFileContainerTarget, ILinkContainerTarget) |
|
114 @factory_config(provided=IHTMLParagraph) |
102 class HTMLParagraph(BaseParagraph): |
115 class HTMLParagraph(BaseParagraph): |
103 """HTML paragraph""" |
116 """HTML paragraph""" |
104 |
117 |
105 icon_class = 'fa-font' |
118 icon_class = 'fa-font' |
106 icon_hint = _("Rich text") |
119 icon_hint = _("Rich text") |
107 |
120 |
108 body = FieldProperty(IHTMLParagraph['body']) |
121 body = FieldProperty(IHTMLParagraph['body']) |
|
122 renderer = FieldProperty(IHTMLParagraph['renderer']) |
109 |
123 |
110 |
124 |
111 @utility_config(name=HTML_PARAGRAPH_TYPE, provides=IParagraphFactory) |
125 @utility_config(name=HTML_PARAGRAPH_TYPE, provides=IParagraphFactory) |
112 class HTMLParagraphFactory(BaseParagraphFactory): |
126 class HTMLParagraphFactory(BaseParagraphFactory): |
113 """HTML paragraph factory""" |
127 """HTML paragraph factory""" |