示例#1
0
    def menus(self):
        filters = [
            NamedButton('all_promos', dest=''),
            NamedButton('future_promos'),
            NamedButton('unpaid_promos'),
            NamedButton('rejected_promos'),
            NamedButton('pending_promos'),
            NamedButton('live_promos'),
        ]
        menus = [NavMenu(filters, base_path='/promoted', title='show',
                        type='lightdrop')]

        if self.sort == 'live_promos' and c.user_is_sponsor:
            srnames = promote.all_live_promo_srnames()
            buttons = [NavButton('all', '')]
            try:
                srnames.remove(Frontpage.name)
                frontbutton = NavButton('FRONTPAGE', Frontpage.name,
                                        aliases=['/promoted/live_promos/%s' %
                                                 urllib.quote(Frontpage.name)])
                buttons.append(frontbutton)
            except KeyError:
                pass

            srnames = sorted(srnames, key=lambda name: name.lower())
            buttons.extend([NavButton(name, name) for name in srnames])
            menus.append(NavMenu(buttons, base_path='/promoted/live_promos',
                                 title='subreddit', type='lightdrop'))

        return menus
示例#2
0
    def menus(self):
        if self.sort in {'underdelivered', 'reported', 'house', 'fraud'}:
            menus = []
        else:
            menus = super(SponsorListingController, self).menus
            menus.append(NavMenu([
                QueryButton("exclude managed", dest=None,
                            query_param='include_managed'),
                QueryButton("include managed", dest="yes",
                            query_param='include_managed'),
            ], base_path=request.path, type='lightdrop'))

        if self.sort == 'live_promos':
            srnames = promote.all_live_promo_srnames()
            buttons = [NavButton('all', '', use_params=True)]
            try:
                srnames.remove(Frontpage.name)
                frontbutton = NavButton('FRONTPAGE', Frontpage.name,
                                        use_params=True,
                                        aliases=['/promoted/live_promos/%s' %
                                                 urllib.quote(Frontpage.name)])
                buttons.append(frontbutton)
            except KeyError:
                pass

            srnames = sorted(srnames, key=lambda name: name.lower())
            buttons.extend(
                NavButton(name, name, use_params=True) for name in srnames)
            base_path = self.base_path + '/live_promos'
            menus.append(NavMenu(buttons, base_path=base_path,
                                 title='subreddit', type='lightdrop'))
        return menus
示例#3
0
    def menus(self):
        filters = [
            NamedButton('all_promos', dest=''),
            NamedButton('future_promos'),
            NamedButton('unpaid_promos'),
            NamedButton('rejected_promos'),
            NamedButton('pending_promos'),
            NamedButton('live_promos'),
        ]
        menus = [
            NavMenu(filters,
                    base_path='/promoted',
                    title='show',
                    type='lightdrop')
        ]

        if self.sort == 'live_promos' and c.user_is_sponsor:
            sr_names = self.subreddits_with_promos()
            buttons = [NavButton(name, name) for name in sr_names]
            frontbutton = NavButton('FRONTPAGE',
                                    Frontpage.name,
                                    aliases=[
                                        '/promoted/live_promos/%s' %
                                        urllib.quote(Frontpage.name)
                                    ])
            buttons.insert(0, frontbutton)
            buttons.insert(0, NavButton('all', ''))
            menus.append(
                NavMenu(buttons,
                        base_path='/promoted/live_promos',
                        title='subreddit',
                        type='lightdrop'))

        return menus
示例#4
0
 def __init__(self, path, user):
     # CUSTOM
     buttons = [
         OffsiteButton(menu.ip_history, '/admin/iphistory?username='******'/admin/nukecontent?recipient=' + urllib.quote_plus(user.name)),
     ]
     NavMenu.__init__(self, buttons, base_path = path,
                      title = 'admin', type="tabdrop")
示例#5
0
    def build_toolbars(self):
        toolbars = []
        if c.user_is_loggedin and c.user.employee:
            tabs = [
                NavButton(
                    _("reddit live"),
                    "/",
                ),
                NavButton(
                    _("active"),
                    "/active",
                ),
                NavButton(
                    _("live"),
                    "/open",
                ),
                NavButton(
                    _("closed"),
                    "/closed",
                ),
            ]

            if c.user_is_admin:
                tabs.append(NavButton(
                    _("reported"),
                    "/reported",
                ))

            toolbars.append(NavMenu(
                tabs,
                base_path="/live/",
                type="tabmenu",
            ))
        return toolbars
