diff --git a/TODO b/TODO index c8f1523c6..b12d43b8e 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,4 @@ - logout detection - conflict detection -- deleting cloned nodes ends with 500 (probably only on folders) - -Later: -- context menu on items (add subnote etc.) -- sync with sync server \ No newline at end of file + - note title and content changes are not in audit_log table +- deleting cloned nodes ends with 500 (probably only on folders) \ No newline at end of file diff --git a/src/audit_api.py b/src/audit_api.py index 25191e1e9..c7b9caf26 100644 --- a/src/audit_api.py +++ b/src/audit_api.py @@ -6,7 +6,7 @@ from sql import getSingleResult audit_api = Blueprint('audit_api', __name__) -@audit_api.route('/audit/', methods = ['GET']) +@audit_api.route('/api/audit/', methods = ['GET']) @login_required def getNote(full_load_time): browser_id = request.headers['x-browser-id'] diff --git a/src/notes_api.py b/src/notes_api.py index 6b1fb94aa..1aa9b902a 100644 --- a/src/notes_api.py +++ b/src/notes_api.py @@ -16,7 +16,7 @@ import audit_category notes_api = Blueprint('notes_api', __name__) -@notes_api.route('/notes/', methods = ['GET']) +@notes_api.route('/api/notes/', methods = ['GET']) @login_required def getNote(note_id): execute("update options set opt_value = ? where opt_name = 'start_node'", [note_id]) @@ -34,7 +34,7 @@ def getNote(note_id): 'images': getResults("select * from images where note_id = ? order by note_offset", [note_id]) }) -@notes_api.route('/notes/', methods = ['PUT']) +@notes_api.route('/api/notes/', methods = ['PUT']) @login_required def updateNote(note_id): detail = getSingleResult("select * from notes where note_id = ?", [note_id]) @@ -99,7 +99,7 @@ def updateNote(note_id): return jsonify({}) -@notes_api.route('/notes/', methods = ['DELETE']) +@notes_api.route('/api/notes/', methods = ['DELETE']) @login_required def deleteNote(note_id): children = getResults("select note_id from notes_tree where note_pid = ?", [note_id]) @@ -115,7 +115,7 @@ def deleteNote(note_id): commit() return jsonify({}) -@notes_api.route('/notes//children', methods = ['POST']) +@notes_api.route('/api/notes//children', methods = ['POST']) @login_required def createChild(parent_note_id): note = request.get_json(force=True) @@ -173,7 +173,7 @@ def createChild(parent_note_id): 'note_id': noteId }) -@notes_api.route('/notes', methods = ['GET']) +@notes_api.route('/api/notes', methods = ['GET']) @login_required def searchNotes(): search = '%' + request.args['search'] + '%' diff --git a/src/notes_history_api.py b/src/notes_history_api.py index 8b8e26a3f..23b36ed56 100644 --- a/src/notes_history_api.py +++ b/src/notes_history_api.py @@ -14,14 +14,14 @@ from sql import getResults, getSingleResult notes_history_api = Blueprint('notes_history_api', __name__) -@notes_history_api.route('/notes-history/', methods = ['GET']) +@notes_history_api.route('/api/notes-history/', methods = ['GET']) @login_required def getNoteHistory(note_id): history = getResults("select * from notes_history where note_id = ? order by date_modified desc", [note_id]) return jsonify(history) -@notes_history_api.route('/recent-changes/', methods = ['GET']) +@notes_history_api.route('/api/recent-changes/', methods = ['GET']) @login_required def getRecentChanges(): recent_changes = getResults("select * from notes_history order by date_modified desc limit 1000") diff --git a/src/notes_move_api.py b/src/notes_move_api.py index ede63a8c0..390c93fea 100644 --- a/src/notes_move_api.py +++ b/src/notes_move_api.py @@ -8,7 +8,7 @@ from sql import getSingleResult notes_move_api = Blueprint('notes_move_api', __name__) -@notes_move_api.route('/notes//moveTo/', methods = ['PUT']) +@notes_move_api.route('/api/notes//moveTo/', methods = ['PUT']) @login_required def moveToNote(note_id, parent_id): res = getSingleResult('select max(note_pos) as max_note_pos from notes_tree where note_pid = ?', [parent_id]) @@ -27,7 +27,7 @@ def moveToNote(note_id, parent_id): commit() return jsonify({}) -@notes_move_api.route('/notes//moveBefore/', methods = ['PUT']) +@notes_move_api.route('/api/notes//moveBefore/', methods = ['PUT']) def moveBeforeNote(note_id, before_note_id): before_note = getSingleResult("select * from notes_tree where note_id = ?", [before_note_id]) @@ -42,7 +42,7 @@ def moveBeforeNote(note_id, before_note_id): return jsonify({}) -@notes_move_api.route('/notes//moveAfter/', methods = ['PUT']) +@notes_move_api.route('/api/notes//moveAfter/', methods = ['PUT']) def moveAfterNote(note_id, after_note_id): after_note = getSingleResult("select * from notes_tree where note_id = ?", [after_note_id]) @@ -57,7 +57,7 @@ def moveAfterNote(note_id, after_note_id): return jsonify({}) -@notes_move_api.route('/notes//expanded/', methods = ['PUT']) +@notes_move_api.route('/api/notes//expanded/', methods = ['PUT']) def setExpandedNote(note_id, expanded): execute("update notes_tree set is_expanded = ? where note_id = ?", [expanded, note_id]) diff --git a/src/password_api.py b/src/password_api.py index 143c59534..962696aaa 100644 --- a/src/password_api.py +++ b/src/password_api.py @@ -7,7 +7,7 @@ import change_password password_api = Blueprint('password_api', __name__) -@password_api.route('/password/change', methods = ['POST']) +@password_api.route('/api/password/change', methods = ['POST']) @login_required def changePassword(): req = request.get_json(force=True) diff --git a/src/settings_api.py b/src/settings_api.py index 4d30bdbe2..c3b4144d7 100644 --- a/src/settings_api.py +++ b/src/settings_api.py @@ -8,7 +8,7 @@ settings_api = Blueprint('settings_api', __name__) allowed_options = [ 'encryption_session_timeout', 'history_snapshot_time_interval' ] -@settings_api.route('/settings', methods = ['GET']) +@settings_api.route('/api/settings', methods = ['GET']) @login_required def get_settings(): dict = {} @@ -20,7 +20,7 @@ def get_settings(): return jsonify(dict) -@settings_api.route('/settings', methods = ['POST']) +@settings_api.route('/api/settings', methods = ['POST']) @login_required def set_settings(): req = request.get_json(force=True) diff --git a/src/templates/app.html b/src/templates/app.html index 7307659e8..e834673a5 100644 --- a/src/templates/app.html +++ b/src/templates/app.html @@ -188,7 +188,7 @@ diff --git a/src/tree_api.py b/src/tree_api.py index 65ab3d696..675e5449f 100644 --- a/src/tree_api.py +++ b/src/tree_api.py @@ -10,7 +10,7 @@ from sql import getResults, getSingleResult, getOption tree_api = Blueprint('tree_api', __name__) -@tree_api.route('/tree', methods = ['GET']) +@tree_api.route('/api/tree', methods = ['GET']) @login_required def getTree(): notes = getResults("select " diff --git a/static/js/convert2html.js b/static/js/convert2html.js index 7a0e4916e..987b2474b 100644 --- a/static/js/convert2html.js +++ b/static/js/convert2html.js @@ -1,6 +1,6 @@ function convertNoteToHtml(noteId, failedNotes) { $.ajax({ - url: baseUrl + 'notes/' + noteId, + url: baseApiUrl + 'notes/' + noteId, type: 'GET', async: false, success: function (note) { @@ -18,7 +18,7 @@ function convertNoteToHtml(noteId, failedNotes) { } $.ajax({ - url: baseUrl + 'notes/' + noteId, + url: baseApiUrl + 'notes/' + noteId, type: 'PUT', data: JSON.stringify(note), contentType: "application/json", diff --git a/static/js/encryption.js b/static/js/encryption.js index 18d65b26f..8db6d8dbf 100644 --- a/static/js/encryption.js +++ b/static/js/encryption.js @@ -338,7 +338,7 @@ function updateSubTreeRecursively(noteId, updateCallback, successCallback) { function updateNoteSynchronously(noteId, updateCallback, successCallback) { $.ajax({ - url: baseUrl + 'notes/' + noteId, + url: baseApiUrl + 'notes/' + noteId, type: 'GET', async: false, success: function (note) { @@ -353,7 +353,7 @@ function updateNoteSynchronously(noteId, updateCallback, successCallback) { } $.ajax({ - url: baseUrl + 'notes/' + noteId, + url: baseApiUrl + 'notes/' + noteId, type: 'PUT', data: JSON.stringify(note), contentType: "application/json", diff --git a/static/js/note.js b/static/js/note.js index d694efbc9..3fe1a8fb9 100644 --- a/static/js/note.js +++ b/static/js/note.js @@ -94,7 +94,7 @@ function updateNoteFromInputs(note) { function saveNoteToServer(note, callback) { $.ajax({ - url: baseUrl + 'notes/' + note.detail.note_id, + url: baseApiUrl + 'notes/' + note.detail.note_id, type: 'PUT', data: JSON.stringify(note), contentType: "application/json", @@ -134,7 +134,7 @@ function createNote(node, parentKey, target, encryption) { const newNoteNameEncryptedIfNecessary = encryption > 0 ? encryptString(newNoteName) : newNoteName; $.ajax({ - url: baseUrl + 'notes/' + parentKey + '/children' , + url: baseApiUrl + 'notes/' + parentKey + '/children' , type: 'POST', data: JSON.stringify({ note_title: newNoteNameEncryptedIfNecessary, @@ -192,7 +192,7 @@ function setNoteBackgroundIfEncrypted(note) { } function loadNote(noteId) { - $.get(baseUrl + 'notes/' + noteId).then(function(note) { + $.get(baseApiUrl + 'notes/' + noteId).then(function(note) { globalCurrentNote = note; if (newNoteCreated) { diff --git a/static/js/note_history.js b/static/js/note_history.js index cf085e0b3..089599804 100644 --- a/static/js/note_history.js +++ b/static/js/note_history.js @@ -11,7 +11,7 @@ $(document).bind('keydown', 'alt+h', function() { $("#noteHistoryContent").empty(); $.ajax({ - url: baseUrl + 'notes-history/' + globalCurrentNote.detail.note_id, + url: baseApiUrl + 'notes-history/' + globalCurrentNote.detail.note_id, type: 'GET', success: function (result) { globalHistoryItems = result; diff --git a/static/js/recent_changes.js b/static/js/recent_changes.js index 27d87d625..a41e9f484 100644 --- a/static/js/recent_changes.js +++ b/static/js/recent_changes.js @@ -6,7 +6,7 @@ $(document).bind('keydown', 'alt+r', function() { }); $.ajax({ - url: baseUrl + 'recent-changes/', + url: baseApiUrl + 'recent-changes/', type: 'GET', success: function (result) { const groupedByDate = {}; diff --git a/static/js/settings.js b/static/js/settings.js index e9d03b82d..bd347ec2c 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -1,6 +1,6 @@ function displaySettings() { $.ajax({ - url: baseUrl + 'settings', + url: baseApiUrl + 'settings', type: 'GET', success: function (result) { $("#encryptionTimeoutInSeconds").val(result['encryption_session_timeout']); @@ -32,7 +32,7 @@ $("#changePasswordForm").submit(() => { } $.ajax({ - url: baseUrl + 'password/change', + url: baseApiUrl + 'password/change', type: 'POST', data: JSON.stringify({ 'current_password': oldPassword, @@ -64,7 +64,7 @@ $("#encryptionTimeoutForm").submit(() => { const encryptionTimeout = $("#encryptionTimeoutInSeconds").val(); $.ajax({ - url: baseUrl + 'settings', + url: baseApiUrl + 'settings', type: 'POST', data: JSON.stringify({ name: 'encryption_session_timeout', @@ -86,7 +86,7 @@ $("#historySnapshotTimeIntervalForm").submit(() => { const historySnapshotTimeInterval = $("#historySnapshotTimeIntervalInSeconds").val(); $.ajax({ - url: baseUrl + 'settings', + url: baseApiUrl + 'settings', type: 'POST', data: JSON.stringify({ name: 'history_snapshot_time_interval', diff --git a/static/js/tree.js b/static/js/tree.js index 059920a46..9f69c75a6 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -76,7 +76,7 @@ function setExpandedToServer(note_id, is_expanded) { expanded_num = is_expanded ? 1 : 0; $.ajax({ - url: baseUrl + 'notes/' + note_id + '/expanded/' + expanded_num, + url: baseApiUrl + 'notes/' + note_id + '/expanded/' + expanded_num, type: 'PUT', contentType: "application/json", success: function(result) {} @@ -89,7 +89,7 @@ let globalEncryptedDataKey; let globalFullLoadTime; setInterval(() => { - $.get(baseUrl + 'audit/' + globalFullLoadTime).then(resp => { + $.get(baseApiUrl + 'audit/' + globalFullLoadTime).then(resp => { if (resp.changed) { window.location.reload(true); } @@ -97,7 +97,7 @@ setInterval(() => { }, 60 * 1000); $(function(){ - $.get(baseUrl + 'tree').then(resp => { + $.get(baseApiUrl + 'tree').then(resp => { const notes = resp.notes; let startNoteId = resp.start_note_id; globalEncryptionSalt = resp.password_derived_key_salt; @@ -169,7 +169,7 @@ $("input[name=search]").keyup(function (e) { } if (e && e.which === $.ui.keyCode.ENTER) { - $.get(baseUrl + 'notes?search=' + searchString).then(resp => { + $.get(baseApiUrl + 'notes?search=' + searchString).then(resp => { console.log("search: ", resp); // Pass a string to perform case insensitive matching diff --git a/static/js/tree_mutations.js b/static/js/tree_mutations.js index 0a5f1d410..797f80190 100644 --- a/static/js/tree_mutations.js +++ b/static/js/tree_mutations.js @@ -1,6 +1,6 @@ function moveBeforeNode(node, beforeNode) { $.ajax({ - url: baseUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key, + url: baseApiUrl + 'notes/' + node.key + '/moveBefore/' + beforeNode.key, type: 'PUT', contentType: "application/json", success: function () { @@ -11,7 +11,7 @@ function moveBeforeNode(node, beforeNode) { function moveAfterNode(node, afterNode) { $.ajax({ - url: baseUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key, + url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + afterNode.key, type: 'PUT', contentType: "application/json", success: function () { @@ -22,7 +22,7 @@ function moveAfterNode(node, afterNode) { function moveToNode(node, toNode) { $.ajax({ - url: baseUrl + 'notes/' + node.key + '/moveTo/' + toNode.key, + url: baseApiUrl + 'notes/' + node.key + '/moveTo/' + toNode.key, type: 'PUT', contentType: "application/json", success: function () { @@ -39,7 +39,7 @@ function moveToNode(node, toNode) { function deleteNode(node) { if (confirm('Are you sure you want to delete note "' + node.title + '"?')) { $.ajax({ - url: baseUrl + 'notes/' + node.key, + url: baseApiUrl + 'notes/' + node.key, type: 'DELETE', success: function () { if (node.getParent() !== null && node.getParent().getChildren().length <= 1) { @@ -69,7 +69,7 @@ function deleteNode(node) { function moveNodeUp(node) { if (node.getParent() !== null) { $.ajax({ - url: baseUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key, + url: baseApiUrl + 'notes/' + node.key + '/moveAfter/' + node.getParent().key, type: 'PUT', contentType: "application/json", success: function () {