From be7f77dbb9ab5f7ab61728967368a3780301abdb Mon Sep 17 00:00:00 2001 From: Ignazio Setti Date: Tue, 28 Jan 2014 20:02:45 +0100 Subject: [PATCH 1/3] Replace connect-flash with express-flash --- app.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index dea4a69972..1bedc9013c 100755 --- a/app.js +++ b/app.js @@ -3,7 +3,7 @@ */ var express = require('express'); -var flash = require('connect-flash'); +var flash = require('express-flash'); var less = require('less-middleware'); var path = require('path'); var mongoose = require('mongoose'); diff --git a/package.json b/package.json index 38227e9566..da11a2a7f7 100755 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "async": "~0.2.10", "bcrypt": "~0.7.7", "cheerio": "~0.13.1", - "connect-flash": "~0.1.1", "express": "~3.4.8", + "express-flash": "~0.0.2", "express-validator": "~1.0.1", "fbgraph": "~0.2.8", "github-api": "~0.7.0", From 28d3c14bca2048a70c601982f148105bd4e81ff2 Mon Sep 17 00:00:00 2001 From: Ignazio Setti Date: Tue, 28 Jan 2014 20:03:01 +0100 Subject: [PATCH 2/3] Make flash messages available to every view --- app.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app.js b/app.js index 1bedc9013c..f48d53c41d 100755 --- a/app.js +++ b/app.js @@ -64,6 +64,10 @@ app.use(function(req, res, next) { next(); }); app.use(flash()); +app.use(function(req, res, next) { + res.locals.flash = req.flash.bind(req); + next(); +}); app.use(less({ src: __dirname + '/public', compress: true })); app.use(app.router); app.use(express.static( path.join(__dirname, 'public'), { maxAge: 864000000 } )); From 32f64b3a9239b32c0a669fe88d338233a9e661eb Mon Sep 17 00:00:00 2001 From: Ignazio Setti Date: Tue, 28 Jan 2014 20:03:41 +0100 Subject: [PATCH 3/3] Split the view into partials --- views/layout.jade | 54 ++-------------------------------- views/partials/flash.jade | 13 ++++++++ views/partials/footer.jade | 17 +++++++++++ views/partials/navigation.jade | 34 +++++++++++++++++++++ 4 files changed, 67 insertions(+), 51 deletions(-) create mode 100644 views/partials/flash.jade create mode 100644 views/partials/footer.jade create mode 100644 views/partials/navigation.jade diff --git a/views/layout.jade b/views/layout.jade index c5f48dbdd4..348eedf2f9 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -19,56 +19,8 @@ html script(src='/js/main.js?v=#{cacheBuster}') body #wrap - .navbar.navbar-default.navbar-fixed-top - .container - .navbar-header - button.navbar-toggle(type='button', data-toggle='collapse', data-target='.navbar-collapse') - span.sr-only Toggle navigation - span.icon-bar - span.icon-bar - span.icon-bar - a.navbar-brand(href='/') Project name - .collapse.navbar-collapse - ul.nav.navbar-nav - li(class=title=='Home'?'active':undefined) - a(href='/') Home - li(class=title=='API Browser'?'active':undefined) - a(href='/api') API Browser - li(class=title=='Contact'?'active':undefined) - a(href='/contact') Contact - ul.nav.navbar-nav.navbar-right - if !user - li(class=title=='Login'?'active':undefined) - a(href='/login') Login - li(class=title=='Create Account'?'active':undefined) - a(href='/signup') Create Account - else - li.dropdown(class=title=='Account Management'?'active':undefined) - a.dropdown-toggle(href='#', data-toggle='dropdown') - if user.profile.picture - img(src='#{user.profile.picture}') - | #{user.profile.name || user.id}  - i.caret - ul.dropdown-menu - li: a(href='/account') My Account - li.divider - li: a(href='/logout') Logout + include partials/navigation .container + include partials/flash block content - #footer - .container.text-center - div - | © 2014 Company, Inc. - div - strong Hackathon Starter - | Project - | · - | Created by - a(href='http://sahatyalkabov.com') Sahat Yalkabov - div - | Code licensed under - a(href='http://opensource.org/licenses/mit-license.html') MIT License - div - a(href='https://github.com/sahat/hackathon-starter') GitHub Project - | · - a(href='https://github.com/sahat/hackathon-starter/issues') Issues + include partials/footer diff --git a/views/partials/flash.jade b/views/partials/flash.jade new file mode 100644 index 0000000000..e399b71727 --- /dev/null +++ b/views/partials/flash.jade @@ -0,0 +1,13 @@ +#flash + if messages.errors + .alert.alert-danger.animated.fadeIn + for error in messages.errors + div= error.msg + if messages.info + .alert.alert-info.animated.fadeIn + for info in messages.info + div= info.msg + if messages.success + .alert.alert-success.animated.fadeIn + for success in messages.success + div= success.msg \ No newline at end of file diff --git a/views/partials/footer.jade b/views/partials/footer.jade new file mode 100644 index 0000000000..224fd3c2d2 --- /dev/null +++ b/views/partials/footer.jade @@ -0,0 +1,17 @@ +#footer + .container.text-center + div + | © 2014 Company, Inc. + div + strong Hackathon Starter + | Project + | · + | Created by + a(href='http://sahatyalkabov.com') Sahat Yalkabov + div + | Code licensed under + a(href='http://opensource.org/licenses/mit-license.html') MIT License + div + a(href='https://github.com/sahat/hackathon-starter') GitHub Project + | · + a(href='https://github.com/sahat/hackathon-starter/issues') Issues diff --git a/views/partials/navigation.jade b/views/partials/navigation.jade new file mode 100644 index 0000000000..60ba52ab15 --- /dev/null +++ b/views/partials/navigation.jade @@ -0,0 +1,34 @@ +.navbar.navbar-default.navbar-fixed-top + .container + .navbar-header + button.navbar-toggle(type='button', data-toggle='collapse', data-target='.navbar-collapse') + span.sr-only Toggle navigation + span.icon-bar + span.icon-bar + span.icon-bar + a.navbar-brand(href='/') Project name + .collapse.navbar-collapse + ul.nav.navbar-nav + li(class=title=='Home'?'active':undefined) + a(href='/') Home + li(class=title=='API Browser'?'active':undefined) + a(href='/api') API Browser + li(class=title=='Contact'?'active':undefined) + a(href='/contact') Contact + ul.nav.navbar-nav.navbar-right + if !user + li(class=title=='Login'?'active':undefined) + a(href='/login') Login + li(class=title=='Create Account'?'active':undefined) + a(href='/signup') Create Account + else + li.dropdown(class=title=='Account Management'?'active':undefined) + a.dropdown-toggle(href='#', data-toggle='dropdown') + if user.profile.picture + img(src='#{user.profile.picture}') + | #{user.profile.name || user.id}  + i.caret + ul.dropdown-menu + li: a(href='/account') My Account + li.divider + li: a(href='/logout') Logout \ No newline at end of file