forked from cory/tildefriends
Look ma, no CDNs.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3699 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
33
core/core.js
33
core/core.js
@ -280,10 +280,27 @@ function setGlobalSettings(settings) {
|
||||
|
||||
var kStaticFiles = [
|
||||
{uri: '/', path: 'index.html', type: 'text/html; 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: '/client.js', path: 'client.js', type: 'text/javascript; charset=UTF-8'},
|
||||
{uri: '/robots.txt', path: 'robots.txt', type: 'text/plain; charset=UTF-8'},
|
||||
{uri: '/style.css', type: 'text/css; charset=UTF-8'},
|
||||
{uri: '/favicon.png', type: 'image/png'},
|
||||
{uri: '/client.js', type: 'text/javascript; charset=UTF-8'},
|
||||
{uri: '/robots.txt', type: 'text/plain; charset=UTF-8'},
|
||||
|
||||
{uri: '/codemirror/codemirror.min.js'},
|
||||
{uri: '/codemirror/base16-dark.min.css'},
|
||||
{uri: '/codemirror/matchesonscrollbar.min.css'},
|
||||
{uri: '/codemirror/dialog.min.css'},
|
||||
{uri: '/codemirror/codemirror.min.css'},
|
||||
{uri: '/codemirror/trailingspace.min.js'},
|
||||
{uri: '/codemirror/dialog.min.js'},
|
||||
{uri: '/codemirror/search.min.js'},
|
||||
{uri: '/codemirror/searchcursor.min.js'},
|
||||
{uri: '/codemirror/jump-to-line.min.js'},
|
||||
{uri: '/codemirror/matchesonscrollbar.min.js'},
|
||||
{uri: '/codemirror/annotatescrollbar.min.js'},
|
||||
{uri: '/codemirror/javascript.min.js'},
|
||||
{uri: '/codemirror/css.min.js'},
|
||||
{uri: '/codemirror/xml.min.js'},
|
||||
{uri: '/codemirror/htmlmixed.min.js'},
|
||||
];
|
||||
|
||||
function startsWithBytes(data, bytes) {
|
||||
@ -301,8 +318,10 @@ function startsWithBytes(data, bytes) {
|
||||
async function staticFileHandler(request, response, blobId, uri) {
|
||||
for (var i in kStaticFiles) {
|
||||
if (uri === kStaticFiles[i].uri) {
|
||||
var data = await File.readFile("core/" + kStaticFiles[i].path);
|
||||
response.writeHead(200, {"Content-Type": kStaticFiles[i].type, "Content-Length": data.byteLength});
|
||||
var path = kStaticFiles[i].path || uri.substring(1);
|
||||
var type = kStaticFiles[i].type || guessType(path);
|
||||
var data = await File.readFile("core/" + path);
|
||||
response.writeHead(200, {"Content-Type": type, "Content-Length": data.byteLength});
|
||||
response.end(data);
|
||||
return;
|
||||
}
|
||||
@ -374,6 +393,8 @@ async function getBlobOrContent(id) {
|
||||
function guessType(path) {
|
||||
const k_extension_to_type = {
|
||||
'css': 'text/css',
|
||||
'html': 'text/html',
|
||||
'js': 'text/javascript',
|
||||
};
|
||||
var extension = path.split('.').pop();
|
||||
return k_extension_to_type[extension];
|
||||
|
Reference in New Issue
Block a user