Skip to content

Commit

Permalink
added links to domains and fixed comment JSON feed to include link_id…
Browse files Browse the repository at this point in the history
… and parent_id
  • Loading branch information
KeyserSosa committed Oct 24, 2008
1 parent d9e398a commit 2d1203f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
16 changes: 15 additions & 1 deletion r2/r2/lib/jsontemplates.py
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/public/static/reddit.css
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions r2/r2/templates/link.html
Expand Up @@ -72,7 +72,7 @@
${thing.title}
</%call>
&#32;
${unsafe(self.domain())}
${self.domain()}
</p>
<p class="tagline">
${self.tagline()}
Expand Down Expand Up @@ -138,7 +138,7 @@

<%def name="domain()">
<span class="domain">
(${thing.domain})
(<a href="/domain/${thing.domain}">${thing.domain}</a>)
</span>
</%def>

Expand Down
9 changes: 2 additions & 7 deletions r2/r2/templates/linkcompressed.html
Expand Up @@ -24,19 +24,14 @@

<%inherit file="link.html"/>

<%def name="domain()" buffered="True">
<%def name="domain()">
<span class="domain">
<% from r2.models import FakeSubreddit, Default %>
%if isinstance(c.site, FakeSubreddit) and thing.subreddit.name != "reddit.com":
[${unsafe(self.subreddit())}]
%endif
&#32;
%if c.user_is_admin:
(<a href="/admin/info?domain=${thing.domain}">${thing.domain}</a>)
%else:
(${thing.domain})
%endif

(<a href="/domain/${thing.domain}">${thing.domain}</a>)
</span>
</%def>

Expand Down

0 comments on commit 2d1203f

Please sign in to comment.