updates to RSS feed to link to permalink page instead of goto. Also adds thumbnails and media support. Default user preference is now to show thumbnails on subreddits that show them by default

This commit is contained in:
KeyserSosa
2008-08-28 11:21:49 -07:00
parent 2717d8e515
commit 0c04094a0b
3 changed files with 46 additions and 12 deletions

View File

@@ -59,7 +59,7 @@ class Account(Thing):
spammer = 0,
sort_options = {},
has_subscribed = False,
pref_media = 'off',
pref_media = 'subreddit',
share = {},
)

View File

@@ -1,4 +1,4 @@
## "The contents of this file are subject to the Common Public Attribution
## The contents of this file are subject to the Common Public Attribution
## License Version 1.0. (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License at
## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
@@ -19,22 +19,32 @@
## All portions of the code written by CondeNet are Copyright (c) 2006-2008
## CondeNet, Inc. All Rights Reserved.
################################################################################
<?xml version="1.0" encoding="UTF-8"?>
<%!
from pylons.i18n import _
from r2.models.subreddit import DefaultSR
%>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:media="http://search.yahoo.com/mrss">
<channel>
<title>${self.Title()}</title>
<link>http://${c.domain}${c.site.path}</link>
<description>${c.site.description or ''}</description>
<image>
<%
if g.css_killswitch or not c.site.header:
header_img = DefaultSR.header
else:
header_img = c.site.header
%>
<url>${header_img}</url>
<title>${self.Title()}</title>
<link>http://${c.domain}${c.site.path}</link>
</image>
${next.body()}
</channel>
</rss>
<%def name="Title()">
${c.site.name}: ${_("what's new online")}
${c.site.name}: ${_("what's new online")}
</%def>

View File

@@ -23,16 +23,40 @@
<%!
from pylons.i18n import _, ungettext
from r2.lib.template_helpers import add_sr
from r2.models import FakeSubreddit
%>
<%
com_label = ungettext("comment", "comments", thing.num_comments)
url = "http://%s%s" % (request.host, add_sr(thing.permalink, nocname=True))
sr_path = "http://%s%s" % (request.host, thing.subreddit.path)
%>
<item>
<title>${thing.title}</title>
<link>http://${request.host}/goto?rss=true&amp;id=${thing._fullname}</link>
<guid>http://${request.host}/goto?rss=true&amp;id=${thing._fullname}</guid>
<link>${url}</link>
<guid isPermaLink="true">${url}</guid>
<pubDate>${thing._date.isoformat()}</pubDate>
<dc:date>${thing._date.isoformat()}</dc:date>
<description>
%if thing.thumbnail:
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;
&lt;a href="${url}"&gt;&lt;img src="${thing.thumbnail}" alt="${thing.title}" title="${thing.title}" /&gt;&lt;/a&gt;
&lt;/td&gt;&lt;td&gt;
%endif
submitted by &lt;a href="http://${request.host}/user/${thing.author.name}"&gt;${thing.author.name}&lt;/a&gt;
%if isinstance(c.site, FakeSubreddit):
to &lt;a href="${sr_path}"&gt;${thing.subreddit.name}&lt;/a&gt;
%endif
&lt;br/&gt;
&lt;a href="${thing.url}"&gt;[link]&lt;/a&gt;
&lt;a href="http://${request.host}${add_sr(thing.permalink, nocname=True)}"&gt;[comments]&lt;/a&gt;
&lt;a href="${url}"&gt;[${thing.num_comments} ${com_label}]&lt;/a&gt;
%if thing.thumbnail:
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
%endif
</description>
%if thing.thumbnail:
<media:title>${thing.title}</media:title>
<media:thumbnail url="${thing.thumbnail}" />
%endif
</item>