コード例 #1
0
ファイル: test_templatetags.py プロジェクト: StetHD/canvas-2
 def test_title_in_metadata(self):
     user = self.user
     title = "here's a title for this comment"
     cmt = create_comment(title=title)
     ctx = self._ctx(user, cmt)
     cmt = TemplateComment(cmt.details(), request_context=ctx)
     self.assertTrue(strip_template_chars(title) in cmt.shareable_metadata()['title'])
コード例 #2
0
 def test_title_in_metadata(self):
     user = self.user
     title = "here's a title for this comment"
     cmt = create_comment(title=title)
     ctx = self._ctx(user, cmt)
     cmt = TemplateComment(cmt.details(), request_context=ctx)
     self.assertTrue(
         strip_template_chars(title) in cmt.shareable_metadata()['title'])
コード例 #3
0
    def shareable_metadata(self):
        title = 'Canvas'

        if self.thread_title:
            title = strip_template_chars(self.thread_title)
        elif self.title:
            title = strip_template_chars(self.title)
        elif self.category:
            title += ' | Posted in #' + self.category

        description = self.reply_text or self.remix_text or knobs.TAGLINE

        # Suppress flagged comments. Ie, comments that are not public.
        if self.is_inappropriate or self.is_disabled or self.is_removed:
            description = ''

        image = None
        if self.reply_content_id:
            # Get the largest thumbnail we can, from the list of candidates.
            image_data = {}
            for image_type in knobs.FACEBOOK_SHARE_IMAGE_TYPE:
                try:
                    image_data = self.reply_content[image_type]
                except IndexError:
                    continue
                if not image_data:
                    continue
                if image_data['kb'] < knobs.FACEBOOK_SHARE_IMAGE_SIZE_CUTOFF:
                    break
            image = image_data.get('name')

        return {
            'title': title,
            'description': strip_template_chars(description.strip()),
            'image': image,
        }
コード例 #4
0
ファイル: details_models.py プロジェクト: eiritana/canvas
 def ugc_title(self):
     return strip_template_chars(self.title)
コード例 #5
0
ファイル: details_models.py プロジェクト: eiritana/canvas
 def ugc_reply_text(self):
     return strip_template_chars(self.reply_text)
コード例 #6
0
 def ugc_title(self):
     return strip_template_chars(self.title)
コード例 #7
0
ファイル: details_models.py プロジェクト: StetHD/canvas-2
 def ugc_reply_text(self):
     return strip_template_chars(self.reply_text)