From 7d011dac99dc33412a23a8d4402485cad3bb9d5d Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 16 Jun 2015 10:36:19 +0100 Subject: [PATCH 1/9] Add i18n content for moved core nodes --- hardware/Arduino/35-arduino.html | 38 +++---- hardware/Arduino/35-arduino.js | 28 ++--- .../Arduino/locales/en-US/35-arduino.json | 38 +++++++ io/serialport/25-serial.html | 72 ++++++------ io/serialport/25-serial.js | 87 ++++++++------ io/serialport/locales/en-US/25-serial.json | 51 +++++++++ social/email/61-email.html | 42 +++---- social/email/61-email.js | 61 +++++----- social/email/locales/en-US/61-email.json | 43 +++++++ social/feedparser/32-feedparse.html | 11 +- social/feedparser/32-feedparse.js | 6 +- .../locales/en-US/32-feedparse.json | 13 +++ social/irc/91-irc.html | 44 ++++--- social/irc/91-irc.js | 90 +++++++-------- social/irc/locales/en-US/91-irc.json | 39 +++++++ social/twitter/27-twitter.html | 107 +++++++++--------- social/twitter/27-twitter.js | 104 ++++++++--------- social/twitter/locales/en-US/27-twitter.json | 43 +++++++ storage/mongodb/66-mongodb.html | 74 ++++++------ storage/mongodb/66-mongodb.js | 18 +-- storage/mongodb/locales/en-US/66-mongodb.json | 31 +++++ storage/redis/65-redisout.html | 27 ++--- storage/redis/65-redisout.js | 19 ++-- storage/redis/locales/en-US/65-redisout.json | 21 ++++ 24 files changed, 689 insertions(+), 418 deletions(-) create mode 100644 hardware/Arduino/locales/en-US/35-arduino.json create mode 100644 io/serialport/locales/en-US/25-serial.json create mode 100644 social/email/locales/en-US/61-email.json create mode 100644 social/feedparser/locales/en-US/32-feedparse.json create mode 100644 social/irc/locales/en-US/91-irc.json create mode 100644 social/twitter/locales/en-US/27-twitter.json create mode 100644 storage/mongodb/locales/en-US/66-mongodb.json create mode 100644 storage/redis/locales/en-US/65-redisout.json diff --git a/hardware/Arduino/35-arduino.html b/hardware/Arduino/35-arduino.html index 982cfe09..f1868908 100644 --- a/hardware/Arduino/35-arduino.html +++ b/hardware/Arduino/35-arduino.html @@ -19,21 +19,21 @@
- +
- +
- - + +
-
Note: You cannot use the same pin for both output and input.
+
diff --git a/social/irc/91-irc.js b/social/irc/91-irc.js index ffc1bc28..32ec6d81 100644 --- a/social/irc/91-irc.js +++ b/social/irc/91-irc.js @@ -47,45 +47,45 @@ module.exports = function(RED) { this.channel = n.channel || this.serverConfig.channel; var node = this; if (node.serverConfig.ircclient === null) { - node.log("CONNECT: "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:"connecting"}); + node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); + node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")}); var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient.setMaxListeners(0); node.serverConfig.ircclient.addListener('error', function(message) { - if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); } + if (RED.settings.verbose) { node.log(RED._("irc.errors.err")+": "+JSON.stringify(message)); } }); node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("NET: "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:"net error"}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } + node.status({fill:"red",shape:"ring",text:RED._("common.status.neterror")}); }); node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("CONNECTED "); } + if (RED.settings.verbose) { node.log(RED._("irc.errors.connected")); } }); node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.lastseen = Date.now(); - node.log(node.serverConfig.ircclient.nick+" ONLINE: "+message.server); - node.status({fill:"yellow",shape:"dot",text:"connected"}); + node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); + node.status({fill:"yellow",shape:"dot",text:RED._("common.status.connected")}); node.serverConfig.ircclient.join( node.channel, function(data) { - node.log(data+" JOINED: "+node.channel); - node.status({fill:"green",shape:"dot",text:"joined"}); + node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); + node.status({fill:"green",shape:"dot",text:RED._("common.status.joined")}); }); }); node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("PING from "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:"ok"}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } + node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")}); }); node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("QUIT: "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:"quit"}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } + node.status({fill:"grey",shape:"ring",text:RED._("common.status.quit")}); //node.serverConfig.ircclient.disconnect( function() { // node.serverConfig.ircclient.connect(); //}); - //if (RED.settings.verbose) { node.log("restart"); } // then retry + //if (RED.settings.verbose) { node.log(RED._("irc.errors.restart")); } // then retry }); node.serverConfig.ircclient.addListener('raw', function (message) { // any message received means we are alive //console.log("RAW:"+JSON.stringify(message)); @@ -102,8 +102,8 @@ module.exports = function(RED) { if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins //node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:"no connection"}); - if (RED.settings.verbose) { node.log("CONNECTION LOST ?"); } + node.status({fill:"grey",shape:"ring",text:RED._("common.status.noconnection")}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } } //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link }, 60000); // check every 1 min @@ -113,11 +113,11 @@ module.exports = function(RED) { node.ircclient = node.serverConfig.ircclient; node.ircclient.addListener('registered', function(message) { - //node.log(node.ircclient.nick+" ONLINE"); - node.status({fill:"yellow",shape:"dot",text:"connected"}); + //node.log(node.ircclient.nick+" "+RED._("irc.errors.online")); + node.status({fill:"yellow",shape:"dot",text:RED._("common.status.connected")}); node.ircclient.join( node.channel, function(data) { - // node.log(data+" JOINED "+node.channel); - node.status({fill:"green",shape:"dot",text:"joined"}); + // node.log(data+" "+RED._("irc.errors.joined")+" "+node.channel); + node.status({fill:"green",shape:"dot",text:RED._("common.status.joined")}); }); }); node.ircclient.addListener('message', function (from, to, message) { @@ -136,27 +136,27 @@ module.exports = function(RED) { node.ircclient.addListener('join', function(channel, who) { var msg = { "payload": { "type":"join", "who":who, "channel":channel } }; node.send([null,msg]); - //node.log(who+' has joined '+channel); + //node.log(who+' '+RED._("irc.errors.hasjoined")+' '+channel); }); node.ircclient.addListener('invite', function(channel, from, message) { var msg = { "payload": { "type":"invite", "who":from, "channel":channel, "message":message } }; node.send([null,msg]); - //node.log(from+' sent invite to '+channel+': '+message); + //node.log(from+' '+RED._("irc.errors.sentinvite")+' '+channel+': '+message); }); node.ircclient.addListener('part', function(channel, who, reason) { var msg = { "payload": { "type":"part", "who":who, "channel":channel, "reason":reason } }; node.send([null,msg]); - //node.log(who+' has left '+channel+': '+reason); + //node.log(who+' '+RED._("irc.errors.hasleft")+' '+channel+': '+reason); }); node.ircclient.addListener('quit', function(nick, reason, channels, message) { var msg = { "payload": { "type":"quit", "who":nick, "channel":channels, "reason":reason } }; node.send([null,msg]); - //node.log(nick+' has quit '+channels+': '+reason); + //node.log(nick+' '+RED._("irc.errors.hasquit")+' '+channels+': '+reason); }); node.ircclient.addListener('kick', function(channel, who, by, reason) { var msg = { "payload": { "type":"kick", "who":who, "channel":channel, "by":by, "reason":reason } }; node.send([null,msg]); - //node.log(who+' was kicked from '+channel+' by '+by+': '+reason); + //node.log(who+' '+RED._("irc.errors.kickedfrom")+' '+channel+' by '+by+': '+reason); }); node.ircclient.addListener('names', function (channel, nicks) { var msg = { "payload": { "type": "names", "channel": channel, "names": nicks} }; @@ -182,45 +182,45 @@ module.exports = function(RED) { this.channel = n.channel || this.serverConfig.channel; var node = this; if (node.serverConfig.ircclient === null) { - node.log("CONNECT: "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:"connecting"}); + node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); + node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")}); var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient.setMaxListeners(0); node.serverConfig.ircclient.addListener('error', function(message) { - if (RED.settings.verbose) { node.log("ERR: "+JSON.stringify(message)); } + if (RED.settings.verbose) { node.log(RED._("irc.errors.err")+": "+JSON.stringify(message)); } }); node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("NET: "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:"net error"}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } + node.status({fill:"red",shape:"ring",text:RED._("common.status.neterror")}); }); node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("CONNECTED "); } + if (RED.settings.verbose) { node.log(RED._("irc.errors.connected")); } }); node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.lastseen = Date.now(); - node.log(node.serverConfig.ircclient.nick+" ONLINE: "+message.server); - node.status({fill:"yellow",shape:"dot",text:"connected"}); + node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); + node.status({fill:"yellow",shape:"dot",text:RED._("common.status.connected")}); node.serverConfig.ircclient.join( node.channel, function(data) { - node.log(data+" JOINED: "+node.channel); - node.status({fill:"green",shape:"dot",text:"joined"}); + node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); + node.status({fill:"green",shape:"dot",text:RED._("common.status.joined")}); }); }); node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("PING from "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:"ok"}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } + node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")}); }); node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.lastseen = Date.now(); - if (RED.settings.verbose) { node.log("QUIT: "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:"quit"}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } + node.status({fill:"grey",shape:"ring",text:RED._("common.status.quit")}); //node.serverConfig.ircclient.disconnect( function() { // node.serverConfig.ircclient.connect(); //}); - //if (RED.settings.verbose) { node.log("restart"); } // then retry + //if (RED.settings.verbose) { node.log(RED._("irc.errors.restart")); } // then retry }); node.serverConfig.ircclient.addListener('raw', function (message) { // any message received means we are alive //console.log("RAW:"+JSON.stringify(message)); @@ -237,8 +237,8 @@ module.exports = function(RED) { if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins //node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:"no connection"}); - if (RED.settings.verbose) { node.log("CONNECTION LOST ?"); } + node.status({fill:"grey",shape:"ring",text:RED._("common.status.noconnection")}); + if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } } //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link }, 60000); // check every 1 min @@ -249,7 +249,7 @@ module.exports = function(RED) { node.on("input", function(msg) { if (Object.prototype.toString.call( msg.raw ) === '[object Array]') { - if (RED.settings.verbose) { node.log("RAW command:"+msg.raw); } + if (RED.settings.verbose) { node.log(RED._("irc.errors.rawcommand")+":"+msg.raw); } node.ircclient.send.apply(node.ircclient,msg.raw); } else { @@ -259,7 +259,7 @@ module.exports = function(RED) { if ((msg.hasOwnProperty('topic'))&&(typeof msg.topic === "string")) { ch = msg.topic.split(","); // split on , so we can send to multiple } - else { node.warn("msg.topic not set"); } + else { node.warn(RED._("irc.errors.topicnotset")); } } for (var c = 0; c < ch.length; c++) { if (node.sendFlag == "false") { // send whole message object to each channel diff --git a/social/irc/locales/en-US/91-irc.json b/social/irc/locales/en-US/91-irc.json new file mode 100644 index 00000000..233df59f --- /dev/null +++ b/social/irc/locales/en-US/91-irc.json @@ -0,0 +1,39 @@ +{ + "irc": { + "label": { + "ircserver": "IRC Server", + "channel": "Channel", + "action": "Action", + "port": "Port", + "ssl": "Use Secure SSL connection?", + "self": "Allow self-signed certificates?", + "nickname": "Nickname" + }, + "payload": "Send payload to channel(s)", + "topic": "Use msg.topic to set nickname or channel(s)", + "msg": "Send complete msg object to channel(s)", + "tip": { + "in": "The channel to join must start with a #
You may join multiple channels by comma separating a list - #chan1,#chan2,etc.", + "out": "The channel to join must start with a #
Sending the complete object will stringify the whole msg object before sending." + }, + "errors": { + "connect": "CONNECT", + "err": "ERR", + "net": "NET", + "connected": "CONNECTED", + "online": "ONLINE", + "joined": "JOINED", + "ping": "PING from", + "quit": "QUIT", + "restart": "restart", + "connectionlost": "CONNECTION LOST?", + "hasjoined": "has joined", + "sentinvite": "sent invite to", + "hasleft": "has left", + "hasquit": "has quit", + "kickedfrom": "was kicked from", + "rawcommand": "RAW command", + "topicnotset": "msg.topic not set" + } + } +} \ No newline at end of file diff --git a/social/twitter/27-twitter.html b/social/twitter/27-twitter.html index f88420d1..80b70e83 100644 --- a/social/twitter/27-twitter.html +++ b/social/twitter/27-twitter.html @@ -23,34 +23,7 @@ (function() { var twitterConfigNodeId = null; var twitterConfigNodeIntervalId = null; - - function showTwitterAuthStart() { - var pathname = document.location.pathname; - if (pathname.slice(-1) != "/") { - pathname += "/"; - } - var callback = encodeURIComponent(location.protocol+"//"+location.hostname+":"+location.port+pathname+"twitter-credentials/"+twitterConfigNodeId+"/auth/callback"); - $("#node-config-dialog-ok").button("disable"); - $("#node-config-twitter-row").html('
Click here to authenticate with Twitter.
'); - $("#node-config-twitter-start").click(function() { - twitterConfigNodeIntervalId = window.setTimeout(pollTwitterCredentials,2000); - }); - } - function updateTwitterScreenName(sn) { - $("#node-config-input-screen_name").val(sn); - $("#node-config-twitter-row").html(''+sn+''); - } - function pollTwitterCredentials(e) { - $.getJSON('credentials/twitter-credentials/'+twitterConfigNodeId,function(data) { - if (data.screen_name) { - updateTwitterScreenName(data.screen_name); - twitterConfigNodeIntervalId = null; - $("#node-config-dialog-ok").button("enable"); - } else { - twitterConfigNodeIntervalId = window.setTimeout(pollTwitterCredentials,2000); - } - }) - } + RED.nodes.registerType('twitter-credentials',{ category: 'config', defaults: { @@ -66,8 +39,36 @@ }, exportable: false, oneditprepare: function() { - twitterConfigNodeId = this.id; - if (!this.screen_name || this.screen_name === "") { + var clickhere = this._("twitter.label.clickhere"); + var twitterID = this._("twitter.label.twitter-id"); + function showTwitterAuthStart() { + var pathname = document.location.pathname; + if (pathname.slice(-1) != "/") { + pathname += "/"; + } + var callback = encodeURIComponent(location.protocol+"//"+location.hostname+":"+location.port+pathname+"twitter-credentials/"+twitterConfigNodeId+"/auth/callback"); + $("#node-config-dialog-ok").button("disable"); + $("#node-config-twitter-row").html('
'+clickhere+'
'); + $("#node-config-twitter-start").click(function() { + twitterConfigNodeIntervalId = window.setTimeout(pollTwitterCredentials,2000); + }); + } + function updateTwitterScreenName(sn) { + $("#node-config-input-screen_name").val(sn); + $("#node-config-twitter-row").html(''+sn+''); + } + function pollTwitterCredentials(e) { + $.getJSON('credentials/twitter-credentials/'+twitterConfigNodeId,function(data) { + if (data.screen_name) { + updateTwitterScreenName(data.screen_name); + twitterConfigNodeIntervalId = null; + $("#node-config-dialog-ok").button("enable"); + } else { + twitterConfigNodeIntervalId = window.setTimeout(pollTwitterCredentials,2000); + } + }) + } + if (!this.screen_name || this.screen_name == "") { showTwitterAuthStart(); } else { if (this.credentials.screen_name) { @@ -93,29 +94,27 @@ diff --git a/social/twitter/27-twitter.js b/social/twitter/27-twitter.js index deadc6e0..2c767d66 100644 --- a/social/twitter/27-twitter.js +++ b/social/twitter/27-twitter.js @@ -16,7 +16,7 @@ module.exports = function(RED) { "use strict"; - var Ntwitter = require('twitter-ng'); + var ntwitter = require('twitter-ng'); var OAuth= require('oauth').OAuth; var request = require('request'); @@ -37,17 +37,17 @@ module.exports = function(RED) { * Populate msg.location based on data found in msg.tweet. */ function addLocationToTweet(msg) { - if (msg.tweet) { - if (msg.tweet.geo) { // if geo is set, always set location from geo - if (msg.tweet.geo.coordinates && msg.tweet.geo.coordinates.length === 2) { + if(msg.tweet) { + if(msg.tweet.geo) { // if geo is set, always set location from geo + if(msg.tweet.geo.coordinates && msg.tweet.geo.coordinates.length === 2) { if (!msg.location) { msg.location = {}; } // coordinates[0] is lat, coordinates[1] is lon msg.location.lat = msg.tweet.geo.coordinates[0]; msg.location.lon = msg.tweet.geo.coordinates[1]; msg.location.icon = "twitter"; } - } else if (msg.tweet.coordinates) { // otherwise attempt go get it from coordinates - if (msg.tweet.coordinates.coordinates && msg.tweet.coordinates.coordinates.length === 2) { + } else if(msg.tweet.coordinates) { // otherwise attempt go get it from coordinates + if(msg.tweet.coordinates.coordinates && msg.tweet.coordinates.coordinates.length === 2) { if (!msg.location) { msg.location = {}; } // WARNING! coordinates[1] is lat, coordinates[0] is lon!!! msg.location.lat = msg.tweet.coordinates.coordinates[1]; @@ -70,7 +70,7 @@ module.exports = function(RED) { var credentials = RED.nodes.getCredentials(this.twitter); if (credentials && credentials.screen_name == this.twitterConfig.screen_name) { - var twit = new Ntwitter({ + var twit = new ntwitter({ consumer_key: "OKjYEd1ef2bfFolV25G5nQ", consumer_secret: "meRsltCktVMUI8gmggpXett7WBLd1k0qidYazoML6g", access_token_key: credentials.access_token, @@ -92,10 +92,10 @@ module.exports = function(RED) { for (var i=0;i=0;t-=1) { @@ -124,7 +124,7 @@ module.exports = function(RED) { addLocationToTweet(msg); } node.send(msg); - if (t === 0) { + if (t == 0) { node.since_ids[u] = tweet.id_str; } } @@ -135,14 +135,14 @@ module.exports = function(RED) { }); },60000)); } - }())); + }()); } } else if (this.user === "dm") { node.poll_ids = []; twit.getDirectMessages({ - screen_name:node.twitterConfig.screen_name, - trim_user:0, - count:1 + screen_name:node.twitterConfig.screen_name, + trim_user:0, + count:1 },function(err,cb) { if (err) { node.error(err); @@ -154,11 +154,11 @@ module.exports = function(RED) { node.since_id = '0'; } node.poll_ids.push(setInterval(function() { - twit.getDirectMessages({ - screen_name:node.twitterConfig.screen_name, - trim_user:0, - since_id:node.since_id - },function(err,cb) { + twit.getDirectMessages({ + screen_name:node.twitterConfig.screen_name, + trim_user:0, + since_id:node.since_id + },function(err,cb) { if (cb) { for (var t=cb.length-1;t>=0;t-=1) { var tweet = cb[t]; @@ -170,7 +170,7 @@ module.exports = function(RED) { addLocationToTweet(msg); } node.send(msg); - if (t === 0) { + if (t == 0) { node.since_id = tweet.id_str; } } @@ -191,9 +191,7 @@ module.exports = function(RED) { if (bits.length == 4) { if ((Number(bits[0]) < Number(bits[2])) && (Number(bits[1]) < Number(bits[3]))) { st = { locations: node.tags }; - } - else { - node.log("possible bad geo area format. Should be lower-left lon, lat, upper-right lon, lat"); + node.log(RED._("twitter.status.using-geo",{location:node.tags.toString()})); } } @@ -218,19 +216,19 @@ module.exports = function(RED) { } }); stream.on('limit', function(tweet) { - node.warn("tweet rate limit hit"); + node.warn(RED._("twitter.errors.ratelimit")); }); stream.on('error', function(tweet,rc) { if (rc == 420) { - node.warn("Twitter rate limit hit"); + node.warn(RED._("twitter.errors.ratelimit")); } else { - node.warn("Stream error:"+tweet.toString()+" ("+rc+")"); + node.warn(RED._("twitter.errors.streamerror",{error:tweet.toString(),rc:rc})); } setTimeout(setupStream,10000); }); stream.on('destroy', function (response) { if (this.active) { - node.warn("twitter ended unexpectedly"); + node.warn(RED._("twitter.errors.unexpectedend")); setTimeout(setupStream,10000); } }); @@ -243,10 +241,10 @@ module.exports = function(RED) { node.error(err); } } else { - this.error("Invalid tag property"); + this.error(RED._("twitter.errors.invalidtag")); } } else { - this.error("missing twitter credentials"); + this.error(RED._("twitter.errors.missingcredentials")); } this.on('close', function() { @@ -273,7 +271,7 @@ module.exports = function(RED) { var node = this; if (credentials && credentials.screen_name == this.twitterConfig.screen_name) { - var twit = new Ntwitter({ + var twit = new ntwitter({ consumer_key: "OKjYEd1ef2bfFolV25G5nQ", consumer_secret: "meRsltCktVMUI8gmggpXett7WBLd1k0qidYazoML6g", access_token_key: credentials.access_token, @@ -281,11 +279,11 @@ module.exports = function(RED) { }); node.on("input", function(msg) { if (msg.hasOwnProperty("payload")) { - node.status({fill:"blue",shape:"dot",text:"tweeting"}); + node.status({fill:"blue",shape:"dot",text:RED._("twitter.status.tweeting")}); if (msg.payload.length > 140) { msg.payload = msg.payload.slice(0,139); - node.warn("Tweet greater than 140 : truncated"); + node.warn(RED._("twitter.errors.truncated")); } if (msg.media && Buffer.isBuffer(msg.media)) { @@ -298,13 +296,13 @@ module.exports = function(RED) { var r = request.post(signedUrl,function(err,httpResponse,body) { if (err) { node.error(err,msg); - node.status({fill:"red",shape:"ring",text:"failed"}); + node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); } else { var response = JSON.parse(body); if (response.errors) { var errorList = response.errors.map(function(er) { return er.code+": "+er.message }).join(", "); - node.error("Send tweet failed: "+errorList,msg); - node.status({fill:"red",shape:"ring",text:"failed"}); + node.error(RED._("twitter.errors.sendfail",{error:errorList}),msg); + node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); } else { node.status({}); } @@ -317,14 +315,14 @@ module.exports = function(RED) { } else { twit.updateStatus(msg.payload, function (err, data) { if (err) { - node.status({fill:"red",shape:"ring",text:"failed"}); + node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); node.error(err,msg); } node.status({}); }); } } - else { node.warn("No payload to tweet"); } + else { node.warn(RED._("twitter.errors.nopayload")); } }); } } @@ -340,16 +338,14 @@ module.exports = function(RED) { "HMAC-SHA1" ); - RED.httpAdmin.get('/twitter-credentials/:id/auth', function(req, res) { + RED.httpAdmin.get('/twitter-credentials/:id/auth', function(req, res){ var credentials = {}; oa.getOAuthRequestToken({ - oauth_callback: req.query.callback - },function(error, oauth_token, oauth_token_secret, results) { + oauth_callback: req.query.callback + },function(error, oauth_token, oauth_token_secret, results){ if (error) { - var resp = '

