diff --git a/journalmarks/journalmarks.py b/journalmarks/journalmarks.py index 5b5b5fa..720cf89 100644 --- a/journalmarks/journalmarks.py +++ b/journalmarks/journalmarks.py @@ -160,6 +160,23 @@ def create(): return json.dumps(tag) +@journalmarks.route('/update', methods=['POST']) +@login_required +def update(): + if request.json.keys() != {'tag', 'content'}: + return ('invalid fields', 400, None) + tag, content = request.json['tag'], request.json['content'] + try: + j = Journalmark.select().where( + (Journalmark.tag == tag) & (Journalmark.user == flask_g.user) + ).get() + except DoesNotExist: + return ('tag not found', 404, None) + j.content = json.dumps(content) + j.save() + return json.dumps('ok') + + @journalmarks.route('/overview', methods=['GET']) @login_required def overview(): diff --git a/journalmarks/static/journalmarks.js b/journalmarks/static/journalmarks.js index 3c42f19..48e1123 100644 --- a/journalmarks/static/journalmarks.js +++ b/journalmarks/static/journalmarks.js @@ -119,9 +119,12 @@ function journalmarks_initkey(username, password) { } -function journalmarks_encrypturl(url) { +function journalmarks_encrypturl(url, comment) { return new Promise(function(resolve, reject) { - var bytes = enc.encode(JSON.stringify({url: url})); + var content = {url: url}; + if(typeof comment === 'string') + content.comment = comment; + var bytes = enc.encode(JSON.stringify(content)); encrypt(bytes, userkey).then(function(encurl) { resolve(encurl); }).catch(function(error) { diff --git a/journalmarks/templates/index.html b/journalmarks/templates/index.html index 6157fb2..a254bd9 100644 --- a/journalmarks/templates/index.html +++ b/journalmarks/templates/index.html @@ -1,6 +1,8 @@ {% extends "base.html" %} {% block script %} + {% endblock %} {% block body %} -
You can now create a new Journalmark by simply pasting a URL into the text field. To access an existing Journalmark, enter its tag code. There's also a listing of all your Journalmarks on the overview page. Finally, you can also logout again. -
+You can now create a new Journalmark by simply pasting a URL into the text field. To access an existing Journalmark, enter its tag code. There's also a listing of all your Journalmarks on the overview page. Finally, you can also logout again. +
+ +