Skip to content

Commit

Permalink
Implement cropping for CroppedDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed Sep 10, 2015
1 parent 7b3daad commit 4563e1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.2.1 (unreleased)
------------------

- Nothing changed yet.
- Implement cropping for CroppedDescription.
[pbauer]


1.2 (2015-07-18)
Expand Down
11 changes: 8 additions & 3 deletions plone/app/contentlisting/catalog.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# -*- coding: utf-8 -*-
from .contentlisting import BaseContentListingObject
from .interfaces import IContentListingObject
from Acquisition import aq_base
from Acquisition import aq_get
from Products.CMFCore.utils import getToolByName
from plone.app.layout.icons.interfaces import IContentIcon
from plone.registry.interfaces import IRegistry
from plone.uuid.interfaces import IUUID
from zope import interface
from zope.component import getMultiAdapter
from zope.component import queryMultiAdapter
from zope.component import queryUtility


class CatalogContentListingObject(BaseContentListingObject):
Expand Down Expand Up @@ -108,9 +112,10 @@ def Description(self):
return self._brain.Description

def CroppedDescription(self):
# TODO: Let's port Plones description cropping here instead of
# implementing it all in the templates.
return self.Description()
registry = queryUtility(IRegistry)
length = registry.get('plone.search_results_description_length')
plone_view = getMultiAdapter((self, self.request), name='plone')
return plone_view.cropText(self.Description(), length)

def Type(self):
return self._brain.Type
Expand Down

0 comments on commit 4563e1e

Please sign in to comment.