1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Add warning of too large interval for feedparser

To close #408
This commit is contained in:
Dave Conway-Jones 2018-03-11 21:10:37 +00:00
parent 0253f67882
commit f92f16fd08
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
4 changed files with 11 additions and 8 deletions

View File

@ -6,7 +6,7 @@
</div>
<div class="form-row">
<label for="node-input-interval"><i class="fa fa-repeat"></i> <span data-i18n="feedparse.label.refresh"></span></label>
<input type="text" id="node-input-interval" style="width: 50px"> <span data-i18n="feedparse.label.minutes"></span>
<input type="text" id="node-input-interval" style="width:60px"> <span data-i18n="feedparse.label.minutes"></span>
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
@ -19,6 +19,7 @@
<p>The <code>msg.topic</code> contains the original article link. The <code>msg.payload</code>
contains the description, and <code>msg.article</code> contains the complete article object,
which has properties such as <code>.title</code>, <code>.summary</code>, <code>.date</code> and so on.</p>
<p>The Refresh interval cannot be greater than 35790 minutes (approx 24.8 days).
</script>
<script type="text/javascript">
@ -28,13 +29,13 @@
defaults: {
name: {value:""},
url: {value:"", required:true},
interval: { value:15, required: true,validate:RED.validators.number()}
interval: { value:15, required:true, validate:function(v) {return (!isNaN(parseInt(v)) && (parseInt(v) <= 35790))} }
},
inputs:0,
outputs:1,
icon: "feed.png",
label: function() {
return this.name||this.url;
return this.name||this.url||"feedparser";
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@ -8,6 +8,7 @@ module.exports = function(RED) {
function FeedParseNode(n) {
RED.nodes.createNode(this,n);
this.url = n.url;
if (n.interval > 35790) { this.warn(RED._("feedparse.errors.invalidinterval")) }
this.interval = (parseInt(n.interval)||15) * 60000;
var node = this;
this.interval_id = null;

View File

@ -7,7 +7,8 @@
},
"errors": {
"badstatuscode": "error - Bad status code",
"invalidurl": "Invalid url"
"invalidurl": "Invalid url",
"invalidinterval": "Repeat interval too large"
}
}
}
}

View File

@ -1,10 +1,10 @@
{
"name": "node-red-node-feedparser",
"version": "0.1.9",
"version": "0.1.10",
"description": "A Node-RED node to get RSS Atom feeds.",
"dependencies": {
"feedparser": "1.1.3",
"request": "~2.74.0"
"feedparser": "^2.2.9",
"request": "^2.83.0"
},
"repository": {
"type": "git",