3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-05 02:19:26 +01:00
dbot/modules/project/pages.js

107 lines
4.3 KiB
JavaScript
Raw Normal View History

var exec = require('child_process').exec,
request = require('request'),
_ = require('underscore');
2013-04-18 13:06:13 +02:00
var pages = function(dbot) {
2013-06-30 17:40:47 +02:00
var rev, diff, branch, credit, authors = [];
2013-04-21 07:06:26 +02:00
exec("git log --format='%cN¬' | sort -u | tr -d '\n'", function (error, stdout, sderr) {
var credit = stdout.split("¬"); // nobody uses ¬, do they?
for (var i = 0; i < credit.length; i++) {
if ((credit[i].split(" ").length) == 2){
console.log(credit[i]);
authors.push(credit[i]);
}
}
});
2013-04-18 18:54:09 +02:00
exec("git rev-list --all | wc -l", function(error, stdout, stderr) {
2013-04-21 07:06:26 +02:00
rev = stdout;
});
2013-04-20 19:42:34 +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-21 07:06:26 +02:00
exec("git log -1", function(error, stdout, stderr) {
diff = stdout
2013-04-20 19:42:34 +02:00
});
/* TODO: merge back into github module */
var milestones;
request({"url":"https://api.github.com/repos/" + dbot.config.modules.github.defaultrepo + "/milestones?state=open","headers":{"User-Agent":"reality/depressionbot (project module)"}}, function(error, response, body){
try {
milestones = JSON.parse(body);
} catch(err) {
milestones = {};
}
});
2013-04-18 13:06:13 +02:00
return {
'/project': function(req, res) {
2013-06-30 17:40:47 +02:00
dbot.api.quotes.getQuote(dbot.config.name, function(quote) {
if(!quote) quote = dbot.config.name;
2013-06-30 17:40:47 +02:00
res.render('project', {
"translation": dbot.modules.project.api.translationProgress(),
"configList": dbot.modules.project.api.configList(),
"authors": authors,
"credits": dbot.t("credits"),
"thanks": dbot.t("thanks"),
2013-04-18 13:06:13 +02:00
"name": dbot.config.name,
2013-06-30 17:40:47 +02:00
"intro": dbot.t("dbotintro", {
"botname": dbot.config.name
}),
"curr839": dbot.config.language,
"repo": dbot.config.modules.github.defaultrepo,
"branch": dbot.t("branch",{
"branch": branch
}),
"currver": dbot.config.version,
"currlang": dbot.t("dbotspeaks",{
"lang839": dbot.config.language,
"langen": dbot.strings[dbot.config.language]["en"],
"lang": dbot.t(dbot.config.language),
"name": dbot.config.name
}),
"projectstatus": dbot.t("projectstatus"),
"revnum": dbot.t("revnum",{
"name": dbot.config.name,
"rev": rev
}),
"modules": dbot.config.moduleNames,
"loadmod": dbot.t("loadedmodules"),
"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"),
"closedmilestone": dbot.t("closedmilestone"),
"development": dbot.t("development"),
"dquote": quote,
"diff": diff,
"pagetitle": dbot.t("pagetitle", {
"botname": dbot.config.name
}),
"git": dbot.t("git"),
"milestonehead": dbot.t("milestones"),
"propaganda": dbot.t("propaganda"),
"languagecurr": dbot.t(dbot.config.language),
"languagenati": dbot.t("langhead-native"),
"languageeng": dbot.t("en"),
"languageprog": dbot.t("langhead-progress"),
"languagetrans": dbot.t("langhead-translations"),
"languagetranshead": dbot.t("translations"),
"pullreqs": dbot.t("outstanding-pullreq")
});
});
}
2013-04-18 13:06:13 +02:00
};
};
exports.fetch = function(dbot) {
return pages(dbot);
};