forked from cory/tildefriends
		
	Add a thing to remove apps from your app list. Should I have called in 'uninstall'?
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3916 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -366,6 +366,22 @@ function save(save_to) { | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function deleteApp() { | ||||
| 	let name = document.getElementById("name"); | ||||
| 	let path = name && name.value ? name.value : url(); | ||||
|  | ||||
| 	if (confirm(`Are you sure you want to delete the app '${path}'?`)) { | ||||
| 		fetch(path + 'delete').then(function(response) { | ||||
| 			if (!response.ok) { | ||||
| 				throw new Error(response.status + ' ' + response.statusText); | ||||
| 			} | ||||
| 			alert('Deleted.'); | ||||
| 		}).catch(function(error) { | ||||
| 			alert(error); | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| function pullFromParent() { | ||||
| 	load(gParentApp ? gParentApp.path : null).then(x => save()).catch(function(error) { | ||||
| 		alert(error) | ||||
|   | ||||
							
								
								
									
										30
									
								
								core/core.js
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								core/core.js
									
									
									
									
									
								
							| @@ -459,6 +459,34 @@ async function blobHandler(request, response, blobId, uri) { | ||||
|  | ||||
| 			response.writeHead(200, {"Content-Type": "text/plain; charset=utf-8"}); | ||||
| 			response.end("/" + newBlobId); | ||||
| 		} else if (uri == "/delete") { | ||||
| 			let match; | ||||
| 			if (match = /^\/\~(\w+)\/(\w+)$/.exec(blobId)) { | ||||
| 				var user = match[1]; | ||||
| 				var appName = match[2]; | ||||
| 				var credentials = auth.query(request.headers); | ||||
| 				if (credentials && credentials.session && | ||||
| 					(credentials.session.name == user || | ||||
| 					(credentials.permissions.administration && user == 'core'))) { | ||||
| 					var database = new Database(user); | ||||
| 					var apps = new Set(); | ||||
| 					try { | ||||
| 						apps = new Set(JSON.parse(database.get('apps'))); | ||||
| 					} catch { | ||||
| 					} | ||||
| 					if (apps.delete(appName)) { | ||||
| 						database.set('apps', JSON.stringify([...apps])); | ||||
| 					} | ||||
| 					database.remove('path:' + appName); | ||||
| 				} else { | ||||
| 					response.writeHead(401, {"Content-Type": "text/plain; charset=utf-8"}); | ||||
| 					response.end("401 Unauthorized"); | ||||
| 					return; | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			response.writeHead(200, {"Content-Type": "text/plain; charset=utf-8"}); | ||||
| 			response.end('OK'); | ||||
| 		} else { | ||||
| 			var data; | ||||
| 			var type; | ||||
| @@ -581,7 +609,7 @@ loadSettings().then(function() { | ||||
| 			return staticDirectoryHandler(request, response, 'deps/split/', match[1]); | ||||
| 		} else if (match = /^\/smoothie\/([\.\w-/]*)$/.exec(request.uri)) { | ||||
| 			return staticDirectoryHandler(request, response, 'deps/smoothie/', match[1]); | ||||
| 		} else if (match = /^(.*)(\/save?)$/.exec(request.uri)) { | ||||
| 		} else if (match = /^(.*)(\/(?:save|delete)?)$/.exec(request.uri)) { | ||||
| 			return blobHandler(request, response, match[1], match[2]); | ||||
| 		} else if (match = /^\/trace$/.exec(request.uri)) { | ||||
| 			var data = trace(); | ||||
|   | ||||
| @@ -33,6 +33,7 @@ | ||||
| 					<input type="button" id="push_to_parent" value="Push to Parent" onclick="pushToParent()"> | ||||
| 					<input type="button" id="pull_from_parent" value="Pull from Parent" onclick="pullFromParent()"> | ||||
| 					<input type="button" id="revert" name="revert" value="Revert to Saved" onclick="revert()"> | ||||
| 					<input type="button" id="delete" name="delete" value="Delete" onclick="deleteApp()"> | ||||
| 				</div> | ||||
| 				<div class="hbox" style="height: 100%"> | ||||
| 					<div id="filesPane"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user