Oh no!

'+ - '

Something went wrong with the authentication process. The following error was returned:

'+ - '

'+error.statusCode+': '+error.data+'

'+ - '

One known cause of this type of failure is if the clock is wrong on system running Node-RED.'; + var error = {statusCode: 401, data: "dummy error"}; + var resp = RED._("twitter.errors.oautherror",{statusCode: error.statusCode, errorData: error.data}); res.send(resp) } else { credentials.oauth_token = oauth_token; @@ -360,7 +356,7 @@ module.exports = function(RED) { }); }); - RED.httpAdmin.get('/twitter-credentials/:id/auth/callback', function(req, res, next) { + RED.httpAdmin.get('/twitter-credentials/:id/auth/callback', function(req, res, next){ var credentials = RED.nodes.getCredentials(req.params.id); credentials.oauth_verifier = req.query.oauth_verifier; @@ -368,17 +364,17 @@ module.exports = function(RED) { credentials.oauth_token, credentials.token_secret, credentials.oauth_verifier, - function(error, oauth_access_token, oauth_access_token_secret, results) { - if (error) { + function(error, oauth_access_token, oauth_access_token_secret, results){ + if (error){ RED.log.error(error); - res.send("something in twitter oauth broke."); + res.send(RED._("twitter.errors.oauthbroke")); } else { credentials = {}; credentials.access_token = oauth_access_token; credentials.access_token_secret = oauth_access_token_secret; credentials.screen_name = "@"+results.screen_name; RED.nodes.addCredentials(req.params.id,credentials); - res.send("Authorised - you can close this window and return to Node-RED"); + res.send(RED._("twitter.errors.authorized")); } } ); diff --git a/social/twitter/locales/en-US/27-twitter.json b/social/twitter/locales/en-US/27-twitter.json new file mode 100644 index 00000000..81213943 --- /dev/null +++ b/social/twitter/locales/en-US/27-twitter.json @@ -0,0 +1,43 @@ +{ + "twitter": { + "label": { + "twitter-id":"Twitter ID", + "search": "Search", + "for": "for", + "user": "User", + "dmslabel": "DMs", + "tweetslabel": "tweets", + "clickhere": "Click here to authenticate with Twitter." + }, + "placeholder": { + "for": "comma-separated words, @ids, #tags", + "user": "comma-separated @twitter handles" + }, + "search": { + "public": "all public tweets", + "follow": "the tweets of who you follow", + "user": "the tweets of specific users", + "direct": "your direct messages" + }, + "tip": "Tip: Use commas without spaces between multiple search terms. Comma = OR, Space = AND.
The Twitter API WILL NOT deliver 100% of all tweets.
Tweets of who you follow will include their retweets and favourites.", + "status": { + "using-geo": "Using geo location: __location__", + "tweeting": "tweeting", + "failed":"failed" + }, + "errors": { + "ratelimit":"tweet rate limit hit", + "streamerror":"stream error: __error__ (__rc__)", + "unexpectedend":"stream ended unexpectedly", + "invalidtag":"invalid tag property", + "missingcredentials":"missing twitter credentials", + "truncated":"truncated tweet greater than 140 characters", + "sendfail":"send tweet failed: __error__", + "nopayload":"no payload to tweet", + + "oauthbroke":"something in twitter oauth broke.", + "oautherror": "

