Example #1
0
 def __init__(self, user, type, cellnames, container_name, editable):
     self.user, self.type, self.cells = user, type, cellnames
     self.container_name = container_name
     self.name           = "tr_%s_%s" % (user.name, type)
     self.editable       = editable
     Wrapped.__init__(self)
     Ajaxed.__init__(self, 'UserTable', 'add')
Example #2
0
File: pages.py Project: vin/reddit
    def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
                 infotext = '', content = None, title = '', robots = None, 
                 show_sidebar = True, **context):
        Wrapped.__init__(self, **context)
        self.title          = title
        self.robots         = robots
        self.infotext       = infotext
        self.loginbox       = True
        self.show_sidebar   = show_sidebar
        self.space_compress = space_compress

        #put the sort menus at the top
        self.nav_menu = MenuArea(menus = nav_menus) if nav_menus else None

        #add the infobar
        self.infobar = None
        if c.firsttime and c.site.firsttext and not infotext:
            infotext = c.site.firsttext
        if infotext:
            self.infobar = InfoBar(message = infotext)

        self.srtopbar = None
        if not c.cname:
            self.srtopbar = SubredditTopBar()

        if c.user_is_loggedin and self.show_sidebar:
            self._content = PaneStack([ShareLink(), content])
        else:
            self._content = content
        
        self.toolbars = self.build_toolbars()
Example #3
0
 def __init__(self, link = None, button = None, css=None, 
              url = None, title = '', score_fmt = None, vote = True, target = "_parent", 
              bgcolor = None, width = 100):
     Wrapped.__init__(self, link = link, score_fmt = score_fmt,
                      likes = link.likes if link else None, 
                      button = button, css = css, url = url, title = title, 
                      vote = vote, target = target, bgcolor=bgcolor, width=width)
Example #4
0
 def __init__(self, sr = None, link = None, listing = '',
              timedeltatext = '', *a, **kw):
     Wrapped.__init__(self, sr = sr, link = link,
                      datefmt = datefmt,
                      timedeltatext = timedeltatext,
                      listing = listing,
                      *a, **kw)
Example #5
0
 def __init__(self, sr = None, link = None, listing = '',
              timedeltatext = '', *a, **kw):
     Wrapped.__init__(self, sr = sr, link = link,
                      datefmt = datefmt,
                      timedeltatext = timedeltatext,
                      listing = listing,
                      *a, **kw)
Example #6
0
File: pages.py Project: vin/reddit
 def __init__(self, user, type, cellnames, container_name, editable):
     self.user, self.type, self.cells = user, type, cellnames
     self.container_name = container_name
     self.name           = "tr_%s_%s" % (user.name, type)
     self.editable       = editable
     Wrapped.__init__(self)
     Ajaxed.__init__(self, 'UserTable', 'add')
Example #7
0
File: pages.py Project: cmak/reddit
    def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
                 infotext = '', content = None, title = '', show_sidebar = True,
                 **context):
        Wrapped.__init__(self, **context)
        self.title          = title
        self.infotext       = infotext
        self.loginbox       = True
        self.show_sidebar   = show_sidebar
        self.space_compress = space_compress

        #put the sort menus at the top
        self.nav_menu = MenuArea(menus = nav_menus) if nav_menus else None

        #add the infobar
        self.infobar = None
        if c.firsttime and c.site.firsttext and not infotext:
            infotext = c.site.firsttext
        if infotext:
            self.infobar = InfoBar(message = infotext)

        #c.subredditbox is set by VSRMask
        self.subreddit_sidebox = False
        if c.subreddit_sidebox:
            self.subreddit_sidebox = True
            self.subreddit_checkboxes = c.site == Default

        self._content = content
        self.toolbars = self.build_toolbars()
