Created
February 15, 2011 21:10
-
-
Save mauritslamers/828248 to your computer and use it in GitHub Desktop.
Revisions
-
mauritslamers created this gist
Feb 15, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ App.prototype.save = function() { var that = this, stylesheets = [], scripts = [], fw,i,len, stylesheet, script, html, savr; var Saver = function(app, file) { var that = this; that.save = function() { file.handler.handle(file, null, function(r) { var path; if (r.data.length > 0) { path = l.path.join(app.savePath, file.savePath()); File.createDirectory(l.path.dirname(path)); l.fs.writeFile(path, r.data, function(err) { if (err) throw err; }); } }); }; }; var finisher = function(){ stylesheet = new File({ path: that.name + '.css', framework: that, handler: sharedHandlers.build(['join']), children: stylesheets }); savr = new Saver(that, stylesheet); savr.save(); script = new File({ path: that.name + '.js', framework: that, handler: sharedHandlers.build(['join']), children: scripts }); savr = new Saver(that, script); savr.save(); html.content = this.rootContent( '<link href="' + that.urlPrefix + stylesheet.url() + '" rel="stylesheet" type="text/css">', '<script type="text/javascript" src="' + that.urlPrefix + script.url() + '"></script>' ); savr = new Saver(that, html); savr.save(); }; var parseFw = function(framework) { var file, url; for (url in that.server.files) { //l.sys.puts('parsing url: ' + url); file = that.server.files[url]; if (file.framework === framework) { if (file.isStylesheet()) stylesheets.push(file); if (file.isScript()) scripts.push(file); if (file.isResource()) new Saver(that, file).save(); } if (file.isHtml){ html = file; finisher(); } } }; that.urlPrefix = '../'; sharedHandlers.urlPrefix = that.urlPrefix; for(i=0,len=that.frameworks.length;i<len;i+=1){ parseFw(that.frameworks[i]); }