src/pyams_content/component/paragraph/html.py
changeset 586 28445044f6e3
parent 555 8e8a14452567
child 1157 ffb751b038cc
equal deleted inserted replaced
585:9fa8e9776bda 586:28445044f6e3
    20 from pyams_content.component.association.interfaces import IAssociationContainer
    20 from pyams_content.component.association.interfaces import IAssociationContainer
    21 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget, IBaseExtFile
    21 from pyams_content.component.extfile.interfaces import IExtFileContainerTarget, IBaseExtFile
    22 from pyams_content.component.illustration.interfaces import IIllustrationTarget
    22 from pyams_content.component.illustration.interfaces import IIllustrationTarget
    23 from pyams_content.component.links.interfaces import ILinkContainerTarget, IInternalLink, IExternalLink, IMailtoLink
    23 from pyams_content.component.links.interfaces import ILinkContainerTarget, IInternalLink, IExternalLink, IMailtoLink
    24 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    24 from pyams_content.component.paragraph.interfaces import IParagraphFactory
    25 from pyams_content.component.paragraph.interfaces.html import RAW_PARAGRAPH_TYPE, IRawParagraph, HTML_PARAGRAPH_TYPE, \
    25 from pyams_content.component.paragraph.interfaces.html import \
    26     IHTMLParagraph, RAW_PARAGRAPH_RENDERERS, HTML_PARAGRAPH_RENDERERS
    26     RAW_PARAGRAPH_TYPE, RAW_PARAGRAPH_NAME, RAW_PARAGRAPH_RENDERERS, IRawParagraph, \
       
    27     HTML_PARAGRAPH_TYPE, HTML_PARAGRAPH_NAME, HTML_PARAGRAPH_RENDERERS, IHTMLParagraph
    27 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    28 from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
    28 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    29 from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
    29 from pyams_sequence.interfaces import ISequentialIntIds
    30 from pyams_sequence.interfaces import ISequentialIntIds
    30 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent
    31 from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent
    31 
    32 
    45 from pyramid.threadlocal import get_current_registry
    46 from pyramid.threadlocal import get_current_registry
    46 from zope.interface import implementer
    47 from zope.interface import implementer
    47 from zope.lifecycleevent import ObjectCreatedEvent
    48 from zope.lifecycleevent import ObjectCreatedEvent
    48 from zope.schema.fieldproperty import FieldProperty
    49 from zope.schema.fieldproperty import FieldProperty
    49 
    50 
    50 from pyams_content import _
       
    51 
       
    52 
    51 
    53 #
    52 #
    54 # Raw HTML paragraph
    53 # Raw HTML paragraph
    55 #
    54 #
    56 
    55 
    58 @factory_config(provided=IRawParagraph)
    57 @factory_config(provided=IRawParagraph)
    59 class RawParagraph(BaseParagraph):
    58 class RawParagraph(BaseParagraph):
    60     """Raw HTML paragraph"""
    59     """Raw HTML paragraph"""
    61 
    60 
    62     icon_class = 'fa-code'
    61     icon_class = 'fa-code'
    63     icon_hint = _("Raw HTML ")
    62     icon_hint = RAW_PARAGRAPH_NAME
    64 
    63 
    65     body = FieldProperty(IRawParagraph['body'])
    64     body = FieldProperty(IRawParagraph['body'])
    66     renderer = FieldProperty(IRawParagraph['renderer'])
    65     renderer = FieldProperty(IRawParagraph['renderer'])
    67 
    66 
    68 
    67 
    69 @utility_config(name=RAW_PARAGRAPH_TYPE, provides=IParagraphFactory)
    68 @utility_config(name=RAW_PARAGRAPH_TYPE, provides=IParagraphFactory)
    70 class RawParagraphFactory(BaseParagraphFactory):
    69 class RawParagraphFactory(BaseParagraphFactory):
    71     """Raw paragraph factory"""
    70     """Raw paragraph factory"""
    72 
    71 
    73     name = _("Raw HTML paragraph")
    72     name = RAW_PARAGRAPH_NAME
    74     content_type = RawParagraph
    73     content_type = RawParagraph
    75 
    74 
    76 
    75 
    77 @adapter_config(context=IRawParagraph, provides=IContentChecker)
    76 @adapter_config(context=IRawParagraph, provides=IContentChecker)
    78 class RawParagraphContentChecker(BaseParagraphContentChecker):
    77 class RawParagraphContentChecker(BaseParagraphContentChecker):
   114 @factory_config(provided=IHTMLParagraph)
   113 @factory_config(provided=IHTMLParagraph)
   115 class HTMLParagraph(BaseParagraph):
   114 class HTMLParagraph(BaseParagraph):
   116     """HTML paragraph"""
   115     """HTML paragraph"""
   117 
   116 
   118     icon_class = 'fa-font'
   117     icon_class = 'fa-font'
   119     icon_hint = _("Rich text")
   118     icon_hint = HTML_PARAGRAPH_NAME
   120 
   119 
   121     body = FieldProperty(IHTMLParagraph['body'])
   120     body = FieldProperty(IHTMLParagraph['body'])
   122     renderer = FieldProperty(IHTMLParagraph['renderer'])
   121     renderer = FieldProperty(IHTMLParagraph['renderer'])
   123 
   122 
   124 
   123 
   125 @utility_config(name=HTML_PARAGRAPH_TYPE, provides=IParagraphFactory)
   124 @utility_config(name=HTML_PARAGRAPH_TYPE, provides=IParagraphFactory)
   126 class HTMLParagraphFactory(BaseParagraphFactory):
   125 class HTMLParagraphFactory(BaseParagraphFactory):
   127     """HTML paragraph factory"""
   126     """HTML paragraph factory"""
   128 
   127 
   129     name = _("Rich text paragraph")
   128     name = HTML_PARAGRAPH_NAME
   130     content_type = HTMLParagraph
   129     content_type = HTMLParagraph
   131 
   130 
   132 
   131 
   133 FULL_EMAIL = re.compile('(.*) \<(.*)\>')
   132 FULL_EMAIL = re.compile('(.*) \<(.*)\>')
   134 
   133