3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 04:49:25 +01:00

update web to use new express version

This commit is contained in:
reality 2014-09-04 14:19:23 +00:00
parent b18a61ebd1
commit 78057dca3c
2 changed files with 12 additions and 11 deletions

View File

@ -39,7 +39,7 @@ var pages = function(dbot) {
var server = req.params.server, var server = req.params.server,
user = req.params.uid; user = req.params.uid;
dbot.api.users.resolveUser(server, user, function(user) { dbot.api.users.resolveUser(server, user, function(err, user) {
var warnings = []; var warnings = [];
this.db.search('warnings', { this.db.search('warnings', {
'server': server, 'server': server,
@ -54,7 +54,6 @@ var pages = function(dbot) {
callback(false); callback(false);
}); });
}, function(err) { }, function(err) {
console.log(warnings);
res.render('warnings', { res.render('warnings', {
'name': dbot.config.name, 'name': dbot.config.name,
'server': server, 'server': server,

View File

@ -4,7 +4,11 @@ var express = require('express'),
flash = require('connect-flash'), flash = require('connect-flash'),
_ = require('underscore')._, _ = require('underscore')._,
fs = require('fs'), fs = require('fs'),
LocalStrategy = require('passport-local').Strategy; LocalStrategy = require('passport-local').Strategy,
cookieParser = require('cookie-parser');
bodyParser = require('body-parser');
expressSession = require('express-session');
methodOverride = require('method-override');
var webInterface = function(dbot) { var webInterface = function(dbot) {
this.config = dbot.config.modules.web; this.config = dbot.config.modules.web;
@ -14,15 +18,14 @@ var webInterface = function(dbot) {
this.app.use(express.static(this.pub)); this.app.use(express.static(this.pub));
this.app.set('view engine', 'jade'); this.app.set('view engine', 'jade');
this.app.use(express.cookieParser()); this.app.use(cookieParser());
this.app.use(express.bodyParser()); this.app.use(methodOverride());
this.app.use(express.methodOverride()); this.app.use(expressSession({ 'secret': 'wat' }));
this.app.use(express.session({ 'secret': 'wat' })); this.app.use(bodyParser());
this.app.use(flash()); this.app.use(flash());
this.app.use(passport.initialize()); this.app.use(passport.initialize());
this.app.use(passport.session()); this.app.use(passport.session());
this.app.use(this.app.router);
passport.serializeUser(function(user, done) { passport.serializeUser(function(user, done) {
done(null, user.id); done(null, user.id);
@ -46,7 +49,7 @@ var webInterface = function(dbot) {
'Please provide a valid server (Servers: ' + 'Please provide a valid server (Servers: ' +
_.keys(dbot.config.servers).join(', ') + ')' }); _.keys(dbot.config.servers).join(', ') + ')' });
dbot.api.users.resolveUser(server, username, function(user) { dbot.api.users.resolveUser(server, username, function(err, user) {
if(user) { if(user) {
this.api.getWebUser(user.id, function(webUser) { this.api.getWebUser(user.id, function(webUser) {
if(webUser) { if(webUser) {
@ -95,8 +98,7 @@ var webInterface = function(dbot) {
this.onLoad = function() { this.onLoad = function() {
this.reloadPages(); this.reloadPages();
var routes = _.pluck(_.without(_.pluck(this.app._router.stack, 'route'), undefined), 'path'),
var routes = _.pluck(dbot.modules.web.app.routes.get, 'path'),
moduleNames = _.keys(dbot.modules); moduleNames = _.keys(dbot.modules);
_.each(moduleNames, function(moduleName) { _.each(moduleNames, function(moduleName) {