Define packaging for iframe JS in the same way as pad.js and timeslider.js.

This commit is contained in:
Chad Weider 2012-01-31 00:12:10 -08:00
parent 458b5a4f03
commit 348e7ef1d5
3 changed files with 38 additions and 36 deletions

View File

@ -239,9 +239,15 @@ function getAceFile(callback) {
// the kernel isnt actually on the file system. // the kernel isnt actually on the file system.
handleEmbed(null, requireDefinition()); handleEmbed(null, requireDefinition());
} else { } else {
fs.readFile(ROOT_DIR + filename, "utf8", function (error, data) { var contents = '';
handleEmbed(error, isolateJS(data, shortFilename)); tarCode(tar[shortFilename] || shortFilename
}); , function (content) {
contents += content;
}
, function () {
handleEmbed(null, contents);
}
);
} }
} else { } else {
fs.readFile(ROOT_DIR + filename, "utf8", handleEmbed); fs.readFile(ROOT_DIR + filename, "utf8", handleEmbed);

View File

@ -48,4 +48,18 @@
, "broadcast_revisions.js" , "broadcast_revisions.js"
, "timeslider.js" , "timeslider.js"
] ]
, "ace2_inner.js": [
"ace2_common.js"
, "skiplist.js"
, "virtual_lines.js"
, "easysync2.js"
, "cssmanager.js"
, "colorutils.js"
, "undomodule.js"
, "contentcollector.js"
, "changesettracker.js"
, "linestylefilter.js"
, "domline.js"
, "ace2_inner.js"
]
} }

View File

@ -228,30 +228,24 @@ function Ace2Editor()
buffer.push('<script type="application/javascript" src="'+KERNEL_SOURCE+'"><\/script>'); buffer.push('<script type="application/javascript" src="'+KERNEL_SOURCE+'"><\/script>');
} }
} }
function pushScriptTagsFor(buffer, files) { function pushScriptsTo(buffer) {
var sorted = sortFilesByEmbeded(files); /* Folling is for packaging regular expression. */
var embededFiles = sorted.embeded; /* $$INCLUDE_JS("../static/js/ace2_inner.js"); */
var remoteFiles = sorted.remote; var ACE_SOURCE = '../static/js/ace2_inner.js';
if (Ace2Editor.EMBEDED && Ace2Editor.EMBEDED[ACE_SOURCE]) {
for (var i = 0, ii = remoteFiles.length; i < ii; i++) { buffer.push('<script type="text/javascript">');
var file = remoteFiles[i]; buffer.push(Ace2Editor.EMBEDED[ACE_SOURCE]);
buffer.push('require("/ace2_inner");');
buffer.push('<\/script>');
} else {
file = ACE_SOURCE;
file = file.replace(/^\.\.\/static\/js\//, '../minified/'); file = file.replace(/^\.\.\/static\/js\//, '../minified/');
buffer.push('<script type="application/javascript" src="' + file + '"><\/script>'); buffer.push('<script type="application/javascript" src="' + file + '"><\/script>');
}
buffer.push('<script type="text/javascript">'); buffer.push('<script type="text/javascript">');
for (var i = 0, ii = embededFiles.length; i < ii; i++) { buffer.push('require("/ace2_inner");');
var file = embededFiles[i];
buffer.push(Ace2Editor.EMBEDED[file].replace(/<\//g, '<\\/'));
buffer.push(';\n');
}
for (var i = 0, ii = files.length; i < ii; i++) {
var file = files[i];
file = file.replace(/^\.\.\/static\/js\//, '');
buffer.push('require('+ JSON.stringify('/' + file) + ');\n');
}
buffer.push('<\/script>'); buffer.push('<\/script>');
} }
}
function pushStyleTagsFor(buffer, files) { function pushStyleTagsFor(buffer, files) {
var sorted = sortFilesByEmbeded(files); var sorted = sortFilesByEmbeded(files);
var embededFiles = sorted.embeded; var embededFiles = sorted.embeded;
@ -324,18 +318,6 @@ function Ace2Editor()
var includedJS = []; var includedJS = [];
var $$INCLUDE_JS = function(filename) {includedJS.push(filename)}; var $$INCLUDE_JS = function(filename) {includedJS.push(filename)};
$$INCLUDE_JS("../static/js/ace2_common.js");
$$INCLUDE_JS("../static/js/skiplist.js");
$$INCLUDE_JS("../static/js/virtual_lines.js");
$$INCLUDE_JS("../static/js/easysync2.js");
$$INCLUDE_JS("../static/js/cssmanager.js");
$$INCLUDE_JS("../static/js/colorutils.js");
$$INCLUDE_JS("../static/js/undomodule.js");
$$INCLUDE_JS("../static/js/contentcollector.js");
$$INCLUDE_JS("../static/js/changesettracker.js");
$$INCLUDE_JS("../static/js/linestylefilter.js");
$$INCLUDE_JS("../static/js/domline.js");
$$INCLUDE_JS("../static/js/ace2_inner.js");
pushRequireScriptTo(iframeHTML); pushRequireScriptTo(iframeHTML);
// Inject my plugins into my child. // Inject my plugins into my child.
iframeHTML.push('\ iframeHTML.push('\
@ -346,7 +328,7 @@ function Ace2Editor()
});\ });\
</script>\ </script>\
'); ');
pushScriptTagsFor(iframeHTML, includedJS); pushScriptsTo(iframeHTML);
iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>'); iframeHTML.push('<style type="text/css" title="dynamicsyntax"></style>');
iframeHTML.push('</head><body id="innerdocbody" class="syntax" spellcheck="false">&nbsp;</body></html>'); iframeHTML.push('</head><body id="innerdocbody" class="syntax" spellcheck="false">&nbsp;</body></html>');