From ec450e407028e42f2557d27340225aa55bc179be Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 20:14:37 +0000 Subject: [PATCH 01/10] Add pull request notification * Add message when there are pull requests with client side javascript * Add string for OAOSIDL, for future usage * Title cased credits * Removed text transform from random quote * Shoved commit count to left * Added lines to top and bottom of ``h2`` * Removed redundant CSS * Added JQuery --- modules/project/pages.js | 1 + modules/project/strings.json | 6 ++++++ public/project.css | 30 ++++++++++++++++++++++++++++++ views/project/project.jade | 21 ++++++++++++--------- 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/modules/project/pages.js b/modules/project/pages.js index f248dcd..5578d68 100644 --- a/modules/project/pages.js +++ b/modules/project/pages.js @@ -93,6 +93,7 @@ var pages = function(dbot) { "languageprog": dbot.t("langhead-progress"), "languagetrans": dbot.t("langhead-translations"), "languagetranshead": dbot.t("translations"), + "pullreqs": dbot.t("outstanding-pullreq") }); }, }; diff --git a/modules/project/strings.json b/modules/project/strings.json index 8960da3..be11111 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -189,5 +189,11 @@ }, "langhead-native": { "en": "Native" + }, + "outstanding-pullreq": { + "en": "There are outstanding pull requests" + }, + "oaosidl": { + "en": "The Official Aberystwyth Open Source International Development League" } } diff --git a/public/project.css b/public/project.css index 736b633..95ff2d4 100644 --- a/public/project.css +++ b/public/project.css @@ -3,6 +3,10 @@ pre#gitdiff { width:80; margin:auto; text-transform:none; + clear:both; +} +ul#credits { + text-transform:capitalize; } div#main { font-size:18px; @@ -19,6 +23,7 @@ p.intro { border:1px solid #ccc; padding:20px; border-radius:4px; + text-transform:none; } div.progress.open { background-color: #f4fff4; @@ -74,3 +79,28 @@ h3 { #translations td { text-transform:none; } +p#pullreq { + float:right; + border-left:1px solid #ccc; + border-top:1px solid #ccc; + border-top-left-radius:5px; + padding:10px; + margin:5px; + display:none; +} +p#revnum { + float:left; + border-right:1px solid #ccc; + border-top:1px solid #ccc; + border-top-right-radius: 5px; + margin:5px; + padding:10px; + margin-bottom:0px; +} +h2 { + border-bottom: 1px solid #ccc; + border-top:1px solid #ccc; + margin-left:auto; + margin-right:auto; + width:40%; +} diff --git a/views/project/project.jade b/views/project/project.jade index 22d5c93..560de26 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -8,12 +8,13 @@ html(lang='#{curr839}') link(rel='stylesheet', type='text/css', href='/styles.css') link(rel="stylesheet", href="/project.css") title #{pagetitle} - - var mstone = "milestone" - style(type="text/css") - each milestone in milestones - - current = mstone+milestone.number - - wdth = ((milestone.open_issues/(milestone.open_issues + milestone.closed_issues))*100) - .current { width: wdth% } + script + $(document).ready(function() { + $.get("https://api.github.com/repos/#{repo}/pulls", function(data) { + if ($.parseJSON(data).length) { $("#pullreq").show();} + }); + }); + body div.container div#page @@ -23,7 +24,9 @@ html(lang='#{curr839}') #{dquote} section#git h2 #{development} - p.center + p#pullreq + a(href="https://github.com/"+repo+"/pulls") #{pullreqs} + p#revnum #{revnum} pre#gitdiff #{diff} @@ -36,7 +39,7 @@ html(lang='#{curr839}') th #{closedmilestone} each milestone in milestones - var wdth = ((milestone.closed_issues/(milestone.open_issues + milestone.closed_issues))*100) - tr(id=mstone+milestone.number) + tr(id="milestone"+milestone.number) td a(href="https://github.com/"+repo+"/issues?milestone="+milestone.number) #{milestone.title} @@ -79,7 +82,7 @@ html(lang='#{curr839}') td #{language.count} / #{translation.en.count} h3 #{credits} #{thanks} - ul + ul#credits each author in authors li #{author} From fe57328e3d68ddee26b54da8b988f44cf3a48b3e Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 20:28:51 +0000 Subject: [PATCH 02/10] fix missing string --- modules/project/strings.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/project/strings.json b/modules/project/strings.json index be11111..58fb470 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -195,5 +195,8 @@ }, "oaosidl": { "en": "The Official Aberystwyth Open Source International Development League" + }, + "link-autotitle": { + "en": "Automatically titling links in channels" } } From 75e03c15b76adfbcbcb16d8acbf660b47bae3422 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Sun, 21 Apr 2013 20:44:41 +0000 Subject: [PATCH 03/10] add french translations --- modules/project/strings.json | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/modules/project/strings.json b/modules/project/strings.json index 58fb470..daa07b0 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -1,7 +1,4 @@ { - "dbotintro": { - "en": "{botname} lorem ipsum dolor sit amet" - }, "dbotspeaks": { "en": "{name} speaks {lang}", "de": "{name} spricht {lang} ({langen})", @@ -10,10 +7,12 @@ "nl": "{name} spreekt {lang} ({langen})" }, "thanks": { - "en": "With thanks to:" + "en": "With thanks to:", + "fr": "Merci à:" }, "credits": { - "en": "Authors" + "en": "Authors", + "fr": "Développeurs" }, "pagetitle": { "en": "{botname} web interface", @@ -115,6 +114,7 @@ }, "milestones": { "en": "Milestones" + "fr": "étapes" }, "milestoneprog": { "en": "Progress", @@ -173,22 +173,32 @@ "en": "{branch}" }, "git": { - "en": "version control" + "en": "version control", + "de": "Versionsverwaltung", + "es": "Control de versiones", + "fr": "Festion de versions", + "it": "Controllo versione", + "nl": "Versiebeheersysteem" }, "langhead-current": { - "en": "Current" + "en": "Current", + "fr": "Courant" }, "langhead-translations": { - "en": "Completion" + "en": "Completion", + "fr": "Achèvement" }, "translations": { - "en": "Translations" + "en": "Translations", + "fr": "Traductions" }, "langhead-progress": { - "en": "Translation Progress" + "en": "Translation Progress", + "fr": "Avancement de la Traduction" }, "langhead-native": { - "en": "Native" + "en": "Native", + "fr": "Natale" }, "outstanding-pullreq": { "en": "There are outstanding pull requests" From 3f5bf0e5a553ab1b2d5bb6347b58341d9f901118 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Mon, 22 Apr 2013 23:58:48 +0000 Subject: [PATCH 04/10] Fix typographical error The strings.json for the project module was malformed. This commit rectifies the issue --- modules/project/strings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/project/strings.json b/modules/project/strings.json index daa07b0..5dc8c3e 100644 --- a/modules/project/strings.json +++ b/modules/project/strings.json @@ -113,7 +113,7 @@ "nl": "Debug uitgeschakeld" }, "milestones": { - "en": "Milestones" + "en": "Milestones", "fr": "étapes" }, "milestoneprog": { From 194135791a934c92a58cdec261d2e5306ce3b828 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Tue, 23 Apr 2013 00:31:36 +0000 Subject: [PATCH 05/10] Add footer to pages linking to ./project --- public/styles.css | 15 +++++++++++++++ views/layout.jade | 3 +++ views/project/project.jade | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/public/styles.css b/public/styles.css index 39703bb..8e8dfaa 100644 --- a/public/styles.css +++ b/public/styles.css @@ -223,3 +223,18 @@ div.imgwrap > img { .thumbnail:hover > div.imgwrap > span.nicks { display: inline; } + +/* footer */ +#footer { + margin-top:5px; + margin-right:10px; + margin-left:10px; +} +#footer a { + float:right; + padding-left:2px; + padding-right:2px; + background-color:#f5f5f5; + border-radius:3px; +} + diff --git a/views/layout.jade b/views/layout.jade index bb3cf2e..ad2d14e 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -14,6 +14,9 @@ html(lang='en') a(href='/') #{name} web interface div.container#main block content + div#footer + a#project(href='/project') About + script(type="text/javascript", src="/bootstrap/js/bootstrap.min.js") script(type="text/javascript", src="/d3/d3.v3.min.js") script(type="text/javascript", src="/script.js") diff --git a/views/project/project.jade b/views/project/project.jade index 560de26..d2dfb42 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -50,7 +50,7 @@ html(lang='#{curr839}') print #{Math.round(wdth)+"%"} td #{milestone.open_issues} td #{milestone.closed_issues} - a(#href="https://github.com/"+repo+"/") + a(href="https://github.com/"+repo+"/") #{propaganda} h3 #{languagetranshead} table#translations From 4361c61f6e3422cef509ff83bd51880242639b3f Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 24 Apr 2013 09:27:12 +0000 Subject: [PATCH 06/10] Added branch notification Added current branch to note underneath last-diff. For the purposes of licensing, this commit is licensed under copyleft-next, version 0.1.0 or later. Therefore, this commit is compatible with any version of the GNU General Public License as published by the Free Software Foundation. --- public/project.css | 12 ++++++++++++ views/project/project.jade | 2 ++ 2 files changed, 14 insertions(+) diff --git a/public/project.css b/public/project.css index 95ff2d4..3e743e7 100644 --- a/public/project.css +++ b/public/project.css @@ -97,6 +97,18 @@ p#revnum { padding:10px; margin-bottom:0px; } +p#branch { + border-right:1px solid #ccc; + border-left:1px solid #ccc; + border-bottom:1px solid #ccc; + margin:auto; + display:inline-block; + padding:10px; + margin-top:0px; + border-bottom-left-radius:5px; + border-bottom-right-radius:5px; + +} h2 { border-bottom: 1px solid #ccc; border-top:1px solid #ccc; diff --git a/views/project/project.jade b/views/project/project.jade index d2dfb42..29f56ea 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -30,6 +30,8 @@ html(lang='#{curr839}') #{revnum} pre#gitdiff #{diff} + p#branch + #{branch} h3 #{milestonehead} table#milestones.center tr From 388adda383a20e424e1e088054786062174aa960 Mon Sep 17 00:00:00 2001 From: reality Date: Mon, 22 Apr 2013 19:36:13 +0000 Subject: [PATCH 07/10] GPL --- LICENCE | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/LICENCE b/LICENCE index 627898c..205b8c1 100644 --- a/LICENCE +++ b/LICENCE @@ -1,18 +1,14 @@ Copyright (c) 2012-2013 Luke Slater (tinmachin3@gmail.com) -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +You should have received a copy of the GNU General Public License +along with this program. If not, see . From b9a9866e5e65b0acafe8fd9add2298c041d1766c Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 23 Apr 2013 18:48:41 +0000 Subject: [PATCH 08/10] nickserv module in master --- modules/nickserv/config.json | 9 +++++++++ modules/nickserv/nickserv.js | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 modules/nickserv/config.json create mode 100644 modules/nickserv/nickserv.js diff --git a/modules/nickserv/config.json b/modules/nickserv/config.json new file mode 100644 index 0000000..3bcaece --- /dev/null +++ b/modules/nickserv/config.json @@ -0,0 +1,9 @@ +{ + "servers": { + "nc": { + "matcher": "STATUS ([^ ]+) (\\d)$", + "acceptableState": 3, + "infoCommand": "status" + } + } +} diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js new file mode 100644 index 0000000..28f20ae --- /dev/null +++ b/modules/nickserv/nickserv.js @@ -0,0 +1,37 @@ +var nickserv = function(dbot) { + this.authStack = {}; + + this.api = { + 'auth': function(server, nick, callback) { + var nickserv = dbot.config.servers[server].nickserv, + infoCommand = this.config.servers[server].infoCommand; + + if(!_.has(this.authStack, server)) this.authStack[server] = {}; + this.authStack[server][nick] = callback; + + dbot.say(server, nickserv, infoCommand + ' ' + nick); + } + }; + + this.listener = function(event) { + var nickserv = dbot.config.servers[event.server].nickserv, + statusRegex = this.config.servers[event.server].matcher, + acceptableState = this.config.servers[event.server].acceptableState; + + if(event.user == nickserv) { + var info = event.params.match(statusRegex); + if(info && _.has(this.authStack, event.server)) { + if(info[2] == acceptableState ) { + this.authStack[event.server][info[1]](true); + } else { + this.authStack[event.server][info[1]](false); + } + } + } + }.bind(this); + this.on = 'NOTICE'; +}; + +exports.fetch = function(dbot) { + return new nickserv(dbot); +}; From f129c36f5e7effb26f5d8f3db4fad04886b34c26 Mon Sep 17 00:00:00 2001 From: reality Date: Tue, 23 Apr 2013 19:07:23 +0000 Subject: [PATCH 09/10] command can use nickserv [#421] --- modules/command/api.js | 26 ++++++++-------- modules/command/command.js | 59 +++++++++++++++++++----------------- modules/command/config.json | 1 + modules/nickserv/nickserv.js | 1 + 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/modules/command/api.js b/modules/command/api.js index da718d3..4abaa9b 100644 --- a/modules/command/api.js +++ b/modules/command/api.js @@ -17,22 +17,24 @@ var api = function(dbot) { /** * Does the user have the correct access level to use the command? */ - 'hasAccess': function(user, command) { - var access = true; + 'hasAccess': function(server, user, command, callback) { var accessNeeded = dbot.commands[command].access; - if(accessNeeded == 'admin') { - if(!_.include(dbot.config.admins, user)) { - access = false; - } - } else if(accessNeeded == 'moderator') { - if(!_.include(dbot.config.moderators, user) && - !_.include(dbot.config.admins, user)) { - access = false; + if(accessNeeded == 'admin' || accessNeeded == 'moderator') { + if(!_.include(dbot.config[accessNeeded + 's'], user)) { // lol + callback(false); + } else { + if(_.has(dbot.modules, 'nickserv') && this.config.useNickserv == true) { + dbot.api.nickserv.auth(server, user, function(result) { + callback(result); + }); + } else { + callback(true); + } } + } else { + callback(true); } - - return access; }, /** diff --git a/modules/command/command.js b/modules/command/command.js index 935f6e0..670f5e3 100644 --- a/modules/command/command.js +++ b/modules/command/command.js @@ -20,41 +20,44 @@ var command = function(dbot) { return; } } - + if(this.api.isBanned(event.user, commandName)) { event.reply(dbot.t('command_ban', {'user': event.user})); } else { - if(!this.api.isIgnoring(event.user, commandName) && - !this.api.isIgnoring(event.channel, commandName) && - this.api.hasAccess(event.user, commandName) && - dbot.commands[commandName].disabled !== true) { - if(this.api.applyRegex(commandName, event)) { - try { - var command = dbot.commands[commandName]; - var results = command.apply(dbot.modules[command.module], [event]); - if(_.has(command, 'hooks') && results !== false) { - _.each(command['hooks'], function(hook) { - hook.apply(hook.module, _.values(results)); - }, this); - } - } catch(err) { - if(dbot.config.debugMode == true) { - event.reply('- Error in ' + commandName + ':'); - event.reply('- Message: ' + err); - event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim()); - } - } - dbot.save(); - } else { - if(commandName !== '~') { - if(_.has(dbot.usage, commandName)) { - event.reply('Usage: ' + dbot.usage[commandName]); + this.api.hasAccess(event.server, event.user, commandName, function(result) { + if(result) { + if(!this.api.isIgnoring(event.user, commandName) && + !this.api.isIgnoring(event.channel, commandName) && + dbot.commands[commandName].disabled !== true) { + if(this.api.applyRegex(commandName, event)) { + try { + var command = dbot.commands[commandName]; + var results = command.apply(dbot.modules[command.module], [event]); + if(_.has(command, 'hooks') && results !== false) { + _.each(command['hooks'], function(hook) { + hook.apply(hook.module, _.values(results)); + }, this); + } + } catch(err) { + if(dbot.config.debugMode == true) { + event.reply('- Error in ' + commandName + ':'); + event.reply('- Message: ' + err); + event.reply('- Top of stack: ' + err.stack.split('\n')[1].trim()); + } + } + dbot.save(); } else { - event.reply(dbot.t('syntax_error')); + if(commandName !== '~') { + if(_.has(dbot.usage, commandName)) { + event.reply('Usage: ' + dbot.usage[commandName]); + } else { + event.reply(dbot.t('syntax_error')); + } + } } } } - } + }.bind(this)); } }.bind(this); this.on = 'PRIVMSG'; diff --git a/modules/command/config.json b/modules/command/config.json index bace93b..b27be88 100644 --- a/modules/command/config.json +++ b/modules/command/config.json @@ -1,5 +1,6 @@ { "ignorable": false, "help": "http://github.com/reality/depressionbot/blob/master/modules/command/README.md", + "useNickserv": false, "dbKeys": [ "ignores", "bans" ] } diff --git a/modules/nickserv/nickserv.js b/modules/nickserv/nickserv.js index 28f20ae..e489878 100644 --- a/modules/nickserv/nickserv.js +++ b/modules/nickserv/nickserv.js @@ -18,6 +18,7 @@ var nickserv = function(dbot) { statusRegex = this.config.servers[event.server].matcher, acceptableState = this.config.servers[event.server].acceptableState; + if(event.user == nickserv) { var info = event.params.match(statusRegex); if(info && _.has(this.authStack, event.server)) { From 9114ee25a9879d9ebe611f72a858e51b12cfc786 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 24 Apr 2013 09:41:51 +0000 Subject: [PATCH 10/10] Move project scripts to an external file. * Add link to ``project.js`` on project webpage. * Move scripts to ``project.js``. * Very definitely not do anything else. --- public/project.js | 15 +++++++++++++++ views/project/project.jade | 9 +-------- 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 public/project.js diff --git a/public/project.js b/public/project.js new file mode 100644 index 0000000..697c5f6 --- /dev/null +++ b/public/project.js @@ -0,0 +1,15 @@ +$(document).ready(function() { + $.get("https://api.github.com/repos/#{repo}/pulls", function(data) { + if ($.parseJSON(data).length) { $("#pullreq").show();} + }); +}); +$(document).keypress(function(e) { +WebFontConfig={google:{families:["Ubuntu::latin"]}};(function(){var e=document.createElement("script");e.src=("https:"==document.location.protocol?"https":"http")+"://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";e.type="text/javascript";e.async="true";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})() + $('body').css({ + "background-image":"url('http://i.imgur.com/Yh8V2Oa.jpg')", + "font-family": "Ubuntu, \"Source Sans Pro\",sans-serif" + }); + $('a').css("color","#DD4814"); + $('#title').css("color","white"); + $('#main').css("border-color","#420432"); +}); diff --git a/views/project/project.jade b/views/project/project.jade index 29f56ea..5dca431 100644 --- a/views/project/project.jade +++ b/views/project/project.jade @@ -7,14 +7,7 @@ html(lang='#{curr839}') link(rel="stylesheet", type="text/css", href="/bootstrap/css/bootstrap.min.css") link(rel='stylesheet', type='text/css', href='/styles.css') link(rel="stylesheet", href="/project.css") - title #{pagetitle} - script - $(document).ready(function() { - $.get("https://api.github.com/repos/#{repo}/pulls", function(data) { - if ($.parseJSON(data).length) { $("#pullreq").show();} - }); - }); - + script(src="../project.js") body div.container div#page