2013-04-18 16:30:00 +02:00
|
|
|
var exec = require('child_process').exec,
|
2013-04-19 12:55:20 +02:00
|
|
|
request = require('request'),
|
|
|
|
_ = require('underscore');
|
2013-04-18 13:06:13 +02:00
|
|
|
|
|
|
|
var pages = function(dbot) {
|
2013-04-18 20:57:04 +02:00
|
|
|
var quoteCat = dbot.db.quoteArrs[dbot.config.name],
|
2013-04-19 06:28:03 +02:00
|
|
|
rev, diff, branch;
|
2013-04-18 18:54:09 +02:00
|
|
|
|
2013-04-19 06:28:03 +02:00
|
|
|
exec("git rev-list --all | wc -l", function(error, stdout, stderr) {
|
|
|
|
rev = stdout
|
2013-04-18 20:57:04 +02:00
|
|
|
});
|
2013-04-20 19:42:34 +02:00
|
|
|
|
2013-04-19 06:28:03 +02:00
|
|
|
exec("git rev-parse --abbrev-ref HEAD", function(error, stdout, stderr) {
|
|
|
|
branch = stdout
|
|
|
|
});
|
2013-04-20 19:42:34 +02:00
|
|
|
|
2013-04-19 06:28:03 +02:00
|
|
|
exec("git log -1", function(error, stdout, stderr) {
|
|
|
|
diff = stdout
|
2013-04-20 19:42:34 +02:00
|
|
|
});
|
|
|
|
|
2013-04-18 16:30:00 +02:00
|
|
|
/* TODO: merge back into github module */
|
|
|
|
var milestones;
|
2013-04-19 06:28:03 +02:00
|
|
|
request("https://api.github.com/repos/" + dbot.config.github.defaultrepo + "/milestones?state=open", function(error, response, body){
|
|
|
|
milestones = JSON.parse(body);
|
2013-04-18 16:30:00 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-04-18 13:06:13 +02:00
|
|
|
return {
|
|
|
|
'/project': function(req, res) {
|
2013-04-18 20:57:04 +02:00
|
|
|
var quote = dbot.config.name;
|
|
|
|
if(quoteCat) {
|
|
|
|
quote = quoteCat[Math.floor(Math.random()*quoteCat.length)];
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:06:13 +02:00
|
|
|
res.render('project', {
|
2013-04-20 22:00:59 +02:00
|
|
|
"configList": dbot.modules.project.api.configList(), // what variable do I put here
|
2013-04-18 13:06:13 +02:00
|
|
|
"name": dbot.config.name,
|
2013-04-18 18:12:01 +02:00
|
|
|
"intro": dbot.t("dbotintro", {
|
|
|
|
"botname": dbot.config.name
|
|
|
|
}),
|
2013-04-18 13:45:15 +02:00
|
|
|
"curr839": dbot.config.language,
|
2013-04-19 06:28:03 +02:00
|
|
|
"repo": dbot.config.github.defaultrepo,
|
|
|
|
"branch": dbot.t("branch",{
|
|
|
|
"branch": branch
|
|
|
|
}),
|
2013-04-18 13:06:13 +02:00
|
|
|
"currver": dbot.config.version,
|
2013-04-18 13:45:15 +02:00
|
|
|
"currlang": dbot.t("dbotspeaks",{
|
|
|
|
"lang839": dbot.config.language,
|
|
|
|
"langen": dbot.strings[dbot.config.language]["en"],
|
|
|
|
"lang": dbot.t(dbot.config.language),
|
2013-04-18 13:06:13 +02:00
|
|
|
"name": dbot.config.name
|
|
|
|
}),
|
2013-04-18 13:45:15 +02:00
|
|
|
"projectstatus": dbot.t("projectstatus"),
|
|
|
|
"revnum": dbot.t("revnum",{
|
2013-04-18 13:06:13 +02:00
|
|
|
"name": dbot.config.name,
|
2013-04-19 06:28:03 +02:00
|
|
|
"rev": rev
|
2013-04-18 13:06:13 +02:00
|
|
|
}),
|
|
|
|
"modules": dbot.config.moduleNames,
|
2013-04-18 13:45:15 +02:00
|
|
|
"loadmod": dbot.t("loadedmodules"),
|
2013-04-18 16:30:00 +02:00
|
|
|
"debugmode": dbot.t("debugmode-" + dbot.config.debugMode),
|
|
|
|
"milestones": milestones,
|
|
|
|
"milestoneprog": dbot.t("milestoneprog"),
|
|
|
|
"config": dbot.t("configoptions"),
|
|
|
|
"milestonename": dbot.t("milestonename"),
|
|
|
|
"openmilestone": dbot.t("openmilestone"),
|
2013-04-18 18:12:01 +02:00
|
|
|
"closedmilestone": dbot.t("closedmilestone"),
|
2013-04-18 18:27:07 +02:00
|
|
|
"development": dbot.t("development"),
|
2013-04-18 20:57:04 +02:00
|
|
|
"dquote": quote,
|
2013-04-18 18:12:01 +02:00
|
|
|
"diff": diff,
|
|
|
|
"pagetitle": dbot.t("pagetitle", {
|
|
|
|
"botname": dbot.config.name
|
2013-04-19 06:28:03 +02:00
|
|
|
}),
|
|
|
|
"git": dbot.t("git"),
|
|
|
|
"milestonehead": dbot.t("milestones"),
|
|
|
|
"propaganda": dbot.t("propaganda")
|
2013-04-18 13:06:13 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return pages(dbot);
|
|
|
|
};
|