Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
Archivo: api.py Proyecto: cmak/reddit
    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)
Ejemplo n.º 4
0
    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 abort(403, 'forbidden')
        link = links[0]

        wrapper = make_wrapper(render_class = StarkComment,
                               target = "_top")
        b = TopCommentBuilder(link, CommentSortMenu.operator('confidence'),
                              num=10, wrap=wrapper)

        listing = NestedListing(b, 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()
Ejemplo n.º 5
0
  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()
Ejemplo n.º 6
0
 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"),
Ejemplo n.º 7
0
 def __init__(self, query, sr_ids, **kw):
     UnbannedCommentBuilder.__init__(self, query, sr_ids, **kw)
     self.sort = CommentSortMenu.operator(CommentSortMenu.default)
Ejemplo n.º 8
0
 def __init__(self, query, sr_ids, **kw):
     UnbannedCommentBuilder.__init__(self, query, sr_ids, **kw)
     self.sort = CommentSortMenu.operator(CommentSortMenu.default)
Ejemplo n.º 9
0
 pref_research=VBoolean('research'),
 pref_numsites=VInt('numsites', 1, 100),
 pref_lang=VLang('lang'),
 pref_media=VOneOf('media', ('on', 'off', 'subreddit')),
 # pref_media_preview=VOneOf('media_preview', ('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"),
Ejemplo n.º 10
0
 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"),