Exemplo n.º 1
0
def add_fields_to_indexing_schema(schemata):
    for t in TYPE_CONFIGURATION:
        title = ' '.join(t.split('_'))

        meta_robots_index_override = schema.Bool(
            title=_("label_meta_robots_override_%s" % t,
                    default=u"Override the default for %s" % title),
            default=False,
            required=False)
        meta_robots_index_override.__name__ = 'meta_robots_index_override_%s' % t
        meta_robots_index_override.interface = schemata
        schemata._InterfaceClass__attrs[meta_robots_index_override.__name__] = meta_robots_index_override

        meta_robots_follow = schema.Choice(
            title=_("label_meta_robots_follow_%s" % t,
                    default=u"Meta Robots Follow Tag for %s" % title),
            values=['follow', 'nofollow'],
            required=False)
        meta_robots_follow.__name__ = 'meta_robots_follow_%s' % t
        meta_robots_follow.interface = schemata
        schemata._InterfaceClass__attrs[meta_robots_follow.__name__] = meta_robots_follow

        meta_robots_index = schema.Choice(
            title=_("label_meta_robots_index_%s" % t,
                    default=u"Meta Robots Index Tag for %s" % title),
            values=['index', 'noindex'],
            required=False)
        meta_robots_index.__name__ = 'meta_robots_index_%s' % t
        meta_robots_index.interface = schemata
        schemata._InterfaceClass__attrs[meta_robots_index.__name__] = meta_robots_index

        meta_robots_advanced = schema.List(
            title=_("label_meta_robots_advanced_%s" % t,
                    default=u"Meta Robots Advanced Tag for %s" % title),
            value_type=schema.Choice(
                      values=['noodp', 'noydir', 'noarchive', 'nosnippet']
                      ),
            required=False)
        meta_robots_advanced.__name__ = 'meta_robots_advanced_%s' % t
        meta_robots_advanced.interface = schemata
        schemata._InterfaceClass__attrs[meta_robots_advanced.__name__] = meta_robots_advanced
Exemplo n.º 2
0
    def handleApply(self, action):  # pylint: disable=W0613
        data, errors = self.extractData()
        if errors:
            return

        annotations = IAnnotations(self.context)
        annotations[PERSEO] = PersistentMapping()
        for k, v in data.items():
            if v:
                annotations[PERSEO][k] = v

        self.setStatusMessage(self.message_ok)
        self.redirectAction()

    @button.buttonAndHandler(_(u"Cancel"))
    def handleCancel(self, action):  # pylint: disable=W0613
        self.setStatusMessage(self.message_cancel)
        self.redirectAction()


manageSEOContext = wrap_form(
    SEOContextForm, label=_(u"PerSEO settings"), description=_(u"Manage PerSEO settings for this content.")
)


class PerseoTabAvailable(BrowserView):
    def checkPerseoTabAvailable(self):
        """ Checks visibility of SEO tab for context
        """
        return not IPloneSiteRoot.providedBy(self.context) and IAnnotatable.providedBy(self.context)