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
Provenance
- Commit
ae33e7b- Tree
7a3a4b0- Author
ciaranj <ciaranj@gmail.com>- Committer
ciaranj <ciaranj@gmail.com>- Parent 1
704c933- Parent 2
b766234
7 files changed+46 added−31 removed
modified:examples/public/stylesheets/style.css+11 added
79 unmodified lines8081828384858687888990919293949579 unmodified lines background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#c7c7c7));}input[name=name] { width: 80px;}a { color: #1ABFF1; -webkit-transition-property: padding; -webkit-transition-duration: 0.15s;}a:hover { padding: 0 5px;}a:hover:before { content: 'visit: ';}No newline at end of fileNo newline at end of filemodified:examples/app.js+5 added-1 removed
6 unmodified lines78910111213141511 unmodified lines2728293031323330343536373828 unmodified lines6 unmodified lines use(MethodOverride) use(ContentLength) use(CommonLogger) set('root', dirname(__filename)) enable('cache static files') enable('cache view contents')})
var messages = [],11 unmodified lines })})
post('/chat', function(){ messages .push(escape(this.param('message')) .replace(/(http:\/\/[^\s]+)/g, '<a href="$1" target="express-chat">$1</a>') messages.push(escape(this.param('message')).replace(/:\)/g, '<img src="http://icons3.iconfinder.netdna-cdn.com/data/icons/ledicons/emoticon_smile.png">')) .replace(/:\)/g, '<img src="http://icons3.iconfinder.netdna-cdn.com/data/icons/ledicons/emoticon_smile.png">')) this.halt(200)})
get('/chat/messages', function(){28 unmodified linesmodified:lib/express/plugins/view.js+7 added-7 removed
1 2 // Express - View - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)3 4-var posix = require('posix')5-4 /**7- * Template content cache.5+ * Module dependencies.6 */7 10-var cache = {}8+var posix = require('posix')9 10 /**11 * Supported template engines.12 */65 unmodified lines78 }))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 linesmodified:lib/express/collection.js+1 added-2 removed
27 unmodified lines28 function 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 }35 36 // --- Collection507 unmodified linesmodified:lib/express/core.js+5 added
275 unmodified lines276 277 configure('test', function(){278 enable('throw exceptions')279 })280+281+configure('production', function(){282+ enable('cache view contents')283+ enable('cache static files')284+})modified:lib/express/static.js+15 added-18 removed
11 unmodified lines12 this.message = "`" + path + "' is not a valid path"13 }14 }) 15 16-var static_file_cache={};17- 16 // --- File17 18 exports.File = Class({19 16 unmodified lines36 * - 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 lines48 Express is currently **3.5** times faster than Sinatra.49 50 ## Examples51 52- require.paths.unshift('lib')52+Below is a minimal app example when express is already within your load path.53+54 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