AzaToth has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76016
Change subject: adding color filter for the IRC output
......................................................................
adding color filter for the IRC output
Change-Id: I6e44d8332a73871eb855c624d801d723cc5bdde4
---
A src/colors.js
M src/relay.js
M src/template.txt
3 files changed, 22 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/labs/tools/grrrit
refs/changes/16/76016/1
diff --git a/src/colors.js b/src/colors.js
new file mode 100644
index 0000000..5088eba
--- /dev/null
+++ b/src/colors.js
@@ -0,0 +1,13 @@
+var irc_colors = require('irc-colors');
+
+exports.color = function(colors, text) {
+ var _fun = irc_colors;
+ colors = colors.split('.');
+ // irc-colors allows for linked colors, for example:
+ // irc_colors.bold.red.underline("blablabla")
+ for(var i = 0; i < colors.length; ++i) {
+ _fun = _fun[colors[i]];
+ }
+
+ return _fun(text);
+};
diff --git a/src/relay.js b/src/relay.js
index ea8339b..02307c1 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -13,6 +13,7 @@
}
swig.init({
+ filters: require('./colors.js'),
autoescape: false,
root: __dirname
});
diff --git a/src/template.txt b/src/template.txt
index e2eb733..bcd65a7 100644
--- a/src/template.txt
+++ b/src/template.txt
@@ -1,12 +1,16 @@
-({{type}}) {{user}}:
+({{type|color(green)}}) {{user|color(bold.teal)}}:
{% if approvals %}
[{% for value in approvals -%}
- {{loop.key}}: {{value}}{% if not loop.last %} {% endif -%}
+ {% if value > 0 %}
+ {{loop.key}}: {{value|color(blue)}}{% if not
loop.last %} {% endif -%}
+ {% else %}
+ {{loop.key}}: {{value|color(bold.red)}}{% if
not loop.last %} {% endif -%}
+ {% endif %}
{%- endfor -%}]
{% endif %}
{{message}}
[{{repo}}]
{% if branch %} ({{branch}}) {% endif %}
- - {{url}}
+ - {{url|color(teal)}}
{% if via %}(via {{via}}) {% endif %}
- {% if owner %}(owner: {{ owner }}){% endif %}
+ {% if owner %}(owner: {{ owner |color(bold.olive)}}){% endif %}
--
To view, visit https://gerrit.wikimedia.org/r/76016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e44d8332a73871eb855c624d801d723cc5bdde4
Gerrit-PatchSet: 1
Gerrit-Project: labs/tools/grrrit
Gerrit-Branch: master
Gerrit-Owner: AzaToth <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits