mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 23:05:10 +01:00
Atom feed for public tag
This commit is contained in:
24
digimarks.py
24
digimarks.py
@@ -12,6 +12,7 @@ from urlparse import urlparse, urlunparse
|
|||||||
from utilkit import datetimeutil
|
from utilkit import datetimeutil
|
||||||
|
|
||||||
from flask import Flask, abort, redirect, render_template, request, url_for, jsonify
|
from flask import Flask, abort, redirect, render_template, request, url_for, jsonify
|
||||||
|
from werkzeug.contrib.atom import AtomFeed
|
||||||
from flask_peewee.db import Database
|
from flask_peewee.db import Database
|
||||||
#from flask_peewee.utils import get_object_or_404
|
#from flask_peewee.utils import get_object_or_404
|
||||||
from peewee import * # noqa
|
from peewee import * # noqa
|
||||||
@@ -406,7 +407,6 @@ def publictag(tagkey):
|
|||||||
@app.route('/pub/<tagkey>/json')
|
@app.route('/pub/<tagkey>/json')
|
||||||
def publictagjson(tagkey):
|
def publictagjson(tagkey):
|
||||||
""" json representation of the Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
|
""" json representation of the Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
|
||||||
#this_tag = get_object_or_404(PublicTag.select().where(PublicTag.tagkey == tagkey))
|
|
||||||
try:
|
try:
|
||||||
this_tag = PublicTag.get(PublicTag.tagkey == tagkey)
|
this_tag = PublicTag.get(PublicTag.tagkey == tagkey)
|
||||||
bookmarks = Bookmark.select().where(Bookmark.userkey == this_tag.userkey, Bookmark.tags.contains(this_tag.tag), Bookmark.status == Bookmark.VISIBLE)
|
bookmarks = Bookmark.select().where(Bookmark.userkey == this_tag.userkey, Bookmark.tags.contains(this_tag.tag), Bookmark.status == Bookmark.VISIBLE)
|
||||||
@@ -418,6 +418,28 @@ def publictagjson(tagkey):
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/pub/<tagkey>/feed')
|
||||||
|
def publictagfeed(tagkey):
|
||||||
|
""" rss/atom representation of the Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
|
||||||
|
try:
|
||||||
|
this_tag = PublicTag.get(PublicTag.tagkey == tagkey)
|
||||||
|
bookmarks = Bookmark.select().where(Bookmark.userkey == this_tag.userkey, Bookmark.tags.contains(this_tag.tag), Bookmark.status == Bookmark.VISIBLE).limit(15)
|
||||||
|
feed = AtomFeed(this_tag.tag, feed_url=request.url, url=url_for('publictag', tagkey=tagkey))
|
||||||
|
for bookmark in bookmarks:
|
||||||
|
updated_date = bookmark.modified_date
|
||||||
|
if not bookmark.modified_date:
|
||||||
|
updated_date = bookmark.created_date
|
||||||
|
feed.add(bookmark.title,
|
||||||
|
content_type='html',
|
||||||
|
author='digimarks',
|
||||||
|
url=bookmark.url,
|
||||||
|
updated=updated_date,
|
||||||
|
published=bookmark.created_date)
|
||||||
|
return feed.get_response()
|
||||||
|
except PublicTag.DoesNotExist:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<userkey>/<tag>/makepublic', methods=['GET', 'POST'])
|
@app.route('/<userkey>/<tag>/makepublic', methods=['GET', 'POST'])
|
||||||
def addpublictag(userkey, tag):
|
def addpublictag(userkey, tag):
|
||||||
#user = get_object_or_404(User.get(User.key == userkey))
|
#user = get_object_or_404(User.get(User.key == userkey))
|
||||||
|
|||||||
Reference in New Issue
Block a user