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'])
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'])
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, }
def ugc_title(self): return strip_template_chars(self.title)
def ugc_reply_text(self): return strip_template_chars(self.reply_text)