Something went wrong with the authentication process. The following error was returned:

__statusCode__: __errorData__

One known cause of this type of failure is if the clock is wrong on system running Node-RED

", + "authorized": "

Authorised - you can close this window and return to Node-RED

" + } + } +} \ No newline at end of file diff --git a/storage/mongodb/66-mongodb.html b/storage/mongodb/66-mongodb.html index 1b448de9..233995d3 100644 --- a/storage/mongodb/66-mongodb.html +++ b/storage/mongodb/66-mongodb.html @@ -16,26 +16,26 @@ @@ -62,43 +62,42 @@ @@ -86,8 +86,8 @@
- - + +
diff --git a/hardware/Arduino/35-arduino.js b/hardware/Arduino/35-arduino.js index ca171bfd..22011ef0 100644 --- a/hardware/Arduino/35-arduino.js +++ b/hardware/Arduino/35-arduino.js @@ -75,9 +75,9 @@ module.exports = function(RED) { if (typeof this.serverConfig === "object") { this.board = this.serverConfig.board; var node = this; - node.status({fill:"red",shape:"ring",text:RED._("common.status.connecting")}); + node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")}); node.board.on('connect', function() { - node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); //console.log("i",node.state,node.pin); if (node.state == "ANALOG") { node.board.on('analogChange', function(e) { @@ -122,10 +122,10 @@ module.exports = function(RED) { if (typeof this.serverConfig === "object") { this.board = this.serverConfig.board; var node = this; - node.status({fill:"red",shape:"ring",text:RED._("common.status.connecting")}); + node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")}); node.board.on('connect', function() { - node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); //console.log("o",node.state,node.pin); node.board.pinMode(node.pin, node.state); node.on("input", function(msg) { diff --git a/io/serialport/25-serial.html b/io/serialport/25-serial.html index 4eec0d77..efb54045 100644 --- a/io/serialport/25-serial.html +++ b/io/serialport/25-serial.html @@ -20,8 +20,8 @@
- - + +
@@ -61,8 +61,8 @@
- - + +
diff --git a/io/serialport/25-serial.js b/io/serialport/25-serial.js index bbbbfbee..221e4f28 100644 --- a/io/serialport/25-serial.js +++ b/io/serialport/25-serial.js @@ -76,10 +76,10 @@ module.exports = function(RED) { } }); node.port.on('ready', function() { - node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); }); node.port.on('closed', function() { - node.status({fill:"red",shape:"ring",text:RED._("common.status.not-connected")}); + node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")}); }); } else { this.error(RED._("serial.errors.missing-conf")); @@ -108,7 +108,7 @@ module.exports = function(RED) { if (node.serialConfig.out != "count") { buf = new Buffer(bufMaxSize); } else { buf = new Buffer(Number(node.serialConfig.newline)); } var i = 0; - node.status({fill:"grey",shape:"dot",text:RED._("common.status.not-connected")}); + node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.not-connected")}); node.port = serialPool.get(this.serialConfig.serialport, this.serialConfig.serialbaud, this.serialConfig.databits, @@ -179,10 +179,10 @@ module.exports = function(RED) { } }); this.port.on('ready', function() { - node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); }); this.port.on('closed', function() { - node.status({fill:"red",shape:"ring",text:RED._("common.status.not-connected")}); + node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")}); }); } else { this.error(RED._("serial.errors.missing-conf")); diff --git a/social/email/61-email.html b/social/email/61-email.html index fec319a9..67cdf040 100644 --- a/social/email/61-email.html +++ b/social/email/61-email.html @@ -62,8 +62,8 @@
- - + +
@@ -144,8 +144,8 @@
- - + +
diff --git a/social/email/61-email.js b/social/email/61-email.js index 4863906e..2f4b04b1 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -73,7 +73,7 @@ module.exports = function(RED) { if (smtpTransport) { node.status({fill:"blue",shape:"dot",text:RED._("email.status.sending")}); if (msg.to && node.name && (msg.to !== node.name)) { - node.warn(RED._("common.errors.nooverride")); + node.warn(RED._("node-red:common.errors.nooverride")); } var sendopts = { from: node.userid }; // sender address sendopts.to = node.name || msg.to; // comma separated list of addressees @@ -237,20 +237,20 @@ module.exports = function(RED) { node.log(RED._("email.status.newemail",{topic:pay.topic})); } else { node.log(RED._("email.status.duplicate",{topic:pay.topic})); } - //node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")}); + //node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); node.status({}); }); } else { node.log(RED._("email.status.inboxzero")); - //node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")}); + //node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); node.status({}); } } imap.end(); }); }); - node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")}); + node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); imap.connect(); }); diff --git a/social/feedparser/32-feedparse.html b/social/feedparser/32-feedparse.html index bd17aa6e..ad9ce283 100644 --- a/social/feedparser/32-feedparse.html +++ b/social/feedparser/32-feedparse.html @@ -24,8 +24,8 @@
- - + +
diff --git a/social/irc/91-irc.html b/social/irc/91-irc.html index 7596d6cd..bbc5ad6c 100644 --- a/social/irc/91-irc.html +++ b/social/irc/91-irc.html @@ -24,8 +24,8 @@
- - + +
@@ -133,8 +133,8 @@
- - + +
diff --git a/social/irc/91-irc.js b/social/irc/91-irc.js index 32ec6d81..fcad4afc 100644 --- a/social/irc/91-irc.js +++ b/social/irc/91-irc.js @@ -48,7 +48,7 @@ module.exports = function(RED) { var node = this; if (node.serverConfig.ircclient === null) { node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")}); + node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient.setMaxListeners(0); @@ -58,7 +58,7 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:RED._("common.status.neterror")}); + node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")}); }); node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.lastseen = Date.now(); @@ -67,21 +67,21 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.lastseen = Date.now(); node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); - node.status({fill:"yellow",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); node.serverConfig.ircclient.join( node.channel, function(data) { node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); - node.status({fill:"green",shape:"dot",text:RED._("common.status.joined")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); }); }); node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); }); node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:RED._("common.status.quit")}); + node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")}); //node.serverConfig.ircclient.disconnect( function() { // node.serverConfig.ircclient.connect(); //}); @@ -102,7 +102,7 @@ module.exports = function(RED) { if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins //node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:RED._("common.status.noconnection")}); + node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")}); if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } } //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link @@ -114,10 +114,10 @@ module.exports = function(RED) { node.ircclient.addListener('registered', function(message) { //node.log(node.ircclient.nick+" "+RED._("irc.errors.online")); - node.status({fill:"yellow",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); node.ircclient.join( node.channel, function(data) { // node.log(data+" "+RED._("irc.errors.joined")+" "+node.channel); - node.status({fill:"green",shape:"dot",text:RED._("common.status.joined")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); }); }); node.ircclient.addListener('message', function (from, to, message) { @@ -183,7 +183,7 @@ module.exports = function(RED) { var node = this; if (node.serverConfig.ircclient === null) { node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")}); + node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient.setMaxListeners(0); @@ -193,7 +193,7 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:RED._("common.status.neterror")}); + node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")}); }); node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.lastseen = Date.now(); @@ -202,21 +202,21 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.lastseen = Date.now(); node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); - node.status({fill:"yellow",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); node.serverConfig.ircclient.join( node.channel, function(data) { node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); - node.status({fill:"green",shape:"dot",text:RED._("common.status.joined")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); }); }); node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); }); node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:RED._("common.status.quit")}); + node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")}); //node.serverConfig.ircclient.disconnect( function() { // node.serverConfig.ircclient.connect(); //}); @@ -237,7 +237,7 @@ module.exports = function(RED) { if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins //node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:RED._("common.status.noconnection")}); + node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")}); if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } } //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link diff --git a/social/twitter/27-twitter.html b/social/twitter/27-twitter.html index 80b70e83..6628dcfa 100644 --- a/social/twitter/27-twitter.html +++ b/social/twitter/27-twitter.html @@ -111,8 +111,8 @@
- - + +
@@ -194,8 +194,8 @@
- - + +
diff --git a/storage/mongodb/66-mongodb.html b/storage/mongodb/66-mongodb.html index 233995d3..4701942b 100644 --- a/storage/mongodb/66-mongodb.html +++ b/storage/mongodb/66-mongodb.html @@ -34,8 +34,8 @@
- - + +
@@ -94,8 +94,8 @@
- - + +
@@ -187,8 +187,8 @@
- - + +
diff --git a/storage/redis/65-redisout.html b/storage/redis/65-redisout.html index 85cda043..6dc8f633 100644 --- a/storage/redis/65-redisout.html +++ b/storage/redis/65-redisout.html @@ -35,8 +35,8 @@
- - + +
diff --git a/storage/redis/65-redisout.js b/storage/redis/65-redisout.js index 22cfce47..63aeb288 100644 --- a/storage/redis/65-redisout.js +++ b/storage/redis/65-redisout.js @@ -43,7 +43,7 @@ module.exports = function(RED) { clearTimeout(connection.retry_timer); connection.end(); } - delete connections[connection._id]; + delete connections[connection._id]; } } }; @@ -61,17 +61,17 @@ module.exports = function(RED) { this.client = redisConnectionPool.get(this.hostname,this.port); if (this.client.connected) { - this.status({fill:"green",shape:"dot",text:RED._("common.status.connected")}); + this.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); } else { - this.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")},true); + this.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")},true); } var node = this; this.client.on("end", function() { - node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")}); + node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")}); }); this.client.on("connect", function() { - node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")}); + node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); }); this.on("input", function(msg) { From ba0e2c37967013b15d02d224c5dafed6ab889d98 Mon Sep 17 00:00:00 2001 From: dceejay Date: Tue, 16 Jun 2015 14:38:36 +0100 Subject: [PATCH 3/9] Merge linting error fixes into i18n branch of n-r-n --- io/serialport/25-serial.js | 62 ++++++++++----------------- social/email/61-email.html | 4 +- social/email/61-email.js | 2 +- social/feedparser/32-feedparse.js | 2 +- social/twitter/27-twitter.html | 2 +- social/twitter/27-twitter.js | 68 +++++++++++++++--------------- storage/mongodb/66-mongodb.js | 10 ++++- storage/redis/65-redisout.js | 6 +-- test/social/email/61-email_spec.js | 2 +- 9 files changed, 73 insertions(+), 85 deletions(-) diff --git a/io/serialport/25-serial.js b/io/serialport/25-serial.js index 221e4f28..998c5b1c 100644 --- a/io/serialport/25-serial.js +++ b/io/serialport/25-serial.js @@ -52,7 +52,7 @@ module.exports = function(RED) { this.serialConfig.newline); node.addCh = ""; if (node.serialConfig.addchar == "true" || node.serialConfig.addchar === true) { - node.addCh = this.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0"); + node.addCh = this.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0"); // jshint ignore:line } node.on("input",function(msg) { if (msg.hasOwnProperty("payload")) { @@ -121,7 +121,7 @@ module.exports = function(RED) { if (node.serialConfig.newline.substr(0,2) == "0x") { splitc = new Buffer([parseInt(node.serialConfig.newline)]); } else { - splitc = new Buffer(node.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0")); + splitc = new Buffer(node.serialConfig.newline.replace("\\n","\n").replace("\\r","\r").replace("\\t","\t").replace("\\e","\e").replace("\\f","\f").replace("\\0","\0")); // jshint ignore:line } this.port.on('data', function(msg) { @@ -132,7 +132,7 @@ module.exports = function(RED) { } else { // do the timer thing - if (node.serialConfig.out === "time") { + if (node.serialConfig.out === "time") { if (node.tout) { i += 1; buf[i] = msg; @@ -168,11 +168,11 @@ module.exports = function(RED) { buf[i] = msg; i += 1; if ((msg === splitc[0]) || (i === bufMaxSize)) { - var m = new Buffer(i); - buf.copy(m,0,0,i); - if (node.serialConfig.bin !== "bin") { m = m.toString(); } - node.send({"payload":m}); - m = null; + var n = new Buffer(i); + buf.copy(n,0,0,i); + if (node.serialConfig.bin !== "bin") { n = n.toString(); } + node.send({"payload":n}); + n = null; i = 0; } } @@ -199,13 +199,13 @@ module.exports = function(RED) { RED.nodes.registerType("serial in",SerialInNode); - var serialPool = function() { + var serialPool = (function() { var connections = {}; return { get:function(port,baud,databits,parity,stopbits,newline,callback) { var id = port; if (!connections[id]) { - connections[id] = function() { + connections[id] = (function() { var obj = { _emitter: new events.EventEmitter(), serial: null, @@ -217,24 +217,13 @@ module.exports = function(RED) { } //newline = newline.replace("\\n","\n").replace("\\r","\r"); var setupSerial = function() { - //if (newline == "") { - obj.serial = new serialp.SerialPort(port,{ - baudrate: baud, - databits: databits, - parity: parity, - stopbits: stopbits, - parser: serialp.parsers.raw - },true, function(err, results) { if (err) { obj.serial.emit('error',err); } }); - //} - //else { - // obj.serial = new serialp.SerialPort(port,{ - // baudrate: baud, - // databits: databits, - // parity: parity, - // stopbits: stopbits, - // parser: serialp.parsers.readline(newline) - // },true, function(err, results) { if (err) obj.serial.emit('error',err); }); - //} + obj.serial = new serialp.SerialPort(port,{ + baudrate: baud, + databits: databits, + parity: parity, + stopbits: stopbits, + parser: serialp.parsers.raw + },true, function(err, results) { if (err) { obj.serial.emit('error',err); } }); obj.serial.on('error', function(err) { RED.log.error(RED._("serial.errors.error",{port:port,error:err.toString()})); obj._emitter.emit('closed'); @@ -258,16 +247,9 @@ module.exports = function(RED) { obj._emitter.emit('ready'); }); obj.serial.on('data',function(d) { - //console.log(Buffer.isBuffer(d),d.length,d); - //if (typeof d !== "string") { - // //d = d.toString(); - for (var z=0; z/i.test(payload)) { sendopts.html = payload; } // html body if (msg.attachments) { sendopts.attachments = msg.attachments; } // add attachments } diff --git a/social/feedparser/32-feedparse.js b/social/feedparser/32-feedparse.js index 6190aa3e..ee3569e7 100644 --- a/social/feedparser/32-feedparse.js +++ b/social/feedparser/32-feedparse.js @@ -46,7 +46,7 @@ module.exports = function(RED) { feedparser.on('readable', function () { var stream = this, article; - while (article = stream.read()) { + while (article = stream.read()) { // jshint ignore:line if (!(article.guid in node.seen) || ( node.seen[article.guid] !== 0 && node.seen[article.guid] != article.date.getTime())) { node.seen[article.guid] = article.date?article.date.getTime():0; var msg = { diff --git a/social/twitter/27-twitter.html b/social/twitter/27-twitter.html index 6628dcfa..44b6efd2 100644 --- a/social/twitter/27-twitter.html +++ b/social/twitter/27-twitter.html @@ -68,7 +68,7 @@ } }) } - if (!this.screen_name || this.screen_name == "") { + if (!this.screen_name || this.screen_name === "") { showTwitterAuthStart(); } else { if (this.credentials.screen_name) { diff --git a/social/twitter/27-twitter.js b/social/twitter/27-twitter.js index 2c767d66..8279d4d1 100644 --- a/social/twitter/27-twitter.js +++ b/social/twitter/27-twitter.js @@ -16,7 +16,7 @@ module.exports = function(RED) { "use strict"; - var ntwitter = require('twitter-ng'); + var Ntwitter = require('twitter-ng'); var OAuth= require('oauth').OAuth; var request = require('request'); @@ -37,17 +37,17 @@ module.exports = function(RED) { * Populate msg.location based on data found in msg.tweet. */ function addLocationToTweet(msg) { - if(msg.tweet) { - if(msg.tweet.geo) { // if geo is set, always set location from geo - if(msg.tweet.geo.coordinates && msg.tweet.geo.coordinates.length === 2) { + if (msg.tweet) { + if (msg.tweet.geo) { // if geo is set, always set location from geo + if (msg.tweet.geo.coordinates && msg.tweet.geo.coordinates.length === 2) { if (!msg.location) { msg.location = {}; } // coordinates[0] is lat, coordinates[1] is lon msg.location.lat = msg.tweet.geo.coordinates[0]; msg.location.lon = msg.tweet.geo.coordinates[1]; msg.location.icon = "twitter"; } - } else if(msg.tweet.coordinates) { // otherwise attempt go get it from coordinates - if(msg.tweet.coordinates.coordinates && msg.tweet.coordinates.coordinates.length === 2) { + } else if (msg.tweet.coordinates) { // otherwise attempt go get it from coordinates + if (msg.tweet.coordinates.coordinates && msg.tweet.coordinates.coordinates.length === 2) { if (!msg.location) { msg.location = {}; } // WARNING! coordinates[1] is lat, coordinates[0] is lon!!! msg.location.lat = msg.tweet.coordinates.coordinates[1]; @@ -70,7 +70,7 @@ module.exports = function(RED) { var credentials = RED.nodes.getCredentials(this.twitter); if (credentials && credentials.screen_name == this.twitterConfig.screen_name) { - var twit = new ntwitter({ + var twit = new Ntwitter({ consumer_key: "OKjYEd1ef2bfFolV25G5nQ", consumer_secret: "meRsltCktVMUI8gmggpXett7WBLd1k0qidYazoML6g", access_token_key: credentials.access_token, @@ -92,10 +92,10 @@ module.exports = function(RED) { for (var i=0;i=0;t-=1) { @@ -124,7 +124,7 @@ module.exports = function(RED) { addLocationToTweet(msg); } node.send(msg); - if (t == 0) { + if (t === 0) { node.since_ids[u] = tweet.id_str; } } @@ -135,14 +135,14 @@ module.exports = function(RED) { }); },60000)); } - }()); + }())); } } else if (this.user === "dm") { node.poll_ids = []; twit.getDirectMessages({ - screen_name:node.twitterConfig.screen_name, - trim_user:0, - count:1 + screen_name:node.twitterConfig.screen_name, + trim_user:0, + count:1 },function(err,cb) { if (err) { node.error(err); @@ -154,11 +154,11 @@ module.exports = function(RED) { node.since_id = '0'; } node.poll_ids.push(setInterval(function() { - twit.getDirectMessages({ - screen_name:node.twitterConfig.screen_name, - trim_user:0, - since_id:node.since_id - },function(err,cb) { + twit.getDirectMessages({ + screen_name:node.twitterConfig.screen_name, + trim_user:0, + since_id:node.since_id + },function(err,cb) { if (cb) { for (var t=cb.length-1;t>=0;t-=1) { var tweet = cb[t]; @@ -170,7 +170,7 @@ module.exports = function(RED) { addLocationToTweet(msg); } node.send(msg); - if (t == 0) { + if (t === 0) { node.since_id = tweet.id_str; } } @@ -271,7 +271,7 @@ module.exports = function(RED) { var node = this; if (credentials && credentials.screen_name == this.twitterConfig.screen_name) { - var twit = new ntwitter({ + var twit = new Ntwitter({ consumer_key: "OKjYEd1ef2bfFolV25G5nQ", consumer_secret: "meRsltCktVMUI8gmggpXett7WBLd1k0qidYazoML6g", access_token_key: credentials.access_token, @@ -338,14 +338,14 @@ module.exports = function(RED) { "HMAC-SHA1" ); - RED.httpAdmin.get('/twitter-credentials/:id/auth', function(req, res){ + RED.httpAdmin.get('/twitter-credentials/:id/auth', function(req, res) { var credentials = {}; oa.getOAuthRequestToken({ - oauth_callback: req.query.callback - },function(error, oauth_token, oauth_token_secret, results){ + oauth_callback: req.query.callback + },function(error, oauth_token, oauth_token_secret, results) { if (error) { - var error = {statusCode: 401, data: "dummy error"}; - var resp = RED._("twitter.errors.oautherror",{statusCode: error.statusCode, errorData: error.data}); + var err = {statusCode: 401, data: "dummy error"}; + var resp = RED._("twitter.errors.oautherror",{statusCode: err.statusCode, errorData: err.data}); res.send(resp) } else { credentials.oauth_token = oauth_token; @@ -356,7 +356,7 @@ module.exports = function(RED) { }); }); - RED.httpAdmin.get('/twitter-credentials/:id/auth/callback', function(req, res, next){ + RED.httpAdmin.get('/twitter-credentials/:id/auth/callback', function(req, res, next) { var credentials = RED.nodes.getCredentials(req.params.id); credentials.oauth_verifier = req.query.oauth_verifier; @@ -364,8 +364,8 @@ module.exports = function(RED) { credentials.oauth_token, credentials.token_secret, credentials.oauth_verifier, - function(error, oauth_access_token, oauth_access_token_secret, results){ - if (error){ + function(error, oauth_access_token, oauth_access_token_secret, results) { + if (error) { RED.log.error(error); res.send(RED._("twitter.errors.oauthbroke")); } else { diff --git a/storage/mongodb/66-mongodb.js b/storage/mongodb/66-mongodb.js index d3f24a7a..61d7852c 100644 --- a/storage/mongodb/66-mongodb.js +++ b/storage/mongodb/66-mongodb.js @@ -1,5 +1,5 @@ /** - * Copyright 2013,2014 IBM Corp. + * Copyright 2013,2015 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,6 +87,9 @@ module.exports = function(RED) { if (typeof msg.payload !== "object") { msg.payload = {"payload": msg.payload}; } + if (msg.hasOwnProperty("_id") && !msg.payload.hasOwnProperty("_id")) { + msg.payload._id = msg._id; + } coll.save(msg.payload,function(err, item) { if (err) { node.error(err,msg); @@ -104,6 +107,9 @@ module.exports = function(RED) { if (typeof msg.payload !== "object") { msg.payload = {"payload": msg.payload}; } + if (msg.hasOwnProperty("_id") && !msg.payload.hasOwnProperty("_id")) { + msg.payload._id = msg._id; + } coll.insert(msg.payload, function(err, item) { if (err) { node.error(err,msg); @@ -163,7 +169,6 @@ module.exports = function(RED) { if (this.mongoConfig) { var node = this; - var selector; MongoClient.connect(this.mongoConfig.url, function(err,db) { if (err) { node.error(err); @@ -182,6 +187,7 @@ module.exports = function(RED) { return; } } + var selector; if (node.operation === "find") { msg.projection = msg.projection || {}; selector = ensureValidSelectorObject(msg.payload); diff --git a/storage/redis/65-redisout.js b/storage/redis/65-redisout.js index 63aeb288..cb28a92e 100644 --- a/storage/redis/65-redisout.js +++ b/storage/redis/65-redisout.js @@ -20,7 +20,7 @@ module.exports = function(RED) { var hashFieldRE = /^([^=]+)=(.*)$/; - var redisConnectionPool = function() { + var redisConnectionPool = (function() { var connections = {}; var obj = { get: function(host,port) { @@ -43,12 +43,12 @@ module.exports = function(RED) { clearTimeout(connection.retry_timer); connection.end(); } - delete connections[connection._id]; + delete connections[connection._id]; } } }; return obj; - }(); + }()); function RedisOutNode(n) { diff --git a/test/social/email/61-email_spec.js b/test/social/email/61-email_spec.js index 6a072f35..030a5b30 100644 --- a/test/social/email/61-email_spec.js +++ b/test/social/email/61-email_spec.js @@ -73,7 +73,7 @@ describe('email Node', function() { }); - describe('email in', function() { + describe.skip('email in', function() { it('should load with defaults', function(done) { var flow = [ { id:"n1", type:"e-mail in", wires:[["n2"]] }, From fd4b319af96a5679add2d95d3e8bb5aecad1d128 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 16 Jun 2015 16:13:55 +0100 Subject: [PATCH 4/9] Fix misnamed nls message in serial node --- io/serialport/locales/en-US/25-serial.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/serialport/locales/en-US/25-serial.json b/io/serialport/locales/en-US/25-serial.json index 3e4f542f..4e39027a 100644 --- a/io/serialport/locales/en-US/25-serial.json +++ b/io/serialport/locales/en-US/25-serial.json @@ -27,7 +27,7 @@ "split": { "character": "on the character", "timeout": "after a timeout of", - "length": "into fixed lengths of" + "lengths": "into fixed lengths of" }, "output": { "ascii": "ascii strings", From ee5ff8b01063677defb1161f90518add463f2238 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 7 Jul 2015 21:31:28 +0100 Subject: [PATCH 5/9] Send status message id to be nls'd in editor --- hardware/Arduino/35-arduino.js | 8 ++++---- io/serialport/25-serial.js | 10 +++++----- social/email/61-email.js | 18 +++++++++--------- social/irc/91-irc.js | 32 ++++++++++++++++---------------- social/twitter/27-twitter.js | 8 ++++---- storage/redis/65-redisout.js | 8 ++++---- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/hardware/Arduino/35-arduino.js b/hardware/Arduino/35-arduino.js index 22011ef0..8a578126 100644 --- a/hardware/Arduino/35-arduino.js +++ b/hardware/Arduino/35-arduino.js @@ -75,9 +75,9 @@ module.exports = function(RED) { if (typeof this.serverConfig === "object") { this.board = this.serverConfig.board; var node = this; - node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")}); + node.status({fill:"red",shape:"ring",text:"node-red:common.status.connecting"}); node.board.on('connect', function() { - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"}); //console.log("i",node.state,node.pin); if (node.state == "ANALOG") { node.board.on('analogChange', function(e) { @@ -122,10 +122,10 @@ module.exports = function(RED) { if (typeof this.serverConfig === "object") { this.board = this.serverConfig.board; var node = this; - node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")}); + node.status({fill:"red",shape:"ring",text:"node-red:common.status.connecting"}); node.board.on('connect', function() { - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"}); //console.log("o",node.state,node.pin); node.board.pinMode(node.pin, node.state); node.on("input", function(msg) { diff --git a/io/serialport/25-serial.js b/io/serialport/25-serial.js index 998c5b1c..b5468c00 100644 --- a/io/serialport/25-serial.js +++ b/io/serialport/25-serial.js @@ -76,10 +76,10 @@ module.exports = function(RED) { } }); node.port.on('ready', function() { - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"}); }); node.port.on('closed', function() { - node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")}); + node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"}); }); } else { this.error(RED._("serial.errors.missing-conf")); @@ -108,7 +108,7 @@ module.exports = function(RED) { if (node.serialConfig.out != "count") { buf = new Buffer(bufMaxSize); } else { buf = new Buffer(Number(node.serialConfig.newline)); } var i = 0; - node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.not-connected")}); + node.status({fill:"grey",shape:"dot",text:"node-red:common.status.not-connected"}); node.port = serialPool.get(this.serialConfig.serialport, this.serialConfig.serialbaud, this.serialConfig.databits, @@ -179,10 +179,10 @@ module.exports = function(RED) { } }); this.port.on('ready', function() { - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"}); }); this.port.on('closed', function() { - node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")}); + node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"}); }); } else { this.error(RED._("serial.errors.missing-conf")); diff --git a/social/email/61-email.js b/social/email/61-email.js index e7124131..3e0e9dcc 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -71,7 +71,7 @@ module.exports = function(RED) { this.on("input", function(msg) { if (msg.hasOwnProperty("payload")) { if (smtpTransport) { - node.status({fill:"blue",shape:"dot",text:RED._("email.status.sending")}); + node.status({fill:"blue",shape:"dot",text:"email.status.sending"}); if (msg.to && node.name && (msg.to !== node.name)) { node.warn(RED._("node-red:common.errors.nooverride")); } @@ -103,7 +103,7 @@ module.exports = function(RED) { smtpTransport.sendMail(sendopts, function(error, info) { if (error) { node.error(error,msg); - node.status({fill:"red",shape:"ring",text:RED._("email.status.sendfail")}); + node.status({fill:"red",shape:"ring",text:"email.status.sendfail"}); } else { node.log(RED._("email.status.messagesent",{response:info.response})); node.status({}); @@ -179,11 +179,11 @@ module.exports = function(RED) { this.on("input", function(msg) { imap.once('ready', function() { - node.status({fill:"blue",shape:"dot",text:RED._("email.status.fetching")}); + node.status({fill:"blue",shape:"dot",text:"email.status.fetching"}); var pay = {}; imap.openBox(node.box, false, function(err, box) { if (err) { - node.status({fill:"red",shape:"ring",text:RED._("email.status.foldererror")}); + node.status({fill:"red",shape:"ring",text:"email.status.foldererror"}); node.error(RED._("email.errors.fetchfail",{folder:node.box}),err); } else { @@ -227,7 +227,7 @@ module.exports = function(RED) { }); f.on('error', function(err) { node.warn(RED._("email.errors.messageerror",{error:err})); - node.status({fill:"red",shape:"ring",text:RED._("email.status.messageerror")}); + node.status({fill:"red",shape:"ring",text:"email.status.messageerror"}); }); f.on('end', function() { delete(pay._msgid); @@ -237,26 +237,26 @@ module.exports = function(RED) { node.log(RED._("email.status.newemail",{topic:pay.topic})); } else { node.log(RED._("email.status.duplicate",{topic:pay.topic})); } - //node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); + //node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"}); node.status({}); }); } else { node.log(RED._("email.status.inboxzero")); - //node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); + //node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"}); node.status({}); } } imap.end(); }); }); - node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); + node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"}); imap.connect(); }); imap.on('error', function(err) { node.log(err); - node.status({fill:"red",shape:"ring",text:RED._("email.status.connecterror")}); + node.status({fill:"red",shape:"ring",text:"email.status.connecterror"}); }); this.on("close", function() { diff --git a/social/irc/91-irc.js b/social/irc/91-irc.js index fcad4afc..b4a7d63c 100644 --- a/social/irc/91-irc.js +++ b/social/irc/91-irc.js @@ -48,7 +48,7 @@ module.exports = function(RED) { var node = this; if (node.serverConfig.ircclient === null) { node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); + node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"}); var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient.setMaxListeners(0); @@ -58,7 +58,7 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")}); + node.status({fill:"red",shape:"ring",text:"node-red:common.status.neterror"}); }); node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.lastseen = Date.now(); @@ -67,21 +67,21 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.lastseen = Date.now(); node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); - node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"}); node.serverConfig.ircclient.join( node.channel, function(data) { node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"}); }); }); node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"}); }); node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")}); + node.status({fill:"grey",shape:"ring",text:"node-red:common.status.quit"}); //node.serverConfig.ircclient.disconnect( function() { // node.serverConfig.ircclient.connect(); //}); @@ -102,7 +102,7 @@ module.exports = function(RED) { if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins //node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")}); + node.status({fill:"grey",shape:"ring",text:"node-red:common.status.noconnection"}); if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } } //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link @@ -114,10 +114,10 @@ module.exports = function(RED) { node.ircclient.addListener('registered', function(message) { //node.log(node.ircclient.nick+" "+RED._("irc.errors.online")); - node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"}); node.ircclient.join( node.channel, function(data) { // node.log(data+" "+RED._("irc.errors.joined")+" "+node.channel); - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"}); }); }); node.ircclient.addListener('message', function (from, to, message) { @@ -183,7 +183,7 @@ module.exports = function(RED) { var node = this; if (node.serverConfig.ircclient === null) { node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); - node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); + node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"}); var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient.setMaxListeners(0); @@ -193,7 +193,7 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } - node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")}); + node.status({fill:"red",shape:"ring",text:"node-red:common.status.neterror"}); }); node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.lastseen = Date.now(); @@ -202,21 +202,21 @@ module.exports = function(RED) { node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.lastseen = Date.now(); node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); - node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"}); node.serverConfig.ircclient.join( node.channel, function(data) { node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"}); }); }); node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"}); }); node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.lastseen = Date.now(); if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } - node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")}); + node.status({fill:"grey",shape:"ring",text:"node-red:common.status.quit"}); //node.serverConfig.ircclient.disconnect( function() { // node.serverConfig.ircclient.connect(); //}); @@ -237,7 +237,7 @@ module.exports = function(RED) { if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins //node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.connect(); - node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")}); + node.status({fill:"grey",shape:"ring",text:"node-red:common.status.noconnection"}); if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } } //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link diff --git a/social/twitter/27-twitter.js b/social/twitter/27-twitter.js index 8279d4d1..8d1438fd 100644 --- a/social/twitter/27-twitter.js +++ b/social/twitter/27-twitter.js @@ -279,7 +279,7 @@ module.exports = function(RED) { }); node.on("input", function(msg) { if (msg.hasOwnProperty("payload")) { - node.status({fill:"blue",shape:"dot",text:RED._("twitter.status.tweeting")}); + node.status({fill:"blue",shape:"dot",text:"twitter.status.tweeting"}); if (msg.payload.length > 140) { msg.payload = msg.payload.slice(0,139); @@ -296,13 +296,13 @@ module.exports = function(RED) { var r = request.post(signedUrl,function(err,httpResponse,body) { if (err) { node.error(err,msg); - node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); + node.status({fill:"red",shape:"ring",text:"twitter.status.failed"}); } else { var response = JSON.parse(body); if (response.errors) { var errorList = response.errors.map(function(er) { return er.code+": "+er.message }).join(", "); node.error(RED._("twitter.errors.sendfail",{error:errorList}),msg); - node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); + node.status({fill:"red",shape:"ring",text:"twitter.status.failed"}); } else { node.status({}); } @@ -315,7 +315,7 @@ module.exports = function(RED) { } else { twit.updateStatus(msg.payload, function (err, data) { if (err) { - node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); + node.status({fill:"red",shape:"ring",text:"twitter.status.failed"}); node.error(err,msg); } node.status({}); diff --git a/storage/redis/65-redisout.js b/storage/redis/65-redisout.js index cb28a92e..c2c905e9 100644 --- a/storage/redis/65-redisout.js +++ b/storage/redis/65-redisout.js @@ -61,17 +61,17 @@ module.exports = function(RED) { this.client = redisConnectionPool.get(this.hostname,this.port); if (this.client.connected) { - this.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); + this.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"}); } else { - this.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")},true); + this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"},true); } var node = this; this.client.on("end", function() { - node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")}); + node.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"}); }); this.client.on("connect", function() { - node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); + node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"}); }); this.on("input", function(msg) { From 1ff66443fba02783d9995a0a2cada9f42944897a Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Tue, 14 Jul 2015 21:03:07 +0100 Subject: [PATCH 6/9] add be i118n version with test --- function/rbe/README.md | 15 ++++++++++- function/rbe/locales/en-US/rbe.json | 19 ++++++++++++++ function/rbe/package.json | 2 +- function/rbe/rbe.html | 21 +++++++++------- function/rbe/rbe.js | 27 ++++++++++++-------- test/function/rbe/rbe_spec.js | 39 +++++++++++++++++++++++++---- 6 files changed, 97 insertions(+), 26 deletions(-) create mode 100644 function/rbe/locales/en-US/rbe.json diff --git a/function/rbe/README.md b/function/rbe/README.md index e7475bf5..c43946ff 100644 --- a/function/rbe/README.md +++ b/function/rbe/README.md @@ -18,6 +18,9 @@ Usage A simple node to provide report by exception (RBE) and deadband function - only passes on data if it has changed. +This works on a per **msg.topic** basis. This means that a single rbe node can +handle multiple topics at the same time. + ###RBE mode Outputs the **msg** if the **msg.payload** is different to the previous one. @@ -29,4 +32,14 @@ same value. Saves bandwidth, etc... In deadband mode the incoming payload should contain a parseable *number* and is output only if greater than + or - the *band gap* away from the previous output. -Will accept numbers, or parseable strings like "18.4 C" or "$500" +The deadband value can be specified as a fixed number, or a percentage. E.g. 10 +or 5% . If % mode is used then the output will only get sent if the input payload +value is equal or more than the specified % away from the previously sent value. + +For example - if last sent value was 100, and deadband is set to 10% - a value +of 110 will pass - then the next value has to be 121 in order to pass (= 110 + 10% = 121). + +This is mainly useful if you want to operate across multiple topics at the same +time that may have widely differing input ranges. + +Will only accept numbers, or parseable strings like "18.4 C" or "$500" diff --git a/function/rbe/locales/en-US/rbe.json b/function/rbe/locales/en-US/rbe.json new file mode 100644 index 00000000..fda5cecd --- /dev/null +++ b/function/rbe/locales/en-US/rbe.json @@ -0,0 +1,19 @@ +{ + "rbe": { + "label": { + "func": "Mode", + "bandgap": "Band gap", + "name": "Name" + }, + "eg":{ + "bandgap": "e.g. 10 or 5%" + }, + "opts": { + "rbe": "RBE - report if value changed", + "deadband": "Deadband - report if changed more than", + }, + "warn": { + "nonumber": "no number found in payload" + } + } +} diff --git a/function/rbe/package.json b/function/rbe/package.json index 5add0be8..e9a86991 100644 --- a/function/rbe/package.json +++ b/function/rbe/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-rbe", - "version" : "0.0.4", + "version" : "0.0.7", "description" : "A Node-RED node that provides report-by-exception (RBE) and deadband capability.", "dependencies" : { }, diff --git a/function/rbe/rbe.html b/function/rbe/rbe.html index 2476fa95..c8fa4b4f 100644 --- a/function/rbe/rbe.html +++ b/function/rbe/rbe.html @@ -16,19 +16,19 @@ @@ -38,16 +38,19 @@ different to the previous one. Works on numbers and strings.

In deadband mode the incoming payload should contain a parseable number and is output only if greater than + or - the band gap away from the previous output.

+

Deadband also supports % - only sends if the input differs by more than x% of the original value.

+

Note: This works on a per msg.topic basis. This means that a single rbe node can +handle multiple topics at the same time.