mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:49:01 +01:00 
			
		
		
		
	all APIs are not prefixed with /api
This commit is contained in:
		
							parent
							
								
									ff58456332
								
							
						
					
					
						commit
						e28c06ef37
					
				
							
								
								
									
										5
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								TODO
									
									
									
									
									
								
							| @ -1,7 +1,4 @@ | ||||
| - logout detection | ||||
| - conflict detection | ||||
|   - note title and content changes are not in audit_log table | ||||
| - deleting cloned nodes ends with 500 (probably only on folders) | ||||
| 
 | ||||
| Later: | ||||
| - context menu on items (add subnote etc.) | ||||
| - sync with sync server | ||||
| @ -6,7 +6,7 @@ from sql import getSingleResult | ||||
| 
 | ||||
| audit_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_required | ||||
| def getNote(full_load_time): | ||||
|     browser_id = request.headers['x-browser-id'] | ||||
|  | ||||
| @ -16,7 +16,7 @@ import audit_category | ||||
| 
 | ||||
| notes_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_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/<string:note_id>', methods = ['PUT']) | ||||
| @notes_api.route('/api/notes/<string:note_id>', 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/<string:note_id>', methods = ['DELETE']) | ||||
| @notes_api.route('/api/notes/<string:note_id>', 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/<string:parent_note_id>/children', methods = ['POST']) | ||||
| @notes_api.route('/api/notes/<string:parent_note_id>/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'] + '%' | ||||
|  | ||||
| @ -14,14 +14,14 @@ from sql import getResults, getSingleResult | ||||
| 
 | ||||
| notes_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_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") | ||||
|  | ||||
| @ -8,7 +8,7 @@ from sql import getSingleResult | ||||
| 
 | ||||
| notes_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_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/<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]) | ||||
| 
 | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -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) | ||||
|  | ||||
| @ -188,7 +188,7 @@ | ||||
|     </div> | ||||
| 
 | ||||
|     <script type="text/javascript"> | ||||
|       const baseUrl = ''; | ||||
|       const baseApiUrl = 'api/'; | ||||
|     </script> | ||||
| 
 | ||||
|     <script src="stat/lib/jquery.min.js"></script> | ||||
|  | ||||
| @ -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 " | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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", | ||||
|  | ||||
| @ -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) { | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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 = {}; | ||||
|  | ||||
| @ -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', | ||||
|  | ||||
| @ -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
 | ||||
|  | ||||
| @ -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 () { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner