Permalink
Browse files

srbar updates

  • Loading branch information...
1 parent b9d93f0 commit 852b989f9e5a968c88c7e3b94792ca04ea53a468 Mike committed Jul 16, 2009
Showing with 65 additions and 16 deletions.
  1. +1 −0 r2/example.ini
  2. +1 −0 r2/r2/lib/app_globals.py
  3. +43 −8 r2/r2/lib/pages/pages.py
  4. +10 −5 r2/r2/public/static/css/reddit.css
  5. +10 −3 r2/r2/templates/subreddittopbar.html
View
@@ -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 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 @@ def __init__(self):
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 @@ def my_reddits_dropdown(self):
title = _('my reddits'),
type = 'srdrop')
+ 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]
- def recent_reddits(self):
- return NavMenu([SubredditButton(sr) for sr in self.reddits],
+ 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">&nbsp;&ndash;&nbsp;</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 @@ def monthly_summary(self):
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,15 +1889,19 @@ 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;
border-bottom: 1px solid gray;
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") + " &raquo;"), "/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) + " &raquo;"),
+ "/reddits/", id="sr-more-link")}
</div>

0 comments on commit 852b989

Please sign in to comment.