Add /bookmarks/create_bookmark endpoint. No interface yet.
This commit is contained in:
parent
ac2b820a30
commit
8a0bbbcc56
3 changed files with 27 additions and 4 deletions
|
@ -18,6 +18,14 @@ def album(a, minimal=False):
|
||||||
|
|
||||||
return j
|
return j
|
||||||
|
|
||||||
|
def bookmark(b):
|
||||||
|
j = {
|
||||||
|
'id': b.id,
|
||||||
|
'url': b.url,
|
||||||
|
'title': b.title,
|
||||||
|
}
|
||||||
|
return j
|
||||||
|
|
||||||
def exception(e):
|
def exception(e):
|
||||||
j = {
|
j = {
|
||||||
'error_type': e.error_type,
|
'error_type': e.error_type,
|
||||||
|
|
|
@ -378,11 +378,26 @@ def get_albums_json():
|
||||||
|
|
||||||
@site.route('/bookmarks')
|
@site.route('/bookmarks')
|
||||||
@session_manager.give_token
|
@session_manager.give_token
|
||||||
def get_bookmarks():
|
def get_bookmarks_html():
|
||||||
session = session_manager.get(request)
|
session = session_manager.get(request)
|
||||||
bookmarks = list(P.get_bookmarks())
|
bookmarks = list(P.get_bookmarks())
|
||||||
return flask.render_template('bookmarks.html', bookmarks=bookmarks, session=session)
|
return flask.render_template('bookmarks.html', bookmarks=bookmarks, session=session)
|
||||||
|
|
||||||
|
@site.route('/bookmarks.json')
|
||||||
|
@session_manager.give_token
|
||||||
|
def get_bookmarks_json():
|
||||||
|
bookmarks = [etiquette.jsonify.bookmark(b) for b in P.get_bookmarks()]
|
||||||
|
return jsonify.make_json_response(bookmarks)
|
||||||
|
|
||||||
|
@site.route('/bookmarks/create_bookmark', methods=['POST'])
|
||||||
|
@decorators.required_fields(['url'], forbid_whitespace=True)
|
||||||
|
def post_bookmarks_create():
|
||||||
|
url = request.form['url']
|
||||||
|
title = request.form.get('title', None)
|
||||||
|
bookmark = P.new_bookmark(url=url, title=title)
|
||||||
|
response = etiquette.jsonify.bookmark(bookmark)
|
||||||
|
response = jsonify.make_json_response(response)
|
||||||
|
return response
|
||||||
|
|
||||||
@site.route('/file/<photoid>')
|
@site.route('/file/<photoid>')
|
||||||
def get_file(photoid):
|
def get_file(photoid):
|
||||||
|
|
|
@ -44,11 +44,11 @@
|
||||||
{% for bookmark in bookmarks %}
|
{% for bookmark in bookmarks %}
|
||||||
<div class="bookmark_card">
|
<div class="bookmark_card">
|
||||||
<a href="{{bookmark.url}}" class="bookmark_title">
|
<a href="{{bookmark.url}}" class="bookmark_title">
|
||||||
{% if bookmark.title %}
|
{%- if bookmark.title -%}
|
||||||
{{bookmark.title}}
|
{{bookmark.title}}
|
||||||
{% else %}
|
{%- else -%}
|
||||||
{{bookmark.id}}
|
{{bookmark.id}}
|
||||||
{% endif %}
|
{%- endif -%}
|
||||||
</a>
|
</a>
|
||||||
<a href="{{bookmark.url}}" class="bookmark_url">{{bookmark.url}}</a>
|
<a href="{{bookmark.url}}" class="bookmark_url">{{bookmark.url}}</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue