Skip to content
Myr

Merge branch 'update-ext'

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

authored by visionmedia · committed by visionmedia · parents 606da1c, 37d490c · Browse files · 15 files+82 added−65 removed
This commit

State

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

Diff stats

15 files+82 added−65 removed

  • tests:+1 added−1 removed
  • other:+81 added−64 removed

15 files+82 added−65 removed

modified:lib/express/pages/show-exceptions.js+12 added-8 removed
modified:lib/express/plugins/cache.js+24 added-21 removed
124 unmodified lines
125 if (key.indexOf('*') === -1)126 return callback(this.data[key] instanceof Cache127 ? this.data[key].val128 : null)129 var regexp = this.normalize(key) 130 callback(this.data.reduce(function(vals, cache){131 if (regexp.test(cache.key))132 vals[cache.key] = cache.val133 return vals134 }, {}))129 var regexp = this.normalize(key),130 keys = Object.keys(this.data),131 matches = {}132 for (var i = 0, len = keys.length; i < len; ++i)133 if (regexp.test(keys[i]))134 matches[keys[i]] = this.data[keys[i]].val135 callback(matches)136 },137 138 /**139 * Clear data matching the given _key_.
11 unmodified lines
151 clear: function(key, callback) {152 if (key.indexOf('*') === -1)153 delete this.data[key]154 else {154 var regexp = this.normalize(key)155 this.data.each(function(val, key){156 if (regexp.test(key))157 delete this.data[key]158 }, this)155 var regexp = this.normalize(key),156 keys = Object.keys(this.data)157 for (var i = 0, len = keys.length; i < len; ++i)158 if (regexp.test(keys[i]))159 delete this.data[keys[i]]160 }161 callback()162 },163 164 /**164 * Reap caches older than _ms_.165 * Reap caches older than _ms_ or caches which166 * have been "cleared" (null).167 *168 * @param {int} ms169 * @api private170 */171 170 reap: function(ms, callback) {171 var self = this,172 threshold = +new Date(Date.now() - ms)173 this.data.each(function(cache){174 if (cache.created < threshold)175 self.clear(cache.key, function(){})176 })177 if (callback) callback()172 reap: function(ms) {173 var threshold = +new Date(Date.now() - ms),174 keys = Object.keys(this.data)175 for (var i = 0, len = keys.length; i < len; ++i)176 if (this.data[keys[i]].created < threshold ||177 this.data[keys[i]].val === null)178 this.clear(keys[i], function(){})179 },180 181 /**182 * Convert the given key matching _pattern_
6 unmodified lines
189 * @api private190 */191 192 normalize: function(pattern) {193 // TODO: ensure that stuff like "page:/users/1?foo=bar" will work194 // because they wont right now :)195 return new RegExp('^' + pattern.replace(/[*]/g, '(.*?)') + '$')196 }197})198
15 unmodified lines
214 * @api private215 */216 217 init: function(options) {215 this.merge(options || {})218 Object.merge(this, options)219 this.store = new (this.dataStore || exports.Store.Memory)(options)220 Request.include({ cache: this.store })221 this.startReaper()222 },
14 unmodified lines
modified:lib/express/plugins/cookie.js+10 added-3 removed
33 unmodified lines
34 */3536exports.compileCookie = function(name, val, options) {37 if (!options) return name + '=' + val38 return name + '=' + val + '; ' + options.map(function(val, key){38 var val,39 buf = [name + '=' + val],40 keys = Object.keys(options)41 for (var i = 0, len = keys.length; i < len; ++i) {42 val = options[keys[i]]43 if (val instanceof Date)44 val = val.toGMTString()41 return val === true ? key : key + '=' + val42 }).join('; ')45 buf.push(val === true 46 ? keys[i]47 : keys[i] + '=' + val)48 }49 return buf.join('; ')50}5152// --- Cookie53
68 unmodified lines
modified:lib/express/plugins/hooks.js+1 added-1 removed
37 unmodified lines
38 * Initialize extensions.39 */40 41 init: function() {42 global.merge({42 Object.merge(global, {43 before: exports.before,44 after: exports.after45 })46 }
27 unmodified lines
modified:lib/express/plugins/logger.js+1 added-1 removed
65 unmodified lines
66 * @api private67 */6869 init: function(options) {70 this.merge(options || {})70 Object.merge(this, options)71 }72 },73 74 on: {
19 unmodified lines
modified:lib/express/plugins/session.js+9 added-11 removed
126 unmodified lines
127 * @api public128 */129 130 length: function(callback) {131 callback(null, this.store.values.length)131 callback(null, Object.keys(this.store).length)132 },133 134 /**135 * Reap sessions older than _ms_.136 *137 * @param {int} ms138 * @param {function} callback138 * @api private139 */140 142 reap: function(ms, callback) {143 var threshold = +new Date(Date.now() - ms)144 this.store.each(function(session, sid){145 if (session.lastAccess < threshold)146 this.destroy(sid)147 }, this)148 if (callback) callback()141 reap: function(ms) {142 var threshold = +new Date(Date.now() - ms),143 sids = Object.keys(this.store)144 for (var i = 0, len = sids.length; i < len; ++i)145 if (this.store[sids[i]].lastAccess < threshold)146 this.destroy(sids[i])147 },148149 /**150 * Creates and passes a shiny new session.
2 unmodified lines
153 * @api public154 */155 156 generate: function(callback) {159 callback(null, new exports.Base(utils.uid()))157 callback(null, new exports.Base(utils.uid()))158 }159})160161// --- Session
16 unmodified lines
178 */179 180 init: function(options) {181 this.cookie = {}184 this.merge(options || {})182 Object.merge(this, options)183 this.cookie.httpOnly = true184 this.store = new (this.dataStore || exports.Store.Memory)(options)185 this.startReaper()186 },
47 unmodified lines
modified:lib/express/plugins/view.js+1 added-1 removed
153 unmodified lines
154 options.context = options.context || this155 content = (engines[engine] = engines[engine] || require(engine)).render(content, options)156 if (type === 'views') this.contentType(contentType)157 if (layout)158 this.render([layout, contentType, engine].join('.'), options.mergeDeep({158 this.render([layout, contentType, engine].join('.'), Object.mergeDeep(options, {159 layout: false,160 locals: { body: content }161 }), callback)162 else if (type === 'partials')
11 unmodified lines
modified:lib/express/spec/mocks.js+1 added-1 removed
77 unmodified lines
78 'accept': 'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',79 'accept-language': 'en-us',80 'connection': 'keep-alive'81 }82 this.mergeDeep(options)82 Object.mergeDeep(this, options)83 }84})8586// --- MockResponse
92 unmodified lines
modified:lib/express/core.js+2 added-2 removed
11 unmodified lines
12 http = require('http'),13 sys = require('sys'),14 fs = require('fs')1516global.merge(require('express/plugin'))17global.merge(require('express/dsl'))16Object.merge(global, require('express/plugin'))17Object.merge(global, require('express/dsl'))1819// --- Route2021Route = new Class({
306 unmodified lines
modified:lib/express/event.js+1 added-1 removed
11 unmodified lines
12 */13 14 constructor: function(name, data) {15 this.name = name16 this.merge(data)16 Object.merge(this, data)17 },18 19 /**20 * Return event string.
9 unmodified lines
modified:lib/express/http.js+1 added-1 removed
27 unmodified lines
28 path = url.pathname || '/',29 search = url.search || '',30 hash = url.hash || '',31 port = url.port || 80,32 headers = (headers || {}).merge({ Host: url.hostname }),32 headers = Object.merge(headers || {}, { Host: url.hostname }),33 client = http.createClient(port, url.hostname)34 if (typeof data === 'object' && 'redirects' in data)35 redirects = data.redirects,36 delete data.redirects
79 unmodified lines
modified:lib/express/plugins.js+9 added-9 removed
12// Express - Plugins - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)34global.merge(require('express/plugins/hooks'))5global.merge(require('express/plugins/static'))6global.merge(require('express/plugins/flash'))7global.merge(require('express/plugins/cache'))8global.merge(require('express/plugins/cookie'))9global.merge(require('express/plugins/session'))10global.merge(require('express/plugins/logger'))11global.merge(require('express/plugins/content-length'))12global.merge(require('express/plugins/method-override'))4Object.merge(global, require('express/plugins/hooks'))5Object.merge(global, require('express/plugins/static'))6Object.merge(global, require('express/plugins/flash'))7Object.merge(global, require('express/plugins/cache'))8Object.merge(global, require('express/plugins/cookie'))9Object.merge(global, require('express/plugins/session'))10Object.merge(global, require('express/plugins/logger'))11Object.merge(global, require('express/plugins/content-length'))12Object.merge(global, require('express/plugins/method-override'))
modified:lib/express/request.js+9 added-4 removed
46 unmodified lines
47 * @api private48 */49 50 constructor: function(request, response) {51 this.merge(request)51 Object.merge(this, request)52 response.headers = {}53 this.response = response 54 this.url = url.parse(this.url)55 this.url.pathname = exports.normalizePath(this.url.pathname)
64 unmodified lines
120121 accepts: function() {122 var accept = this.header('accept')123 if (!accept || accept === '*/*') return true124 return arguments.any(function(path){124 return Object.values(arguments).any(function(path){125 var type = mime.type(path)126 return accept.indexOf(type) !== -1 ||127 accept.indexOf(type.split('/')[0] + '/*') !== -1128 })
179 unmodified lines
308 if (data instanceof Function)309 reverse = callback,310 callback = data,311 data = null312 data = { request: this, response: this.response }.merge(data)312 data = Object.merge({ request: this, response: this.response }, data)313 // TODO: no need to reverse plugins every time....314 var self = this,315 complete = 0,316 total = this.plugins.length,317 plugins = reverse
2 unmodified lines
320 ;(function next(err) {321 if (err || complete === total)322 callback(err)323 else {323 if (plugins.at(complete++).trigger(new Event(name, data), next) !== true)324 // TODO: remove when this issue is resolved...325 if (plugins[complete] === undefined)326 ++complete,327 next()328 else if (plugins[complete++].trigger(new Event(name, data), next) !== true)329 next()330 }331 })()332 return this333 },
95 unmodified lines
modified:lib/support/extnot shown

Its text is not shown, modified.

modified:Makefile+1 added-1 removed
11 2AB = ab3ABFLAGS = -n 3000 -c 504NODE = node5COFFEE = coffee
38 unmodified lines