示例#6
0
    def header_nav(self):
        buttons =  [NavButton(menu.popular, ""),
                    NamedButton("new")]
        if c.user_is_admin:
            buttons.append(NamedButton("banned"))

        return NavMenu(buttons, base_path = '/categories')
    def build_toolbars(self):
        toolbars = []

        if c.liveupdate_permissions:
            tabs = [
                NavButton(
                    _("updates"),
                    "/",
                ),
            ]

            if c.liveupdate_permissions.allow("settings"):
                tabs.append(NavButton(
                    _("settings"),
                    "/edit",
                ))

            # all contributors should see this so they can leave if they want
            tabs.append(NavButton(
                _("contributors"),
                "/contributors",
            ))

            toolbars.append(NavMenu(
                tabs,
                base_path="/live/" + c.liveupdate_event._id,
                type="tabmenu",
            ))

        return toolbars
示例#8
0
    def nav(self):
        cloud = Tag.tag_cloud_for_subreddits([c.current_or_default_sr._id])

        buttons = []
        for tag, weight in cloud:
            buttons.append(NavButton(tag.name, tag.name, css_class=self.numbers[weight - 1]))

        return NavMenu(buttons, type="flatlist", separator=' ', base_path='/tag/')
示例#9
0
    def build_toolbars(self):
        main_buttons = [NavButton(menu.sitewide, "/"),
                        NamedButton("languages"),
                        NamedButton("adverts")]

        toolbar = [PageNameNav("nomenu", title=self.title),
                   NavMenu(main_buttons, base_path="/traffic", type="tabmenu")]

        return toolbar
示例#10
0
 def content(self):
     about_buttons = [
         NavButton(_('about reddit'), '/'),
         NavButton(_('team'), '/team'),
         NavButton(_('postcards'), '/postcards'),
         NavButton(_('alien'), '/alien'),
         #NavButton(_('guide'), '/guide')
     ]
     about_menu = NavMenu(about_buttons, type='tabmenu', base_path='/about/', css_class='about-menu')
     return self.content_stack([AboutTitle(self.title_msg), about_menu, self._content])
示例#11
0
def admin_menu(**kwargs):
    buttons = [
        OffsiteButton("traffic", "/traffic"),
        NavButton(menu.awards, "awards"),
        NavButton(menu.errors, "error log"),
    ]

    admin_menu = NavMenu(buttons, title='admin tools', base_path='/admin',
                         type="lightdrop", **kwargs)
    return admin_menu
示例#12
0
 def menus(self):
     filters = [
         NamedButton('all_promos', dest='', use_params=True,
                     aliases=['/sponsor']),
         NamedButton('future_promos', use_params=True),
         NamedButton('unpaid_promos', use_params=True),
         NamedButton('rejected_promos', use_params=True),
         NamedButton('pending_promos', use_params=True),
         NamedButton('live_promos', use_params=True),
     ]
     menus = [NavMenu(filters, base_path=self.base_path, title='show',
                      type='lightdrop')]
     return menus
示例#13
0
    def nav(self):
        is_moderator = c.user_is_loggedin and \
            c.site.is_moderator(c.user) or c.user_is_admin

        buttons = [NavButton(plurals.moderators, 'moderators')]
        if c.site.type != 'public':
            buttons.append(NavButton(plurals.contributors, 'contributors'))

        if is_moderator:
            buttons.append(NamedButton('edit'))
            buttons.extend([NavButton(menu.banusers, 'banned'),
                            NamedButton('spam')])
        return [NavMenu(buttons, type = "flatlist", base_path = "/about/")]
示例#14
0
    def __init__(self, title, nav_menus = None, *a, **kw):
        buttons = [NamedButton('current_promos', dest = ''),
                   NamedButton('new_promo')]

        menu  = NavMenu(buttons, title='show', base_path = '/promote',
                        type='flatlist')

        if nav_menus:
            nav_menus.insert(0, menu)
        else:
            nav_menus = [menu]

        Reddit.__init__(self, title, nav_menus = nav_menus, *a, **kw)
