From 6b3ee4bb703811edf1b4f0b437b76e33527b39b4 Mon Sep 17 00:00:00 2001 From: bsimpson63 Date: Mon, 19 Nov 2012 11:26:03 -0500 Subject: [PATCH] Add AllMinusBox sidebox. --- r2/r2/lib/pages/pages.py | 22 +++++++++++++++++++++- r2/r2/public/static/css/reddit.css | 9 +++++++++ r2/r2/templates/allminusbox.html | 27 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 r2/r2/templates/allminusbox.html diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 421419aa3..320f40d76 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -22,7 +22,7 @@ from r2.lib.wrapped import Wrapped, Templated, CachedTemplate from r2.models import Account, FakeAccount, DefaultSR, make_feedurl -from r2.models import FakeSubreddit, Subreddit, Ad, AdSR, SubSR +from r2.models import FakeSubreddit, Subreddit, Ad, AdSR, SubSR, AllMinus, AllSR from r2.models import Friends, All, Sub, NotFound, DomainSR, Random, Mod, RandomNSFW, MultiReddit, ModSR, Frontpage from r2.models import Link, Printable, Trophy, bidding, PromoCampaign, PromotionWeights, Comment from r2.models import Flair, FlairTemplate, FlairTemplateBySubredditIndex @@ -319,6 +319,10 @@ class Reddit(Templated): box = SubscriptionBox(srs) ps.append(SideContentBox(_('these subreddits'), [box])) + if (isinstance(c.site, AllMinus) or + isinstance(c.site, AllSR) and c.user.gold): + ps.append(AllMinusBox(c.user)) + # don't show the subreddit info bar on cnames unless the option is set if not isinstance(c.site, FakeSubreddit) and (not c.cname or c.site.show_cname_sidebar): ps.append(SubredditInfoBar()) @@ -1694,6 +1698,22 @@ class SubscriptionBox(Templated): def reddits(self): return wrap_links(self.srs) + +class AllMinusBox(Templated): + def __init__(self, user): + if user.gold: + sr_ids = Subreddit.user_subreddits(user) + srs = Subreddit._byID(sr_ids, data=True, return_dict=False) + path = '/r/all' + if srs: + path += '-' + '-'.join([sr.name for sr in srs]) + text = _('See /r/all minus your subscribed subreddits') + else: + path = '/gold' + text = _('/r/all filtering is a gold only feature') + Templated.__init__(self, text=text, path=path) + + class CreateSubreddit(Templated): """reddit creation form.""" def __init__(self, site = None, name = ''): diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index e8f23a927..86ad29f46 100755 --- a/r2/r2/public/static/css/reddit.css +++ b/r2/r2/public/static/css/reddit.css @@ -5045,6 +5045,15 @@ tr.gold-accent + tr > td { padding-top: 10px; } +.allminus-box { + padding: 5px; + margin: 0; +} + +.allminus-box a { + font-size: small; +} + #per-sr-karma { width: 300px; margin: .6em auto 0 auto; diff --git a/r2/r2/templates/allminusbox.html b/r2/r2/templates/allminusbox.html new file mode 100644 index 000000000..9e4c02439 --- /dev/null +++ b/r2/r2/templates/allminusbox.html @@ -0,0 +1,27 @@ +## The contents of this file are subject to the Common Public Attribution +## License Version 1.0. (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License at +## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public +## License Version 1.1, but Sections 14 and 15 have been added to cover use of +## software over a computer network and provide for limited attribution for the +## Original Developer. In addition, Exhibit A has been modified to be +## consistent with Exhibit B. +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for +## the specific language governing rights and limitations under the License. +## +## The Original Code is reddit. +## +## The Original Developer is the Initial Developer. The Initial Developer of +## the Original Code is reddit Inc. +## +## All portions of the code written by reddit are Copyright (c) 2006-2012 +## reddit Inc. All Rights Reserved. +############################################################################### + +
+ + ${thing.text} + +