products/CPSRSS

changeset 243:56a93ccb2b27

Factorized summarize() to CPSUtil.text
author Georges Racinet on purity.racinet.fr <georges@racinet.fr>
date Mon, 06 Dec 2010 04:18:29 +0100
parents d5edc7d46e93
children 350fa123d006
files skins/getRSSItems.py
diffstat 1 files changed, 2 insertions(+), 13 deletions(-) [+]
line diff
     1.1 --- a/skins/getRSSItems.py
     1.2 +++ b/skins/getRSSItems.py
     1.3 @@ -9,6 +9,8 @@
     1.4  
     1.5  import operator
     1.6  
     1.7 +from Products.CPSUtil.text import summarize
     1.8 +
     1.9  LOG_KEY = 'CPSPortlets.getRSSItems'
    1.10  
    1.11  DEFAULT_RSS_ITEM_DISPLAY = 'cpsportlet_rssitem_display'
    1.12 @@ -48,19 +50,6 @@
    1.13      data_items.sort(key=operator.itemgetter('modified_parsed'), reverse=True)
    1.14      data_items = data_items[:max_items]
    1.15  
    1.16 -def summarize(text='', max_words=20):
    1.17 -    """summarize the text by returning the first max_words
    1.18 -    """
    1.19 -    if not max_words:
    1.20 -        return text
    1.21 -    if not text:
    1.22 -        return ''
    1.23 -    split_text = text.split(' ', max_words)[0:max_words]
    1.24 -    res = ''
    1.25 -    if split_text:
    1.26 -        res = ' '.join(split_text) + ' ...'
    1.27 -    return res
    1.28 -
    1.29  render_method = kw.get('render_method') or DEFAULT_RSS_ITEM_DISPLAY
    1.30  render_method = getattr(context, render_method, None)
    1.31