src/pyams_content/features/thesaurus/__init__.py
changeset 1132 f1276d7bc4ce
child 1133 52a1a1db5ec5
equal deleted inserted replaced
1131:64747fd623b3 1132:f1276d7bc4ce
       
     1 #
       
     2 # Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     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
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 from persistent import Persistent
       
    16 from zope.container.contained import Contained
       
    17 from zope.interface import implementer
       
    18 from zope.schema.fieldproperty import FieldProperty
       
    19 
       
    20 from pyams_content.features.thesaurus.interfaces import IThesaurusTermHTMLInfo, IThesaurusTermHTMLTarget, \
       
    21     THESAURUS_TERM_HTML_INFO_KEY
       
    22 from pyams_thesaurus.interfaces.extension import IThesaurusTermExtension
       
    23 from pyams_utils.adapter import adapter_config, get_annotation_adapter
       
    24 from pyams_utils.factory import factory_config
       
    25 from pyams_utils.registry import utility_config
       
    26 
       
    27 from pyams_content import _
       
    28 
       
    29 
       
    30 @factory_config(provided=IThesaurusTermHTMLInfo)
       
    31 @implementer(IThesaurusTermHTMLInfo)
       
    32 class ThesaurusTermHTMLInfo(Persistent, Contained):
       
    33     """Thesaurus term HTML description"""
       
    34 
       
    35     description = FieldProperty(IThesaurusTermHTMLInfo['description'])
       
    36 
       
    37 
       
    38 @adapter_config(context=IThesaurusTermHTMLTarget, provides=IThesaurusTermHTMLInfo)
       
    39 def thesaurus_term_html_description_factory(context):
       
    40     """Thesaurus term HTML description factory"""
       
    41     return get_annotation_adapter(context, THESAURUS_TERM_HTML_INFO_KEY, IThesaurusTermHTMLInfo)
       
    42 
       
    43 
       
    44 @utility_config(name='html', provides=IThesaurusTermExtension)
       
    45 class HTMLThesaurusExtension(object):
       
    46     """HTML description thesaurus extension"""
       
    47 
       
    48     label = _("Rich text description")
       
    49 
       
    50     target_interface = IThesaurusTermHTMLTarget
       
    51     target_view = 'html-description.html'
       
    52 
       
    53     icon = '<i class="fa fa-fw fa-font"></i>'