diff --git a/etiquette/objects.py b/etiquette/objects.py index ccf920b..bf074a4 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -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: diff --git a/frontends/etiquette_flask/backend/endpoints/bookmark_endpoints.py b/frontends/etiquette_flask/backend/endpoints/bookmark_endpoints.py index a4c2876..195382a 100644 --- a/frontends/etiquette_flask/backend/endpoints/bookmark_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/bookmark_endpoints.py @@ -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())