3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-18 00:22:35 +01:00
dbot/modules/project/project.js

81 lines
2.7 KiB
JavaScript
Raw Normal View History

2013-04-18 13:06:13 +02:00
/**
* Module Name: Project
* Description: Web page which shows git status and other various stats about
* the dbot.
2013-04-18 13:06:13 +02:00
*/
_ = require('underscore'),
exec = require('child_process').exec;
2013-04-20 19:42:34 +02:00
2013-04-18 13:06:13 +02:00
var project = function(dbot) {
this.api = {
'configList' : function(callback){
2013-04-20 19:42:34 +02:00
var list = [];
if(_.has(dbot.modules,'dent')){
list.push(dbot.t("dent-account", {
"username": dbot.config.modules.dent.username
2013-04-20 19:42:34 +02:00
}));
if(_.has(dbot.config.modules.dent.dentQuotes)) {
list.push(dbot.t("dent-push"));
}
2013-04-20 19:42:34 +02:00
}
if(_.has(dbot.modules,'link')){
if(dbot.config.modules.link.autoTitle){
list.push(dbot.t("link-autotitle"));
2013-04-20 19:42:34 +02:00
}
}
if(_.has(dbot.modules,'quotes')){
list.push(dbot.t("quote-rmlimit", {
"limit": dbot.config.modules.quotes.rmLimit
2013-04-20 19:42:34 +02:00
}));
}
if(_.has(dbot.modules,'report')){
if(dbot.config.modules.report.notifyVoice){
list.push(dbot.t("report-notifyvoice"));
2013-04-20 19:42:34 +02:00
}
}
if(_.has(dbot.modules,'web')){
list.push(dbot.t("web-port", {
"port": dbot.config.modules.web.webPort
2013-04-20 19:42:34 +02:00
}));
}
return list;
},
'translationProgress' : function(callback){
var translation = [] ;
var str = _.filter(dbot.strings, function(strings, key) {
return _.include(this.config.string_exceptions, key) != true;
}, this);
str = _.values(str);
for (var i = 0; i < str.length; i++){
var cur = _.keys(str[i]);
for (var j = 0; j < cur.length; j++) {
translation = translation.concat(cur[j]);
}
}
var t = {};
for (var k = 0; k < translation.length; k++) {
var curr = translation[k];
if (t[curr]) {
t[curr]["count"] += 1;
} else {
t[curr] = {};
t[curr]["iso"] = curr;
t[curr]["count"] = 1;
t[curr]["own"] = dbot.strings[curr][curr];
t[curr]["local"] = dbot.t(curr);
t[curr]["english"] = dbot.strings[curr]["en"];
}
}
console.log(t);
return t;
}
};
this.api['translationProgress'].external = true;
};
2013-04-20 19:42:34 +02:00
exports.fetch = function(dbot){
2013-04-18 13:06:13 +02:00
return new project(dbot);
};