示例#15
0
def admin_menu(**kwargs):
    buttons = [
        OffsiteButton("traffic", "/traffic"),
        NavButton(menu.awards, "awards", sr_path=False),
        NavButton(menu.errors, "error log", sr_path=False),
        # SAIDIT
        NavButton(menu.global_user_bans, "globaluserbans", sr_path=False),
        NavButton(menu.ip_bans, "ipbans", sr_path=False),
        NavButton(menu.nuke_user_content, "nukecontent", sr_path=False),
    ]

    admin_menu = NavMenu(buttons, title='admin tools', base_path='/admin',
                         type="lightdrop", **kwargs)
    return admin_menu
示例#16
0
    def __init__(self, team, alumni, sorts, extra_sorts):
        Templated.__init__(self, team=team, alumni=alumni, sorts=sorts + extra_sorts)

        sort_buttons = []
        extra_sort_index = random.randint(len(sorts), len(self.sorts)-1)
        for idx, sort in enumerate(self.sorts):
            css_class = 'choice-'+sort['id']
            if sort in extra_sorts and idx != extra_sort_index:
                css_class += ' hidden-sort'
            button = OffsiteButton(sort['title'], '#sort/'+sort['id'], css_class=css_class)
            sort_buttons.append(button)
        self.sort_menu = NavMenu(sort_buttons, title=_('sorted by'), base_path=request.path, type='lightdrop', default='#sort/random')

        # The caching check won't catch the hidden-sort classes
        self.sort_menu.cachable = False
示例#17
0
    def header_nav(self):
        path = "/user/%s/" % self.user.name
        main_buttons = [NavButton(menu.overview, '/', aliases = ['/overview']),
                   NavButton(_('Comments'), 'comments'),
                   NamedButton('submitted')]
        
        if votes_visible(self.user):
            main_buttons += [NamedButton('liked'),
                        NamedButton('disliked'),
                        NamedButton('hidden')]

        if c.user_is_loggedin and self.user._id == c.user._id:
            # User is looking at their own page
            main_buttons.append(NamedButton('drafts'))
            
        return NavMenu(main_buttons, base_path = path, title = _('View'), _id='nav', type='navlist')
示例#18
0
    def build_toolbars(self):
        tabs = [
            NavButton(
                _("reddit live"),
                "/",
            ),
            NavButton(
                _("happening now"),
                "/happening_now",
            ),
        ]

        if c.user_is_loggedin:
            tabs.extend((NavButton(
                _("my live threads"),
                "/mine",
            ), ))

        if c.user_is_loggedin and c.user.employee:
            tabs.extend([
                NavButton(
                    _("active"),
                    "/active",
                ),
                NavButton(
                    _("live"),
                    "/open",
                ),
                NavButton(
                    _("closed"),
                    "/closed",
                ),
            ])

            if c.user_is_admin:
                tabs.extend([
                    NavButton(
                        _("reported"),
                        "/reported",
                    ),
                ])

        return [NavMenu(
            tabs,
            base_path="/live/",
            type="tabmenu",
        )]
示例#19
0
    def __init__(self, sorts, team, alumni):
        Templated.__init__(self, sorts=sorts, team=team, alumni=alumni)

        sort_buttons = [
            OffsiteButton(
                sort["title"],
                "#sort/" + sort["id"],
                css_class="choice-" + sort["id"],
            )
            for sort in sorts.values()]
        self.sort_menu = NavMenu(
            sort_buttons, 
            title=_("sorted by"),
            base_path=request.path,
            type="lightdrop",
            default="#sort/random",
        )
示例#20
0
    def footer_nav(self):
        """navigation buttons in the footer."""
        buttons = [NamedButton("help", False, nocname=True),
                   NamedButton("blog", False, nocname=True),
                   NamedButton("stats", False, nocname=True),
                   NamedButton("feedback",     False),
                   NamedButton("bookmarklets", False),
                   NamedButton("socialite",    False),
                   NamedButton("buttons",      True),
                   NamedButton("widget",       True),
                   NamedButton("code",         False, nocname=True),
                   NamedButton("mobile",       False, nocname=True),
                   NamedButton("store",        False, nocname=True),
                   NamedButton("ad_inq",       False, nocname=True),
                   ]

        return NavMenu(buttons, base_path = "/", type = "flatlist")
