diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96609e97..5bc779e8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Link update subtext to Github diff of current version versus tracking branch.
- Add Catalan translation.
- Add ability to filter out newsfeed items based on prohibited words found in title (resolves #1071)
+- Add options to truncate description support of a feed in newsfeed module
+- Add reloadInterval option for particular feed in newsfeed module
+- Add no-cache entries of HTTP headers in newsfeed module (fetcher)
### Updated
@@ -51,7 +54,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Changed 'default.js' - listen on all attached interfaces by default.
- Add execution of `npm list` after the test are ran in Travis CI.
- Change hooks for the vendors e2e tests.
-- Add log when clientonly failed on starting.
+- Add log when clientonly failed on starting.
- Add warning color when are using full ip whitelist.
- Set version of the `express-ipfilter` on 0.3.1.
diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md
index 843c2dda..a240b60f 100644
--- a/modules/default/newsfeed/README.md
+++ b/modules/default/newsfeed/README.md
@@ -57,25 +57,27 @@ The third party [MMM-Gestures](https://github.com/thobach/MMM-Gestures) module s
The following properties can be configured:
-| Option | Description
-| ----------------- | -----------
-| `feeds` | An array of feed urls that will be used as source.
More info about this object can be found below.
**Default value:** `[{ title: "New York Times", url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml", encoding: "UTF-8" }]`
-| `showSourceTitle` | Display the title of the source.
**Possible values:** `true` or `false`
**Default value:** `true`
-| `showPublishDate` | Display the publish date of an headline.
**Possible values:** `true` or `false`
**Default value:** `true`
-| `showDescription` | Display the description of an item.
**Possible values:** `true` or `false`
**Default value:** `false`
-| `wrapTitle` | Wrap the title of the item to multiple lines.
**Possible values:** `true` or `false`
**Default value:** `true`
-| `wrapDescription` | Wrap the description of the item to multiple lines.
**Possible values:** `true` or `false`
**Default value:** `true`
-| `hideLoading` | Hide module instead of showing LOADING status.
**Possible values:** `true` or `false`
**Default value:** `false`
-| `reloadInterval` | How often does the content needs to be fetched? (Milliseconds)
**Possible values:** `1000` - `86400000`
**Default value:** `300000` (5 minutes)
-| `updateInterval` | How often do you want to display a new headline? (Milliseconds)
**Possible values:**`1000` - `60000`
**Default value:** `10000` (10 seconds)
-| `animationSpeed` | Speed of the update animation. (Milliseconds)
**Possible values:**`0` - `5000`
**Default value:** `2500` (2.5 seconds)
-| `maxNewsItems` | Total amount of news items to cycle through. (0 for unlimited)
**Possible values:**`0` - `...`
**Default value:** `0`
-| `ignoreOldItems` | Ignore news items that are outdated.
**Possible values:**`true` or `false
**Default value:** `false`
-| `ignoreOlderThan` | How old should news items be before they are considered outdated? (Milliseconds)
**Possible values:**`1` - `...`
**Default value:** `86400000` (1 day)
-| `removeStartTags` | Some newsfeeds feature tags at the **beginning** of their titles or descriptions, such as _[VIDEO]_. This setting allows for the removal of specified tags from the beginning of an item's description and/or title.
**Possible values:**`'title'`, `'description'`, `'both'`
-| `startTags` | List the tags you would like to have removed at the beginning of the feed item
**Possible values:** `['TAG']` or `['TAG1','TAG2',...]`
-| `removeEndTags` | Remove specified tags from the **end** of an item's description and/or title.
**Possible values:**`'title'`, `'description'`, `'both'`
-| `endTags` | List the tags you would like to have removed at the end of the feed item
**Possible values:** `['TAG']` or `['TAG1','TAG2',...]`
+| Option | Description
+| ------------------ | -----------
+| `feeds` | An array of feed urls that will be used as source.
More info about this object can be found below.
**Default value:** `[{ title: "New York Times", url: "http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml", encoding: "UTF-8" }]`
You can add `reloadInterval` option to set particular reloadInterval to a feed.
+| `showSourceTitle` | Display the title of the source.
**Possible values:** `true` or `false`
**Default value:** `true`
+| `showPublishDate` | Display the publish date of an headline.
**Possible values:** `true` or `false`
**Default value:** `true`
+| `showDescription` | Display the description of an item.
**Possible values:** `true` or `false`
**Default value:** `false`
+| `wrapTitle` | Wrap the title of the item to multiple lines.
**Possible values:** `true` or `false`
**Default value:** `true`
+| `wrapDescription` | Wrap the description of the item to multiple lines.
**Possible values:** `true` or `false`
**Default value:** `true`
+| `truncDescription` | Truncate description?
**Possible values:** `true` or `false`
**Default value:** `true`
+| `lengthDescription`| How many characters to be displayed for a truncated description?
**Possible values:** `1` - `500`
**Default value:** `400`
+| `hideLoading` | Hide module instead of showing LOADING status.
**Possible values:** `true` or `false`
**Default value:** `false`
+| `reloadInterval` | How often does the content needs to be fetched? (Milliseconds)
**Possible values:** `1000` - `86400000`
**Default value:** `300000` (5 minutes)
+| `updateInterval` | How often do you want to display a new headline? (Milliseconds)
**Possible values:**`1000` - `60000`
**Default value:** `10000` (10 seconds)
+| `animationSpeed` | Speed of the update animation. (Milliseconds)
**Possible values:**`0` - `5000`
**Default value:** `2500` (2.5 seconds)
+| `maxNewsItems` | Total amount of news items to cycle through. (0 for unlimited)
**Possible values:**`0` - `...`
**Default value:** `0`
+| `ignoreOldItems` | Ignore news items that are outdated.
**Possible values:**`true` or `false
**Default value:** `false`
+| `ignoreOlderThan` | How old should news items be before they are considered outdated? (Milliseconds)
**Possible values:**`1` - `...`
**Default value:** `86400000` (1 day)
+| `removeStartTags` | Some newsfeeds feature tags at the **beginning** of their titles or descriptions, such as _[VIDEO]_. This setting allows for the removal of specified tags from the beginning of an item's description and/or title.
**Possible values:**`'title'`, `'description'`, `'both'`
+| `startTags` | List the tags you would like to have removed at the beginning of the feed item
**Possible values:** `['TAG']` or `['TAG1','TAG2',...]`
+| `removeEndTags` | Remove specified tags from the **end** of an item's description and/or title.
**Possible values:**`'title'`, `'description'`, `'both'`
+| `endTags` | List the tags you would like to have removed at the end of the feed item
**Possible values:** `['TAG']` or `['TAG1','TAG2',...]`
| `prohibitedWords` | Remove news feed item if one of these words is found anywhere in the title (case insensitive and greedy matching)
**Possible values:** `['word']` or `['word1','word2',...]`
The `feeds` property contains an array with multiple objects. These objects have the following properties:
diff --git a/modules/default/newsfeed/fetcher.js b/modules/default/newsfeed/fetcher.js
index f4fb44d9..354cff0b 100644
--- a/modules/default/newsfeed/fetcher.js
+++ b/modules/default/newsfeed/fetcher.js
@@ -61,17 +61,16 @@ var Fetcher = function(url, reloadInterval, encoding) {
});
} else {
-
- // console.log("Can't parse feed item:");
- // console.log(item);
- // console.log('Title: ' + title);
- // console.log('Description: ' + description);
- // console.log('Pubdate: ' + pubdate);
-
+ console.log("Can't parse feed item:");
+ console.log(item);
+ console.log("Title: " + title);
+ console.log("Description: " + description);
+ console.log("Pubdate: " + pubdate);
}
});
- parser.on("end", function() {
+ parser.on("end", function() {
+ //console.log("end parsing - " + url);
self.broadcastItems();
scheduleTimer();
});
@@ -83,7 +82,9 @@ var Fetcher = function(url, reloadInterval, encoding) {
nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
- headers = {"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)"}
+ headers = {"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)",
+ "Cache-Control": "max-age=0, no-cache, no-store, must-revalidate",
+ "Pragma": "no-cache"}
request({uri: url, encoding: null, headers: headers})
.on("error", function(error) {
diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js
index 75a5e2b5..95f05d60 100644
--- a/modules/default/newsfeed/newsfeed.js
+++ b/modules/default/newsfeed/newsfeed.js
@@ -23,8 +23,10 @@ Module.register("newsfeed",{
showDescription: false,
wrapTitle: true,
wrapDescription: true,
+ truncDescription: true,
+ lengthDescription: 400,
hideLoading: false,
- reloadInterval: 5 * 60 * 1000, // every 5 minutes
+ reloadInterval: 5 * 60 * 1000, // every 5 minutes
updateInterval: 10 * 1000,
animationSpeed: 2.5 * 1000,
maxNewsItems: 0, // 0 for unlimited
@@ -35,7 +37,6 @@ Module.register("newsfeed",{
startTags: [],
endTags: [],
prohibitedWords: []
-
},
// Define required scripts.
@@ -169,7 +170,9 @@ Module.register("newsfeed",{
if (this.config.showDescription) {
var description = document.createElement("div");
description.className = "small light" + (!this.config.wrapDescription ? " no-wrap" : "");
- description.innerHTML = this.newsItems[this.activeItem].description;
+ var txtDesc = this.newsItems[this.activeItem].description;
+ //Log.info('txtDesc.length = ' + txtDesc.length + " - " + this.config.lengthDescription);
+ description.innerHTML = (this.config.truncDescription ? (txtDesc.length > this.config.lengthDescription ? txtDesc.substring(0, this.config.lengthDescription) + "..." : txtDesc) : txtDesc);
wrapper.appendChild(description);
}
diff --git a/modules/default/newsfeed/node_helper.js b/modules/default/newsfeed/node_helper.js
index af1d32b8..47650997 100644
--- a/modules/default/newsfeed/node_helper.js
+++ b/modules/default/newsfeed/node_helper.js
@@ -36,7 +36,7 @@ module.exports = NodeHelper.create({
var url = feed.url || "";
var encoding = feed.encoding || "UTF-8";
- var reloadInterval = config.reloadInterval || 5 * 60 * 1000;
+ var reloadInterval = feed.reloadInterval || config.reloadInterval || 5 * 60 * 1000;
if (!validUrl.isUri(url)) {
self.sendSocketNotification("INCORRECT_URL", url);