-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Specific ignoreOlderThan value (override) per URL Feature #3429
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,9 @@ | |
{ | ||
title: "New York Times", | ||
url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml", | ||
encoding: "UTF-8" //ISO-8859-1 | ||
encoding: "UTF-8", //ISO-8859-1 | ||
ignoreOldItems: false, | ||
Check failure on line 9 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 9 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
|
||
ignoreOlderThan: 24 * 60 * 60 * 1000 | ||
} | ||
], | ||
showAsList: false, | ||
|
@@ -24,8 +26,10 @@ | |
updateInterval: 10 * 1000, | ||
animationSpeed: 2.5 * 1000, | ||
maxNewsItems: 0, // 0 for unlimited | ||
ignoreOldItems: false, | ||
ignoreOlderThan: 24 * 60 * 60 * 1000, // 1 day | ||
// // Lets make this an array, so it holds the value for each newsfeed, currently there is only one: New York Times | ||
// ignoreOldItems: Array.from({length: feeds.length}, () => false), | ||
// // Let's make this an array, so it holds the values for each newsfeed, currently there is only one: New York Times | ||
Check failure on line 31 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 31 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
|
||
// ignoreOlderThan:Array.from({length: feeds.length}, () => 24 * 60 * 60 * 1000), // all feeds are set to 1 day | ||
Check failure on line 32 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 32 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
|
||
removeStartTags: "", | ||
removeEndTags: "", | ||
startTags: [], | ||
|
@@ -176,19 +180,23 @@ | |
}); | ||
} | ||
}, | ||
|
||
getFeedProperty(feed, property) { | ||
Check failure on line 183 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 183 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this function so you can access values inside the objects in the feed array. |
||
return feed[property] || defaultValues[property]; | ||
Check failure on line 184 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 184 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
|
||
}, | ||
/** | ||
Check failure on line 186 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 186 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
|
||
* Generate an ordered list of items for this configured module. | ||
* @param {object} feeds An object with feeds returned by the node helper. | ||
*/ | ||
generateFeed (feeds) { | ||
let newsItems = []; | ||
for (let feed in feeds) { | ||
const feedItems = feeds[feed]; | ||
if (this.subscribedToFeed(feed)) { | ||
for (let i = 0; i < feeds.length; i++) { | ||
const feedItems = feeds[i]; | ||
if (this.subscribedToFeed(feedItems)) { | ||
for (let item of feedItems) { | ||
item.sourceTitle = this.titleForFeed(feed); | ||
if (!(this.config.ignoreOldItems && Date.now() - new Date(item.pubdate) > this.config.ignoreOlderThan)) { | ||
let ignoreOldItems = getFeedProperty(feedItems, 'ignoreOldItems'); | ||
Check failure on line 196 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 196 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 196 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
Check failure on line 196 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
Check failure on line 196 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (21.x)
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed how the the variables are accessed when trying to display the feed by using the getFeedProperty() |
||
let ignoreOlderThan = getFeedProperty(feedItems, 'ignoreOlderThan'); | ||
Check failure on line 197 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 197 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (18.x)
Check failure on line 197 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
Check failure on line 197 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (20.x)
Check failure on line 197 in modules/default/newsfeed/newsfeed.js GitHub Actions / test (21.x)
|
||
item.sourceTitle = this.titleForFeed(feedItems); | ||
if (!(ignoreOldItems && Date.now() - new Date(item.pubdate) > ignoreOlderThan)) { | ||
newsItems.push(item); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than having ignorOldItems and ignorOlderThan be global parameters, I added them inside the feed array and gave then default values of false and 1day.