Skip to content

Commit

Permalink
Punt
Browse files Browse the repository at this point in the history
  • Loading branch information
aclark4life committed Aug 25, 2013
1 parent a1d125c commit 76e2869
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
21 changes: 21 additions & 0 deletions rpi/asthma_files_site/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<configure
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:gs="http://namespaces.zope.org/genericsetup"
xmlns:monkey="http://namespaces.plone.org/monkey"
xmlns:plone="http://namespaces.plone.org/plone">

<include package=".browser" />
<include package=".content" />
<include package="five.grok" />
<include package="collective.monkeypatcher" />
<include package="z3c.jbot" file="meta.zcml" />

<browser:jbot directory="template-overrides" />

<!--
<browser:resource
name="asthma_files_logo.png"
image="theme/images/logo.png"
/>
-->

<gs:registerProfile
name="default"
Expand All @@ -22,6 +27,22 @@
title="Asthma Files Site"
/>

<!--
<monkey:patch
description="Add image_artifact to Banner tile"
class="collective.cover.tiles.banner.BannerTile"
original="accepted_ct"
replacement=".content.image_artifact.accepted_ct"
/>
<monkey:patch
description="Add image_artifact to Banner tile"
class="collective.cover.tiles.banner.BannerTile"
original="accepted_ct"
replacement=".content.image_artifact.populate_with_object"
/>
-->

<plone:static directory="theme" type="theme" />

</configure>
37 changes: 37 additions & 0 deletions rpi/asthma_files_site/content/image_artifact.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collective.cover.tiles.banner import BannerTile
from plone.directives import form
from plone.namedfile.field import NamedBlobImage
from zope.schema import TextLine
Expand Down Expand Up @@ -29,3 +30,39 @@ class IImageArtifact(form.Schema):
subject = TextLine(title=u"Subject", required=False)

dublin_core_type = TextLine(title=u"Type", required=False)


# Monkey patch collective.cover
def accepted_ct():
return ['Image', 'Link', 'image_artifact']


# Monkey patch collective.cover
def populate_with_object(obj):
"""Tile can be populated with images and links; in this case we're not
going to take care of any modification of the original object; we just
copy the data to the tile and deal with it.
"""
if obj.context.portal_type not in accepted_ct():
return

super(banner.BannerTile, self).populate_with_object(obj.context) # check permissions
obj = aq_base(obj.context) # avoid acquisition
title = obj.context.Title()
# if image, store a copy of its data
if obj.context.portal_type == 'Image' or obj.context.portal_type == 'image_artifact':
if hasattr(obj.context, 'getImage'):
data = obj.context.getImage().data
else:
data = obj.context.image.data
image = NamedBlobImage(data)
else:
image = None
remote_url = obj.context.getRemoteUrl() if obj.context.portal_type == 'Link' else None

data_mgr = ITileDataManager(self)
data_mgr.set({
'title': title,
'image': image,
'remote_url': remote_url,
})

0 comments on commit 76e2869

Please sign in to comment.