# HG changeset patch # User Daniele Nicolodi # Date 1313317435 -7200 # Node ID 83c2d2f07df4769775bf657b971c0db84ae28c0f # Parent 8d21600963d7f5a5048d32ab73f3956861095be6 Atom feed for database submissions. diff -r 8d21600963d7 -r 83c2d2f07df4 src/ltpdarepo/__init__.py --- a/src/ltpdarepo/__init__.py Wed Nov 09 10:39:24 2011 +0100 +++ b/src/ltpdarepo/__init__.py Sun Aug 14 12:23:55 2011 +0200 @@ -174,6 +174,9 @@ from .views.browse import module app.register_blueprint(module, url_prefix='/browse') +from .views.feed import module +app.register_blueprint(module, url_prefix='/browse') + from .views.profile import module app.register_blueprint(module, url_prefix='/user') diff -r 8d21600963d7 -r 83c2d2f07df4 src/ltpdarepo/static/feed.png Binary file src/ltpdarepo/static/feed.png has changed diff -r 8d21600963d7 -r 83c2d2f07df4 src/ltpdarepo/static/style.css --- a/src/ltpdarepo/static/style.css Wed Nov 09 10:39:24 2011 +0100 +++ b/src/ltpdarepo/static/style.css Sun Aug 14 12:23:55 2011 +0200 @@ -155,6 +155,15 @@ border-bottom: 1px solid black; } +.content { + position: relative; +} + +.feed img { + margin: 0.5em 0; + border: none; +} + /** definition lists **/ .data { diff -r 8d21600963d7 -r 83c2d2f07df4 src/ltpdarepo/templates/database.html --- a/src/ltpdarepo/templates/database.html Wed Nov 09 10:39:24 2011 +0100 +++ b/src/ltpdarepo/templates/database.html Sun Aug 14 12:23:55 2011 +0200 @@ -1,4 +1,7 @@ {% extends "layout.html" %} +{% block head %} + +{% endblock %} {% block title %}{{ database.id }}{% endblock %} {% block body %}

Database «{{ database.id }}»

@@ -24,4 +27,9 @@ {% endfor %} {% endif %} +

Feed

+

Atom feed with the latest submisions to the database:

+ + + {% endblock %} diff -r 8d21600963d7 -r 83c2d2f07df4 src/ltpdarepo/views/feed.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ltpdarepo/views/feed.py Sun Aug 14 12:23:55 2011 +0200 @@ -0,0 +1,43 @@ +from flask import Blueprint, request, url_for, g +from werkzeug.contrib.atom import AtomFeed + +from .browse import Objs + +from ltpdarepo.database import Database +from ltpdarepo.security import require, view + +app = Blueprint('feed', __name__) + + +@app.route('//atom.xml') +@require('user') +def atom(database): + with view('database', database): + db = Database.load(id=database) + if db is None: + # not found + abort(404) + + feed = AtomFeed( + title=db.id, subtitle=db.description, + url=url_for('browse.database', database=database, _external=True), + feed_url=request.url, + generator=('LTPDA Repository', None, g.version)) + + # first n objects ordered per descending submission time + objs = Objs(database=database).orderby('submitted', 1).limit(64) + + for obj in objs.all(): + obj['url'] = url_for('browse.obj', database=database, + objid=obj['id'], _external=True) + feed.add(title='%s: %s' % (obj['name'], obj['title']), + content='%s %s' % (obj['description'], obj['analysis']), + content_type='text', + author=obj['author'], + url=obj['url'], + updated=obj['submitted']) + + # return with the correct mime type + return feed.get_response() + +module = app