diff --git a/modules/project/pages.js b/modules/project/pages.js index a724636..ed94690 100644 --- a/modules/project/pages.js +++ b/modules/project/pages.js @@ -1,21 +1,37 @@ var exec = require('child_process').exec, - request = require('request'); + request = require('request'), + _ = require('underscore'); var pages = function(dbot) { var quoteCat = dbot.db.quoteArrs[dbot.config.name], - rev, diff; + rev, diff, branch, credit, authors = []; + 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]); + } + } + }); - exec("git rev-list --all | wc -l", function(a, b, c) { - rev = b + exec("git rev-list --all | wc -l", function(error, stdout, stderr) { + rev = stdout; }); - exec("git log -1", function(a, b, c) { - diff = b + + exec("git rev-parse --abbrev-ref HEAD", function(error, stdout, stderr) { + branch = stdout }); - + + + exec("git log -1", function(error, stdout, stderr) { + diff = stdout + }); + /* TODO: merge back into github module */ var milestones; - request("https://api.github.com/repos/" + dbot.config.github.defaultrepo + "/milestones?state=open", function(e, r, b){ - milestones = JSON.parse(b); + request("https://api.github.com/repos/" + dbot.config.github.defaultrepo + "/milestones?state=open", function(error, response, body){ + milestones = JSON.parse(body); }); @@ -27,11 +43,20 @@ var pages = function(dbot) { } 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"), "name": dbot.config.name, "intro": dbot.t("dbotintro", { "botname": dbot.config.name }), "curr839": dbot.config.language, + "repo": dbot.config.github.defaultrepo, + "branch": dbot.t("branch",{ + "branch": branch + }), "currver": dbot.config.version, "currlang": dbot.t("dbotspeaks",{ "lang839": dbot.config.language, @@ -42,8 +67,7 @@ var pages = function(dbot) { "projectstatus": dbot.t("projectstatus"), "revnum": dbot.t("revnum",{ "name": dbot.config.name, - "rev": rev, - "ver": "abcdef" // TODO, obviously + "rev": rev }), "modules": dbot.config.moduleNames, "loadmod": dbot.t("loadedmodules"), @@ -59,7 +83,16 @@ var pages = function(dbot) { "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") }); }, }; diff --git a/modules/project/project.js b/modules/project/project.js index 25e3e35..59a2fbe 100644 --- a/modules/project/project.js +++ b/modules/project/project.js @@ -4,10 +4,74 @@ * the dbot. */ -var project = function(dbot) { - // Nothing to see here go away love zuzak -} +_ = require('underscore'), + exec = require('child_process').exec; -exports.fetch = function(dbot) { +var project = function(dbot) { + + this.api = { + 'configList' : function(callback){ + var list = []; + if(_.has(dbot.modules,'dent')){ + list.push(dbot.t("dent-account", { + "username": dbot.config.dent.username + })); + } + if(_.has(dbot.config.dent.dentQuotes)) { + list.push(dbot.t("dent-push")); + } + if(_.has(dbot.modules,'link')){ + if(dbot.config.link.autoTitle){ + list.push(dbot.t("link-autotitle")); + } + } + if(_.has(dbot.modules,'quotes')){ + list.push(dbot.t("quote-rmlimit", { + "limit": dbot.config.quotes.rmLimit + })); + } + if(_.has(dbot.modules,'report')){ + if(dbot.config.report.notifyVoice){ + list.push(dbot.t("report-notifyvoice")); + } + } + if(_.has(dbot.modules,'web')){ + list.push(dbot.t("web-port", { + "port": dbot.config.web.webPort + })); + } + return list; + }, + 'translationProgress' : function(callback){ + var translation = [] ; + var str = _.values(dbot.strings); + 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; +}; + +exports.fetch = function(dbot){ return new project(dbot); -} +}; diff --git a/modules/project/strings.json b/modules/project/strings.json index 4e2407e..8960da3 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -9,11 +9,17 @@ "it": "{name} parla {lang} ({langen})", "nl": "{name} spreekt {lang} ({langen})" }, + "thanks": { + "en": "With thanks to:" + }, + "credits": { + "en": "Authors" + }, "pagetitle": { "en": "{botname} web interface", "fr": "{botname} interface réseau", "de": "{botname} Web-Interface", - "it": "{botname} interfaccia web", + "it": "{botname} interfaccia web" }, "en": { "en": "English", @@ -57,14 +63,21 @@ "fr": "na'vi", "de": "Na'vi", "it": "Na'vi", - "nl": "Na'vi" + "nl": "Na'vi", + "na'vi": "Na'vi" + }, "es": { "en": "Spanish", "fr": "espagnole", "de": "Spanisch", "it": "spagnolo", - "nl": "Spaans" + "nl": "Spaans", + "es": "Español" + }, + "nl": { + "en": "Dutch", + "nl": "Nederlands" }, "revnum": { "en": "{name} is at revision {rev}", @@ -100,6 +113,9 @@ "it": "debug spento", "nl": "Debug uitgeschakeld" }, + "milestones": { + "en": "Milestones" + }, "milestoneprog": { "en": "Progress", "fr": "Progression", @@ -134,5 +150,44 @@ "de": "Entwicklung", "it": "Sviluppo", "nl": "Ontwikkeling" + }, + "dent-account": { + "en": "Submitting dents to @{username}" + }, + "dent-push": { + "en": "Pushing quotes to identi.ca" + }, + "quote-rmlimit": { + "en": "Quote removal throttle set to {limit}" + }, + "report-notifyvoice": { + "en": "Voiced users are being notified of reports" + }, + "web-port": { + "en": "Web is listening on {port}" + }, + "propaganda": { + "en": "Contribute to the code on Github!" + }, + "branch": { + "en": "{branch}" + }, + "git": { + "en": "version control" + }, + "langhead-current": { + "en": "Current" + }, + "langhead-translations": { + "en": "Completion" + }, + "translations": { + "en": "Translations" + }, + "langhead-progress": { + "en": "Translation Progress" + }, + "langhead-native": { + "en": "Native" } } diff --git a/public/project.css b/public/project.css index 7d382b2..3e71250 100644 --- a/public/project.css +++ b/public/project.css @@ -2,24 +2,20 @@ pre#gitdiff { text-align:left; width:80; margin:auto; + text-transform:none; } div#main { - text-align:inherit; font-size:18px; -} -h2,h3,h4,h5,h6,.center { - text-align:center; text-transform:lowercase; } -table#milestones { +table { margin:auto; width:80%; } -table#milestones td { +table td { padding:5px; } p.intro { - text-align:center; border:1px solid #ccc; padding:20px; border-radius:4px; @@ -31,11 +27,16 @@ div.progress.open { div.progress { margin-top:auto; margin-bottom:auto; + text-align:left; + font-size:50%; + color:gray; + min-width:200px; } div.progress-inner.open { - width:20%; background-color: #3fff3f; background-image: linear-gradient(to bottom,#3fff3f,#7fff7f); + float:left; + margin-right:2px; } div.progress.closed { background-color: #fff5f5; @@ -44,14 +45,13 @@ div.progress.closed { div.progress-inner.closed { background-color: #ff3f3f; background-image: linear-gradient(to bottom,#ff3f3f,#ff7f7f); - width:20%; } -#config { - text-align:center; - text-transform:lowercase; +ul { + margin-left:0; + margin-bottom:5px; + font-size:80%; } - li { background-image: linear-gradient(to bottom, #f5ebe2, #f5e6d8); border:1px solid #f5dcc5; diff --git a/public/styles.css b/public/styles.css index 5786bcc..39703bb 100644 --- a/public/styles.css +++ b/public/styles.css @@ -44,7 +44,7 @@ div#backlink { div#title { font-size: 42px; font-weight: bold; - margin: 0 0 10px 0; + margin: 0 0 10px 10px; color: #444; } diff --git a/views/project/project.jade b/views/project/project.jade index dcf7141..fa865d7 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -22,33 +22,65 @@ html(lang='#{curr839}') p.intro #{dquote} section#git - h3 #{development} - p.center - #{revnum} - pre#gitdiff - #{diff} - h4 #{milestoneprog} - table#milestones.center - tr - th #{milestonename} - th #{milestoneprog} - th #{openmilestone} - th #{closedmilestone} - each milestone in milestones - - var mstone = "milestone" - - var wd = "width:" - - var pc = "%" - - var wdth = ((milestone.closed_issues/(milestone.open_issues + milestone.closed_issues))*100) - tr(id=mstone+milestone.number) - td - a(href=milestone.url) - #{milestone.title} - td - div.progress(class=milestone.state) - div.progress-inner(style=wd+wdth+pc)(class=milestone.state) -   - td #{milestone.open_issues} - td #{milestone.closed_issues} + h3 #{development} + p.center + #{revnum} + pre#gitdiff + #{diff} + h4 #{milestoneprog} + table#milestones.center + tr + th #{milestonename} + th #{milestoneprog} + th #{openmilestone} + th #{closedmilestone} + each milestone in milestones + - var wdth = ((milestone.closed_issues/(milestone.open_issues + milestone.closed_issues))*100) + tr(id=mstone+milestone.number) + td + a(href=milestone.url) + #{milestone.title} + td + div.progress(class=milestone.state) + div.progress-inner(style="width:"+wdth+"%")(class=milestone.state) +   + print #{Math.round(wdth)+"%"} + td #{milestone.open_issues} + td #{milestone.closed_issues} + h4 #{languagetranshead} + table + tr + th #{languagecurr} + th #{languagenati} + unless (curr839 == "en") + th #{languageeng} + th #{languageprog} + th #{languagetrans} + each language in translation + - var w = ((language.count/translation.en.count)*100) + tr + td #{language.local} + td #{language.own} + unless (curr839 == "en") + td #{language.english} + td.prog + unless (language.iso == curr839) + div.progress(class="open") + div.progress-inner(style="width:"+w+"%")(class="open") +   + print #{Math.round(w)+"%"} + else + div.progress(class="closed") + div.progress-inner(style="width:"+w+"%")(class="closed") +   + print #{Math.round(w)+"%"} + td #{language.count} / #{translation.en.count} + h4 #{credits} + #{thanks} + ul + each author in authors + li + #{author} section#config h3 #{config} ul