From 2d1203feefd1235e3cc200b8d06ef0ef02ee1b15 Mon Sep 17 00:00:00 2001
From: KeyserSosa
Date: Fri, 24 Oct 2008 15:25:37 -0700
Subject: [PATCH] added links to domains and fixed comment JSON feed to include
link_id and parent_id
---
r2/r2/lib/jsontemplates.py | 16 +++++++++++++++-
r2/r2/public/static/reddit.css | 2 +-
r2/r2/templates/link.html | 4 ++--
r2/r2/templates/linkcompressed.html | 9 ++-------
4 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/r2/r2/lib/jsontemplates.py b/r2/r2/lib/jsontemplates.py
index a74033c6eb..fb3682f246 100644
--- a/r2/r2/lib/jsontemplates.py
+++ b/r2/r2/lib/jsontemplates.py
@@ -160,7 +160,21 @@ class CommentJsonTemplate(ThingJsonTemplate):
body = "body",
likes = "likes",
author = "author",
- created = "created")
+ created = "created",
+ link_id = "link_id",
+ parent_id = "parent_id",
+ )
+
+ def thing_attr(self, thing, attr):
+ from r2.models import Comment, Link
+ if attr == 'link_id':
+ return make_fullname(Link, thing.link_id)
+ elif attr == "parent_id":
+ try:
+ return make_fullname(Comment, thing.parent_id)
+ except AttributeError:
+ return make_fullname(Link, thing.link_id)
+ return ThingJsonTemplate.thing_attr(self, thing, attr)
def kind(self, wrapped):
from r2.models import Comment
diff --git a/r2/r2/public/static/reddit.css b/r2/r2/public/static/reddit.css
index 66b4d4aceb..530e39fdce 100644
--- a/r2/r2/public/static/reddit.css
+++ b/r2/r2/public/static/reddit.css
@@ -489,7 +489,7 @@ before enabling */
opacity: 1;
}
.domain { color: #888; font-size:x-small; }
-.domain a { color: #336699 }
+.domain a { color: #888 }
.domain a:hover { text-decoration: underline }
.tagline { color:#888; font-size:x-small;
diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html
index a7d26eb04e..e2e698694f 100644
--- a/r2/r2/templates/link.html
+++ b/r2/r2/templates/link.html
@@ -72,7 +72,7 @@
${thing.title}
%call>
- ${unsafe(self.domain())}
+ ${self.domain()}
${self.tagline()}
@@ -138,7 +138,7 @@
<%def name="domain()">
- (${thing.domain})
+ (${thing.domain})
%def>
diff --git a/r2/r2/templates/linkcompressed.html b/r2/r2/templates/linkcompressed.html
index d3b7dc5f79..2500f54771 100644
--- a/r2/r2/templates/linkcompressed.html
+++ b/r2/r2/templates/linkcompressed.html
@@ -24,19 +24,14 @@
<%inherit file="link.html"/>
-<%def name="domain()" buffered="True">
+<%def name="domain()">
<% from r2.models import FakeSubreddit, Default %>
%if isinstance(c.site, FakeSubreddit) and thing.subreddit.name != "reddit.com":
[${unsafe(self.subreddit())}]
%endif
- %if c.user_is_admin:
- (${thing.domain})
- %else:
- (${thing.domain})
- %endif
-
+ (${thing.domain})
%def>