Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21f56d5
commit 8d97f12
Showing
6 changed files
with
85 additions
and
73 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
YUI.add('my-yui-module', function (Y) { | ||
|
||
// It's not a YUI tutorial :) | ||
Y.Node.create('<p>Successfully loaded module "my-yui-module"</p>').appendTo(document.body); | ||
Y.Node.create('<p style="background-color: lightgreen;">Successfully loaded module "my-yui-module"</p>').appendTo(document.body); | ||
|
||
}, '1.0', {requires: ['widget', 'widget-stdmod']}); |
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
var fs = require('fs'); | ||
|
||
exports.YuiComboHandler = function(path_prefix) { | ||
return function(req, res){ | ||
var querystring = req.url.split('?')[1], | ||
modules = querystring.split('&'); | ||
|
||
var MODE = "JS"; | ||
if(modules[0].indexOf(".css") != -1) { | ||
MODE = "CSS"; | ||
} | ||
|
||
var ret = "", fileCount = 0; | ||
modules.forEach(function(f) { | ||
fs.readFile(path_prefix+f, encoding="utf8", function(err, data) { | ||
fileCount++; | ||
|
||
// Fix CSS assets path | ||
if(MODE == "CSS") { | ||
var l = f.split('/'), fp = l.slice(0,l.length-1); | ||
data = data.replace(/url\(\s*["']?([^"'\)]+)["']?\s*\)/g,"url("+fp.join('/')+"/$1)"); | ||
} | ||
|
||
ret += data; | ||
|
||
if(err) { | ||
console.log("YuiComboLoader error : "); | ||
console.log(err); | ||
res.send(err); | ||
} | ||
else if(fileCount == modules.length) { | ||
|
||
// CSS Handling | ||
if(MODE == "CSS") { | ||
res.header("Content-Type", "text/css"); | ||
} | ||
// JS Handling | ||
else { | ||
res.header("Content-Type", "application/javascript"); | ||
} | ||
|
||
// Cache-Control | ||
// TODO: make configurable | ||
res.header('Expires', new Date((new Date()).getTime() + (60 * 60 * 1000 * 24 * 365 * 10)) ); | ||
res.header('Age', '300'); | ||
res.header('Cache-Control', 'max-age=315360000'); | ||
|
||
|
||
res.header('Date', new Date() ); | ||
res.send(ret); | ||
} | ||
}); | ||
}); | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.