From d533a4259d5f260f8c6cd7bfc5c02fad15ca4fdb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 10 Jun 2015 12:28:02 -0400 Subject: [PATCH] feature(html) html -> tmpl: 2 x times speed up --- lib/client/files.js | 4 ++-- lib/server/route.js | 13 +++++++------ html/auth.html => tmpl/auth.hbs | 0 html/auth/dropbox.html => tmpl/auth/dropbox.hbs | 0 html/auth/github.html => tmpl/auth/github.hbs | 0 html/config.html => tmpl/config.hbs | 0 html/fs/file.html => tmpl/fs/file.hbs | 0 html/fs/index.html => tmpl/fs/index.hbs | 0 html/fs/link.html => tmpl/fs/link.hbs | 0 html/fs/panel.html => tmpl/fs/panel.hbs | 0 html/fs/path.html => tmpl/fs/path.hbs | 0 html/fs/pathLink.html => tmpl/fs/pathLink.hbs | 0 html/upload.html => tmpl/upload.hbs | 0 html/view/media.html => tmpl/view/media.hbs | 0 14 files changed, 9 insertions(+), 8 deletions(-) rename html/auth.html => tmpl/auth.hbs (100%) rename html/auth/dropbox.html => tmpl/auth/dropbox.hbs (100%) rename html/auth/github.html => tmpl/auth/github.hbs (100%) rename html/config.html => tmpl/config.hbs (100%) rename html/fs/file.html => tmpl/fs/file.hbs (100%) rename html/fs/index.html => tmpl/fs/index.hbs (100%) rename html/fs/link.html => tmpl/fs/link.hbs (100%) rename html/fs/panel.html => tmpl/fs/panel.hbs (100%) rename html/fs/path.html => tmpl/fs/path.hbs (100%) rename html/fs/pathLink.html => tmpl/fs/pathLink.hbs (100%) rename html/upload.html => tmpl/upload.hbs (100%) rename html/view/media.html => tmpl/view/media.hbs (100%) diff --git a/lib/client/files.js b/lib/client/files.js index 3c377cb0..484eac19 100644 --- a/lib/client/files.js +++ b/lib/client/files.js @@ -18,7 +18,7 @@ FILES_HTML = 'file|path|link|pathLink|media', FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl|upload', funcs = [], - DIR_HTML = '/html/', + DIR_HTML = '/tmpl/', DIR_HTML_FS = DIR_HTML + 'fs/', DIR_JSON = '/json/'; @@ -78,7 +78,7 @@ else path = DIR_HTML_FS + name; - path += '.html'; + path += '.hbs'; } else if (isJSON) { path = DIR_JSON + name + '.json'; } diff --git a/lib/server/route.js b/lib/server/route.js index 8d410a61..44a9a55b 100644 --- a/lib/server/route.js +++ b/lib/server/route.js @@ -2,7 +2,7 @@ 'use strict'; var DIR = __dirname + '/../../', - DIR_HTML = DIR + 'html/', + DIR_HTML = DIR + 'tmpl/', DIR_LIB = DIR + 'lib/', DIR_SERVER = __dirname + '/', DIR_FS = DIR_HTML + 'fs/', @@ -23,7 +23,7 @@ CloudFunc = require(DIR_LIB + 'cloudfunc'), - PATH_INDEX = DIR_FS + 'index.html', + PATH_INDEX = DIR_FS + 'index.hbs', TMPL_PATH = [ 'file', @@ -97,7 +97,7 @@ callback(); } else { filesList = TMPL_PATH.map(function(name) { - var path = DIR_FS + name + '.html'; + var path = DIR_FS + name + '.hbs'; paths[path] = name; @@ -143,9 +143,10 @@ request : request, response : response, gzip : true, - name : name + name : name, + mime : 'text/html' }; - + console.log(p.mime, '...') if (!isAuth && !isFS) callback(); else if (isAuth) { @@ -164,7 +165,7 @@ if (!error) buildIndex(dir, function(error, data) { p.name = PATH_INDEX; - + console.log(p, '88888') if (error) ponse.sendError(error, p); else diff --git a/html/auth.html b/tmpl/auth.hbs similarity index 100% rename from html/auth.html rename to tmpl/auth.hbs diff --git a/html/auth/dropbox.html b/tmpl/auth/dropbox.hbs similarity index 100% rename from html/auth/dropbox.html rename to tmpl/auth/dropbox.hbs diff --git a/html/auth/github.html b/tmpl/auth/github.hbs similarity index 100% rename from html/auth/github.html rename to tmpl/auth/github.hbs diff --git a/html/config.html b/tmpl/config.hbs similarity index 100% rename from html/config.html rename to tmpl/config.hbs diff --git a/html/fs/file.html b/tmpl/fs/file.hbs similarity index 100% rename from html/fs/file.html rename to tmpl/fs/file.hbs diff --git a/html/fs/index.html b/tmpl/fs/index.hbs similarity index 100% rename from html/fs/index.html rename to tmpl/fs/index.hbs diff --git a/html/fs/link.html b/tmpl/fs/link.hbs similarity index 100% rename from html/fs/link.html rename to tmpl/fs/link.hbs diff --git a/html/fs/panel.html b/tmpl/fs/panel.hbs similarity index 100% rename from html/fs/panel.html rename to tmpl/fs/panel.hbs diff --git a/html/fs/path.html b/tmpl/fs/path.hbs similarity index 100% rename from html/fs/path.html rename to tmpl/fs/path.hbs diff --git a/html/fs/pathLink.html b/tmpl/fs/pathLink.hbs similarity index 100% rename from html/fs/pathLink.html rename to tmpl/fs/pathLink.hbs diff --git a/html/upload.html b/tmpl/upload.hbs similarity index 100% rename from html/upload.html rename to tmpl/upload.hbs diff --git a/html/view/media.html b/tmpl/view/media.hbs similarity index 100% rename from html/view/media.html rename to tmpl/view/media.hbs