Add Bookmark.atomify and /bookmarks.atom.
This commit is contained in:
parent
732c13440e
commit
d1b0fb6aec
2 changed files with 39 additions and 0 deletions
|
@ -807,6 +807,34 @@ class Bookmark(ObjectBase):
|
|||
def _uncache(self):
|
||||
self.photodb.caches[Bookmark].remove(self.id)
|
||||
|
||||
def atomify(self, web_root='') -> bs4.BeautifulSoup:
|
||||
web_root = web_root.rstrip('/')
|
||||
soup = bs4.BeautifulSoup('', 'xml')
|
||||
entry = soup.new_tag('entry')
|
||||
soup.append(entry)
|
||||
|
||||
id_element = soup.new_tag('id')
|
||||
id_element.string = str(self.id)
|
||||
entry.append(id_element)
|
||||
|
||||
title = soup.new_tag('title')
|
||||
title.string = self.title
|
||||
entry.append(title)
|
||||
|
||||
link = soup.new_tag('link')
|
||||
link['href'] = self.url
|
||||
entry.append(link)
|
||||
|
||||
published = soup.new_tag('published')
|
||||
published.string = self.created.isoformat()
|
||||
entry.append(published)
|
||||
|
||||
typ = soup.new_tag('etiquette:type')
|
||||
typ.string = 'bookmark'
|
||||
entry.append(typ)
|
||||
|
||||
return soup
|
||||
|
||||
@decorators.required_feature('bookmark.edit')
|
||||
@worms.atomic
|
||||
def delete(self) -> None:
|
||||
|
|
|
@ -32,6 +32,17 @@ def post_bookmark_edit(bookmark_id):
|
|||
|
||||
# Bookmark listings ################################################################################
|
||||
|
||||
@site.route('/bookmarks.atom')
|
||||
def get_bookmarks_atom():
|
||||
bookmarks = common.P.get_bookmarks()
|
||||
response = etiquette.helpers.make_atom_feed(
|
||||
bookmarks,
|
||||
feed_id='/bookmarks' + request.query_string.decode('utf-8'),
|
||||
feed_title='bookmarks',
|
||||
feed_link=request.url.replace('/bookmarks.atom', '/bookmarks'),
|
||||
)
|
||||
return flasktools.atom_response(response)
|
||||
|
||||
@site.route('/bookmarks')
|
||||
def get_bookmarks_html():
|
||||
bookmarks = list(common.P.get_bookmarks())
|
||||
|
|
Loading…
Reference in a new issue