products/CPSRSS

changeset 163:008b8ea67855

- #1143 remove dependency on CPSBoxes
author jmorliaguet
date Fri, 25 Nov 2005 19:23:20 +0000
parents 323f74c507e4
children 675ded72f72f
files CHANGES Extensions/install.py RSSBox.py __init__.py skins/boxes_rss.pt skins/getCustomBoxTypes.py skins/rssbox_edit_form.pt skins/rssbox_get_info.py
diffstat 8 files changed, 1 insertions(+), 269 deletions(-) [+]
line diff
     1.1 --- a/CHANGES
     1.2 +++ b/CHANGES
     1.3 @@ -6,7 +6,7 @@
     1.4  -
     1.5  Bug fixes:
     1.6  ~~~~~~~~~~
     1.7 --
     1.8 +- #1143 remove dependency on CPSBoxes
     1.9  New internal features:
    1.10  ~~~~~~~~~~~~~~~~~~~~~~
    1.11  -
     2.1 --- a/Extensions/install.py
     2.2 +++ b/Extensions/install.py
     2.3 @@ -153,70 +153,6 @@
     2.4          pr(" Creating RSS Tool (portal_rss)")
     2.5          portal.manage_addProduct["CPSRSS"].manage_addTool('RSS Tool')
     2.6  
     2.7 -    ##########################################
     2.8 -    # PORTAL TYPE
     2.9 -    ##########################################
    2.10 -
    2.11 -    pr("Installing Portal Types")
    2.12 -
    2.13 -    ttool = portal.portal_types
    2.14 -    ptypes_installed = ttool.objectIds()
    2.15 -
    2.16 -    if 'RSS Box' in ptypes_installed:
    2.17 -        pr(" Type RSS Box Deleted")
    2.18 -        ttool.manage_delObjects('RSS Box')
    2.19 -    pr(" Adding Type RSS Box")
    2.20 -    ttool.manage_addTypeInformation(
    2.21 -        add_meta_type='Factory-based Type Information',
    2.22 -        id='RSS Box',
    2.23 -        typeinfo_name='CPSRSS: RSS Box (RSS Box)')
    2.24 -    ttool['RSS Box'].manage_changeProperties(
    2.25 -        title='portal_type_RSSBox_title',
    2.26 -        description='portal_type_RSSBox_description',
    2.27 -        content_meta_type='RSS Box')
    2.28 -
    2.29 -
    2.30 -
    2.31 -    ##########################################
    2.32 -    # SKINS
    2.33 -    ##########################################
    2.34 -
    2.35 -    pr("Installing Skins")
    2.36 -
    2.37 -    skins = ('cps_rss',)
    2.38 -    paths = {'cps_rss': 'Products/CPSRSS/skins'}
    2.39 -
    2.40 -    for skin in skins:
    2.41 -        path = paths[skin]
    2.42 -        pr(" FS Directory View '%s'" % skin)
    2.43 -        if skin in portal.portal_skins.objectIds():
    2.44 -            dv = portal.portal_skins[skin]
    2.45 -            oldpath = dv.getDirPath()
    2.46 -            if oldpath == path:
    2.47 -                prok()
    2.48 -            else:
    2.49 -                pr("  Correctly installed, correcting path")
    2.50 -                dv.manage_properties(dirpath=path)
    2.51 -        else:
    2.52 -            # Hack to Fix CMF 1.5 incompatibility
    2.53 -            if path.startswith("Products/"):
    2.54 -                path = path[len("Products/"):]
    2.55 -            createDirectoryView(portal.portal_skins, path, skin)
    2.56 -            pr("  Creating skin")
    2.57 -    allskins = portal.portal_skins.getSkinPaths()
    2.58 -    for skin_name, skin_path in allskins:
    2.59 -        if skin_name != 'Basic':
    2.60 -            continue
    2.61 -        path = [x.strip() for x in skin_path.split(',')]
    2.62 -        path = [x for x in path if x not in skins] # strip all
    2.63 -        if path and path[0] == 'custom':
    2.64 -            path = path[:1] + list(skins) + path[1:]
    2.65 -        else:
    2.66 -            path = list(skins) + path
    2.67 -        npath = ', '.join(path)
    2.68 -        portal.portal_skins.addSkinSelection(skin_name, npath)
    2.69 -        pr(" Fixup of skin %s" % skin_name)
    2.70 -
    2.71      ##############################################
    2.72      # i18n support
    2.73      ##############################################
     3.1 deleted file mode 100644
     3.2 --- a/RSSBox.py
     3.3 +++ /dev/null
     3.4 @@ -1,85 +0,0 @@
     3.5 -# (C) Copyright 2003 Nuxeo SARL <http://nuxeo.com>
     3.6 -# Author: Emmanuel Pietriga (ep@nuxeo.com)
     3.7 -#
     3.8 -# This program is free software; you can redistribute it and/or modify
     3.9 -# it under the terms of the GNU General Public License version 2 as published
    3.10 -# by the Free Software Foundation.
    3.11 -#
    3.12 -# This program is distributed in the hope that it will be useful,
    3.13 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 -# GNU General Public License for more details.
    3.16 -#
    3.17 -# You should have received a copy of the GNU General Public License
    3.18 -# along with this program; if not, write to the Free Software
    3.19 -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    3.20 -# 02111-1307, USA.
    3.21 -#
    3.22 -# $Id$
    3.23 -"""An RSS box displays an RSS channel in the portal.
    3.24 -"""
    3.25 -
    3.26 -from zLOG import LOG, DEBUG
    3.27 -from Globals import InitializeClass
    3.28 -from AccessControl import ClassSecurityInfo
    3.29 -
    3.30 -from Products.CMFCore.permissions import View, ModifyPortalContent
    3.31 -from Products.CPSBoxes.BaseBox import BaseBox
    3.32 -
    3.33 -factory_type_information = (
    3.34 -    {'id': 'RSS Box',
    3.35 -     'title': 'portal_type_RSSBox_title',
    3.36 -     'description': 'portal_type_RSSBox_description',
    3.37 -     'meta_type': 'RSS Box',
    3.38 -     'content_icon': 'box.png',
    3.39 -     'product': 'CPSRSS',
    3.40 -     'factory': 'addRSSBox',
    3.41 -     'immediate_view': 'rssbox_edit_form',
    3.42 -     'filter_content_types': 0,
    3.43 -     'actions': ({'id': 'view',
    3.44 -                  'name': 'View',
    3.45 -                  'action': 'basebox_view',
    3.46 -                  'permissions': (View,)},
    3.47 -                 {'id': 'edit',
    3.48 -                  'name': 'Edit',
    3.49 -                  'action': 'rssbox_edit_form',
    3.50 -                  'permissions': (ModifyPortalContent,)},
    3.51 -                 ),
    3.52 -     # additionnal cps stuff
    3.53 -     'cps_is_portalbox': 1,
    3.54 -     },
    3.55 -    )
    3.56 -
    3.57 -
    3.58 -class RSSBox(BaseBox):
    3.59 -    """An RSS Box (for displaying RSS channels)."""
    3.60 -
    3.61 -    portal_type = meta_type = 'RSS Box'
    3.62 -
    3.63 -    security = ClassSecurityInfo()
    3.64 -
    3.65 -    _properties = BaseBox._properties + (
    3.66 -        {'id': 'channel_id', 'type': 'string', 'mode': 'w',
    3.67 -         'label': 'RSS Channel Id'},
    3.68 -        {'id': 'nbMaxItems', 'type': 'int', 'mode': 'w',
    3.69 -         'label': 'Maximum number of items'},
    3.70 -        )
    3.71 -
    3.72 -    def __init__(self, id, channel_id='', nbMaxItems=0, **kw):
    3.73 -        BaseBox.__init__(self, id, provider='rss', category='rssbox', kw=kw)
    3.74 -        self.channel_id = channel_id
    3.75 -        self.nbMaxItems = nbMaxItems
    3.76 -
    3.77 -InitializeClass(RSSBox)
    3.78 -
    3.79 -
    3.80 -def addRSSBox(dispatcher, id, REQUEST=None, **kw):
    3.81 -    """Add an RSS Box."""
    3.82 -    ob = RSSBox(id, **kw)
    3.83 -    dispatcher._setObject(id, ob)
    3.84 -    ob = getattr(dispatcher, id)
    3.85 -    ob.manage_permission(View, ('Anonymous',), 1)
    3.86 -    if REQUEST:
    3.87 -        url = dispatcher.DestinationURL()
    3.88 -        REQUEST.RESPONSE.redirect('%s/manage_main' % url)
    3.89 -
     4.1 --- a/__init__.py
     4.2 +++ b/__init__.py
     4.3 @@ -25,24 +25,10 @@
     4.4  from Products.CMFCore.permissions import AddPortalContent
     4.5  
     4.6  import RSSTool
     4.7 -import RSSBox
     4.8 -
     4.9 -
    4.10 -contentClasses = (RSSBox.RSSBox,)
    4.11 -contentConstructors = (RSSBox.addRSSBox,)
    4.12 -fti = (RSSBox.factory_type_information + ())
    4.13 -
    4.14 -registerDirectory('skins', globals())
    4.15  
    4.16  tools = (RSSTool.RSSTool, )
    4.17  
    4.18  def initialize(registrar):
    4.19 -    ContentInit('RSS Boxes',
    4.20 -                content_types=contentClasses,
    4.21 -                permission=AddPortalContent,
    4.22 -                extra_constructors=contentConstructors,
    4.23 -                fti=fti,
    4.24 -                ).initialize(registrar)
    4.25      ToolInit('RSS Tool',
    4.26               tools = tools,
    4.27               icon = 'tool.png',
     5.1 deleted file mode 100644
     5.2 --- a/skins/boxes_rss.pt
     5.3 +++ /dev/null
     5.4 @@ -1,30 +0,0 @@
     5.5 -<!-- rss box macros -->
     5.6 -<!-- $Id$ -->
     5.7 -
     5.8 -<!-- ============================================================ -->
     5.9 -<metal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
    5.10 -             xmlns:metal="http://xml.zope.org/namespaces/metal"
    5.11 -             define-macro="rssbox_default"
    5.12 -             i18n:domain="cpsrss">
    5.13 -  <metal:block use-macro="python:path(box['settings']['box_skin'])">
    5.14 -    <metal:block fill-slot="box_title"
    5.15 -                 tal:condition="box/box/title"
    5.16 -                 tal:content="box/box/title">
    5.17 -      RSS Feed
    5.18 -    </metal:block>
    5.19 -    <metal:block fill-slot="box_body"
    5.20 -                 tal:define="data python:here.rssbox_get_info(
    5.21 -                                 box['box'].channel_id, box['box'].nbMaxItems)">
    5.22 -      <div tal:condition="data/feedType" tal:content="structure data/htmlData">
    5.23 -	No data available
    5.24 -      </div>
    5.25 -      <ul tal:condition="not:data/feedType">
    5.26 -        <li tal:repeat="item data/lines">
    5.27 -          <a href="."
    5.28 -	     tal:attributes="href item/url; target python:data['newWindow'] and '_blank' or None"
    5.29 -             tal:content="item/title">news item</a>
    5.30 -        </li>
    5.31 -      </ul>
    5.32 -    </metal:block>
    5.33 -  </metal:block>
    5.34 -</metal:block>
     6.1 deleted file mode 100644
     6.2 --- a/skins/getCustomBoxTypes.py
     6.3 +++ /dev/null
     6.4 @@ -1,16 +0,0 @@
     6.5 -## Script (Python) "getCustomBoxTypes"
     6.6 -##parameters=
     6.7 -# $Id$
     6.8 -"""Return custom  box types."""
     6.9 -
    6.10 -items = [{'category': 'rssbox',
    6.11 -          'title': 'portal_type_RssBox_title',
    6.12 -          'desc':'portal_type_RssBox_description',
    6.13 -          'types': [{'provider': 'rss',
    6.14 -                     'id': 'default',
    6.15 -                     'desc': 'description_rss_rssbox_default'},
    6.16 -                    ]
    6.17 -          },
    6.18 -         ]
    6.19 -
    6.20 -return items
     7.1 deleted file mode 100644
     7.2 --- a/skins/rssbox_edit_form.pt
     7.3 +++ /dev/null
     7.4 @@ -1,42 +0,0 @@
     7.5 -<!-- $Id$ -->
     7.6 -
     7.7 -<metal:html xmlns:tal="http://xml.zope.org/namespaces/tal"
     7.8 -            xmlns:metal="http://xml.zope.org/namespaces/metal"
     7.9 -            use-macro="here/main_template/macros/master"
    7.10 -            i18n:domain="cpsrss">
    7.11 -
    7.12 -<metal:main fill-slot="main">
    7.13 -
    7.14 -<metal:boxform use-macro="here/basebox_edit_form/macros/boxform">
    7.15 -
    7.16 -<metal:fields fill-slot="additional_fields">
    7.17 -  <tr valign="top">
    7.18 -    <th align="right" i18n:translate="label_channel">Channel</th>
    7.19 -    <td>
    7.20 -      <select name="channel_id">
    7.21 -        <tal:block repeat="aFeed here/portal_rss/objectValues">
    7.22 -          <option tal:condition="python:box['box'].channel_id == aFeed.id"
    7.23 -                  tal:attributes="value aFeed/id|string:;
    7.24 -                                  selected string:selected;"
    7.25 -                  tal:content="aFeed/title">Feed Title</option>
    7.26 -          <option tal:condition="not:python:box['box'].channel_id == aFeed.id"
    7.27 -                  tal:attributes="value aFeed/id|string:"
    7.28 -                  tal:content="aFeed/title">Feed Title</option>
    7.29 -        </tal:block>
    7.30 -      </select>
    7.31 -    </td>
    7.32 -  </tr>
    7.33 -  <tr valign="top">
    7.34 -    <th align="right" i18n:translate="label_max_items">Max items displayed</th>
    7.35 -    <td>
    7.36 -      <input type="text" name="nbMaxItems:int" size="2" value=""
    7.37 -             tal:attributes="value box/box/nbMaxItems|string:" />
    7.38 -    </td>
    7.39 -  </tr>
    7.40 -</metal:fields>
    7.41 -
    7.42 -</metal:boxform>
    7.43 -
    7.44 -</metal:main>
    7.45 -
    7.46 -</metal:html>
     8.1 deleted file mode 100644
     8.2 --- a/skins/rssbox_get_info.py
     8.3 +++ /dev/null
     8.4 @@ -1,17 +0,0 @@
     8.5 -## Script (Python) "rssbox_get_info"
     8.6 -##parameters=channel_id, maxItems=None
     8.7 -
     8.8 -# $Id$
     8.9 -
    8.10 -channel = getattr(context.portal_rss, channel_id, None)
    8.11 -
    8.12 -if channel is None:
    8.13 -    return {'title': "Broken RSS Channel",
    8.14 -            'description': "This RSS Feed is badly configured (unknown URL).",
    8.15 -            'url': ".",
    8.16 -            'lines': [],
    8.17 -            'newWindow': 0,
    8.18 -            'feedType': 0, #RSS feed
    8.19 -            }
    8.20 -
    8.21 -return channel.getData(maxItems)