diff --git a/buildout.cfg b/buildout.cfg index ffea04dc..f2c075b8 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -6,6 +6,7 @@ extends = package-name = collective.nitf package-extras = [test] +eggs = collective.cover parts += code-analysis @@ -66,6 +67,12 @@ plone.app.querystring = 1.2.5 plone.recipe.codeanalysis = 2.0b1 # use latest version of setuptools setuptools = +# collective.cover version pinnings +collective.js.bootstrap = 2.3.1.1 +plone.app.blocks = 1.1.1 +plone.app.drafts = 1.0a2 +plone.app.tiles = 1.0.1 +plone.tiles = 1.2 [zopepy] recipe = zc.recipe.egg diff --git a/src/collective/nitf/configure.zcml b/src/collective/nitf/configure.zcml index 1705ac5b..002c1f9d 100644 --- a/src/collective/nitf/configure.zcml +++ b/src/collective/nitf/configure.zcml @@ -3,6 +3,7 @@ xmlns:browser="http://namespaces.zope.org/browser" xmlns:five="http://namespaces.zope.org/five" xmlns:i18n="http://namespaces.zope.org/i18n" + xmlns:zcml="http://namespaces.zope.org/zcml" i18n_domain="collective.nitf"> @@ -15,6 +16,7 @@ + NITF + + + collective.nitf + + + diff --git a/src/collective/nitf/static/tile-nitf.png b/src/collective/nitf/static/tile-nitf.png new file mode 100644 index 00000000..d298389f Binary files /dev/null and b/src/collective/nitf/static/tile-nitf.png differ diff --git a/src/collective/nitf/tiles/__init__.py b/src/collective/nitf/tiles/__init__.py new file mode 100644 index 00000000..40a96afc --- /dev/null +++ b/src/collective/nitf/tiles/__init__.py @@ -0,0 +1 @@ +# -*- coding: utf-8 -*- diff --git a/src/collective/nitf/tiles/configure.zcml b/src/collective/nitf/tiles/configure.zcml new file mode 100644 index 00000000..40694713 --- /dev/null +++ b/src/collective/nitf/tiles/configure.zcml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/src/collective/nitf/tiles/nitf.pt b/src/collective/nitf/tiles/nitf.pt new file mode 100644 index 00000000..b6942b4d --- /dev/null +++ b/src/collective/nitf/tiles/nitf.pt @@ -0,0 +1,67 @@ + + + +

+ Drag&drop a News Article here. +

+ +
+ + +

+ + + +

Subtitle

+
+ +
+ +
+ + + + + + + + +

Description

+
+ + +

Section

+
+ + +

May 5

+
+ + + + + + +
+
+ +

+ + diff --git a/src/collective/nitf/tiles/nitf.py b/src/collective/nitf/tiles/nitf.py new file mode 100644 index 00000000..a125b8bc --- /dev/null +++ b/src/collective/nitf/tiles/nitf.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +from collective.cover.tiles.basic import BasicTile +from collective.cover.tiles.basic import IBasicTile +from collective.cover.tiles.configuration_view import IDefaultConfigureForm +from collective.nitf import _ +from collective.nitf.content import INITF +from plone import api +from plone.autoform import directives as form +from plone.tiles.interfaces import ITileDataManager +from zope import schema +from zope.browserpage import ViewPageTemplateFile +from zope.interface import implements + + +class INITFTile(IBasicTile): + + """A tile that shows information about a News Article.""" + + subtitle = schema.Text( + title=_(u'Subtitle'), + required=False, + ) + + form.omitted('section') + form.no_omit(IDefaultConfigureForm, 'section') + section = schema.Text( + title=_(u'Section'), + required=False, + ) + + media_producer = schema.TextLine( + # nitf/body/body.content/media/media-producer + title=_(u'Image Rights'), + required=False, + ) + + +class NITFTile(BasicTile): + + """A tile that shows information about a News Article.""" + + implements(INITFTile) + + index = ViewPageTemplateFile('nitf.pt') + is_configurable = True + is_editable = True + is_droppable = True + + short_name = _(u'msg_short_name_nitf', u'News Article') + + def _accepted_ct(self): + """Return a list of content types accepted by the tile.""" + return ['News Article'] + + def populate_with_object(self, obj): + super(NITFTile, self).populate_with_object(obj) + + if INITF.providedBy(obj): + data_mgr = ITileDataManager(self) + data = data_mgr.get() + data['subtitle'] = obj.subtitle + data['section'] = obj.section + image = obj.getImage() + data['media_producer'] = image.Rights() if image is not None else '' + data_mgr.set(data) + + def _get_field_configuration(self, field): + """Return a dict with the configuration of the field. This is a + helper function to deal with the ugliness of the internal data + structure. + """ + fields = self.get_configured_fields() + return [f for f in fields if f['id'] == field][0] + + @property + def title_tag(self): + field = self._get_field_configuration('title') + tag, title, href = field['htmltag'], field['content'], self.getURL() + return u""" + <{tag}> + {title} + + """.format(tag=tag, title=title, href=href) + + def Date(self): + """Return the date of the object, localized.""" + date = super(NITFTile, self).Date() + return api.portal.get_localized_time(date, long_format=True)