<title>{% block title %}MediaGoblin{% endblock title %}</title>
<link rel="stylesheet" type="text/css"
href="{{ request.staticdirect('/css/base.css') }}"/>
+ {% block mediagoblin_head %}
+ {% endblock mediagoblin_head %}
</head>
<body>
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#}
{% extends "mediagoblin/base.html" %}
+
+{% block mediagoblin_head %}
+ <link rel="alternate" type="application/atom+xml"
+ href="{{ request.urlgen(
+ 'mediagoblin.user_pages.atom_feed',
+ user=user.username) }}">
+{% endblock mediagoblin_head %}
+
{% block mediagoblin_content -%}
{% if user %}
<h1>User page for '{{ user.username }}'</h1>
{% include "mediagoblin/utils/object_gallery.html" %}
</ul>
+ <a href={{ request.urlgen(
+ 'mediagoblin.user_pages.atom_feed',
+ user=user.username) }}> atom feed</a>
{% else %}
{# This *should* not occur as the view makes sure we pass in a user. #}
<p>Sorry, no such user found.<p/>
controller="mediagoblin.user_pages.views:user_home"),
Route('mediagoblin.user_pages.media_home', '/{user}/m/{media}/',
requirements=dict(m_id="[0-9a-fA-F]{24}"),
- controller="mediagoblin.user_pages.views:media_home")]
+ controller="mediagoblin.user_pages.views:media_home"),
+ Route('mediagoblin.user_pages.atom_feed', '/{user}/atom/',
+ controller="mediagoblin.user_pages.views:atom_feed")]
from mediagoblin.decorators import uses_pagination, get_user_media_entry
+from werkzeug.contrib.atom import AtomFeed
@uses_pagination
def user_home(request, page):
template.render(
{'request': request,
'media': media}))
+
+ATOM_DEFAULT_NR_OF_UPDATED_ITEMS = 5
+
+def atom_feed(request):
+ """
+ generates the atom feed with the newest images
+ """
+
+ user = request.db.User.find_one({
+ 'username': request.matchdict['user'],
+ 'status': 'active'})
+ if not user:
+ return exc.HTTPNotFound()
+
+ cursor = request.db.MediaEntry.find({
+ 'uploader': user['_id'],
+ 'state': 'processed'}) \
+ .sort('created', DESCENDING) \
+ .limit(ATOM_DEFAULT_NR_OF_UPDATED_ITEMS)
+
+ feed = AtomFeed(request.matchdict['user'],
+ feed_url=request.url,
+ url=request.host_url)
+
+ for entry in cursor:
+ feed.add(entry.get('title'),
+ entry.get('description'),
+ content_type='html',
+ author=request.matchdict['user'],
+ updated=entry.get('created'),
+ url=entry.url_for_self(request.urlgen))
+
+ return feed.get_response()