Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
all APIs are not prefixed with /api
azivnere28c06ef37cf
diff --git a/TODO b/TODOindex c8f1523c64..b12d43b8e4 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 filediff --git a/src/audit_api.py b/src/audit_api.pyindex 25191e1e96..c7b9caf260 100644--- a/src/audit_api.py+++ b/src/audit_api.py@@ -6,7 +6,7 @@ from sql import getSingleResultaudit_api = Blueprint('audit_api', __name__)-@audit_api.route('/audit/<int:full_load_time>', methods = ['GET'])+@audit_api.route('/api/audit/<int:full_load_time>', methods = ['GET'])@login_requireddef getNote(full_load_time):browser_id = request.headers['x-browser-id']diff --git a/src/notes_api.py b/src/notes_api.pyindex 6b1fb94aae..1aa9b902a4 100644--- a/src/notes_api.py+++ b/src/notes_api.py@@ -16,7 +16,7 @@ import audit_categorynotes_api = Blueprint('notes_api', __name__)-@notes_api.route('/notes/<string:note_id>', methods = ['GET'])+@notes_api.route('/api/notes/<string:note_id>', methods = ['GET'])@login_requireddef 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/<string:note_id>', methods = ['PUT'])+@notes_api.route('/api/notes/<string:note_id>', methods = ['PUT'])@login_requireddef 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/<string:note_id>', methods = ['DELETE'])+@notes_api.route('/api/notes/<string:note_id>', methods = ['DELETE'])@login_requireddef 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/<string:parent_note_id>/children', methods = ['POST'])+@notes_api.route('/api/notes/<string:parent_note_id>/children', methods = ['POST'])@login_requireddef 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_requireddef searchNotes():search = '%' + request.args['search'] + '%'diff --git a/src/notes_history_api.py b/src/notes_history_api.pyindex 8b8e26a3f2..23b36ed56f 100644--- a/src/notes_history_api.py+++ b/src/notes_history_api.py@@ -14,14 +14,14 @@ from sql import getResults, getSingleResultnotes_history_api = Blueprint('notes_history_api', __name__)-@notes_history_api.route('/notes-history/<string:note_id>', methods = ['GET'])+@notes_history_api.route('/api/notes-history/<string:note_id>', methods = ['GET'])@login_requireddef 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_requireddef 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.pyindex ede63a8c0f..390c93fea6 100644--- a/src/notes_move_api.py+++ b/src/notes_move_api.py@@ -8,7 +8,7 @@ from sql import getSingleResultnotes_move_api = Blueprint('notes_move_api', __name__)-@notes_move_api.route('/notes/<string:note_id>/moveTo/<string:parent_id>', methods = ['PUT'])+@notes_move_api.route('/api/notes/<string:note_id>/moveTo/<string:parent_id>', methods = ['PUT'])@login_requireddef 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/<string:note_id>/moveBefore/<string:before_note_id>', methods = ['PUT'])+@notes_move_api.route('/api/notes/<string:note_id>/moveBefore/<string:before_note_id>', 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/<string:note_id>/moveAfter/<string:after_note_id>', methods = ['PUT'])+@notes_move_api.route('/api/notes/<string:note_id>/moveAfter/<string:after_note_id>', 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/<string:note_id>/expanded/<int:expanded>', methods = ['PUT'])+@notes_move_api.route('/api/notes/<string:note_id>/expanded/<int: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.pyindex 143c59534e..962696aaa6 100644--- a/src/password_api.py+++ b/src/password_api.py@@ -7,7 +7,7 @@ import change_passwordpassword_api = Blueprint('password_api', __name__)-@password_api.route('/password/change', methods = ['POST'])+@password_api.route('/api/password/change', methods = ['POST'])@login_requireddef changePassword():req = request.get_json(force=True)diff --git a/src/settings_api.py b/src/settings_api.pyindex 4d30bdbe20..c3b4144d76 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_requireddef 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_requireddef set_settings():req = request.get_json(force=True)diff --git a/src/templates/app.html b/src/templates/app.htmlindex 7307659e88..e834673a52 100644--- a/src/templates/app.html+++ b/src/templates/app.html@@ -188,7 +188,7 @@</div><script type="text/javascript">- const baseUrl = '';+ const baseApiUrl = 'api/';</script><script src="stat/lib/jquery.min.js"></script>diff --git a/src/tree_api.py b/src/tree_api.pyindex 65ab3d696f..675e5449f0 100644--- a/src/tree_api.py+++ b/src/tree_api.py@@ -10,7 +10,7 @@ from sql import getResults, getSingleResult, getOptiontree_api = Blueprint('tree_api', __name__)-@tree_api.route('/tree', methods = ['GET'])+@tree_api.route('/api/tree', methods = ['GET'])@login_requireddef getTree():notes = getResults("select "diff --git a/static/js/convert2html.js b/static/js/convert2html.jsindex 7a0e4916ea..987b2474b6 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.jsindex 18d65b26fc..8db6d8dbfc 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.jsindex d694efbc95..3fe1a8fb92 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.jsindex cf085e0b31..089599804b 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.jsindex 27d87d6251..a41e9f484e 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.jsindex e9d03b82d3..bd347ec2c8 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.jsindex 059920a469..9f69c75a66 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 matchingdiff --git a/static/js/tree_mutations.js b/static/js/tree_mutations.jsindex 0a5f1d410f..797f801900 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 () {