jenkins-bot has submitted this change and it was merged.
Change subject: Replacing swig with swig-templates
..
Replacing swig with swig-templates
Swig is no longer being maintained and swig-templates is a fork.
Also updating to version 2.0.2.
Change-Id: I8d240e867205d5436078b7993593483a95a4a656
---
M package.json
M src/relay.js
M src/template.txt
3 files changed, 9 insertions(+), 13 deletions(-)
Approvals:
Paladox: Looks good to me, approved
jenkins-bot: Verified
diff --git a/package.json b/package.json
index 4595ddc..70db6bf 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"irc-colors": "~1.3.0",
"js-yaml": "^3.4.2",
"ssh2": "~0.5.3",
-"swig": "~0.14.0",
+"swig-templates": "~2.0.2",
"underscore": "~1.8.3",
"winston": "~2.1.1"
},
diff --git a/src/relay.js b/src/relay.js
index dac448a..0462bb6 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -3,7 +3,7 @@
var _ = require('underscore'),
irc = require('irc'),
-swig = require('swig'),
+swig = require('swig-templates'),
processors = require('./preprocess.js'),
fs = require('fs'),
path = require('path'),
@@ -26,12 +26,6 @@
function errorLog(message) {
logging.error(message);
}
-
-swig.init({
-filters: require('./colors.js'),
-autoescape: false,
-root: __dirname
-});
function subscribeToGerritStream(host, port, username, keypath, listener) {
logging.info('Connecting to gerrit..');
@@ -110,7 +104,9 @@
return channels.filter(function(v, i) { return channels.indexOf(v) === i;
});
}
-var template = swig.compileFile('template.txt');
+swig.setFilter('colors', require('./colors.js').color);
+swig.setDefaults({ autoescape: false });
+var template = swig.compileFile(__dirname + '/template.txt');
var ircClient = new irc.Client(config.server, config.nick, {
userName: config.userName,
@@ -140,7 +136,7 @@
if(msg) {
if(config.blacklist.indexOf(msg.user) === -1) {
-var relayMsg = template.render(msg).replace(/\s+/gm, ' ');
+var relayMsg = template(msg).replace(/\s+/gm, ' ');
var channels = channelsForRepo(message.change.project,
message.change.branch);
_.each(channels, function(channel) {
ircClient.say(channel, relayMsg);
diff --git a/src/template.txt b/src/template.txt
index be8558a..92aece2 100644
--- a/src/template.txt
+++ b/src/template.txt
@@ -3,16 +3,16 @@
[{%- for value in approvals -%}
{%- if value == "1" -%}
{{loop.key}}: {{value|color('green')}}{% if not loop.last %}
{% endif -%}
-{%- else if value == "2" -%}
+{%- elseif value == "2" -%}
{{loop.key}}: {{value|color('bold.green')}}{% if not loop.last
%} {% endif -%}
-{%- else if value == "-1" -%}
+{%- elseif value == "-1" -%}
{{loop.key}}: {{value|color('red')}}{% if not loop.last %} {%
endif -%}
{%- else -%}
{{loop.key}}: {{value|color('bold.red')}}{% if not loop.last
%} {% endif -%}
{%- endif -%}
{%- endfor -%}]
{% endif %}
-{{message}}
+{{message}}
{% if inlineComments -%}
({{inlineComments|color('bold.green')}} comment{% if inlineComments >
1 %}s{% endif %})
{% endif %}
--
To view, visit https://gerrit.wikimedia.org/r/320294
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8d240e867205d5436078b7993593483a95a4a656
Gerrit-PatchSet: 10
Gerrit-Project: labs/tools/grrrit
Gerrit-Branch: master
Gerrit-Owner: Paladox
Gerrit-Reviewer: Alex Monk
Gerrit-Reviewer: MarkTraceur
Gerrit-Reviewer: Merlijn van Deen
Gerrit-Reviewer: Paladox
Gerrit-Reviewer: Zppix
Gerrit-Reviewer: jenkins-bot <>
___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits