Skip to content
Myr

fixed up blog example messages

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 · parent b6bc01a · Browse files · 7 files+33 added−15 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+33 added−15 removed

  • other:+33 added−15 removed

7 files+33 added−15 removed

modified:examples/blog/models/post.js+3 added-3 removed
modified:examples/blog/public/style.css+6 added-8 removed
modified:examples/blog/routes/post.js+5 added-4 removed
45 unmodified lines
46 , post = new Post(data.title, data.body);47 48 post.validate(function(err){49 if (err) {50 req.flash('error', err.message);50 req.session.error = err.message;51 return res.redirect('back');52 }5354 post.save(function(err){55 req.flash('info', 'Successfully created post _%s_', post.title);55 req.session.message = 'Successfully created the post.';56 res.redirect('/post/' + post.id);57 }); 58 });59 });
21 unmodified lines
81 app.put('/post/:post', function(req, res, next){82 var post = req.post;83 post.validate(function(err){84 if (err) {85 req.flash('error', err.message);85 req.session.error = err.message;86 return res.redirect('back');87 }8889 post.update(req.body.post, function(err){90 if (err) return next(err);90 req.flash('info', 'Successfully updated post');91 req.session.message = 'Successfully updated post';92 res.redirect('back');93 });94 });95 });
1 unmodified line
modified:examples/blog/views/post/form.jade+2 added
4 unmodified lines
5 h1 Editing #{post.title}6 else7 h1 New Post89 include ../messages1011 form#post(action='/post' + (post.title ? '/' + post.id : ''), method='post')12 if post.title13 input(type='hidden', name='_method', value='put')14 p
8 unmodified lines
modified:examples/blog/views/post/index.jade+2 added
5 unmodified lines
6 h27 = post.title8 a.edit(href='/post/' + post.id + '/edit') Edit9 10 include ../messages11 12 // dates13 p.date.created Created at #{post.createdAt}14 if post.updatedAt15 p.date.updated Updated at #{post.updatedAt}
3 unmodified lines
added:examples/blog/views/messages.jade+6 added
12if error3 p.error= error45if message6 p.message= message
modified:examples/blog/app.js+9 added