예제 #1
0
    def test_frontend_robots_values(self):
        page = self._get_new_page()

        search = ISearch(page)
        search.robot_configuration = [
            u'index', u'follow', u'noimageindex', u'noarchive', u'nosnippet'
        ]

        tile = MetaDataTile(page, self.request)
        result = tile()
        self.assertTrue(
            'index,follow,noimageindex,noarchive,nosnippet' in result)
예제 #2
0
    def test_robots_values(self):
        page = api.content.create(type='Document',
                                  title='Foobar',
                                  container=self.portal)

        search = ISearch(page)
        search.robot_configuration = [
            u'index', u'follow', u'noimageindex', u'noarchive', u'nosnippet'
        ]

        tile = MetaDataTile(page, self.request)
        result = tile()
        self.assertTrue(
            'index,follow,noimageindex,noarchive,nosnippet' in result)
예제 #3
0
    def test_frontend_robots_no_value(self):
        page = self._get_new_page()

        search = ISearch(page)
        search.robot_configuration = [u'follow']

        tile = MetaDataTile(page, self.request)
        result = tile()
        self.assertTrue('follow,noindex' in result)

        search = ISearch(page)
        search.robot_configuration = [u'index']

        tile = MetaDataTile(page, self.request)
        result = tile()
        self.assertTrue('index,nofollow' in result)
예제 #4
0
파일: metadata.py 프로젝트: sm2x/castle.cms
    def get_basic_tags(self):
        try:
            context = self.context
            if ISiteRoot.providedBy(context):
                try:
                    context = context[get_default_page(context)]
                except AttributeError:
                    pass
            tags = {
                'modificationDate': _date(context, 'modified'),
                'publicationDate': _date(context, 'effective'),
                'expirationDate': _date(context, 'expires'),
                'generator': CASTLE_VERSION_STRING,
                "distribution": "Global",
            }
            ldata = ILocation(context, None)
            if ldata is not None:
                if ldata.locations:
                    location = ldata.locations
                    if type(location) in (list, tuple, set):
                        location = location[0]
                    tags['location'] = location

            search = ISearch(context, None)
            if search is not None:
                robot_configuration = self._get_robot_config(search)
                config = robot_configuration[:]
                if 'index' not in config:
                    config.append('noindex')
                if 'follow' not in config:
                    config.append('nofollow')
                tags['robots'] = ','.join(config)

            return ''.join([
                u'<meta name="{}" content="{}">'.format(name, value)
                for name, value in tags.items()
            ])
        except Exception:
            return u''
예제 #5
0
    def __call__(self, es, existing_data):
        annotations = IAnnotations(self.obj)
        data = {}
        counts = annotations.get(COUNT_ANNOTATION_KEY, {})
        for key, value in counts.items():
            key = key.replace('_matomo', '')
            if isinstance(value, dict):
                value = value.get('total') or 0
            if key in ('page_views', ):
                data[key] = value
            else:
                data[key + '_shares'] = value
        sdata = ISearch(self.obj, None)
        if sdata:
            data['searchterm_pins'] = [
                t.lower() for t in sdata.searchterm_pins or [] if t
            ]
        else:
            data['searchterm_pins'] = []

        try:
            data['SearchableText'] = u'%s %s' % (existing_data.get(
                'SearchableText', ''), u' '.join(data['searchterm_pins']))
        except UnicodeError:
            pass

        try:
            data['contributors'] = list(self.obj.creators +
                                        self.obj.contributors)
        except Exception:
            pass
        path = self.obj.getPhysicalPath()
        data['parent_folder'] = '/'.join(path[:-1])
        site_path = api.portal.get().getPhysicalPath()
        if len(path) > (len(site_path) + 1):
            data['immediate_folder'] = path[len(site_path):][0]
        else:
            data['immediate_folder'] = '/'
        return data