Removed "reload views" setting and support code
Before adoption: this commit came in with the history the project adopted, so no landing records it.
development env will always bypass cache, however production will not
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent d0fe19f · Browse files · 5 files·+3 added−86 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+3 added−86 removed
- other:+3 added−86 removed
Provenance
- Commit
262b110- Tree
8923c47- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
d0fe19f
5 files changed+3 added−86 removed
modified:bin/express-1 removed
83 unmodified lines84 ' app.use(connect.staticProvider(__dirname + \'/public\'));',85 '});',86 '',87 'app.configure(\'development\', function(){',88- ' app.set(\'reload views\', 500);',88 ' app.use(connect.errorHandler({ dumpExceptions: true, showStack: true })); ',89 '});',90 '',91 'app.configure(\'production\', function(){',93 unmodified linesmodified:docs/guide.md+3 added-5 removed
81 unmodified lines82 * _env_ Application environment set internally, use _app.set('env')_ on _Server#listen()_83 * _home_ Application base path used for _res.redirect()_ and transparently handling mounted apps.84 * _views_ Root views directory defaulting to **CWD/views**85 * _view engine_ Default view engine name for views rendered without extensions86- * _reload views_ Reloads altered views, by default watches for _mtime_ changes with87- with a 500 millisecond interval.86 87 ### Routing88 89 Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.429 unmodified lines519 520 Apply an application level setting _name_ to _val_, or521 get the value of _name_ when _val_ is not present:522 525- app.set('reload views', 200);526- app.set('reload views');527- // => 200523+ app.set('views', __dirname + '/views');524+ app.set('views');525+ // => ...path...526 527 ### app.enable(name)528 529 Enable the given setting _name_:128 unmodified linesmodified:examples/jade/app.js-8 removed
20 unmodified lines2122232425262728293031322526272816 unmodified lines20 unmodified lines// Optional since express defaults to CWD/views
app.set('views', __dirname + '/views');
// Enable auto-reloading of view contents when changed// with an interval of 1000 milliseconds. Start the app// with $ node examples/jade/app.js// then alter some views :)
app.set('reload views', 1000);// or app.enable('reload views'); for defaults
// Set our default template engine to "jade"// which prevents the need for extensions (although you can still mix and match)app.set('view engine', 'jade');
16 unmodified linesmodified:lib/express/server.js-16 removed
70 unmodified lines71 72 sys.inherits(Server, connect.Server);73 74 /**75- * Start listening on the given `port` / `host`.76- *77- * @param {Number} port78- * @param {String} host79- * @api public80- */81-82-Server.prototype.listen = function(port, host){83- // Setup view reloading84- if (this.set('reload views')) {85- view.watcher.call(this, this.set('reload views'));86- }87- connect.Server.prototype.listen.call(this, port, host);88-};89-90-/**75 * Proxy `connect.Server#use()` to apply settings to76 * mounted applications.77 *78 * @param {String|Function|Server} route182 unmodified linesmodified:lib/express/view.js-56 removed
43 unmodified lines44 viewCache = {};45 };46 47 /**48- * Cache view at the given `path`.49- *50- * @param {String} path51- * @return {String}52- * @api private53- */54-55-function cacheView(path) {56- fs.readFile(path, 'utf8', function(err, data){57- if (!err) {58- viewCache[path] = data;59- }60- });61-}62-63-/**48 * Synchronously cache view at the given `path`.49 *50 * @param {String} path51 * @return {String}16 unmodified lines68 return app.set('views') || process.cwd() + '/views';69 }70 71 /**88- * Setup view reloading, checking at the given `interval`89- * which defaults to 500 milliseconds.90- *91- * @param {Numbers} interval92- * @api private93- */94-95-exports.watcher = function(interval){96- interval = interval === true97- ? 50098- : interval;99-100- function watch(file) {101- fs.watchFile(file, { interval: interval }, function(curr, prev){102- if (curr.mtime > prev.mtime) {103- cacheView(file);104- }105- });106- }107-108- (function traverse(dir){109- fs.readdir(dir, function(err, files){110- if (err) return;111- files.forEach(function(file){112- file = dir + '/' + file;113- fs.stat(file, function(err, stats){114- if (err) {115- return;116- } else if (stats.isFile()) {117- watch(file);118- } else if (stats.isDirectory()) {119- traverse(file);120- }121- });122- });123- });124- })(viewRoot(this));125-};126-127-/**72 * Render `view` partial with the given `options`.73 *74 * Options:75 * - `object` Single object with name derived from the view (unless `as` is present) 189 unmodified lines