forked from GitHub/dbot
Create addIndexLink api func for web to link to index not based on module name. Correct titles for notifications + bans. Also hopefully fix the fineWebPerms access for PUs/Mods [close #565]
This commit is contained in:
parent
165c9491a9
commit
405b3d47e4
@ -126,6 +126,10 @@ var kick = function(dbot) {
|
|||||||
this.internalAPI.addTempBan(server, nick, timeout);
|
this.internalAPI.addTempBan(server, nick, timeout);
|
||||||
}, this);
|
}, this);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
if(_.has(dbot.modules, 'web')) {
|
||||||
|
dbot.api.web.addIndexLink('/bans', 'Ban List');
|
||||||
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ var _ = require('underscore')._;
|
|||||||
|
|
||||||
var pages = function(dbot) {
|
var pages = function(dbot) {
|
||||||
return {
|
return {
|
||||||
'/kick': function(req, res) {
|
'/bans': function(req, res) {
|
||||||
res.render('servers', {
|
res.render('servers', {
|
||||||
'servers': _.keys(dbot.config.servers)
|
'servers': _.keys(dbot.config.servers)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'/kick/:server': function(req, res) {
|
'/bans/:server': function(req, res) {
|
||||||
var server = req.params.server,
|
var server = req.params.server,
|
||||||
bans = [];
|
bans = [];
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@ var _ = require('underscore')._;
|
|||||||
|
|
||||||
var pages = function(dbot) {
|
var pages = function(dbot) {
|
||||||
var pages = {
|
var pages = {
|
||||||
'/report': function(req, res) {
|
'/notify': function(req, res) {
|
||||||
res.render('servers', {
|
res.render('servers', {
|
||||||
'name': dbot.config.name,
|
'name': dbot.config.name,
|
||||||
'servers': _.keys(dbot.config.servers)
|
'servers': _.keys(dbot.config.servers)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'/report/:server': function(req, res) {
|
'/notify/:server': function(req, res) {
|
||||||
var server = req.params.server;
|
var server = req.params.server;
|
||||||
res.render('channels', {
|
res.render('channels', {
|
||||||
'name': dbot.config.name,
|
'name': dbot.config.name,
|
||||||
@ -18,7 +18,7 @@ var pages = function(dbot) {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
'/report/:server/missing': function(req, res) {
|
'/notify/:server/missing': function(req, res) {
|
||||||
var server = req.params.server,
|
var server = req.params.server,
|
||||||
user = req.user,
|
user = req.user,
|
||||||
notifies = this.pending[user.id];
|
notifies = this.pending[user.id];
|
||||||
@ -35,7 +35,7 @@ var pages = function(dbot) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
'/report/:server/:channel': function(req, res) {
|
'/notify/:server/:channel': function(req, res) {
|
||||||
var server = req.params.server,
|
var server = req.params.server,
|
||||||
channel = req.params.channel,
|
channel = req.params.channel,
|
||||||
notifies = [];
|
notifies = [];
|
||||||
|
@ -184,6 +184,12 @@ var report = function(dbot) {
|
|||||||
commands['~report'].regex = [/^~report ([^ ]+) ([^ ]+) (.+)$/, 4];
|
commands['~report'].regex = [/^~report ([^ ]+) ([^ ]+) (.+)$/, 4];
|
||||||
commands['~notify'].regex = [/^~notify ([^ ]+) (.+)$/, 3];
|
commands['~notify'].regex = [/^~notify ([^ ]+) (.+)$/, 3];
|
||||||
this.commands = commands;
|
this.commands = commands;
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
if(_.has(dbot.modules, 'web')) {
|
||||||
|
dbot.api.web.addIndexLink('/notify', 'Notifications');
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.fetch = function(dbot) {
|
exports.fetch = function(dbot) {
|
||||||
|
@ -8,6 +8,7 @@ var express = require('express'),
|
|||||||
|
|
||||||
var webInterface = function(dbot) {
|
var webInterface = function(dbot) {
|
||||||
this.config = dbot.config.modules.web;
|
this.config = dbot.config.modules.web;
|
||||||
|
this.indexLinks = {};
|
||||||
this.pub = 'public';
|
this.pub = 'public';
|
||||||
this.app = express();
|
this.app = express();
|
||||||
|
|
||||||
@ -85,25 +86,25 @@ var webInterface = function(dbot) {
|
|||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.onLoad = function() {
|
this.onLoad = function() {
|
||||||
var routes = _.pluck(dbot.modules.web.app.routes.get, 'path');
|
var routes = _.pluck(dbot.modules.web.app.routes.get, 'path'),
|
||||||
var moduleNames = _.keys(dbot.modules);
|
moduleNames = _.keys(dbot.modules);
|
||||||
var indexModules = [];
|
|
||||||
|
|
||||||
// fix the thingy
|
|
||||||
_.each(moduleNames, function(moduleName) {
|
_.each(moduleNames, function(moduleName) {
|
||||||
var modulePath = '/' + moduleName;
|
var modulePath = '/' + moduleName;
|
||||||
if(_.include(routes, modulePath)) {
|
if(_.include(routes, modulePath)) {
|
||||||
indexModules.push(moduleName);
|
moduleName = moduleName.charAt(0).toUpperCase() +
|
||||||
|
moduleName.slice(1);
|
||||||
|
this.indexLinks[modulePath] = moduleName;
|
||||||
}
|
}
|
||||||
});
|
}.bind(this));
|
||||||
|
|
||||||
this.app.get('/', function(req, res) {
|
this.app.get('/', function(req, res) {
|
||||||
res.render('index', {
|
res.render('index', {
|
||||||
'name': dbot.config.name,
|
'name': dbot.config.name,
|
||||||
'user': req.user,
|
'user': req.user,
|
||||||
'routes': indexModules
|
'routes': this.indexLinks
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
this.app.get('/login', function(req, res) {
|
this.app.get('/login', function(req, res) {
|
||||||
res.render('login', {
|
res.render('login', {
|
||||||
@ -147,6 +148,10 @@ var webInterface = function(dbot) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'addIndexLink': function(route, title) {
|
||||||
|
this.indexLinks[route] = title;
|
||||||
|
},
|
||||||
|
|
||||||
'getWebUser': function(id, callback) {
|
'getWebUser': function(id, callback) {
|
||||||
this.db.read('web_users', id, function(err, webUser) {
|
this.db.read('web_users', id, function(err, webUser) {
|
||||||
callback(webUser);
|
callback(webUser);
|
||||||
@ -155,9 +160,8 @@ var webInterface = function(dbot) {
|
|||||||
|
|
||||||
'hasAccess': function(req, res, next) {
|
'hasAccess': function(req, res, next) {
|
||||||
var path = req.route.path,
|
var path = req.route.path,
|
||||||
module = path.split('/')[1],
|
module = dbot.pages[path].module,
|
||||||
mConfig = dbot.config.modules[module];
|
mConfig = dbot.config.modules[module];
|
||||||
module = dbot.modules[module];
|
|
||||||
|
|
||||||
if(mConfig.requireWebLogin == true) {
|
if(mConfig.requireWebLogin == true) {
|
||||||
if(req.isAuthenticated()) {
|
if(req.isAuthenticated()) {
|
||||||
@ -170,10 +174,10 @@ var webInterface = function(dbot) {
|
|||||||
|
|
||||||
if(accessNeeded != 'regular') {
|
if(accessNeeded != 'regular') {
|
||||||
var allowedUsers = dbot.config.admins;
|
var allowedUsers = dbot.config.admins;
|
||||||
if(module.config.webAccess == 'moderators') {
|
if(mConfig.webAccess == 'moderators') {
|
||||||
allowedUsers = _.union(allowedUsers, dbot.config.moderators);
|
allowedUsers = _.union(allowedUsers, dbot.config.moderators);
|
||||||
}
|
}
|
||||||
if(module.config.webAccess == 'power_users') {
|
if(mConfig.webAccess == 'power_users') {
|
||||||
allowedUsers = _.union(allowedUsers, dbot.config.moderators);
|
allowedUsers = _.union(allowedUsers, dbot.config.moderators);
|
||||||
allowedUsers = _.union(allowedUsers, dbot.config.power_users);
|
allowedUsers = _.union(allowedUsers, dbot.config.power_users);
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,5 @@ block content
|
|||||||
if message
|
if message
|
||||||
p #{message}
|
p #{message}
|
||||||
#modulelinks
|
#modulelinks
|
||||||
- for(var i=0;i<routes.length;i++)
|
for title, route in routes
|
||||||
a.module(href='/'+routes[i]) #{routes[i]}
|
a.module(href=route) #{title}
|
||||||
|
@ -2,7 +2,7 @@ extends ../layout
|
|||||||
|
|
||||||
block content
|
block content
|
||||||
div#backlink
|
div#backlink
|
||||||
a(href='/kick/') « Servers
|
a(href='/bans/') « Servers
|
||||||
p
|
p
|
||||||
div#profile_datatable
|
div#profile_datatable
|
||||||
table.table.table-hover.data
|
table.table.table-hover.data
|
||||||
|
@ -6,5 +6,5 @@ block content
|
|||||||
a(href='/') « Home
|
a(href='/') « Home
|
||||||
ul#quotelist
|
ul#quotelist
|
||||||
-each server in servers
|
-each server in servers
|
||||||
a(href='/kick/'+server)
|
a(href='/bans/'+server)
|
||||||
li.quotes #{server}
|
li.quotes #{server}
|
||||||
|
@ -3,8 +3,8 @@ extends ../layout
|
|||||||
block content
|
block content
|
||||||
h3 Channels on #{server}
|
h3 Channels on #{server}
|
||||||
div#backlink
|
div#backlink
|
||||||
a(href='/report') « Server List
|
a(href='/notify') « Server List
|
||||||
ul#quotelist
|
ul#quotelist
|
||||||
-each channel in channels
|
-each channel in channels
|
||||||
a(href='/report/'+server+'/'+encodeURIComponent(channel))
|
a(href='/notify/'+server+'/'+encodeURIComponent(channel))
|
||||||
li.quotes #{channel}
|
li.quotes #{channel}
|
||||||
|
@ -3,7 +3,7 @@ extends ../layout
|
|||||||
block content
|
block content
|
||||||
h3 Notifications Missed by #{user.primaryNick}
|
h3 Notifications Missed by #{user.primaryNick}
|
||||||
div#backlink
|
div#backlink
|
||||||
a(href='/report') « Notifications
|
a(href='/notify') « Notifications
|
||||||
p
|
p
|
||||||
if notifies
|
if notifies
|
||||||
div#profile_datatable
|
div#profile_datatable
|
||||||
|
@ -2,7 +2,7 @@ extends ../layout
|
|||||||
|
|
||||||
block content
|
block content
|
||||||
div#backlink
|
div#backlink
|
||||||
a(href='/report/'+server) « Server Channels
|
a(href='/notify/'+server) « Server Channels
|
||||||
p
|
p
|
||||||
div#profile_datatable
|
div#profile_datatable
|
||||||
table.table.table-hover.data
|
table.table.table-hover.data
|
||||||
|
@ -5,8 +5,8 @@ block content
|
|||||||
div#backlink
|
div#backlink
|
||||||
a(href='/') « Home
|
a(href='/') « Home
|
||||||
div
|
div
|
||||||
a(href='/report/'+user.server+'/missing') My Missed Notifications
|
a(href='/notify/'+user.server+'/missing') My Missed Notifications
|
||||||
ul#quotelist
|
ul#quotelist
|
||||||
-each server in servers
|
-each server in servers
|
||||||
a(href='/report/'+server)
|
a(href='/notify/'+server)
|
||||||
li.quotes #{server}
|
li.quotes #{server}
|
||||||
|
Loading…
Reference in New Issue
Block a user