Example #8
0
File: pages.py Project: vin/reddit
    def __init__(self):
        Wrapped.__init__(self)

        my_reddits = []
        sr_ids = Subreddit.user_subreddits(c.user if c.user_is_loggedin else None)
        if sr_ids:
            my_reddits = Subreddit._byID(sr_ids, True,
                                         return_dict = False)
            my_reddits.sort(key = lambda sr: sr.name.lower())

        drop_down_buttons = []    
        for sr in my_reddits:
            drop_down_buttons.append(SubredditButton(sr))

        #leaving the 'home' option out for now
        #drop_down_buttons.insert(0, NamedButton('home', sr_path = False,
        #                                        css_class = 'top-option',
        #                                        dest = '/'))
        drop_down_buttons.append(NamedButton('edit', sr_path = False,
                                             css_class = 'bottom-option',
                                             dest = '/reddits/'))
        self.sr_dropdown = SubredditMenu(drop_down_buttons,
                                         title = _('my reddits'),
                                         type = 'srdrop')

    
        pop_reddits = Subreddit.default_srs(c.content_langs, limit = 30)        
        buttons = [SubredditButton(sr) for sr in c.recent_reddits]
        for sr in pop_reddits:
            if sr not in c.recent_reddits:
                buttons.append(SubredditButton(sr))
    
        self.sr_bar = NavMenu(buttons, type='flatlist', separator = '-',
                                        _id = 'sr-bar')
Example #9
0
    def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
                 infotext = '', content = None, title = '', robots = None, 
                 show_sidebar = True, body_class = None, **context):
        Wrapped.__init__(self, **context)
        self.title          = title
        self.robots         = robots
        self.infotext       = infotext
        self.loginbox       = True
        self.show_sidebar   = show_sidebar
        self.space_compress = space_compress
        self.body_class     = body_class

        #put the sort menus at the top
        self.nav_menu = MenuArea(menus = nav_menus) if nav_menus else None

        #add the infobar
        self.infobar = None
        if c.firsttime and c.site.firsttext and not infotext:
            infotext = c.site.firsttext
        if not infotext and hasattr(c.site, 'infotext'):
            infotext = c.site.infotext
        if infotext:
            self.infobar = InfoBar(message = infotext)

        self.srtopbar = None
        if not c.cname:
            self.srtopbar = SubredditTopBar()

        self._content = content
        self.toolbars = self.build_toolbars()
Example #10
0
File: pages.py Project: vin/reddit
 def __init__(self, panes=[], div_id = None, css_class=None, div=False):
     div = div or div_id or css_class or False
     self.div_id    = div_id
     self.css_class = css_class
     self.div       = div
     self.stack     = list(panes)
     Wrapped.__init__(self)
Example #11
0
 def __init__(self, panes=[], div_id = None, css_class=None, div=False):
     div = div or div_id or css_class or False
     self.div_id    = div_id
     self.css_class = css_class
     self.div       = div
     self.stack     = list(panes)
     Wrapped.__init__(self)
Example #12
0
File: pages.py Project: vin/reddit
 def __init__(self, link = None, button = None, css=None, 
              url = None, title = '', score_fmt = None, vote = True, target = "_parent", 
              bgcolor = None, width = 100):
     Wrapped.__init__(self, link = link, score_fmt = score_fmt,
                      likes = link.likes if link else None, 
                      button = button, css = css, url = url, title = title, 
                      vote = vote, target = target, bgcolor=bgcolor, width=width)
Example #13
0
    def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
                 infotext = '', content = None, title = '', robots = None, 
                 show_sidebar = True, body_class = None, **context):
        Wrapped.__init__(self, **context)
        self.title          = title
        self.robots         = robots
        self.infotext       = infotext
        self.loginbox       = True
        self.show_sidebar   = show_sidebar
        self.space_compress = space_compress
        self.body_class     = body_class

        #put the sort menus at the top
        self.nav_menu = MenuArea(menus = nav_menus) if nav_menus else None

        #add the infobar
        self.infobar = None
        if c.firsttime and c.site.firsttext and not infotext:
            infotext = c.site.firsttext
        if not infotext and hasattr(c.site, 'infotext'):
            infotext = c.site.infotext
        if infotext:
            self.infobar = InfoBar(message = infotext)

        self.srtopbar = None
        if not c.cname:
            self.srtopbar = SubredditTopBar()

        self._content = content
        self.toolbars = self.build_toolbars()
