diff --git a/r2/r2/controllers/listingcontroller.py b/r2/r2/controllers/listingcontroller.py index 8151614df..cb8ef7e37 100755 --- a/r2/r2/controllers/listingcontroller.py +++ b/r2/r2/controllers/listingcontroller.py @@ -82,6 +82,9 @@ class ListingController(RedditController, OAuth2ResourceController): # class (probably a subclass of Reddit) to use to render the page. render_cls = Reddit + # class for suggestions next to "next/prev" buttons + next_suggestions_cls = None + #extra parameters to send to the render_cls constructor render_params = {} extra_page_classes = ['listing-page'] @@ -168,7 +171,11 @@ class ListingController(RedditController, OAuth2ResourceController): if (getattr(c.site, "_id", -1) == get_promote_srid() and not c.user_is_sponsor): abort(403, 'forbidden') - pane = LinkListing(self.builder_obj, show_nums = self.show_nums).listing() + model = LinkListing(self.builder_obj, show_nums=self.show_nums) + suggestions = None + if self.next_suggestions_cls: + suggestions = self.next_suggestions_cls() + pane = model.listing(next_suggestions=suggestions) # Indicate that the comment tree wasn't built for comments for i in pane: if hasattr(i, 'full_comment_path'): @@ -228,6 +235,7 @@ class HotController(FixListing, ListingController): where = 'hot' extra_page_classes = ListingController.extra_page_classes + ['hot-page'] show_chooser = True + next_suggestions_cls = ListingSuggestions def make_requested_ad(self): try: @@ -395,6 +403,7 @@ class NewController(ListingController): title_text = _('newest submissions') extra_page_classes = ListingController.extra_page_classes + ['new-page'] show_chooser = True + next_suggestions_cls = ListingSuggestions def keep_fn(self): def keep(item): @@ -444,6 +453,7 @@ class RisingController(NewController): class BrowseController(ListingController): where = 'browse' show_chooser = True + next_suggestions_cls = ListingSuggestions def keep_fn(self): """For merged time-listings, don't show items that are too old @@ -493,6 +503,7 @@ class BrowseController(ListingController): class RandomrisingController(ListingController): where = 'randomrising' title_text = _('you\'re really bored now, eh?') + next_suggestions_cls = ListingSuggestions def query(self): links = get_rising(c.site) diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index 4bb9ad8e5..011818791 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -4329,3 +4329,20 @@ class SubredditSelector(Templated): names.sort(key=str.lower) groups.append((title, names)) return groups + + +class ListingSuggestions(Templated): + def __init__(self): + self.suggestion_type = None + if c.default_sr: + multis = c.user_is_loggedin and LabeledMulti.by_owner(c.user) + if multis: + self.suggestion_type = "multis" + if len(multis) <= 3: + self.suggestions = multis + else: + self.suggestions = random.sample(multis, 3) + else: + self.suggestion_type = "random" + + Templated.__init__(self) diff --git a/r2/r2/models/listing.py b/r2/r2/models/listing.py index adcd63759..91d97c914 100644 --- a/r2/r2/models/listing.py +++ b/r2/r2/models/listing.py @@ -68,9 +68,10 @@ class Listing(object): item.render_replaced = True return builder_items - def listing(self): + def listing(self, next_suggestions=None): self.things, prev, next, bcount, acount = self.get_items() + self.next_suggestions = next_suggestions self._max_num = max(acount, bcount) self.after = None self.before = None diff --git a/r2/r2/public/static/css/reddit.less b/r2/r2/public/static/css/reddit.less index 4b638ee98..0125a36f3 100755 --- a/r2/r2/public/static/css/reddit.less +++ b/r2/r2/public/static/css/reddit.less @@ -963,7 +963,7 @@ a.author { margin-right: 0.5em; } .sitetable { list-style-type: none; } .ajaxhook { position: absolute; top: -1000px; left: 0px; } -.nextprev { +.nextprev, .next-suggestions { color: gray; font-size: larger; margin-top: 10px; @@ -973,6 +973,7 @@ a.author { margin-right: 0.5em; } background: #eee; border: 1px solid #ddd; border-radius: 3px; + font-weight: bold; } a:hover { @@ -990,6 +991,17 @@ a.author { margin-right: 0.5em; } padding-left: .5em; border-left: 1px solid #ccc; } + +} + +.next-suggestions { + margin-left: 1.5em; + + a { + background: none; + font-weight: normal; + margin-left: .5em; + } } /* corner help */ diff --git a/r2/r2/templates/listing.html b/r2/r2/templates/listing.html index 95b6a6a1d..003ea2ba4 100644 --- a/r2/r2/templates/listing.html +++ b/r2/r2/templates/listing.html @@ -35,17 +35,22 @@ %endfor %if thing.nextprev and (thing.prev or thing.next): -
${_("view more:")} - %if thing.prev: - ${plain_link(unsafe("‹ " + _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")} - %endif - %if thing.prev and thing.next: - - %endif - %if thing.next: - ${plain_link(unsafe(_("next") + " ›"), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")} - %endif -
+ %endif %if not thing.things:${_("there doesn't seem to be anything here")}
diff --git a/r2/r2/templates/listingsuggestions.html b/r2/r2/templates/listingsuggestions.html new file mode 100644 index 000000000..a8c7b8c78 --- /dev/null +++ b/r2/r2/templates/listingsuggestions.html @@ -0,0 +1,41 @@ +## 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-2013 +## reddit Inc. All Rights Reserved. +############################################################################### + +<%namespace file="utils.html" import="text_with_links" /> + +%if thing.suggestion_type: + + + +%endif