Skip to content

Commit

Permalink
Atom feed
Browse files Browse the repository at this point in the history
  • Loading branch information
baijum committed Feb 3, 2011
1 parent 4e7ea74 commit 74149bb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
29 changes: 29 additions & 0 deletions py3k/packages.py
Expand Up @@ -37,6 +37,35 @@
from .captcha import get_captcha_key
from .captcha import verify_captcha

from urlparse import urljoin
from werkzeug.contrib.atom import AtomFeed


def make_external(url):
return urljoin(request.url_root, "project", url)


@app.route('/project/<name>/recent.atom')
def recent_feed(name):
feed = AtomFeed("Project: %s"%name,
feed_url=request.url, url=request.url_root)
result = Distribution.query.filter_by(name=name).first()
if result is None:
return redirect(url_for('search_package', name=name, page=1))
comments = Comment.query.filter_by(distribution_id=result.id).order_by(db.desc(Comment.datetime)).limit(5)

for comment in comments:
title = "%s has %s (%s) %s on %s" % (comment.fullname,
name, comment.version,
"Working" if comment.working else "Failing",
comment.platform)
feed.add(title, unicode(comment.comment),
content_type='html',
author=comment.fullname,
url=make_external(name),
updated=comment.datetime,
published=comment.datetime)
return feed.get_response()

@app.route('/project/<name>/add_comment', methods=['POST'])
def add_comment(name):
Expand Down
Binary file added py3k/static/feed-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions py3k/templates/layout.html
Expand Up @@ -4,6 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
{% block title %}<title>Get Python 3</title>{% endblock %}
{% block link %}{% endblock %}
<link rel="stylesheet" type="text/css" href="{{ url_for('.static', filename='css/style.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ url_for('.static', filename='css/jquery-ui-base-1.8.9.css') }}" />
<script src="{{ url_for('.static', filename='js/jquery-1.4.4.min.js') }}"></script>
Expand Down
15 changes: 14 additions & 1 deletion py3k/templates/package_details.html
@@ -1,4 +1,11 @@
{% extends "layout.html" %}
{% block link %}
<link href="{{ url_for('recent_feed', name=result.name) }}"
rel="alternate"
title="Recent Comments"
type="application/atom+xml">
{% endblock %}

{% block body %}

<h2>Want to use Python 3 for your next project ?</h2>
Expand All @@ -17,7 +24,13 @@ <h4 style="color: #243F00">Find out all the third party libraries supported by P
</div>
<p>
</p>
<h2><a href="http://pypi.python.org/pypi/{{ result.name }}">{{ result.name }}</a></h2>
<h2><a href="http://pypi.python.org/pypi/{{ result.name }}">{{ result.name }}</a>
<a href="{{ url_for('recent_feed', name=result.name) }}"
rel="alternate"
title="Recent Comments"
type="application/atom+xml"><img src="{{ url_for('.static', filename='feed-icon.png') }}" /></a>

</h2>

<dl>
<dt>Home Page</dt>
Expand Down

0 comments on commit 74149bb

Please sign in to comment.