Example #14
0
    def __init__(self, *args, **kwargs):
        from r2.lib.user_stats import top_users
        uids = top_users()
        users = Account._byID(uids, data=True, return_dict=False)

        # Filter out accounts banned from the default subreddit
        sr = Subreddit._by_name(g.default_sr)
        self.things = filter(lambda user: not sr.is_banned(user), users)

        Wrapped.__init__(self, *args, **kwargs)
Example #15
0
    def __init__(self, *args, **kwargs):
        from r2.lib.user_stats import top_users
        uids = top_users()
        users = Account._byID(uids, data=True, return_dict=False)

        # Filter out accounts banned from the default subreddit
        sr = Subreddit._by_name(g.default_sr)
        self.things = filter(lambda user: not sr.is_banned(user), users)

        Wrapped.__init__(self, *args, **kwargs)
Example #16
0
    def __init__(self, *args, **kwargs):
        from r2.lib.user_stats import top_users
        uids = top_users()
        # Returns a hash keyed in the uid
        users = Account._byID(uids, data=True)
        # Retrieve the Account objects in this way to preseve the sort order
        all_users = (users[u] for u in uids)

        # Filter out banned and spammy accounts
        self.things = filter(lambda user: not c.site.is_banned(user) and user.spammer < 1, all_users)

        Wrapped.__init__(self, *args, **kwargs)
Example #17
0
File: pages.py Project: vin/reddit
 def __init__(self, original_path, subreddit, sub_domain):
     Wrapped.__init__(self, original_path=original_path)
     if sub_domain and subreddit and original_path:
         self.title = "%s - %s" % (subreddit.title, sub_domain)
         u = UrlParser(subreddit.path + original_path)
         u.hostname = get_domain(cname = False, subreddit = False)
         u.update_query(**request.get.copy())
         u.put_in_frame()
         self.frame_target = u.unparse()
     else:
         self.title = ""
         self.frame_target = None
Example #18
0
 def __init__(self, original_path, subreddit, sub_domain):
     Wrapped.__init__(self, original_path=original_path)
     if sub_domain and subreddit and original_path:
         self.title = "%s - %s" % (subreddit.title, sub_domain)
         u = UrlParser(subreddit.path + original_path)
         u.hostname = get_domain(cname = False, subreddit = False)
         u.update_query(**request.get.copy())
         u.put_in_frame()
         self.frame_target = u.unparse()
     else:
         self.title = ""
         self.frame_target = None
Example #19
0
File: pages.py Project: vin/reddit
    def __init__(self, num_results = 0, prev_search = '', elapsed_time = 0, **kw):

        # not listed explicitly in args to ensure it translates properly
        self.header = kw.get('header', _("previous search"))

        self.prev_search  = prev_search
        self.elapsed_time = elapsed_time

        # All results are approximate unless there are fewer than 10.
        if num_results > 10:
            self.num_results = (num_results / 10) * 10
        else:
            self.num_results = num_results

        Wrapped.__init__(self)
Example #20
0
    def __init__(self, num_results = 0, prev_search = '', elapsed_time = 0, **kw):

        # not listed explicitly in args to ensure it translates properly
        self.header = kw.get('header', _("Previous search"))

        self.prev_search  = prev_search
        self.elapsed_time = elapsed_time

        # All results are approximate unless there are fewer than 10.
        if num_results > 10:
            self.num_results = (num_results / 10) * 10
        else:
            self.num_results = num_results

        Wrapped.__init__(self)