示例#21
0
    def __init__(self, *args, **kwargs):
        nav_buttons = [
            NavButton(_('overview'), '/advertising'),
            OffsiteButton(_('getting started'), 'https://reddit.zendesk.com/hc/en-us/articles/205118995-Step-by-step-How-to-create-an-ad'),
            OffsiteButton(_('audience'), 'https://reddit.zendesk.com/hc/en-us/articles/205183225-Audience-and-Demographics'),
            OffsiteButton(_('best practices'), 'https://reddit.zendesk.com/hc/en-us/sections/200863319-Best-Practices-Tips'),
            OffsiteButton(_('help center'), 'https://reddit.zendesk.com/hc/en-us/categories/200352595-Advertising-'),
            NavButton(_('manage ads'), '/promoted?utm_source=advertising&utm_medium=button&utm_term=manage%20ads&utm_campaign=buttons'),
        ]

        self.create_ad_url = '/promoted/new_promo?utm_source=advertising&utm_medium=button&utm_term=create%20ads&utm_campaign=buttons'

        self.nav_menu = NavMenu(nav_buttons,
            type='flatlist',
            base_path='',
            css_class='advertising-menu',
            separator=None).render()

        sections = SelfServeContent.get_all(return_dict=True)
        self.banner = sections.get('banner')
        self.info = sections.get('info')
        self.advertisers = sections.get('advertisers')
        self.subreddit = sections.get('subreddit')
        self.help = sections.get('help')
        blurbs = SelfServeBlurb.get_all(return_dict=True)
        if 'platform' in blurbs:
            min_cpm = min([
                g.cpm_selfserve_collection.decimal,
                g.cpm_selfserve.decimal,
                g.cpm_selfserve_geotarget_metro.decimal,
            ])
            formatted_min_cpm = format_currency(min_cpm, 'USD', locale=c.locale)
            formatted_min_bid = format_currency(g.min_promote_bid, 'USD', locale=c.locale)
            blurbs['platform'].text = blurbs['platform'].text.replace(
                '[min_promote_bid]', formatted_min_bid).replace(
                '[cpm_selfserve]', formatted_min_cpm)
        self.blurbs = blurbs.values()
        self.advertiser_logos = SelfServeAdvertiser.get_all()
        self.quotes = SelfServeQuote.get_all()
        self.help_text = None
        try:
            self.help_text = WikiPage.get(Frontpage, g.wiki_page_selfserve_help).content
        except NotFound:
            pass
        Templated.__init__(self, *args, **kwargs)
示例#22
0
    def __init__(self, nav_menus=None, *a, **kw):
        #add admin options to the nav_menus
        if c.user_is_admin:
            buttons = []

            if g.translator:
                buttons.append(NavButton(menu.i18n, ""))

            admin_menu = NavMenu(buttons,
                                 title='show',
                                 base_path='/admin',
                                 type="lightdrop")
            if nav_menus:
                nav_menus.insert(0, admin_menu)
            else:
                nav_menus = [admin_menu]

        Reddit.__init__(self, nav_menus=nav_menus, *a, **kw)
示例#23
0
    def header_nav(self):
        """Navigation menu for the header"""
        # Ensure the default button is the first tab
        default_button_name = c.site.default_listing
        button_names = ['new', 'top', 'comments','topcomments']
        if c.default_sr:
            button_names.insert(0, 'blessed')

        main_buttons = []
        for name in button_names:
          kw = dict(dest='', aliases=['/' + name]) if name == default_button_name else {}
          main_buttons.append(NamedButton(name, **kw))

        if c.user_is_loggedin:
            main_buttons.append(NamedButton('saved', False))

        if not c.default_sr:
            main_buttons.insert(0, NamedButton('home', dest = '/', sr_path = False))

        return NavMenu(main_buttons, title = _('Filter by'), _id='nav', type='navlist')
