added links to domains and fixed comment JSON feed to include link_id and parent_id

This commit is contained in:
KeyserSosa
2008-10-24 15:25:37 -07:00
parent d9e398a7fe
commit 2d1203feef
4 changed files with 20 additions and 11 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -72,7 +72,7 @@
${thing.title}
</%call>
&#32;
${unsafe(self.domain())}
${self.domain()}
</p>
<p class="tagline">
${self.tagline()}
@@ -138,7 +138,7 @@
<%def name="domain()">
<span class="domain">
(${thing.domain})
(<a href="/domain/${thing.domain}">${thing.domain}</a>)
</span>
</%def>

View File

@@ -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>