Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support images in combo-dev

  • Loading branch information...
commit 08fb285c51388b783e46c836f471f17be7da2869 1 parent d2c73a7
John Lindal authored
Showing with 38 additions and 23 deletions.
  1. +12 −14 README.md
  2. +14 −7 combo-dev.js
  3. +2 −2 combo.js
  4. +10 −0 manager.js
View
26 README.md
@@ -118,9 +118,9 @@ Development Mode
----------------
To enable rapid iteration during development, configure an instance of
-combo-dev.js to load your raw source files for the modules you are
-currently working on. All other modules will be requested from the
-fallback combo handler, usually an instance of combo.js.
+combo-dev.js to load your local files for the modules you are currently
+working on. All other modules will be requested from the fallback combo
+handler, usually an instance of combo.js.
combo-dev.js requires a config file, because you typically run a separate
instance for each project that you are working on:
@@ -139,22 +139,20 @@ A typical config file looks like this:
"combo":"http://my-nightly-build-combo-server:8666/combo?",
"root":"/Users/johndoe/yui3-stockpile/dev",
- "modules":
+ "code":
{
- "sp-test-blah.js":
- [
- "sp-test-blah/sp-test-blah-debug.js"
- ],
- "sp-test-foo.css":
- [
- "sp-test-foo/skin/sam/sp-test-foo.css"
- ]
+ "sp-test-blah.js": "sp-test-blah/sp-test-blah-debug.js",
+ "sp-test-foo.css": "sp-test-foo/skin/sam/sp-test-foo.css"
+ },
+ "image":
+ {
+ "warn.png": "sp-test-foo/sam/warn.png"
}
}
Requests for the JavaScript for module sp-test-blah or the CSS for module
-sp-test-foo will return the local files. All other requests will be routed
-to the combo handler.
+sp-test-foo or an image named warn.png will return the local files. All
+other requests will be routed to the combo handler.
Caching
-------
View
21 combo-dev.js
@@ -76,6 +76,17 @@ app.get('/combo', function(req, res)
}
else if (query_info.binary)
{
+ var file = path.basename(query);
+ if (file && config.image[ file ])
+ {
+ file = path.resolve(config.root || '', config.image[ file ])
+ if (path.existsSync(file))
+ {
+ util.pump(fs.createReadStream(file), res);
+ return;
+ }
+ }
+
http.get(url.parse(config.combo + query), function (r)
{
util.pump(r, res);
@@ -90,18 +101,14 @@ app.get('/combo', function(req, res)
var module = Y.partition(query.split('&'), function(m)
{
var name = moduleName(m);
- return (name && config.modules[ name ]);
+ return (name && config.code[ name ]);
});
var module_list = module.rejects.join('&');
- var file_list = Y.reduce(module.matches, [], function(list, m)
+ var file_list = Y.map(module.matches, function(m)
{
- Y.each(config.modules[ moduleName(m) ], function(f)
- {
- list.push(path.resolve(config.root || '', f));
- });
- return list;
+ return path.resolve(config.root || '', config.code[ moduleName(m) ]);
});
var file_index = 0,
View
4 combo.js
@@ -284,9 +284,9 @@ app.get('/combo', function(req, res)
function headers(res)
{
res.setHeader('Content-Type', query_info.type);
- res.setHeader('Cache-Control', 'max-age=315360000');
+ res.setHeader('Cache-Control', 'public,max-age=31536000');
res.setHeader('Expires',
- Y.DataType.Date.format(new Date(new Date().getTime() + 10*365*24*3600000),
+ Y.DataType.Date.format(new Date(new Date().getTime() + 365*24*3600000),
{
format: '%a, %d %b %Y %H:%M:%S GMT'
}));
View
10 manager.js
@@ -59,6 +59,16 @@ if (debug)
var app = express.createServer();
app.use(express.static(__dirname + '/client'));
+app.get('/browse', function(req, res)
+{
+ var query = url.parse(req.url).query;
+ if (!query)
+ {
+ res.end();
+ return;
+ }
+});
+
Y.log('listening on port ' + argv.port, 'debug', 'combo');
app.listen(argv.port);
Please sign in to comment.
Something went wrong with that request. Please try again.