mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
srbar updates
This commit is contained in:
@@ -134,6 +134,7 @@ num_comments = 200
|
||||
max_comments = 500
|
||||
num_default_reddits = 10
|
||||
num_serendipity = 100
|
||||
sr_dropdown_threshold = 15
|
||||
|
||||
smtp_server = localhost
|
||||
new_link_share_delay = 5 minutes
|
||||
|
||||
@@ -48,6 +48,7 @@ class Globals(object):
|
||||
'num_query_queue_workers',
|
||||
'max_sr_images',
|
||||
'num_serendipity',
|
||||
'sr_dropdown_threshold',
|
||||
]
|
||||
|
||||
bool_props = ['debug', 'translator',
|
||||
|
||||
@@ -33,7 +33,7 @@ from pylons.controllers.util import abort
|
||||
|
||||
from r2.lib.traffic import load_traffic, load_summary
|
||||
from r2.lib.captcha import get_iden
|
||||
from r2.lib.filters import spaceCompress, _force_unicode, _force_utf8
|
||||
from r2.lib.filters import spaceCompress, _force_unicode, _force_utf8, unsafe
|
||||
from r2.lib.menus import NavButton, NamedButton, NavMenu, PageNameNav, JsButton
|
||||
from r2.lib.menus import SubredditButton, SubredditMenu
|
||||
from r2.lib.menus import OffsiteButton, menu, JsNavMenu
|
||||
@@ -847,12 +847,14 @@ class SubredditTopBar(Templated):
|
||||
self.my_reddits.sort(key = lambda sr: sr.name.lower())
|
||||
|
||||
|
||||
pop_reddits = Subreddit.default_subreddits(ids = False,
|
||||
self.pop_reddits = Subreddit.default_subreddits(ids = False,
|
||||
limit = Subreddit.sr_limit)
|
||||
self.reddits = c.recent_reddits
|
||||
for sr in pop_reddits:
|
||||
if sr not in c.recent_reddits:
|
||||
self.reddits.append(sr)
|
||||
|
||||
# This doesn't actually work.
|
||||
# self.reddits = c.recent_reddits
|
||||
# for sr in pop_reddits:
|
||||
# if sr not in c.recent_reddits:
|
||||
# self.reddits.append(sr)
|
||||
|
||||
def my_reddits_dropdown(self):
|
||||
drop_down_buttons = []
|
||||
@@ -865,12 +867,38 @@ class SubredditTopBar(Templated):
|
||||
title = _('my reddits'),
|
||||
type = 'srdrop')
|
||||
|
||||
|
||||
def recent_reddits(self):
|
||||
return NavMenu([SubredditButton(sr) for sr in self.reddits],
|
||||
def subscribed_reddits(self):
|
||||
return NavMenu([SubredditButton(sr) for sr in self.my_reddits],
|
||||
type='flatlist', separator = '-',
|
||||
_id = 'sr-bar')
|
||||
|
||||
def popular_reddits(self, exclude=[]):
|
||||
exclusions = set(exclude)
|
||||
buttons = [SubredditButton(sr)
|
||||
for sr in self.pop_reddits if sr not in exclusions]
|
||||
|
||||
return NavMenu(buttons,
|
||||
type='flatlist', separator = '-',
|
||||
_id = 'sr-bar')
|
||||
|
||||
def sr_bar (self):
|
||||
menus = []
|
||||
|
||||
if not c.user_is_loggedin:
|
||||
menus.append(self.popular_reddits())
|
||||
else:
|
||||
if len(self.my_reddits) > g.sr_dropdown_threshold:
|
||||
menus.append(self.my_reddits_dropdown())
|
||||
|
||||
menus.append(self.subscribed_reddits())
|
||||
|
||||
sep = '<span class="separator"> – </span>'
|
||||
menus.append(RawString(sep))
|
||||
|
||||
menus.append(self.popular_reddits(exclude=self.my_reddits))
|
||||
|
||||
return menus
|
||||
|
||||
class SubscriptionBox(Templated):
|
||||
"""The list of reddits a user is currently subscribed to to go in
|
||||
the right pane."""
|
||||
@@ -1662,3 +1690,10 @@ class RedditTraffic(Traffic):
|
||||
class InnerToolbarFrame(Templated):
|
||||
def __init__(self, link, expanded = False):
|
||||
Templated.__init__(self, link = link, expanded = expanded)
|
||||
|
||||
class RawString(Templated):
|
||||
def __init__(self, s):
|
||||
self.s = s
|
||||
|
||||
def render(self, *a, **kw):
|
||||
return unsafe(self.s)
|
||||
|
||||
@@ -1889,8 +1889,8 @@ ul#image-preview-list .description pre {
|
||||
}
|
||||
|
||||
#sr-header-area {
|
||||
padding: 3px 0px;
|
||||
background-color: #e0e0e0;
|
||||
padding: 3px 0px 3px 5px;
|
||||
background-color: #f0f0f0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-transform: uppercase;
|
||||
@@ -1898,6 +1898,10 @@ ul#image-preview-list .description pre {
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
#sr-header-area .selected a {
|
||||
color: orangered;
|
||||
}
|
||||
|
||||
.dropdown.srdrop .selected {
|
||||
background: transparent url(/static/droparrowgray.gif) no-repeat scroll center right;
|
||||
display: inline-block;
|
||||
@@ -1906,6 +1910,8 @@ ul#image-preview-list .description pre {
|
||||
padding-left: 5px; /* have to use padding instead of margin cause of ie */
|
||||
color: black;
|
||||
font-weight: normal;
|
||||
margin-left: -5px; /* There's 5px margin intended for the SR list... */
|
||||
margin-right: 10px;/* ...so we move it to the right side plus 5 more */
|
||||
}
|
||||
|
||||
.srdrop .choice {margin-top: 3px;}
|
||||
@@ -1922,19 +1928,18 @@ ul#image-preview-list .description pre {
|
||||
border-top: 1px dotted #369;
|
||||
}
|
||||
|
||||
#sr-bar { margin-left: 10px; }
|
||||
#sr-bar .separator {color: gray; }
|
||||
#sr-bar a {color: black;}
|
||||
|
||||
#sr-more-link {
|
||||
color: black;
|
||||
background-color: #e0e0e0;
|
||||
background-color: #f0f0f0;
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: 3px;
|
||||
padding: 0 5px 0 15px;
|
||||
font-weight: bold;
|
||||
margin: 0 1px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#sr-more-link:hover {text-decoration: underline;}
|
||||
|
||||
@@ -23,7 +23,14 @@
|
||||
<%namespace file="utils.html" import="plain_link"/>
|
||||
|
||||
<div id="sr-header-area">
|
||||
${thing.my_reddits_dropdown()}
|
||||
${thing.recent_reddits()}
|
||||
${plain_link(unsafe(_("more") + " »"), "/reddits/", id="sr-more-link")}
|
||||
%for m in thing.sr_bar():
|
||||
${m.render()}
|
||||
%endfor
|
||||
|
||||
<%
|
||||
editmore = 'edit' if c.user_is_loggedin else 'more'
|
||||
%>
|
||||
|
||||
${plain_link(unsafe(_(editmore) + " »"),
|
||||
"/reddits/", id="sr-more-link")}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user