Example #21
0
File: pages.py Project: cmak/reddit
    def __init__(self, checkboxes = True):
        Wrapped.__init__(self)

        self.checkboxes = checkboxes
        if checkboxes:
            self.title = _('Customize your reddit')
            self.subtitle = _('Select which communities you want to see')
        else:
            self.title = _('Other reddit communities')
            self.subtitle = 'Visit your subscribed reddits (in bold) or explore new ones'
        self.create_link = ('/reddits/', menu.more)
        self.more_link   = ('/reddits/create', _('create'))

        my_reddits = []
        sr_ids = Subreddit.user_subreddits(c.user if c.user_is_loggedin else None)
        if sr_ids:
            my_reddits = Subreddit._byID(sr_ids, True,
                                         return_dict = False)
            my_reddits.sort(key = lambda sr: sr._downs, reverse = True)

        display_reddits = my_reddits[:g.num_side_reddits]
        
        #remove the current reddit
        display_reddits = filter(lambda x: x != c.site, display_reddits)

        pop_reddits = Subreddit.default_srs(c.content_langs, limit = g.num_side_reddits)
        #add english reddits to the list
        if c.content_langs != 'all' and 'en' not in c.content_langs:
            en_reddits = Subreddit.default_srs(['en'])
            pop_reddits += [sr for sr in en_reddits if sr not in pop_reddits]

        for sr in pop_reddits:
            if len(display_reddits) >= g.num_side_reddits:
                break

            if sr != c.site and sr not in display_reddits:
                display_reddits.append(sr)

        col1, col2 = [], []
        cur_col, other = col1, col2
        for sr in display_reddits:
            cur_col.append((sr, sr in my_reddits))
            cur_col, other = other, cur_col

        self.cols = ((col1, col2))
        self.mine = my_reddits
Example #22
0
    def __init__(self):
        Wrapped.__init__(self)
        cache_stats = cache.get('stats')
        if cache_stats:
            top_users, top_day, top_week = cache_stats

            #lookup user objs
            uids = []
            uids.extend(u    for u in top_users)
            uids.extend(u[0] for u in top_day)
            uids.extend(u[0] for u in top_week)
            users = Account._byID(uids, data = True)

            self.top_users = (users[u]            for u in top_users)
            self.top_day   = ((users[u[0]], u[1]) for u in top_day)
            self.top_week  = ((users[u[0]], u[1]) for u in top_week)
        else:
            self.top_users = self.top_day = self.top_week = ()
Example #23
0
File: pages.py Project: vin/reddit
    def __init__(self):
        Wrapped.__init__(self)
        cache_stats = cache.get('stats')
        if cache_stats:
            top_users, top_day, top_week = cache_stats

            #lookup user objs
            uids = []
            uids.extend(u    for u in top_users)
            uids.extend(u[0] for u in top_day)
            uids.extend(u[0] for u in top_week)
            users = Account._byID(uids, data = True)

            self.top_users = (users[u]            for u in top_users)
            self.top_day   = ((users[u[0]], u[1]) for u in top_day)
            self.top_week  = ((users[u[0]], u[1]) for u in top_week)
        else:
            self.top_users = self.top_day = self.top_week = ()
Example #24
0
    def __init__(self):
        Wrapped.__init__(self)
        
        self.title = _('Other reddit communities')
        self.subtitle = 'Visit your subscribed categories (in bold) or explore new ones'
        self.create_link = ('/categories/', menu.more)
        self.more_link   = ('/categories/create', _('Create'))

        my_reddits = []
        sr_ids = Subreddit.user_subreddits(c.user if c.user_is_loggedin else None)
        if sr_ids:
            my_reddits = Subreddit._byID(sr_ids, True,
                                         return_dict = False)
            my_reddits.sort(key = lambda sr: sr._downs, reverse = True)

        display_reddits = my_reddits[:g.num_side_reddits]
        
        #remove the current reddit
        display_reddits = filter(lambda x: x != c.site, display_reddits)

        pop_reddits = Subreddit.default_srs(c.content_langs, limit = g.num_side_reddits)
        #add english reddits to the list
        if c.content_langs != 'all' and 'en' not in c.content_langs:
            en_reddits = Subreddit.default_srs(['en'])
            pop_reddits += [sr for sr in en_reddits if sr not in pop_reddits]

        for sr in pop_reddits:
            if len(display_reddits) >= g.num_side_reddits:
                break

            if sr != c.site and sr not in display_reddits:
                display_reddits.append(sr)

        col1, col2 = [], []
        cur_col, other = col1, col2
        for sr in display_reddits:
            cur_col.append((sr, sr in my_reddits))
            cur_col, other = other, cur_col

        self.cols = ((col1, col2))
        self.mine = my_reddits
