Skip to content
Myr

Merge branch 'master' of git://github.com/visionmedia/express

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Conflicts: lib/express/static.js

authored by ciaranj · committed by ciaranj · parents 704c933, b766234 · Browse files · 7 files+46 added−31 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+46 added−31 removed

  • other:+46 added−31 removed

7 files+46 added−31 removed

modified:examples/public/stylesheets/style.css+11 added
modified:examples/app.js+5 added-1 removed
modified:lib/express/plugins/view.js+7 added-7 removed
12// Express - View - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34var posix = require('posix')54/**7 * Template content cache.5 * Module dependencies.6 */710var cache = {}8var posix = require('posix')910/**11 * Supported template engines.12 */
65 unmodified lines
78 }))79 else80 self.halt(200, content)81 }84 if (set('cache view contents') && cache[view])85 render(cache[view])82 if (set('cache view contents') && self.cache.get(path))83 render(self.cache.get(path))84 else85 posix.cat(path).addCallback(function(content){86 set('cache view contents') ?87 render(self.cache.set(path, content)) :88 render(cache[view] = content)88 render(content)89 }).addErrback(function(e){90 throw e91 })92 }
5 unmodified lines
modified:lib/express/collection.js+1 added-2 removed
27 unmodified lines
28function callback(fn) {29 if (fn === undefined) return30 if (fn instanceof Function) return fn31 if (fn.length < 4) return Function('a, b, c', 'return a ' + fn + ' b')32 if (property.test(fn) ||33 method.test(fn)) fn = 'a.' + fn32 if (property.test(fn) || method.test(fn)) fn = 'a.' + fn33 return Function('a, b, c', 'return ' + fn)34}3536// --- Collection
507 unmodified lines
modified:lib/express/core.js+5 added
275 unmodified lines
276277configure('test', function(){278 enable('throw exceptions')279})280281configure('production', function(){282 enable('cache view contents')283 enable('cache static files')284})
modified:lib/express/static.js+15 added-18 removed
11 unmodified lines
12 this.message = "`" + path + "' is not a valid path"13 }14}) 15 16var static_file_cache={};17 16// --- File1718exports.File = Class({19
16 unmodified lines
36 * - Ensures the file is a regular file (not FIFO, Socket, etc)37 * - Automatically assigns content type38 *39 * @param {Request} request40 * @settings 'cache static files'41 * @api public42 */43 44 send: function(request) {46 var file = this.path47 if ( set('cache statics') && (content= static_file_cache[escape(file)]) ) {45 var cache, file = this.path46 if (set('cache static files') && (cache = request.cache.get(file)))47 request.contentType(cache.type),48 request.halt(200, cache.content)49 path.exists(file, function(exists){50 if (!exists) request.halt()51 posix.stat(file).addCallback(function(stats){52 if (!stats.isFile()) request.halt()53 posix.cat(file, 'binary').addCallback(function(content){54 request.contentType(file)55 if (set('cache static files'))56 request.cache.set(file, { type: file, content: content })57 request.halt(200, content, 'binary')50 }51 else {52 var fileInstance= this;53 path.exists(file, function(exists){54 if (!exists) request.halt()55 posix.stat(file).addCallback(function(stats){56 if (!stats.isFile()) request.halt()57 posix.cat(file, 'binary').addCallback(function(content){58 request.contentType(file)59 request.halt(200, content, 'binary')60 })61 })62 })58 })59 })60 })63 }61 }62})
modified:Readme.md+2 added-3 removed
47 unmodified lines
48 Express is currently **3.5** times faster than Sinatra.4950## Examples5152 require.paths.unshift('lib')52Below is a minimal app example when express is already within your load path.5354 require('express')55 require('express/plugins')56 57 configure(function(){58 use(MethodOverride)59 use(ContentLength)59 use(Redirect)60 set('root', dirname(__filename))61 enable('cache view contents')61 })62 63 get('/hello', function(){64 this.contentType('html')
79 unmodified lines