Skip to content

Commit

Permalink
Tweaks to rss reader and announce app
Browse files Browse the repository at this point in the history
  • Loading branch information
imbrianj committed Oct 29, 2017
1 parent e2c3b92 commit 8eccdbb
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions apps/announceRss.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
module.exports = (function () {
'use strict';

var RssArticles = '';
var RssArticles = {};

return {
version : 20161101,
version : 20171029,

translate : function (token, lang) {
var translate = require(__dirname + '/../lib/translate');
Expand All @@ -48,8 +48,8 @@ module.exports = (function () {
if ((values) && (values.value) && (values.value[0]) && (values.value[0].title)) {
articleTitle = values.value[0].title;

if (RssArticles !== articleTitle) {
if ((articleTitle) && (RssArticles)) {
if (RssArticles[deviceId] !== articleTitle) {
if ((articleTitle) && (RssArticles[deviceId])) {
notify = require(__dirname + '/../lib/notify');

message = this.translate('NEW_ARTICLE', lang);
Expand All @@ -59,7 +59,7 @@ module.exports = (function () {
notify.notify(message, controllers, deviceId);
}

RssArticles = articleTitle;
RssArticles[deviceId] = articleTitle;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion cache/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1509119296393
1509238737150
2 changes: 1 addition & 1 deletion devices/rss/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = (function () {

rssData[j] = { 'title' : util.sanitize(article.title[0]._),
'url' : util.sanitize(article.link[0].$.href),
'description' : article.summary ? util.sanitize(article.summary[0]) : null,
'description' : article.summary ? util.sanitize(article.summary[0]._) : null,
'text' : util.sanitize(article.content[0]._) };

j += 1;
Expand Down
2 changes: 1 addition & 1 deletion js/combo.min.js

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions tests/unit/devices/rss/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ exports.rssControllerTest = {
'use strict';

var rssController = require(__dirname + '/../../../../devices/rss/controller'),
configGet = { host : 'example.com',
port : '80',
path : '/test/',
method : 'GET',
badData : 'FAILURE' },
configGet = { host : 'example.com',
port : '80',
path : '/test/',
method : 'GET',
badData : 'FAILURE' },
testGet = rssController.postPrepare(configGet);

test.deepEqual(testGet, { host : 'example.com', port : '80', path : '/test/', method : 'GET' }, 'Additional params are filtered out.');
Expand All @@ -59,35 +59,35 @@ exports.rssControllerTest = {
var rssController = require(__dirname + '/../../../../devices/rss/controller'),
rssData = { rss : { channel : [{ item : [
{ 'title' : ['Test 1'],
'link' : ['http://example.com/test1'],
'link' : ['http://example.com/test1'],
'description' : ['<span>This is a test</span>'],
'content:encoded' : ['This is a piece of encoded content']
},
{ 'title' : ['Test 2'],
'link' : ['http://example.com/test2'],
'link' : ['http://example.com/test2'],
'description' : ['This is another test'],
'content:encoded' : ['This is another piece of encoded content']
}
]}]}},
atomData = { feed : { entry : [
{ title : [{ '_' : 'Test 1'}],
link : [{'$' : { 'href' : 'http://example.com/test1' }}],
summary : ['This is a test'],
summary : [{ '_' : 'This is a test'}],
content : [{ '_' : 'This is a piece of encoded content'}]
},
{ title : [{ '_' : 'Test 2'}],
link : [{'$' : { 'href' : 'http://example.com/test2' }}],
summary : ['This is another test'],
summary : [{ '_' : 'This is another test'}],
content : [{ '_' : 'This is another piece of encoded content'}]
},
{ title : [{ '_' : 'Test 3'}],
link : [{'$' : { 'href' : 'http://example.com/test3' }}],
summary : ['This is a third test'],
summary : [{ '_' : 'This is a third test'}],
content : [{ '_' : 'This is a 3rd piece of encoded content'}]
},
{ title : [{ '_' : 'Test 4'}],
link : [{'$' : { 'href' : 'http://example.com/test4' }}],
summary : ['This is a fourth test'],
link : [{'$' : { 'href' : 'http://example.com/test4' }}],
summary : [{ '_' : 'This is a fourth test'}],
content : [{ '_' : 'This is a fourth piece of encoded content'}]
},
]}},
Expand Down

0 comments on commit 8eccdbb

Please sign in to comment.