Removed some remnants of the old editor. Fixed an encoding bug.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3381 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2017-01-18 02:02:00 +00:00
parent 993054ce9d
commit e8b9bab468

View File

@ -2,11 +2,9 @@
var kStaticFiles = [ var kStaticFiles = [
{uri: '', path: 'index.html', type: 'text/html; charset=UTF-8'}, {uri: '', path: 'index.html', type: 'text/html; charset=UTF-8'},
{uri: '/edit', path: 'edit.html', type: 'text/html; charset=UTF-8'},
{uri: '/style.css', path: 'style.css', type: 'text/css; charset=UTF-8'}, {uri: '/style.css', path: 'style.css', type: 'text/css; charset=UTF-8'},
{uri: '/favicon.png', path: 'favicon.png', type: 'image/png'}, {uri: '/favicon.png', path: 'favicon.png', type: 'image/png'},
{uri: '/client.js', path: 'client.js', type: 'text/javascript; charset=UTF-8'}, {uri: '/client.js', path: 'client.js', type: 'text/javascript; charset=UTF-8'},
{uri: '/editor.js', path: 'editor.js', type: 'text/javascript; charset=UTF-8'},
{uri: '/robots.txt', path: 'robots.txt', type: 'text/plain; charset=UTF-8'}, {uri: '/robots.txt', path: 'robots.txt', type: 'text/plain; charset=UTF-8'},
]; ];
@ -247,13 +245,6 @@ async function handler(request, response, packageOwner, packageName, uri) {
<meta name="google-signin-client_id" content="${gGlobalSettings['google-signin-client_id']}">`); <meta name="google-signin-client_id" content="${gGlobalSettings['google-signin-client_id']}">`);
} }
data = data.replace("$(VIEW_SOURCE)", "/~" + packageOwner + "/" + packageName + "/view"); data = data.replace("$(VIEW_SOURCE)", "/~" + packageOwner + "/" + packageName + "/view");
data = data.replace("$(EDIT_SOURCE)", "/~" + packageOwner + "/" + packageName + "/edit");
} else if (kStaticFiles[i].uri == "/edit") {
var source = new TextDecoder("UTF-8").decode(File.readFile("packages/" + packageOwner + "/" + packageName + "/" + packageName + ".js")) || "";
source = source.replace(/([&<>"])/g, function(x, item) {
return {'&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;'}[item];
});
data = data.replace("$(SOURCE)", source);
} }
var raw = new TextEncoder("UTF-8").encode(data); var raw = new TextEncoder("UTF-8").encode(data);
response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": raw.length}); response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": raw.length});
@ -266,7 +257,7 @@ async function handler(request, response, packageOwner, packageName, uri) {
if (!found) { if (!found) {
var process; var process;
if (uri === "/view") { if (uri === "/view") {
var data = new TextDecoder("UTF-8").decode(File.readFile("packages/" + packageOwner + "/" + packageName + "/" + packageName + ".js")); var data = File.readFile("packages/" + packageOwner + "/" + packageName + "/" + packageName + ".js");
response.writeHead(200, {"Content-Type": "text/javascript; charset=utf-8", "Content-Length": data.length}); response.writeHead(200, {"Content-Type": "text/javascript; charset=utf-8", "Content-Length": data.length});
response.end(data); response.end(data);
} else if (uri == "/save") { } else if (uri == "/save") {