Example #25
0
    def __init__(self):
        Wrapped.__init__(self)

        my_reddits = []
        sr_ids = Subreddit.user_subreddits(c.user if c.user_is_loggedin else None)
        if sr_ids:
            my_reddits = Subreddit._byID(sr_ids, True,
                                         return_dict = False)
            my_reddits.sort(key = lambda sr: sr.name.lower())

        drop_down_buttons = []    
        for sr in my_reddits:
            drop_down_buttons.append(SubredditButton(sr))

        #leaving the 'home' option out for now
        #drop_down_buttons.insert(0, NamedButton('home', sr_path = False,
        #                                        css_class = 'top-option',
        #                                        dest = '/'))
        drop_down_buttons.append(NamedButton('edit', sr_path = False,
                                             css_class = 'bottom-option',
                                             dest = '/categories/'))
        self.sr_dropdown = SubredditMenu(drop_down_buttons,
                                         title = _('My categories'),
                                         type = 'srdrop')

    
        pop_reddits = Subreddit.default_srs(c.content_langs, limit = 30)
        buttons = []
        for sr in c.recent_reddits:
            # Extra guarding for Issue #50
            if hasattr(sr, 'name'):
                buttons.append(SubredditButton(sr))

        for sr in pop_reddits:
            if sr not in c.recent_reddits:
                buttons.append(SubredditButton(sr))
    
        self.sr_bar = NavMenu(buttons, type='flatlist', separator = '-',
                                        _id = 'sr-bar')
Example #26
0
File: pages.py Project: vin/reddit
 def __init__(self, button = None, width = 100, height=100, referer = "", url = ""):
     Wrapped.__init__(self, button = button, width = width, height = height,
                      referer=referer, url = url)
Example #27
0
File: pages.py Project: vin/reddit
 def __init__(self, link_name = "", emails = None):
     captcha = Captcha() if c.user.needs_captcha() else None
     Wrapped.__init__(self, link_name = link_name,
                      emails = c.user.recent_share_emails(),
                      captcha = captcha)
Example #28
0
File: pages.py Project: vin/reddit
 def __init__(self, link = None, **kw):
     self.title = link.title
     Wrapped.__init__(self, link = link, *kw)
Example #29
0
 def __init__(self, site = None, name = '', listings = []):
     Wrapped.__init__(self, site = site, name = name, listings = listings)
Example #30
0
File: pages.py Project: vin/reddit
 def __init__(self, error=None):
     self.error = _('try entering those letters again') if error else ""
     self.iden = get_captcha()
     Wrapped.__init__(self)
Example #31
0
File: pages.py Project: vin/reddit
 def __init__(self,content = ''):
     Wrapped.__init__(self, content = content)
Example #32
0
 def __init__(self, prev_search = ''):
     Wrapped.__init__(self, prev_search = prev_search)
Example #33
0
 def __init__(self, link):
     Wrapped.__init__(self)
     self.link = link
Example #34
0
 def __init__(self, link_name = "", emails = None):
     captcha = Captcha() if c.user.needs_captcha() else None
     Wrapped.__init__(self, link_name = link_name,
                      emails = c.user.recent_share_emails(),
                      captcha = captcha)
Example #35
0
 def __init__(self, captcha = None, article = '', title= '', subreddits = (), tags = (), sr_id = None):
     Wrapped.__init__(self, captcha = captcha, article = article,
                      title = title, subreddits = subreddits, tags = tags,
                      sr_id = sr_id)
Example #36
0
 def __init__(self, link = None, **kw):
     self.title = link.title
     Wrapped.__init__(self, link = link, *kw)
Example #37
0
 def __init__(self, url='', title='', fullname=''):
     Wrapped.__init__(self, url = url, title = title, fullname = fullname)
Example #38
0
 def __init__(self, link):
     if link:
       self.articleurl = link.url
     else:
       self.articleurl = None
     Wrapped.__init__(self)
