本文整理汇总了Python中r2.lib.menus.CommentSortMenu.operator方法的典型用法代码示例。如果您正苦于以下问题:Python CommentSortMenu.operator方法的具体用法?Python CommentSortMenu.operator怎么用?Python CommentSortMenu.operator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.lib.menus.CommentSortMenu
的用法示例。
在下文中一共展示了CommentSortMenu.operator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET_comments
# 需要导入模块: from r2.lib.menus import CommentSortMenu [as 别名]
# 或者: from r2.lib.menus.CommentSortMenu import operator [as 别名]
def GET_comments(self, link):
if not link:
self.abort404()
if not link.subreddit_slow.can_view(c.user):
abort(403, 'forbidden')
links = list(wrap_links(link))
if not links:
# they aren't allowed to see this link
return self.abort(403, 'forbidden')
link = links[0]
wrapper = make_wrapper(render_class = StarkComment,
target = "_top")
b = TopCommentBuilder(link, CommentSortMenu.operator('confidence'),
wrap = wrapper)
listing = NestedListing(b, num = 10, # TODO: add config var
parent_name = link._fullname)
raw_bar = strings.comments_panel_text % dict(
fd_link=link.permalink)
md_bar = safemarkdown(raw_bar, target="_top")
res = RedditMin(content=CommentsPanel(link=link,
listing=listing.listing(),
expanded=auto_expand_panel(link),
infobar=md_bar))
return res.render()
示例2: POST_morechildren
# 需要导入模块: from r2.lib.menus import CommentSortMenu [as 别名]
# 或者: from r2.lib.menus.CommentSortMenu import operator [as 别名]
def POST_morechildren(self, res, link, sort, children, depth, mc_id):
if children:
builder = CommentBuilder(link, CommentSortMenu.operator(sort), children)
items = builder.get_items(starting_depth = depth, num = 20)
def _children(cur_items):
items = []
for cm in cur_items:
items.append(cm)
if hasattr(cm, 'child'):
if hasattr(cm.child, 'things'):
items.extend(_children(cm.child.things))
cm.child = None
else:
items.append(cm.child)
return items
# assumes there is at least one child
# a = _children(items[0].child.things)
a = []
for item in items:
a.append(item)
if hasattr(item, 'child'):
a.extend(_children(item.child.things))
item.child = None
# the result is not always sufficient to replace the
# morechildren link
if mc_id not in [x._fullname for x in a]:
res._hide('thingrow_' + str(mc_id))
res._send_things(a)
示例3: GET_show
# 需要导入模块: from r2.lib.menus import CommentSortMenu [as 别名]
# 或者: from r2.lib.menus.CommentSortMenu import operator [as 别名]
def GET_show(self, meetup, sort, num_comments):
article = Link._byID(meetup.assoc_link)
# figure out number to show based on the menu
user_num = c.user.pref_num_comments or g.num_comments
num = g.max_comments if num_comments == 'true' else user_num
builder = CommentBuilder(article, CommentSortMenu.operator(sort), None, None)
listing = NestedListing(builder, num=num, parent_name = article._fullname)
displayPane = PaneStack()
# insert reply box only for logged in user
if c.user_is_loggedin:
displayPane.append(CommentReplyBox())
displayPane.append(CommentReplyBox(link_name =
article._fullname))
# finally add the comment listing
displayPane.append(listing.listing())
sort_menu = CommentSortMenu(default = sort, type='dropdown2')
nav_menus = [sort_menu,
NumCommentsMenu(article.num_comments,
default=num_comments)]
content = CommentListing(
content = displayPane,
num_comments = article.num_comments,
nav_menus = nav_menus,
)
# Update last viewed time, and return the previous last viewed time. Actually tracked on the article
lastViewed = None
if c.user_is_loggedin:
clicked = article._getLastClickTime(c.user)
lastViewed = clicked._date if clicked else None
article._click(c.user)
res = ShowMeetup(meetup = meetup, content = content,
fullname=article._fullname,
lastViewed = lastViewed)
return BoringPage(pagename = meetup.title,
content = res,
body_class = 'meetup').render()
示例4: __init__
# 需要导入模块: from r2.lib.menus import CommentSortMenu [as 别名]
# 或者: from r2.lib.menus.CommentSortMenu import operator [as 别名]
def __init__(self, query, sr_ids, **kw):
UnbannedCommentBuilder.__init__(self, query, sr_ids, **kw)
self.sort = CommentSortMenu.operator(CommentSortMenu.default)