diff --git a/modules/poll/pages.js b/modules/poll/pages.js index 0c8ea41..189a707 100644 --- a/modules/poll/pages.js +++ b/modules/poll/pages.js @@ -30,12 +30,12 @@ var pages = function(dbot) { }, // Lists all of the polls - '/polls': function(req, res) { + '/poll': function(req, res) { res.render('polllist', { 'name': dbot.config.name, 'polllist': Object.keys(dbot.db.polls) }); - }, + } }; return pages; }; diff --git a/modules/users/pages.js b/modules/users/pages.js index 79924b1..9bc83ae 100644 --- a/modules/users/pages.js +++ b/modules/users/pages.js @@ -3,7 +3,7 @@ var pages = function(dbot) { var connections = dbot.instance.connections; return { - '/connections': function(req, res) { + '/users': function(req, res) { var connections = Object.keys(dbot.instance.connections); res.render('connections', { 'name': dbot.config.name, 'connections': connections }); }, diff --git a/modules/web/web.js b/modules/web/web.js index 4d0c702..25f4997 100644 --- a/modules/web/web.js +++ b/modules/web/web.js @@ -8,10 +8,6 @@ var webInterface = function(dbot) { this.app.use(express.static(this.pub)); this.app.set('view engine', 'jade'); - - this.app.get('/', function(req, res) { - res.render('index', { 'name': dbot.config.name }); - }); var server = this.app.listen(dbot.config.web.webPort); @@ -35,6 +31,29 @@ var webInterface = function(dbot) { } }.bind(this); + this.onLoad = function() { + var routes = _.pluck(dbot.modules.web.app.routes.get, 'path'); + var moduleNames = _.keys(dbot.modules); + var indexModules = []; + + _.each(moduleNames, function(moduleName) { + var modulePath = '/' + moduleName; + if(_.include(routes, modulePath)) { + indexModules.push(moduleName); + } + }); + + console.log(indexModules); + + // TODO: get list of loaded modules + this.app.get('/', function(req, res) { + res.render('index', { + 'name': dbot.config.name, + 'routes': indexModules + }); + }); + }.bind(this); + this.onDestroy = function() { server.close(); }; diff --git a/views/index.jade b/views/index.jade index 05d931e..4cf489f 100644 --- a/views/index.jade +++ b/views/index.jade @@ -2,6 +2,5 @@ extends layout block content #modulelinks - a.module(href='/quotes') Quotes - a.module(href='/polls') Polls - a.module(href='/connections') Users + - for(var i=0;i