diff --git a/r2/r2/controllers/buttons.py b/r2/r2/controllers/buttons.py index 18ba360d1..fa1933a18 100644 --- a/r2/r2/controllers/buttons.py +++ b/r2/r2/controllers/buttons.py @@ -94,6 +94,8 @@ class ButtonsController(RedditController): css != 'http://www.wired.com/css/redditsocial.css'): css = None + if link: + url = link.url wrapper = make_wrapper(Button if vote else ButtonNoBody, url = url, target = "_new" if newwindow else "_parent", diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py index 66f71a0d7..cdf84a900 100644 --- a/r2/r2/lib/jsontemplates.py +++ b/r2/r2/lib/jsontemplates.py @@ -182,6 +182,7 @@ class SubredditJsonTemplate(ThingJsonTemplate): _data_attrs_ = ThingJsonTemplate.data_attrs(subscribers = "score", title = "title", url = "path", + over18 = "over_18", description = "description") class LinkJsonTemplate(ThingJsonTemplate): diff --git a/r2/r2/lib/pages/things.py b/r2/r2/lib/pages/things.py index 38675e79e..5f6b98d00 100644 --- a/r2/r2/lib/pages/things.py +++ b/r2/r2/lib/pages/things.py @@ -109,16 +109,15 @@ class MessageButtons(PrintableButtons): # formerly ListingController.builder_wrapper def default_thing_wrapper(**params): - style = params.get('style', c.render_style) def _default_thing_wrapper(thing): w = Wrapped(thing) + style = params.get('style', c.render_style) if isinstance(thing, Link): if thing.promoted: w.render_class = PromotedLink w.rowstyle = 'promoted link' elif style == 'htmllite': w.score_fmt = Score.points - return w params['parent_wrapper'] = _default_thing_wrapper return make_wrapper(**params) diff --git a/r2/r2/lib/wrapped.py b/r2/r2/lib/wrapped.py index f0d0685db..cf998c032 100644 --- a/r2/r2/lib/wrapped.py +++ b/r2/r2/lib/wrapped.py @@ -410,8 +410,9 @@ class Wrapped(CachedTemplate): if self.cachable: for i, l in enumerate(self.lookups): if hasattr(l, "wrapped_cache_key"): - # setattr will force a __dict__ entry - setattr(self, "_lookup%d_cache_key" % i, + # setattr will force a __dict__ entry, but only if the + # param doesn't start with "_" + setattr(self, "lookup%d_cache_key" % i, ''.join(map(repr, l.wrapped_cache_key(self, style)))) return CachedTemplate.cache_key(self, attr, style) diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index a2c0d3c7b..8315ed9ba 100644 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -55,6 +55,7 @@ class Link(Thing, Printable): selftext = '', ip = '0.0.0.0') + def __init__(self, *a, **kw): Thing.__init__(self, *a, **kw) diff --git a/r2/r2/models/printable.py b/r2/r2/models/printable.py index b42903b4a..340e874e8 100644 --- a/r2/r2/models/printable.py +++ b/r2/r2/models/printable.py @@ -28,7 +28,6 @@ class Printable(object): can_ban = False deleted = False rowstyle = 'even' - reported = False collapsed = False author = None margin = 0 @@ -75,7 +74,7 @@ class Printable(object): @staticmethod def wrapped_cache_key(wrapped, style): - s = [wrapped._fullname, wrapped._spam] + s = [wrapped._fullname, wrapped._spam, wrapped.reported] if style == 'htmllite': s.extend([c.bgcolor, c.bordercolor,