diff --git a/modules/api/api.js b/modules/api/api.js index 1c10b98..408dc0a 100644 --- a/modules/api/api.js +++ b/modules/api/api.js @@ -5,6 +5,22 @@ var _ = require('underscore')._; var api = function(dbot) { + this.pages = { + '/api': function(req, res) { + var externalApi = {}; + _.each(dbot.api, function(moduleApi, moduleName) { + externalApi[moduleName] = {}; + _.each(moduleApi, function(method, methodName) { + if(method.external == true) { + externalApi[moduleName][methodName] = method.extMap; + } + }); + }); + + res.render('api', { 'name': dbot.config.name, 'api': externalApi }); + } + }; + this.onLoad = function() { dbot.modules.web.app.get('/api/:module/:method', function(req, res) { var module = req.params.module, diff --git a/views/api/api.jade b/views/api/api.jade new file mode 100644 index 0000000..895c272 --- /dev/null +++ b/views/api/api.jade @@ -0,0 +1,21 @@ +extends ../layout + +block content + div#backlink + a(href='/') « Home + div#row + h4 External API Functions + div#row + table.tabe.table-hover.data + thead + tr + th Module + th Path + th Arguments + tbody + -each module,moduleName in api + -each func,funcName in api[moduleName] + tr + td #{moduleName} + td /api/#{moduleName}/#{funcName} + td #{func}