当前位置: 首页>>代码示例>>Python>>正文


Python CommentSortMenu.operator方法代码示例

本文整理汇总了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()
开发者ID:AD42,项目名称:reddit,代码行数:33,代码来源:toolbar.py

示例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)
开发者ID:cmak,项目名称:reddit,代码行数:32,代码来源:api.py

示例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()
开发者ID:JoshuaDavid,项目名称:lesswrong-1,代码行数:48,代码来源:meetupscontroller.py

示例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)
开发者ID:bairyn,项目名称:lesswrong,代码行数:5,代码来源:builder.py


注:本文中的r2.lib.menus.CommentSortMenu.operator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。