make self post domain links point to that link's subreddit page rather than to the (empty) /domain/self.* listing. Also fixes a bug whereby subreddit links on cnames point to the cname rather than to the subreddit

This commit is contained in:
KeyserSosa
2009-05-13 15:45:50 -07:00
parent 36ed3fe248
commit 0d8a7058f2
2 changed files with 17 additions and 14 deletions

View File

@@ -257,6 +257,7 @@ class Link(Thing, Printable):
from r2.lib.count import incr_counts
from r2.lib.media import thumbnail_url
from r2.lib.utils import timeago
from r2.lib.template_helpers import get_domain
saved = Link._saved(user, wrapped) if user else {}
hidden = Link._hidden(user, wrapped) if user else {}
@@ -317,6 +318,17 @@ class Link(Thing, Printable):
else:
item.nofollow = False
item.subreddit_path = item.subreddit.path
if c.cname:
item.subreddit_path = ("http://" +
get_domain(cname = (c.site == item.subreddit),
subreddit = False))
if c.site != item.subreddit:
item.subreddit_path += item.subreddit.path
item.domain_path = "/domain/%s" % item.domain
if item.is_self:
item.domain_path = item.subreddit_path
if c.user_is_loggedin:
incr_counts(wrapped)

View File

@@ -26,6 +26,7 @@
%>
<%inherit file="printable.html"/>
<%namespace file="utils.html" import="plain_link" />
<%def name="numcol()">
<% num = thing.num %>
@@ -81,18 +82,8 @@
</%def>
<%def name="subreddit()" buffered="True">
<%
if c.cname:
path = "http://" + get_domain(cname = (c.site == thing.subreddit),
subreddit = (c.site != thing.subreddit))
else:
path = thing.subreddit.path
endif
%>
<a href="${path}" class="subreddit hover"
${'target="_top"' if c.cname else ''} >
${thing.subreddit.name}
</a>
${plain_link(thing.subreddit.name, thing.subreddit_path, sr_path = False,
cname = False, _class = "subreddit hover")}
<script type="text/javascript">
reddit.sr['${thing._fullname}'] = '${thing.subreddit._fullname}';
</script>
@@ -115,8 +106,8 @@
<%def name="domain()">
<span class="domain">
(<a href="/domain/${thing.domain}">${thing.domain}</a>)
</span>
(${plain_link(thing.domain, thing.domain_path, _sr_path = False)})
</span>
</%def>
<%def name="tagline()">