def getFeedItem(self, context, doc):
     """ getFeedItem
     """
     adapter = queryMultiAdapter((doc, context), IFeedItem)
     if adapter is None:
         adapter = BaseItem(doc, context)
     return adapter
Exemple #2
0
 def test_link_on_default_page(self):
     self.folder._setProperty('default_page', 'doc2')
     feeddatadoc2 = BaseItem(self.doc2, self.feed)
     self.assertEqual(feeddatadoc2.link, self.folder.absolute_url())
Exemple #3
0
 def afterSetUp(self):
     super(TestSyndicationFeedAdapter, self).afterSetUp()
     self.feed = IFeed(self.folder)
     self.feeddatadoc = BaseItem(self.doc1, self.feed)
     self.feeddatafile = BaseItem(self.file, self.feed)
Exemple #4
0
    def update(self):
        super(SocialTagsViewlet, self).update()
        registry = getUtility(IRegistry)
        settings = registry.forInterface(ISocialMediaSchema,
                                         prefix="plone",
                                         check=False)

        if not settings.share_social_data:
            self.tags = []
            return

        self.tags = [
            dict(name="twitter:card", content="summary"),
            dict(name="twitter:title", content=self.page_title),
            dict(property="og:title", content=self.page_title),
            dict(itemprop="name", content=self.page_title),
            dict(property="og:type", content="website"),
            dict(property="og:site_name", content=self.site_title_setting),
        ]
        if settings.twitter_username:
            self.tags.append(
                dict(name="twitter:site",
                     content="@" + settings.twitter_username))
        if settings.facebook_app_id:
            self.tags.append(
                dict(property="fb:app_id", content=settings.facebook_app_id))
        if settings.facebook_username:
            self.tags.append(
                dict(property="og:article:publisher",
                     content="https://www.facebook.com/" +
                     settings.facebook_username))

        # reuse syndication since that packages the data
        # the way we'd prefer likely
        site = getSite()
        feed = FolderFeed(site)
        item = queryMultiAdapter((self.context, feed), IFeedItem, default=None)
        if item is None:
            item = BaseItem(self.context, feed)

        self.tags.extend([
            dict(name="twitter:description", content=item.description),
            dict(property="og:description", content=item.description),
            dict(itemprop="description", content=item.description),
            dict(name="twitter:url", content=item.link),
            dict(property="og:url", content=item.link),
        ])

        found_image = False
        if item.has_enclosure and item.file_length > 0:
            if item.file_type.startswith('image'):
                found_image = True
                self.tags.extend([
                    dict(name="twitter:image", content=item.file_url),
                    dict(property="og:image", content=item.file_url),
                    dict(itemprop="image", content=item.file_url),
                    dict(property="og:image:type", content=item.file_type)
                ])
            elif (item.file_type.startswith('video')
                  or item.file_type == "application/x-shockwave-flash"):
                self.tags.extend([
                    dict(property="og:video", content=item.file_url),
                    dict(property="og:video:type", content=item.file_type)
                ])
            elif item.file_type.startswith('audio'):
                self.tags.extend([
                    dict(property="og:audio", content=item.file_url),
                    dict(property="og:audio:type", content=item.file_type)
                ])

        if not found_image:
            url = getSiteLogo()
            self.tags.extend([
                dict(name="twitter:image", content=url),
                dict(property="og:image", content=url),
                dict(itemprop="image", content=url),
                dict(property="og:image:type", content='image/png')
            ])