Comparar commits

...

12 Commits

Autor SHA1 Mensagem Data
Tj Holowaychuk 957cf45fa1 Release 2.2.2 2011-04-12 02:44:47 -07:00
Tj Holowaychuk f4487343df Fixed filename option passing to template engine 2011-04-12 02:43:03 -07:00
Tj Holowaychuk ca1bdb31e3 Updated jade submodule 2011-04-12 02:41:30 -07:00
Tj Holowaychuk 236a412459 docs 2011-04-11 09:46:28 -07:00
Tj Holowaychuk 759a57bdb6 Added second callback support for res.download() connection errors
since you can no longer respond, it will be helpful to have separate callbacks
2011-04-11 09:44:19 -07:00
Tj Holowaychuk 1abb674a07 temp fix for nodes res.removeHeader() after sent "bug" 2011-04-11 09:14:11 -07:00
Tj Holowaychuk 961146a287 link to express-expose 2011-04-08 17:51:41 -07:00
Tj Holowaychuk 573f940985 fixed example hasMessages
sessions are not always available
2011-04-08 12:44:03 -07:00
Tj Holowaychuk 882916bb2e Updated jade submodule 2011-04-08 12:36:41 -07:00
Tj Holowaychuk 47d1c62732 Updated connect submodule 2011-04-08 12:36:35 -07:00
Tj Holowaychuk d39293c025 refactor 2011-04-08 12:36:26 -07:00
Tj Holowaychuk 2942dafdfd >= connect 1.2.3 2011-04-05 11:25:16 -07:00
11 arquivos alterados com 46 adições e 21 exclusões
+6
Ver Arquivo
@@ -1,4 +1,10 @@
2.2.2 / 2011-04-12
==================
* Added second callback support for `res.download()` connection errors
* Fixed `filename` option passing to template engine
2.2.1 / 2011-04-04
==================
+1
Ver Arquivo
@@ -54,6 +54,7 @@ The following are the major contributors of Express (in no specific order).
## More Information
* [express-expose](http://github.com/visionmedia/express-expose) expose objects, functions, modules and more to client-side js with ease
* [express-configure](http://github.com/visionmedia/express-configuration) async configuration support
* [express-messages](http://github.com/visionmedia/express-messages) flash notification rendering helper
* [express-namespace](http://github.com/visionmedia/express-namespace) namespaced route support
+1 -1
Ver Arquivo
@@ -11,7 +11,7 @@ var fs = require('fs')
* Framework version.
*/
var version = '2.2.0';
var version = '2.2.2';
/**
* Add session support.
+10 -2
Ver Arquivo
@@ -816,7 +816,7 @@ Options may also be passed to the internal _fs.createReadStream()_ call, for exa
// handle
});
### res.download(file[, filename[, callback]])
### res.download(file[, filename[, callback[, callback2]]])
Transfer the given _file_ as an attachment with optional alternative _filename_.
@@ -828,12 +828,20 @@ This is equivalent to:
res.attachment(file);
res.sendfile(file);
An optional callback may be supplied as either the second or third argument, which is passed to _res.sendfile()_:
An optional callback may be supplied as either the second or third argument, which is passed to _res.sendfile()_. Within this callback you may still respond, as the header has not been sent.
res.download(path, 'expenses.doc', function(err){
// handle
});
An optional second callback, _callback2_ may be given to allow you to act on connection related errors, however you should not attempt to respond.
res.download(path, function(err){
// error or finished
}, function(err){
// connection related error
});
### res.send(body|status[, headers|status[, status]])
The _res.send()_ method is a high level response utility allowing you to pass
+2 -1
Ver Arquivo
@@ -14,7 +14,7 @@ exports.boot = function(app){
// App settings and middleware
function bootApplication(app) {
app.use(express.logger({ format: ':method :url :status' }));
app.use(express.logger(':method :url :status'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
@@ -45,6 +45,7 @@ function bootApplication(app) {
},
hasMessages: function(req){
if (!req.session) return false;
return Object.keys(req.session.flash || {}).length;
},
+1 -1
Ver Arquivo
@@ -27,7 +27,7 @@ var exports = module.exports = connect.middleware;
* Framework version.
*/
exports.version = '2.2.1';
exports.version = '2.2.2';
/**
* Shortcut for `new Server(...)`.
+19 -9
Ver Arquivo
@@ -130,6 +130,7 @@ res.send = function(body, headers, status){
*/
res.sendfile = function(path, options, fn){
var next = this.req.next;
options = options || {};
// support function as second arg
@@ -140,7 +141,7 @@ res.sendfile = function(path, options, fn){
options.path = path;
options.callback = fn;
send(this.req, this, this.req.next, options);
send(this.req, this, next, options);
};
/**
@@ -183,32 +184,41 @@ res.attachment = function(filename){
/**
* Transfer the file at the given `path`, with optional
* `filename` as an attachment and optional callback `fn(err)`.
* `filename` as an attachment and optional callback `fn(err)`,
* and optional `fn2(err)` which is invoked when an error has
* occurred after headers have been sent.
*
* @param {String} path
* @param {String|Function} filename or fn
* @param {Function} fn
* @return {Type}
* @param {Function} fn2
* @api public
*/
res.download = function(path, filename, fn){
res.download = function(path, filename, fn, fn2){
var self = this;
// support callback as second arg
if ('function' == typeof filename) {
fn2 = fn;
fn = filename;
filename = null;
}
// transfer the file
this.attachment(filename || path).sendfile(path, function(err){
if (err) self.removeHeader('Content-Disposition');
if (fn) return fn(err);
var sentHeader = self._header;
if (err) {
self.req.next('ENOENT' == err.code
? null
: err);
if (!sentHeader) self.removeHeader('Content-Disposition');
if (sentHeader) {
if (fn2) fn2(err);
} else if (fn) {
fn(err);
} else {
self.req.next(err);
}
} else if (fn) {
fn();
}
});
};
+2 -3
Ver Arquivo
@@ -330,12 +330,10 @@ res._render = function(view, opts, fn, parent, sub){
return renderPartial(self, path, opts, options, view);
};
// Provide filename to engine
options.filename = view.path;
// cached view
if (cache[view]) {
view = cache[view];
options.filename = view.path;
// resolve view
} else {
var orig = view = new View(view, options);
@@ -364,6 +362,7 @@ res._render = function(view, opts, fn, parent, sub){
throw err;
}
options.filename = view.path;
var engine = view.templateEngine;
view.fn = engine.compile(view.contents, options)
if (cacheViews) cache[orig.view] = view;
+2 -2
Ver Arquivo
@@ -1,7 +1,7 @@
{
"name": "express",
"description": "Sinatra inspired web development framework",
"version": "2.2.1",
"version": "2.2.2",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"contributors": [
{ "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" },
@@ -10,7 +10,7 @@
{ "name": "Guillermo Rauch", "email": "rauchg@gmail.com" }
],
"dependencies": {
"connect": ">= 1.2.0 < 2.0.0",
"connect": ">= 1.3.0 < 2.0.0",
"mime": ">= 0.0.1",
"qs": ">= 0.0.6"
},