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


Python menus.CommentSortMenu类代码示例

本文整理汇总了Python中r2.lib.menus.CommentSortMenu的典型用法代码示例。如果您正苦于以下问题:Python CommentSortMenu类的具体用法?Python CommentSortMenu怎么用?Python CommentSortMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommentSortMenu类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GET_comments

    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,代码行数:31,代码来源:toolbar.py

示例2: POST_morechildren

    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,代码行数:30,代码来源:api.py

示例3: GET_show

  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,代码行数:46,代码来源:meetupscontroller.py

示例4:

 pref_hide_ups=VBoolean('hide_ups'),
 pref_hide_downs=VBoolean('hide_downs'),
 pref_over_18=VBoolean('over_18'),
 pref_research=VBoolean('research'),
 pref_numsites=VInt('numsites', 1, 100),
 pref_lang=VLang('lang'),
 pref_media=VOneOf('media', ('on', 'off', 'subreddit')),
 pref_compress=VBoolean('compress'),
 pref_domain_details=VBoolean('domain_details'),
 pref_min_link_score=VInt('min_link_score', -100, 100),
 pref_min_comment_score=VInt('min_comment_score', -100, 100),
 pref_num_comments=VInt('num_comments', 1, g.max_comments,
                        default=g.num_comments),
 pref_highlight_controversial=VBoolean('highlight_controversial'),
 pref_default_comment_sort=VOneOf('default_comment_sort',
                                  CommentSortMenu.visible_options()),
 pref_ignore_suggested_sort=VBoolean("ignore_suggested_sort"),
 pref_show_stylesheets=VBoolean('show_stylesheets'),
 pref_show_flair=VBoolean('show_flair'),
 pref_show_link_flair=VBoolean('show_link_flair'),
 pref_no_profanity=VBoolean('no_profanity'),
 pref_label_nsfw=VBoolean('label_nsfw'),
 pref_show_promote=VBoolean('show_promote'),
 pref_mark_messages_read=VBoolean("mark_messages_read"),
 pref_threaded_messages=VBoolean("threaded_messages"),
 pref_collapse_read_messages=VBoolean("collapse_read_messages"),
 pref_email_messages=VBoolean("email_messages"),
 pref_private_feeds=VBoolean("private_feeds"),
 pref_store_visits=VBoolean('store_visits'),
 pref_hide_ads=VBoolean("hide_ads"),
 pref_show_trending=VBoolean("show_trending"),
开发者ID:ActivateServices,项目名称:reddit,代码行数:31,代码来源:preferences.py

示例5: __init__

 def __init__(self, query, sr_ids, **kw):
     UnbannedCommentBuilder.__init__(self, query, sr_ids, **kw)
     self.sort = CommentSortMenu.operator(CommentSortMenu.default)
开发者ID:bairyn,项目名称:lesswrong,代码行数:3,代码来源:builder.py

示例6:

 pref_public_votes=VBoolean("public_votes"),
 pref_hide_from_robots=VBoolean("hide_from_robots"),
 pref_hide_ups=VBoolean("hide_ups"),
 pref_hide_downs=VBoolean("hide_downs"),
 pref_over_18=VBoolean("over_18"),
 pref_research=VBoolean("research"),
 pref_numsites=VInt("numsites", 1, 100),
 pref_lang=VLang("lang"),
 pref_media=VOneOf("media", ("on", "off", "subreddit")),
 pref_compress=VBoolean("compress"),
 pref_domain_details=VBoolean("domain_details"),
 pref_min_link_score=VInt("min_link_score", -100, 100),
 pref_min_comment_score=VInt("min_comment_score", -100, 100),
 pref_num_comments=VInt("num_comments", 1, g.max_comments, default=g.num_comments),
 pref_highlight_controversial=VBoolean("highlight_controversial"),
 pref_default_comment_sort=VOneOf("default_comment_sort", CommentSortMenu.visible_options()),
 pref_ignore_suggested_sort=VBoolean("ignore_suggested_sort"),
 pref_show_stylesheets=VBoolean("show_stylesheets"),
 pref_show_flair=VBoolean("show_flair"),
 pref_show_link_flair=VBoolean("show_link_flair"),
 pref_no_profanity=VBoolean("no_profanity"),
 pref_label_nsfw=VBoolean("label_nsfw"),
 pref_show_promote=VBoolean("show_promote"),
 pref_mark_messages_read=VBoolean("mark_messages_read"),
 pref_threaded_messages=VBoolean("threaded_messages"),
 pref_collapse_read_messages=VBoolean("collapse_read_messages"),
 pref_email_messages=VBoolean("email_messages"),
 pref_private_feeds=VBoolean("private_feeds"),
 pref_store_visits=VBoolean("store_visits"),
 pref_hide_ads=VBoolean("hide_ads"),
 pref_show_trending=VBoolean("show_trending"),
开发者ID:Shilohtd,项目名称:reddit,代码行数:31,代码来源:preferences.py


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