示例#24
0
    def __init__(self, *args, **kwargs):
        nav_buttons = [
            NavButton(_('overview'), '/advertising'),
            NavButton(_('getting started'), '/wiki/selfservenew?utm_source=advertising&utm_medium=button&utm_term=getting%20started&utm_campaign=buttons'),
            NavButton(_('audience'), '/wiki/mediakit?utm_source=advertising&utm_medium=button&utm_term=audience&utm_campaign=buttons'),
            NavButton(_('best practices'), '/wiki/selfserve?utm_source=advertising&utm_medium=button&utm_term=best%20practices&utm_campaign=buttons#wiki_what_are_the_best_practices_for_reddit_advertising.3F'),
            NavButton(_('help center'), '/wiki/selfserve?utm_source=advertising&utm_medium=button&utm_term=help%20center&utm_campaign=buttons'),
            NavButton(_('manage ads'), '/promoted?utm_source=advertising&utm_medium=button&utm_term=manage%20ads&utm_campaign=buttons'),
        ]

        self.create_ad_url = '/promoted/new_promo?utm_source=advertising&utm_medium=button&utm_term=create%20ads&utm_campaign=buttons'

        self.nav_menu = NavMenu(nav_buttons,
            type='flatlist',
            base_path='',
            css_class='advertising-menu',
            separator=None).render()

        sections = SelfServeContent.get_all(return_dict=True)
        self.banner = sections.get('banner')
        self.info = sections.get('info')
        self.advertisers = sections.get('advertisers')
        self.subreddit = sections.get('subreddit')
        self.help = sections.get('help')
        blurbs = SelfServeBlurb.get_all(return_dict=True)
        if 'platform' in blurbs:
            formatted_cpm = format_currency(g.cpm_selfserve.decimal, 'USD', locale=c.locale)
            formatted_min_bid = format_currency(g.min_promote_bid, 'USD', locale=c.locale)
            blurbs['platform'].text = blurbs['platform'].text.replace(
                '[min_promote_bid]', formatted_min_bid).replace(
                '[cpm_selfserve]', formatted_cpm)
        self.blurbs = blurbs.values()
        self.advertiser_logos = SelfServeAdvertiser.get_all()
        self.quotes = SelfServeQuote.get_all()
        self.help_text = None
        try:
            self.help_text = WikiPage.get(Frontpage, g.wiki_page_selfserve_help).content
        except NotFound:
            pass
        Templated.__init__(self, *args, **kwargs)
示例#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')
示例#26
0
    def corner_buttons(self):
        """set up for buttons in upper right corner of main page."""
        buttons = []
        if c.user_is_loggedin:
            if c.user.name in g.admins:
                if c.user_is_admin:
                   buttons += [NamedButton("adminoff", False,
                                           nocname=not c.authorized_cname,
                                           target = "_self")]
                else:
                   buttons += [NamedButton("adminon",  False,
                                           nocname=not c.authorized_cname,
                                           target = "_self")]

            buttons += [NamedButton('submit', sr_path = not c.default_sr,
                                    nocname=not c.authorized_cname)]
            buttons += [NamedButton("prefs", False,
                                  css_class = "pref-lang")]
            buttons += [NamedButton("logout", False,
                                    nocname=not c.authorized_cname,
                                    target = "_self")]
        
        return NavMenu(buttons, base_path = "/", type = "buttons")
示例#27
0
 def __init__(self, link):
     NavMenu.__init__(self, [], title='admin', type="tabdrop")
示例#28
0
 def __init__(self, path):
     NavMenu.__init__(self, [],
                      base_path=path,
                      title='admin',
                      type="tabdrop")
示例#29
0
 def __init__(self, link):
     NavMenu.__init__(self, [], title="admin", type="tabdrop")
示例#30
0
 def __init__(self, path):
     NavMenu.__init__(self, [], base_path=path, title="admin", type="tabdrop")
示例#31
0
 def header_nav(self):
     buttons = [NavButton(menu.options, ''),
                NamedButton('friends'),
                NamedButton('update'),
                NamedButton('delete')]
     return NavMenu(buttons, base_path = "/prefs", _id='nav', type='navlist')
示例#32
0
 def header_nav(self):
     buttons =  [NamedButton('compose'),
                 NamedButton('inbox'),
                 NamedButton('sent')]
     return NavMenu(buttons, base_path = "/message", _id='nav', type='navlist')