From c15ff9fa865d77db5e22172b118f23bf13b0eba2 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Wed, 24 Aug 2011 20:18:36 -0700 Subject: [PATCH] Add details page for comments. --- r2/r2/controllers/front.py | 9 ++++----- r2/r2/lib/pages/pages.py | 24 ++++++++++++++++++++---- r2/r2/public/static/css/reddit.css | 2 +- r2/r2/templates/link.html | 1 - r2/r2/templates/wrappeduser.html | 5 +++++ 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index a619f1866..352b7bb54 100755 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -113,13 +113,12 @@ class FrontController(RedditController): @prevent_framing_and_css() @validate(VAdmin(), - article = VLink('article')) - def GET_details(self, article): - """The (now depricated) details page. Content on this page + thing = VByName('article')) + def GET_details(self, thing): + """The (now deprecated) details page. Content on this page has been subsubmed by the presence of the LinkInfoBar on the rightbox, so it is only useful for Admin-only wizardry.""" - return DetailsPage(link = article, expand_children=False).render() - + return DetailsPage(thing=thing, expand_children=False).render() def GET_selfserviceoatmeal(self): return BoringPage(_("self service help"), diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index df11fcf79..0b0673763 100755 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -30,6 +30,7 @@ from r2.models.oauth2 import OAuth2Client from r2.models import ModAction from r2.models import Thing from r2.config import cache +from r2.lib.menus import CommentSortMenu from r2.lib.tracking import AdframeInfo from r2.lib.jsonresponse import json_respond from r2.lib.jsontemplates import is_api @@ -951,7 +952,7 @@ class LinkInfoPage(Reddit): num = len(self.duplicates))) if c.user_is_admin: - buttons += [info_button('details')] + buttons.append(NamedButton("details", dest="/details/"+self.link._fullname)) # should we show a traffic tab (promoted and author or sponsor) if (self.link.promoted is not None and @@ -2914,10 +2915,25 @@ class TrafficViewerList(UserList): class DetailsPage(LinkInfoPage): extension_handling= False - def content(self): - # TODO: a better way? + def __init__(self, thing, *args, **kwargs): from admin_pages import Details - return self.content_stack((self.link_listing, Details(link = self.link))) + + if isinstance(thing, Link): + link = thing + comment = None + content = Details(thing=thing) + elif isinstance(thing, Comment): + comment = thing + link = Link._byID(comment.link_id) + content = PaneStack() + content.append(PermalinkMessage(link.make_permalink_slow())) + content.append(LinkCommentSep()) + content.append(CommentPane(link, CommentSortMenu.operator('new'), + comment, None, 1)) + content.append(Details(thing=thing)) + + kwargs['content'] = content + LinkInfoPage.__init__(self, link, comment, *args, **kwargs) class Cnameframe(Templated): """The frame page.""" diff --git a/r2/r2/public/static/css/reddit.css b/r2/r2/public/static/css/reddit.css index cb9f2af98..9d24b8802 100644 --- a/r2/r2/public/static/css/reddit.css +++ b/r2/r2/public/static/css/reddit.css @@ -1221,7 +1221,7 @@ a.star { text-decoration: none; color: #ff8b60 } /* comments */ -.comment { margin-left: 10px; } +.comment, .content .details { margin-left: 10px; } .comment .edit-body { display: none; visibility: hidden; } .comment .midcol { margin-left: 0px; } .comment .title { font-size: small; margin-top: 10px;} diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html index 0c23e9c20..b38dc7140 100644 --- a/r2/r2/templates/link.html +++ b/r2/r2/templates/link.html @@ -239,7 +239,6 @@ ${parent.thing_data_attributes(what)} data-ups="${what.upvotes}" data-downs="${w score = capture(self.score, thing, thing.likes, tag='span'), when = capture(thing_timestamp, thing, thing.timesince), author = WrappedUser(thing.author, thing.attribs, thing).render()))} - <%def name="child()"> diff --git a/r2/r2/templates/wrappeduser.html b/r2/r2/templates/wrappeduser.html index 0334e3e04..4ee69e668 100644 --- a/r2/r2/templates/wrappeduser.html +++ b/r2/r2/templates/wrappeduser.html @@ -92,3 +92,8 @@ %if thing.ip_span: ${unsafe(thing.ip_span)} %endif + +%if c.user_is_admin and thing.context_thing: + + i +%endif