Example #39
0
File: pages.py Project: vin/reddit
 def __init__(self, buttons=["reddit", "like", "dislike",
                          "save", "serendipity!"]):
     Wrapped.__init__(self, buttons = buttons)
Example #40
0
 def __init__(self, comments_url, has_more_comments=False):
     self.comments_url = comments_url
     self.has_more_comments = has_more_comments
     Wrapped.__init__(self)
Example #41
0
 def __init__(self, link, author):
   Wrapped.__init__(self, article=link, author=author)
Example #42
0
 def __init__(self, content, num_comments, nav_menus = []):
     Wrapped.__init__(self, content=content, num_comments=num_comments, menus = nav_menus)
Example #43
0
File: pages.py Project: vin/reddit
 def __init__(self, link_name='', captcha=None, action = 'comment'):
     Wrapped.__init__(self, link_name = link_name, captcha = captcha,
                      action = action)
Example #44
0
 def __init__(self, link_name='', captcha=None, action = 'comment'):
     Wrapped.__init__(self, link_name = link_name, captcha = captcha,
                      action = action)
Example #45
0
File: pages.py Project: vin/reddit
 def __init__(self, prev_search = ''):
     Wrapped.__init__(self, prev_search = prev_search)
Example #46
0
 def __init__(self, error=None):
     self.error = _('Try entering those letters again') if error else ""
     self.iden = get_captcha()
     Wrapped.__init__(self)
Example #47
0
File: pages.py Project: vin/reddit
 def __init__(self, url='', title='', fullname=''):
     Wrapped.__init__(self, url = url, title = title, fullname = fullname)
Example #48
0
 def __init__(self, success=False):
     Wrapped.__init__(self, success = success)
Example #49
0
File: pages.py Project: vin/reddit
 def __init__(self, captcha = None, url = '', title= '', subreddits = ()):
     Wrapped.__init__(self, captcha = captcha, url = url,
                      title = title, subreddits = subreddits)
Example #50
0
 def __init__(self, article):
     self.article = article
     Wrapped.__init__(self)
Example #51
0
 def __init__(self,status,img_src, name="", errors = {}):
     self.errors = list(errors.iteritems())
     Wrapped.__init__(self, status=status, img_src=img_src, name = name)
Example #52
0
 def __init__(self, error):
     # error is an instance of cssutils.py:ValidationError
     Wrapped.__init__(self, error = error)
Example #53
0
File: pages.py Project: vin/reddit
 def __init__(self, image = None, link = None, url = "", styled = True, target = '_top'):
     Wrapped.__init__(self, image = image, link = link, url = url, styled = styled, target = target)
Example #54
0
 def __init__(self, site = None,
              stylesheet_contents = ''):
     Wrapped.__init__(self, site = site,
                      stylesheet_contents = stylesheet_contents)
Example #55
0
File: pages.py Project: vin/reddit
 def __init__(self, captcha=None, title=None, action='/feedback',
                 message='', name='', email='', replyto='', success = False):
     Wrapped.__init__(self, captcha = captcha, title = title, action = action,
                      message = message, name = name, email = email, replyto = replyto,
                      success = success)
Example #56
0
File: pages.py Project: vin/reddit
 def __init__(self,status,img_src, name="", errors = {}):
     self.errors = list(errors.iteritems())
     Wrapped.__init__(self, status=status, img_src=img_src, name = name)
Example #57
0
File: pages.py Project: vin/reddit
 def __init__(self):
     from r2.lib.translation import list_translations
     Wrapped.__init__(self)
     self.translations = list_translations()
Example #58
0
File: pages.py Project: vin/reddit
 def __init__(self, success=False):
     Wrapped.__init__(self, success = success)
Example #59
0
File: pages.py Project: vin/reddit
 def __init__(self, **kw):
     message = kw.get('message', _("This feature is currently unavailable. Sorry"))
     Wrapped.__init__(self, message = message)
Example #60
0
 def __init__(self):
     Wrapped.__init__(self)