Added express.js web interface options.
This commit is contained in:
1 parent
353e440241
commit
5c9d9e67ca
568 files changed
+122395
-1
No files matched your search
@@ -38,10 +38,18 @@ exports.initialize = function(options) {
|
||||
modpowers : config.currency.modpowers,
|
||||
chatterbonus: config.currency.chatterbonus
|
||||
});
|
||||
web = require('./web.js')(db, {
|
||||
port : config.web.port,
|
||||
title : config.twitch.channel,
|
||||
slogan : config.web.slogan,
|
||||
logo : config.web.logo,
|
||||
twitter : config.web.twitter
|
||||
});
|
||||
|
||||
//-------- Start -------
|
||||
irc.start();
|
||||
db.start();
|
||||
web.start();
|
||||
currency.start();
|
||||
if (config.commands === true) commands.start();
|
||||
|
||||
@@ -58,4 +66,5 @@ exports.initialize = function(options) {
|
||||
irc.on('message', function (msg) {
|
||||
irc.queue(msg);
|
||||
});
|
||||
|
||||
};
|
||||
+1
-1
@@ -371,4 +371,4 @@ IRC.prototype.monitor_queue = function() {
|
||||
|
||||
module.exports = function (options) {
|
||||
return new IRC(options);
|
||||
};
|
||||
};
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
var express = require('express'),
|
||||
https = require('https');
|
||||
|
||||
//---- Construct ----
|
||||
function WEB(db, options) {
|
||||
var __self = this;
|
||||
|
||||
__self.db = db;
|
||||
|
||||
__self.port = options.port || 9000;
|
||||
__self.title = options.title;
|
||||
__self.slogan = options.slogan;
|
||||
__self.logo = options.logo;
|
||||
__self.twitter = options.twitter;
|
||||
}
|
||||
|
||||
// ---- Methods ----
|
||||
WEB.prototype.start = function () {
|
||||
var __self = this;
|
||||
__self.srv = express();
|
||||
__self.srv.set('view engine', 'jade');
|
||||
__self.srv.set('views', 'web/templates');
|
||||
__self.srv.use(express.static('./web/public'));
|
||||
|
||||
|
||||
// ---- Routes -----
|
||||
__self.srv.get('/', function(req, res) {
|
||||
//lets get the top 5
|
||||
sql = 'SELECT * FROM viewers ORDER BY points DESC LIMIT 10;';
|
||||
__self.db.execute(sql, function(rows) {
|
||||
res.render('index', {
|
||||
title: __self.title,
|
||||
slogan: __self.slogan,
|
||||
logo: __self.logo,
|
||||
twitter: __self.twitter,
|
||||
rows: rows,
|
||||
});
|
||||
});
|
||||
});
|
||||
__self.srv.get('/ladder', function(req, res) {
|
||||
//get the whole viewer list
|
||||
sql = 'SELECT * FROM viewers ORDER BY points DESC;';
|
||||
__self.db.execute(sql, function(rows) {
|
||||
res.render('ladder', {
|
||||
title: __self.title,
|
||||
slogan: __self.slogan,
|
||||
logo: __self.logo,
|
||||
twitter: __self.twitter,
|
||||
rows: rows
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
__self.srv.listen(__self.port);
|
||||
console.log('Started website at '+__self.port);
|
||||
|
||||
};
|
||||
|
||||
module.exports = function (db, options) {
|
||||
return new WEB(db, options);
|
||||
};
|
||||
Reference in new issue
Block a user