Add intro widget to listing chooser with sample multireddits.

This commit is contained in:
Max Goodman
2013-05-13 00:05:20 -07:00
parent 3748013c14
commit f3ea04aef0
5 changed files with 46 additions and 0 deletions

View File

@@ -526,6 +526,9 @@ wiki_page_registration_info = registration_info
# Template names to record render timings for
timed_templates = Reddit, Link, Comment, LinkListing, NestedListing, SubredditTopBar
# sample multireddits (displayed when a user has no multis)
sample_multis = /user/reddit/m/hello, /user/reddit/m/world
[server:main]
use = egg:Paste#http
host = 0.0.0.0

View File

@@ -186,6 +186,7 @@ class Globals(object):
'TRAFFIC_LOG_HOSTS',
'exempt_login_user_agents',
'timed_templates',
'sample_multis',
],
ConfigValue.str: [

View File

@@ -4104,13 +4104,20 @@ class ListingChooser(Templated):
if c.show_mod_mail:
self.add_item("other", _("moderating"), site=Mod,
description=_("subreddits you mod"))
self.add_item("other", _("saved"), path='/user/%s/saved' % c.user.name)
self.show_samples = False
if c.user_is_loggedin:
multis = LabeledMulti.by_owner(c.user)
multis.sort(key=lambda multi: multi.name.lower())
for multi in multis:
self.add_item("multi", multi.name, site=multi)
self.show_samples = not multis
if self.show_samples:
self.add_samples()
self.selected_item = self.find_selected()
if self.selected_item:
self.selected_item["selected"] = True
@@ -4124,6 +4131,14 @@ class ListingChooser(Templated):
"selected": False,
})
def add_samples(self):
for path in g.sample_multis:
self.add_item(
section="sample",
name=path.rpartition('/')[2],
path=path,
)
def find_selected(self):
path = request.path
matching = []

View File

@@ -7022,6 +7022,24 @@ body.with-listing-chooser {
padding: 4px;
}
.intro {
background: lighten(#f6e69f, 5%);
border: 1px solid lighten(orange, 5%);
border-left: none;
border-right: none;
margin-bottom: 10px;
p {
font-size: 1.15em;
margin: 4px;
margin-left: 8px;
}
ul.multis {
margin: 6px 0;
}
}
ul.global, ul.other {
padding: 8px 0;
li {

View File

@@ -43,6 +43,15 @@
</ul>
<h3>${_('multireddits')}</h3>
%if thing.show_samples:
<div class="intro">
<p>${_('new! create sets of subreddits to view together.')}</p>
<p>${_('for starters, try one of these:')}</p>
<ul class="multis">
${section_items(thing.sections['sample'])}
</ul>
</div>
%endif
<ul class="multis">
${section_items(thing.sections['multi'])}
<li class="create">