Skip to content
Myr

Merge branch 'mounting'

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

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parents 4ce815a, a1609fa · Browse files · 10 files+145 added−88 removed
This commit

State

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

Diff stats

10 files+145 added−88 removed

  • other:+145 added−88 removed

10 files+145 added−88 removed

modified:examples/blog/routes/post.js+70 added-67 removed
modified:examples/blog/routes/site.js+9 added-7 removed
modified:examples/blog/views/post/form.jade+1 added-1 removed
4 unmodified lines
5 h1 New Post67!= messages()89form#post(action='/post' + (post.title ? '/' + post.id : ''), method='post')9form#post(action=base + '/post' + (post.title ? '/' + post.id : ''), method='post')10 - if (post.title)11 input(type='hidden', name='_method', value='put')12 p13 label(for='post[title]') Title:
7 unmodified lines
modified:examples/blog/views/post/index.jade+1 added-1 removed
1.post2 // title3 h24 = post.title5 a.edit(href='/post/' + post.id + '/edit') Edit5 a.edit(href=base + '/post/' + post.id + '/edit') Edit6 7 // flash messages8 != messages()9
7 unmodified lines
modified:examples/blog/views/index.jade+1 added-1 removed
8 unmodified lines
9 p 10 | It looks like you have no posts!11 p12 | Click13 a(href='/post/add') here13 a(href=base + '/post/add') here14 | to create a post. Login15 | as16 em "admin"17 | and
2 unmodified lines
modified:examples/blog/views/layout.jade+1 added-1 removed
1!!! 52html3 head4 title Blog5 link(rel='stylesheet', href='/style.css')5 link(rel='stylesheet', href=base + '/style.css')6 body7 #container!= body
modified:examples/blog/app.js+24 added-6 removed
added:examples/mounting/app.js+23 added
modified:lib/response.js+15 added-4 removed
15 unmodified lines
16 , utils = connect.utils17 , parseRange = require('./utils').parseRange18 , res = http.ServerResponse.prototype19 , send = connect.static.send20 , join = require('path').join21 , mime = require('mime');2223/**24 * Send a response with the given `body` and optional `headers` and `status` code.
269 unmodified lines
294 * app.get('/post/:id', function(req, res){295 * res.redirect('comments');296 * });297 *298 * Unless an absolute `url` is given, the app's mount-point299 * will be respected. For example if we redirect to `/posts`,300 * and our app is mounted at `/blog` we will redirect to `/blog/posts`.301 *302 * @param {String} url303 * @param {Number} code304 * @api public305 */306307res.redirect = function(url, status){303 var basePath = this.app.set('home') || '/'308 var app = this.app309 , base = app.set('home') || '/'310 , status = status || 302311 , body;312313 // Setup redirect map314 var map = {309 back: this.req.header('Referrer', basePath)310 , home: basePath315 back: this.req.header('Referrer', base)316 , home: base317 };318319 // Support custom redirect map320 map.__proto__ = this.app.redirects;321322 // Attempt mapped redirect317 var mapped = typeof map[url] === 'function'323 var mapped = 'function' == typeof map[url]324 ? map[url](this.req, this)325 : map[url];326327 // Perform redirect328 url = mapped || url;329330 // Respect mount-point331 if (app.route && !~url.indexOf('://')) {332 url = join(app.route, url);333 } 334335 // Support text/{plain,html} by default336 if (this.req.accepts('html')) {337 body = '<p>' + http.STATUS_CODES[status] + '. Redirecting to <a href="' + url + '">' + url + '</a></p>';338 this.header('Content-Type', 'text/html');
25 unmodified lines
modified:support/connectnot shown

Its text is not shown, modified.