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): 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
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/")]
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)
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')
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')
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
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
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")
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
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')
def header_nav(self): buttons = [NamedButton('compose'), NamedButton('inbox'), NamedButton('sent')] return NavMenu(buttons, base_path = "/message", _id='nav', type='navlist')
def header_nav(self): buttons = [NavButton(menu.options, ''), NamedButton('friends'), NamedButton('update'), NamedButton('delete')] return NavMenu(buttons, base_path = "/prefs", _id='nav', type='navlist')
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")