コード例 #1
0
class SettingsForm(form.EditForm):
    label = _(u'heading_syndication_properties',
              default=u'Syndication Properties')
    description = _(
        u'description_syndication_properties',
        default=u'Syndication enables you to syndicate this folder so it can'
        u'be synchronized from other web sites.')
    fields = field.Fields(IFeedSettings)

    @button.buttonAndHandler(_(u'Save'), name='save')
    def handleSave(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        self.applyChanges(data)
コード例 #2
0
 def getSyndicationLinkShown(self):
     actions = getToolByName(self.context, 'portal_actions')
     if 'rss' in actions.document_actions.objectIds():
         return actions.document_actions.rss.getProperty('visible')
     else:
         IStatusMessage(self.request).addStatusMessage(
             _(u"Missing rss link action."), "warn")
コード例 #3
0
 def getSyndicationSettingsButtonShown(self):
     actions = getToolByName(self.context, 'portal_actions')
     if 'syndication' in actions.object.objectIds():
         return actions.object.syndication.getProperty('visible')
     else:
         IStatusMessage(self.request).addStatusMessage(
             _(u"Missing syndication settings action."), "warn")
コード例 #4
0
class IFeedSettings(Interface):

    enabled = schema.Bool(title=_(u'Enabled'), default=False)

    feed_types = schema.Tuple(
        title=_(u'Feed Types'),
        required=True,
        missing_value=None,
        default=("RSS", "rss", "rss.xml", "atom.xml", "newsml.xml"),
        value_type=schema.Choice(
            vocabulary=
            "collective.syndication.vocabularies.SyndicationFeedTypes"))

    render_body = schema.Bool(title=_(u'Render Body'),
                              description=_(
                                  u'help_render_body',
                                  default=u'If body text available for item, '
                                  u'render it, otherwise use description.'),
                              default=False)

    max_items = schema.Int(
        title=_(u'label_syndication_max_items', default=u'Maximum Items'),
        description=_(
            u'help_syndication_max_items',
            default=u'Maximum number of items that will be syndicated.'),
        default=15)
コード例 #5
0
    def handleSave(self, action):
        """
        Again, we're customizing this to handle saving
        portal_actions related setting data.
        """
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        self.setSyndicationActionSettings(data)
        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved."),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
コード例 #6
0
class ISiteSyndicationSettings(Interface):

    allowed = schema.Bool(title=_(u'Allowed'),
                          description=_(
                              u'Allow syndication for collections and folders '
                              u'on site.'),
                          default=True)

    default_enabled = schema.Bool(
        title=_(u'Enabled by default'),
        description=_(u'If syndication should be enabled by default for all '
                      u'folders and collections.'),
        default=False)

    search_rss_enabled = schema.Bool(
        title=_(u'Search RSS enabled'),
        description=_(u'Allows users to subscribe to feeds of search results'),
        default=True)

    show_author_info = schema.Bool(
        title=_(u'Show author info'),
        description=_(u'Should feeds include author information'),
        default=True)

    render_body = schema.Bool(title=_(u'Render Body'),
                              description=_(
                                  u'help_render_body',
                                  default=u'If body text available for item, '
                                  u'render it, otherwise use description.'),
                              default=False)

    max_items = schema.Int(
        title=_(u'label_syndication_max_items', default=u'Maximum Items'),
        description=_(
            u'help_syndication_max_items',
            default=u'Maximum number of items that will be syndicated.'),
        default=15)

    allowed_feed_types = schema.Tuple(
        title=_(u'Allowed Feed Types'),
        description=_(u'Separate view name and title by "|"'),
        required=True,
        missing_value=None,
        default=("RSS|RSS 1.0", "rss|RSS 2.0", "rss.xml|RSS 2.0",
                 "atom.xml|Atom", "itunes.xml|iTunes",
                 "newsml.xml|NewsML 1.2"),
        value_type=schema.TextLine())

    site_rss_items = schema.Tuple(
        title=_(u'Site RSS'),
        description=_(u'Paths to folders and collections to link to '
                      u'at the portal root.'),
        required=False,
        default=('/news/aggregator', ),
        value_type=schema.Choice(
            vocabulary=
            "collective.syndication.vocabularies.SyndicatableFeedItems"))

    show_syndication_button = schema.Bool(
        title=_(u"Show Settings Button"),
        description=_(u"Makes it possible to customize syndication settings "
                      u"for particular folders and collections "))

    show_syndication_link = schema.Bool(
        title=_(u"Show Feed Link"),
        description=_(u"Enable RSS link document action on the syndication "
                      u"content item."))
コード例 #7
0
 def handleCancel(self, action):
     IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled."),
                                                   "info")
     self.request.response.redirect(
         "%s/%s" % (self.context.absolute_url(), self.control_panel_view))
コード例 #8
0
class SyndicationControlPanelForm(controlpanel.RegistryEditForm):
    schema = ISiteSyndicationSettings
    label = _(u'Syndication Settings')
    description = _(u'Default syndication settings.')

    def getSyndicationSettingsButtonShown(self):
        actions = getToolByName(self.context, 'portal_actions')
        if 'syndication' in actions.object.objectIds():
            return actions.object.syndication.getProperty('visible')
        else:
            IStatusMessage(self.request).addStatusMessage(
                _(u"Missing syndication settings action."), "warn")

    def getSyndicationLinkShown(self):
        actions = getToolByName(self.context, 'portal_actions')
        if 'rss' in actions.document_actions.objectIds():
            return actions.document_actions.rss.getProperty('visible')
        else:
            IStatusMessage(self.request).addStatusMessage(
                _(u"Missing rss link action."), "warn")

    def getContent(self):
        """
        We override this so we can get actual
        settings for portal_actions related settings
        """
        content = getUtility(IRegistry).forInterface(self.schema,
                                                     prefix=self.schema_prefix)
        show_settings_btn = self.getSyndicationSettingsButtonShown()
        if show_settings_btn != content.show_syndication_button:
            content.show_syndication_button = show_settings_btn
        show_link_btn = self.getSyndicationLinkShown()
        if show_link_btn != content.show_syndication_link:
            content.show_syndication_link = show_link_btn
        return content

    def setSyndicationActionSettings(self, data):
        actions = getToolByName(self.context, 'portal_actions')
        if 'syndication' in actions.object.objectIds():
            actions.object.syndication._setPropValue(
                'visible', data['show_syndication_button'])
        if 'rss' in actions.document_actions.objectIds():
            actions.document_actions.rss._setPropValue(
                'visible', data['show_syndication_link'])

    @button.buttonAndHandler(_(u"Save"), name='save')
    def handleSave(self, action):
        """
        Again, we're customizing this to handle saving
        portal_actions related setting data.
        """
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        self.setSyndicationActionSettings(data)
        self.applyChanges(data)
        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved."),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))

    @button.buttonAndHandler(_(u"Cancel"), name='cancel')
    def handleCancel(self, action):
        IStatusMessage(self.request).addStatusMessage(_(u"Edit cancelled."),
                                                      "info")
        self.request.response.redirect(
            "%s/%s" % (self.context.absolute_url(), self.control_panel_view))