diff --git a/app.js b/app.js index 8bea3de..9903911 100644 --- a/app.js +++ b/app.js @@ -3,9 +3,10 @@ var express = require("express") , path = require('path') , jsforce = require("jsforce") , underscore = require("underscore") - , webRouter = require("./routers/web_router") + , webRouter = require("./routes/web_router") , session = require("express-session") , bodyParser = require("body-parser") + , router = express.Router() , app = express(); app.set("view engine", "html"); @@ -24,7 +25,9 @@ app.use(bodyParser.urlencoded({ extended: true })); -app.use('/', webRouter); +// app.use('/', webRouter); +webRouter(app); +app.use(router); var server = app.listen(process.env.PORT || 3000, function() { var host = server.address().address diff --git a/routers/web_router.js b/routers/web_router.js deleted file mode 100644 index 6612202..0000000 --- a/routers/web_router.js +++ /dev/null @@ -1,13 +0,0 @@ -var express = require("express") - , site = require("../controller/site") - , account = require("../controller/account") - , router = express.Router() - -router.get('/', site.index); -router.post('/login', site.login); -router.get('/about', site.about); -router.get('/oauth/callback', site.callback); -router.get('/account/o', account.list); -router.get('/account/:id', account.view); - -module.exports = router; \ No newline at end of file diff --git a/routes/web_router.js b/routes/web_router.js new file mode 100644 index 0000000..3d52726 --- /dev/null +++ b/routes/web_router.js @@ -0,0 +1,18 @@ +var express = require("express") + , site = require("../controller/site") + , account = require("../controller/account") + , router = express.Router() + +module.exports = function(app) { + app.use(function(req, res, next) { + res.locals.session = req.session; + next(); + }); + + app.get('/', site.index); + app.post('/login', site.login); + app.get('/about', site.about); + app.get('/oauth/callback', site.callback); + app.get('/account/o', account.list); + app.get('/account/:id', account.view); +} \ No newline at end of file diff --git a/views/about.html b/views/about.html index 1e87a87..98fe20c 100644 --- a/views/about.html +++ b/views/about.html @@ -1,5 +1,6 @@ <% include ./template/header.html %>