diff --git a/CHANGELOG.md b/CHANGELOG.md index 91cfb55e..dfd9eaa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Slovakian translation - Alerts now can contain Font Awesome icons - Notifications display time can be set in request +- Newsfeed: added support for `ARTICLE_INFO_REQUEST` notification - Add `name` config option for calendars to be sent along with event broadcasts ### Updated diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md index c06c3f07..b14a7ac6 100644 --- a/modules/default/newsfeed/README.md +++ b/modules/default/newsfeed/README.md @@ -46,6 +46,7 @@ MagicMirror's [notification mechanism](https://github.com/MichMich/MagicMirror/t | `ARTICLE_MORE_DETAILS` | When received the _first time_, shows the corresponding description of the currently displayed news title.
The module expects that the module's configuration option `showDescription` is set to `false` (default value).

When received a _second consecutive time_, shows the full news article in an IFRAME.
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`.

When received the _next consecutive times_, reloads the page and scrolls down by `scrollLength` pixels to paginate through the article. | `ARTICLE_LESS_DETAILS` | Hides the summary or full news article and only displays the news title of the currently viewed news item. | `ARTICLE_TOGGLE_FULL` | Toogles article in fullscreen. +| `ARTICLE_INFO_REQUEST` | Causes `newsfeed` to respond with the notification `ARTICLE_INFO_RESPONSE`, the payload of which provides the `title`, `source`, `date`, `desc` and `url` of the current news title. Note the payload of the sent notification event is ignored. diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 212a6a0f..3bb38d0a 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -189,7 +189,7 @@ Module.register("newsfeed",{ fullArticle.style.top = "0"; fullArticle.style.left = "0"; fullArticle.style.border = "none"; - fullArticle.src = typeof this.newsItems[this.activeItem].url === "string" ? this.newsItems[this.activeItem].url : this.newsItems[this.activeItem].url.href; + fullArticle.src = this.getActiveItemURL() fullArticle.style.zIndex = 1; wrapper.appendChild(fullArticle); } @@ -210,6 +210,10 @@ Module.register("newsfeed",{ return wrapper; }, + getActiveItemURL: function() { + return typeof this.newsItems[this.activeItem].url === "string" ? this.newsItems[this.activeItem].url : this.newsItems[this.activeItem].url.href; + }, + /* registerFeeds() * registers the feeds to be used by the backend. */ @@ -387,6 +391,14 @@ Module.register("newsfeed",{ } else { this.showFullArticle(); } + } else if (notification === "ARTICLE_INFO_REQUEST"){ + this.sendNotification("ARTICLE_INFO_RESPONSE", { + title: this.newsItems[this.activeItem].title, + source: this.newsItems[this.activeItem].sourceTitle, + date: this.newsItems[this.activeItem].pubdate, + desc: this.newsItems[this.activeItem].description, + url: this.getActiveItemURL() + }) } else { Log.info(this.name + " - unknown notification, ignoring: " + notification); }