mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-03 06:15:59 +00:00
Merge pull request #612 from thobach/master
Enabled newsfeed default module for gesture events from https://github.com/thobach/MMM-Gestures
This commit is contained in:
commit
daa2808448
@ -9,14 +9,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Add loaded function to modules, providing an async callback.
|
- Add loaded function to modules, providing an async callback.
|
||||||
|
- Made default newsfeed module aware of gesture events from [MMM-Gestures](https://github.com/thobach/MMM-Gestures)
|
||||||
- Add use pm2 for manager process into Installer RaspberryPi script
|
- Add use pm2 for manager process into Installer RaspberryPi script
|
||||||
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Update .gitignore to not ignore default modules folder.
|
- Update .gitignore to not ignore default modules folder.
|
||||||
- Remove white flash on boot up.
|
- Remove white flash on boot up.
|
||||||
- Added `update` in Raspberry Pi installation script.
|
- Added `update` in Raspberry Pi installation script.
|
||||||
|
|
||||||
|
|
||||||
## [2.1.0] - 2016-12-31
|
## [2.1.0] - 2016-12-31
|
||||||
|
|
||||||
**Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install`
|
**Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install`
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
# Module: News Feed
|
# Module: News Feed
|
||||||
The `newsfeed ` module is one of the default modules of the MagicMirror.
|
The `newsfeed ` module is one of the default modules of the MagicMirror.
|
||||||
This module displays news headlines based on an RSS feed.
|
This module displays news headlines based on an RSS feed. Scrolling through news headlines happens time-based (````updateInterval````), but can also be controlled by sending news feed specific notifications to the module.
|
||||||
|
|
||||||
## Using the module
|
## Using the module
|
||||||
|
|
||||||
|
### Configuration
|
||||||
To use this module, add it to the modules array in the `config/config.js` file:
|
To use this module, add it to the modules array in the `config/config.js` file:
|
||||||
````javascript
|
````javascript
|
||||||
modules: [
|
modules: [
|
||||||
@ -30,6 +31,51 @@ modules: [
|
|||||||
]
|
]
|
||||||
````
|
````
|
||||||
|
|
||||||
|
### Notifications
|
||||||
|
#### Interacting with the module
|
||||||
|
MagicMirror's [notification mechanism](https://github.com/MichMich/MagicMirror/tree/master/modules#thissendnotificationnotification-payload) allows to send notifications to the ````newsfeed```` module. The following notifications are supported:
|
||||||
|
|
||||||
|
<table width="100%">
|
||||||
|
<!-- why, markdown... -->
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Notification Identifier</th>
|
||||||
|
<th width="100%">Description</th>
|
||||||
|
</tr>
|
||||||
|
<thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>ARTICLE_NEXT</code></td>
|
||||||
|
<td>Shows the next news title (hiding the summary or previously fully displayed article)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>ARTICLE_PREVIOUS</code></td>
|
||||||
|
<td>Shows the previous news title (hiding the summary or previously fully displayed article)</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>ARTICLE_MORE_DETAILS</code></td>
|
||||||
|
<td><p>When received the *first time*, shows the corresponding description of the currently displayed news title.<br />The module expects that the module's configuration option ````showDescription```` is set to ````false```` (default value).</p>
|
||||||
|
When received a *second consecutive time*, shows the full news article in an IFRAME.<br />
|
||||||
|
This requires that the news page can be embedded in an IFRAME, e.g. doesn't have the HTTP response header [X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options) set to e.g. ````DENY````.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>ARTICLE_LESS_DETAILS</code></td>
|
||||||
|
<td>Hides the summary or full news article and only displays the news title of the currently viewed news item.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
Note the payload of the sent notification event is ignored.
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
The following example shows how the next news article title can be displayed on the MagicMirror.
|
||||||
|
````javascript
|
||||||
|
this.sendNotification('ARTICLE_NEXT');
|
||||||
|
````
|
||||||
|
|
||||||
|
#### ````newsfeed```` specific notification emitting modules
|
||||||
|
The third party [MMM-Gestures](https://github.com/thobach/MMM-Gestures) module supports above notifications when moving your hand up, down, left or right in front of a gesture sensor attached to the MagicMirror. See module's readme for more details.
|
||||||
|
|
||||||
## Configuration options
|
## Configuration options
|
||||||
|
|
||||||
The following properties can be configured:
|
The following properties can be configured:
|
||||||
|
@ -89,7 +89,8 @@ Module.register("newsfeed",{
|
|||||||
|
|
||||||
if (this.newsItems.length > 0) {
|
if (this.newsItems.length > 0) {
|
||||||
|
|
||||||
if (this.config.showSourceTitle || this.config.showPublishDate) {
|
// this.config.showFullArticle is a run-time configuration, triggered by optional notifications
|
||||||
|
if (!this.config.showFullArticle && (this.config.showSourceTitle || this.config.showPublishDate)) {
|
||||||
var sourceAndTimestamp = document.createElement("div");
|
var sourceAndTimestamp = document.createElement("div");
|
||||||
sourceAndTimestamp.className = "light small dimmed";
|
sourceAndTimestamp.className = "light small dimmed";
|
||||||
|
|
||||||
@ -152,10 +153,12 @@ Module.register("newsfeed",{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!this.config.showFullArticle){
|
||||||
var title = document.createElement("div");
|
var title = document.createElement("div");
|
||||||
title.className = "bright medium light";
|
title.className = "bright medium light";
|
||||||
title.innerHTML = this.newsItems[this.activeItem].title;
|
title.innerHTML = this.newsItems[this.activeItem].title;
|
||||||
wrapper.appendChild(title);
|
wrapper.appendChild(title);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.config.showDescription) {
|
if (this.config.showDescription) {
|
||||||
var description = document.createElement("div");
|
var description = document.createElement("div");
|
||||||
@ -164,6 +167,21 @@ Module.register("newsfeed",{
|
|||||||
wrapper.appendChild(description);
|
wrapper.appendChild(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.config.showFullArticle) {
|
||||||
|
var fullArticle = document.createElement("iframe");
|
||||||
|
fullArticle.className = "";
|
||||||
|
fullArticle.style.width = "100%";
|
||||||
|
fullArticle.style.top = "0";
|
||||||
|
fullArticle.style.left = "0";
|
||||||
|
fullArticle.style.position = "fixed";
|
||||||
|
fullArticle.height = window.innerHeight;
|
||||||
|
fullArticle.style.border = "none";
|
||||||
|
fullArticle.src = this.newsItems[this.activeItem].url;
|
||||||
|
wrapper.appendChild(fullArticle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
wrapper.innerHTML = this.translate("LOADING");
|
wrapper.innerHTML = this.translate("LOADING");
|
||||||
wrapper.className = "small dimmed";
|
wrapper.className = "small dimmed";
|
||||||
@ -256,7 +274,7 @@ Module.register("newsfeed",{
|
|||||||
|
|
||||||
self.updateDom(self.config.animationSpeed);
|
self.updateDom(self.config.animationSpeed);
|
||||||
|
|
||||||
setInterval(function() {
|
timer = setInterval(function() {
|
||||||
self.activeItem++;
|
self.activeItem++;
|
||||||
self.updateDom(self.config.animationSpeed);
|
self.updateDom(self.config.animationSpeed);
|
||||||
}, this.config.updateInterval);
|
}, this.config.updateInterval);
|
||||||
@ -273,5 +291,50 @@ Module.register("newsfeed",{
|
|||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetDescrOrFullArticleAndTimer: function() {
|
||||||
|
this.config.showDescription = false;
|
||||||
|
this.config.showFullArticle = false;
|
||||||
|
if(!timer){
|
||||||
|
this.scheduleUpdateInterval();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
notificationReceived: function(notification, payload, sender) {
|
||||||
|
Log.info(this.name + " - received notification: " + notification);
|
||||||
|
if(notification == "ARTICLE_NEXT"){
|
||||||
|
var before = this.activeItem;
|
||||||
|
this.activeItem++;
|
||||||
|
if (this.activeItem >= this.newsItems.length) {
|
||||||
|
this.activeItem = 0;
|
||||||
|
}
|
||||||
|
this.resetDescrOrFullArticleAndTimer();
|
||||||
|
Log.info(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")");
|
||||||
|
this.updateDom(100);
|
||||||
|
} else if(notification == "ARTICLE_PREVIOUS"){
|
||||||
|
var before = this.activeItem;
|
||||||
|
this.activeItem--;
|
||||||
|
if (this.activeItem < 0) {
|
||||||
|
this.activeItem = this.newsItems.length - 1;
|
||||||
|
}
|
||||||
|
this.resetDescrOrFullArticleAndTimer();
|
||||||
|
Log.info(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")");
|
||||||
|
this.updateDom(100);
|
||||||
|
}
|
||||||
|
// if "more details" is received the first time: show article summary, on second time show full article
|
||||||
|
else if(notification == "ARTICLE_MORE_DETAILS"){
|
||||||
|
this.config.showDescription = !this.config.showDescription;
|
||||||
|
this.config.showFullArticle = !this.config.showDescription;
|
||||||
|
clearInterval(timer);
|
||||||
|
timer = null;
|
||||||
|
Log.info(this.name + " - showing " + this.config.showDescription ? "article description" : "full article");
|
||||||
|
this.updateDom(100);
|
||||||
|
} else if(notification == "ARTICLE_LESS_DETAILS"){
|
||||||
|
this.resetDescrOrFullArticleAndTimer();
|
||||||
|
Log.info(this.name + " - showing only article titles again");
|
||||||
|
this.updateDom(100);
|
||||||
|
} else {
|
||||||
|
Log.info(this.name + " - unknown notification, ignoring: " + notification);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user