def _oembed_comment(thing, **embed_options): link = thing.link_slow subreddit = link.subreddit_slow if (not can_view_link_comments(link) or subreddit.type in Subreddit.private_types): raise ForbiddenError(errors.COMMENT_NOT_ACCESSIBLE) if not thing._deleted: author = thing.author_slow if author._deleted: author_name = _("[account deleted]") else: author_name = author.name title = _('%(author)s\'s comment from discussion "%(title)s"') % { "author": author_name, "title": _force_unicode(link.title), } else: author_name = "" title = "" parent = "true" if embed_options.get('parent') else "false" html = format_html( embeds.get_inject_template(embed_options.get('omitscript')), media=g.media_domain, parent=parent, live="true" if embed_options.get('live') else "false", created=datetime.now(g.tz).isoformat(), comment=thing.make_permalink_slow(force_domain=True), link=link.make_permalink_slow(force_domain=True), title=websafe(title), uuid=uuid1(), ) oembed_response = dict( _OEMBED_BASE, type="rich", title=title, author_name=author_name, html=html, ) if author_name: oembed_response['author_url'] = make_url_https('/user/' + author_name) return oembed_response
def _oembed_comment(thing, **embed_options): link = thing.link_slow subreddit = link.subreddit_slow if (not can_view_link_comments(link) or subreddit.type in Subreddit.private_types): raise ForbiddenError(errors.COMMENT_NOT_ACCESSIBLE) if not thing._deleted: author = thing.author_slow if author._deleted: author_name = _("[account deleted]") else: author_name = author.name title = _('%(author)s\'s comment from discussion "%(title)s"') % { "author": author_name, "title": _force_unicode(link.title), } else: author_name = "" title = "" parent = "true" if embed_options.get('parent') else "false" html = format_html(embeds.get_inject_template(embed_options.get('omitscript')), media=g.media_domain, parent=parent, live="true" if embed_options.get('live') else "false", created=datetime.now(g.tz).isoformat(), comment=thing.make_permalink_slow(force_domain=True), link=link.make_permalink_slow(force_domain=True), title=websafe(title), uuid=uuid1(), ) oembed_response = dict(_OEMBED_BASE, type="rich", title=title, author_name=author_name, html=html, ) if author_name: oembed_response['author_url'] = make_url_https('/user/' + author_name) return oembed_response
def _oembed_comment(thing, **embed_options): link = thing.link_slow if not can_view_link_comments(link): raise ForbiddenError("Cannot access this comment.") if not thing._deleted: author = thing.author_slow if author._deleted: author_name = _("[account deleted]") else: author_name = author.name title = _('%(author)s\'s comment from discussion "%(title)s"') % { "author": author_name, "title": link.title, } else: author_name = "" title = "" html = format_html( embeds.get_inject_template(), media=g.media_domain, parent="true" if embed_options.get('parent') else "false", live="true" if embed_options.get('live') else "false", created=datetime.now(g.tz).isoformat(), comment=thing.make_permalink_slow(force_domain=True), link=link.make_permalink_slow(force_domain=True), title=websafe(title), ) oembed_response = dict( _OEMBED_BASE, type="rich", title=title, author_name=author_name, html=html, ) if author_name: oembed_response['author_url'] = make_url_https('/user/' + author_name) return oembed_response
def _oembed_comment(thing, **embed_options): link = thing.link_slow if not can_view_link_comments(link): raise ForbiddenError("Cannot access this comment.") if not thing._deleted: author = thing.author_slow if author._deleted: author_name = _("[account deleted]") else: author_name = author.name title = _('%(author)s\'s comment from discussion "%(title)s"') % { "author": author_name, "title": _force_unicode(link.title), } else: author_name = "" title = "" html = format_html(embeds.get_inject_template(), media=g.media_domain, parent="true" if embed_options.get('parent') else "false", live="true" if embed_options.get('live') else "false", created=datetime.now(g.tz).isoformat(), comment=thing.make_permalink_slow(force_domain=True), link=link.make_permalink_slow(force_domain=True), title=websafe(title), ) oembed_response = dict(_OEMBED_BASE, type="rich", title=title, author_name=author_name, html=html, ) if author_name: oembed_response['author_url'] = make_url_https('/user/' + author_name) return oembed_response