improved minifying
parent
ba677c6e30
commit
e9a389b0a6
|
@ -135,7 +135,7 @@ exports.padJS = function(req, res)
|
||||||
var quote = item.search("_Q") != -1;
|
var quote = item.search("_Q") != -1;
|
||||||
|
|
||||||
//read the included file
|
//read the included file
|
||||||
fs.readFile("../" + filename, "utf-8", function(err, data)
|
fs.readFile(filename, "utf-8", function(err, data)
|
||||||
{
|
{
|
||||||
//compress the file
|
//compress the file
|
||||||
if(type == "JS")
|
if(type == "JS")
|
||||||
|
|
|
@ -85,20 +85,6 @@ async.waterfall([
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
res.sendfile(filePath, { maxAge: exports.maxAge });
|
||||||
});
|
});
|
||||||
|
|
||||||
//if minified is disabled, we need to server the static files under /p/static too
|
|
||||||
//it looks like dynamic script loading works only for subfolders, thats the reason we're doing this
|
|
||||||
if(settings.minify == false)
|
|
||||||
{
|
|
||||||
//serve static files
|
|
||||||
app.get('/p/static/*', function(req, res)
|
|
||||||
{
|
|
||||||
res.header("Server", serverName);
|
|
||||||
var filePath = path.normalize(__dirname + "/.." + req.url.split("?")[0].replace("p/",""));
|
|
||||||
console.error(filePath);
|
|
||||||
res.sendfile(filePath, { maxAge: exports.maxAge });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//serve minified files
|
//serve minified files
|
||||||
app.get('/minified/:id', function(req, res)
|
app.get('/minified/:id', function(req, res)
|
||||||
{
|
{
|
||||||
|
|
|
@ -247,19 +247,19 @@ function Ace2Editor()
|
||||||
});
|
});
|
||||||
|
|
||||||
// these lines must conform to a specific format because they are passed by the build script:
|
// these lines must conform to a specific format because they are passed by the build script:
|
||||||
iframeHTML.push($$INCLUDE_CSS_Q("static/css/iframe_editor.css"));
|
iframeHTML.push($$INCLUDE_CSS_Q("../static/css/iframe_editor.css"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/ace2_common.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/ace2_common.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/skiplist.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/skiplist.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/virtual_lines.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/virtual_lines.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/easysync2.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/easysync2.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/cssmanager.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/cssmanager.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/colorutils.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/colorutils.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/undomodule.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/undomodule.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/contentcollector.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/contentcollector.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/changesettracker.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/changesettracker.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/linestylefilter.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/linestylefilter.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/domline.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/domline.js"));
|
||||||
iframeHTML.push($$INCLUDE_JS_Q("static/js/ace2_inner.js"));
|
iframeHTML.push($$INCLUDE_JS_Q("../static/js/ace2_inner.js"));
|
||||||
|
|
||||||
iframeHTML.push('\'\\n<style type="text/css" title="dynamicsyntax"></style>\\n\'');
|
iframeHTML.push('\'\\n<style type="text/css" title="dynamicsyntax"></style>\\n\'');
|
||||||
iframeHTML.push('\'</head><body id="innerdocbody" class="syntax" spellcheck="false"> </body></html>\'');
|
iframeHTML.push('\'</head><body id="innerdocbody" class="syntax" spellcheck="false"> </body></html>\'');
|
||||||
|
@ -267,7 +267,7 @@ function Ace2Editor()
|
||||||
var outerScript = 'editorId = "' + info.id + '"; editorInfo = parent.' + thisFunctionsName + '.registry[editorId]; ' + 'window.onload = function() ' + '{ window.onload = null; setTimeout' + '(function() ' + '{ var iframe = document.createElement("IFRAME"); ' + 'iframe.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); ' + 'iframe.frameBorder = 0; iframe.allowTransparency = true; ' + // for IE
|
var outerScript = 'editorId = "' + info.id + '"; editorInfo = parent.' + thisFunctionsName + '.registry[editorId]; ' + 'window.onload = function() ' + '{ window.onload = null; setTimeout' + '(function() ' + '{ var iframe = document.createElement("IFRAME"); ' + 'iframe.scrolling = "no"; var outerdocbody = document.getElementById("outerdocbody"); ' + 'iframe.frameBorder = 0; iframe.allowTransparency = true; ' + // for IE
|
||||||
'outerdocbody.insertBefore(iframe, outerdocbody.firstChild); ' + 'iframe.ace_outerWin = window; ' + 'readyFunc = function() { editorInfo.onEditorReady(); readyFunc = null; editorInfo = null; }; ' + 'var doc = iframe.contentWindow.document; doc.open(); var text = (' + iframeHTML.join('+') + ').replace(/\\\\x3c/g, \'<\');doc.write(text); doc.close(); ' + '}, 0); }';
|
'outerdocbody.insertBefore(iframe, outerdocbody.firstChild); ' + 'iframe.ace_outerWin = window; ' + 'readyFunc = function() { editorInfo.onEditorReady(); readyFunc = null; editorInfo = null; }; ' + 'var doc = iframe.contentWindow.document; doc.open(); var text = (' + iframeHTML.join('+') + ').replace(/\\\\x3c/g, \'<\');doc.write(text); doc.close(); ' + '}, 0); }';
|
||||||
|
|
||||||
var outerHTML = [doctype, '<html><head>', $$INCLUDE_CSS("static/css/iframe_editor.css"),
|
var outerHTML = [doctype, '<html><head>', $$INCLUDE_CSS("../static/css/iframe_editor.css"),
|
||||||
// bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly
|
// bizarrely, in FF2, a file with no "external" dependencies won't finish loading properly
|
||||||
// (throbs busy while typing)
|
// (throbs busy while typing)
|
||||||
'<link rel="stylesheet" type="text/css" href="data:text/css,"/>', '\x3cscript>\n', outerScript, '\n\x3c/script>', '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>'];
|
'<link rel="stylesheet" type="text/css" href="data:text/css,"/>', '\x3cscript>\n', outerScript, '\n\x3c/script>', '</head><body id="outerdocbody"><div id="sidediv"><!-- --></div><div id="linemetricsdiv">x</div><div id="overlaysdiv"><!-- --></div></body></html>'];
|
||||||
|
|
Loading…
Reference in New Issue