From 6008cba2db2baa1230eb9dad0641d10a85571023 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Fri, 31 May 2019 16:14:48 +0200 Subject: [PATCH 1/4] Minor typo corrections --- CHANGELOG.md | 1 + modules/default/newsfeed/README.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a375192..deaa1efc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Allowance HTML5 autoplay-policy (policy is changed from Chrome 66 updates) - Handle SIGTERM messages - Fixes sliceMultiDayEvents so it respects maximumNumberOfDays +- Minor types in default NewsFeed [README.md](https://github.com/MichMich/MagicMirror/blob/develop/modules/default/newsfeed/README.md) ## [2.7.1] - 2019-04-02 diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md index b14a7ac6..2cfc928d 100644 --- a/modules/default/newsfeed/README.md +++ b/modules/default/newsfeed/README.md @@ -45,7 +45,7 @@ MagicMirror's [notification mechanism](https://github.com/MichMich/MagicMirror/t | `ARTICLE_PREVIOUS` | Shows the previous news title (hiding the summary or previously fully displayed article) | `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_TOGGLE_FULL` | Toggles 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. @@ -80,7 +80,7 @@ The following properties can be configured: | `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'` +| `removeStartTags` | Some news feeds 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',...]` From aa80c468c4649af380cfdb1c99b4eae1859d4479 Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Fri, 31 May 2019 16:23:40 +0200 Subject: [PATCH 2/4] Added broadcasting of news feeds with incremental updates Added ability to enable broadcasting of news feed items with `NEWS_FEED` notification and broadcasting updated news feed items with `NEWS_FEED_UPDATE` to other modules. This is merged into the default `newsfeed` module. One can set ability to broadcast the whole news feed or broadcast only updated news feed items. --- CHANGELOG.md | 1 + modules/default/newsfeed/README.md | 10 ++++++++++ modules/default/newsfeed/newsfeed.js | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index deaa1efc..b5d9eea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Russian translation for “Feels” - Calendar module: added `nextDaysRelative` config option - Add `broadcastPastEvents` config option for calendars to include events from the past `maximumNumberOfDays` in event broadcasts +- Added feature to broadcast news feed items `NEWS_FEED` and updated news items `NEWS_FEED_UPDATED` in default [newsfeed](https://github.com/MichMich/MagicMirror/tree/develop/modules/default/newsfeed) module (when news is updated) with documented default and `config.js` options in [README.md](https://github.com/MichMich/MagicMirror/blob/develop/modules/default/newsfeed/README.md) ### Updated - English translation for "Feels" to "Feels like" diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md index 2cfc928d..c6c630e1 100644 --- a/modules/default/newsfeed/README.md +++ b/modules/default/newsfeed/README.md @@ -48,6 +48,14 @@ MagicMirror's [notification mechanism](https://github.com/MichMich/MagicMirror/t | `ARTICLE_TOGGLE_FULL` | Toggles 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. +#### Notifications sent by the module +MagicMirror's [notification mechanism](https://github.com/MichMich/MagicMirror/tree/master/modules#thissendnotificationnotification-payload) can also be used to send notifications from the current module to all other modules. The following notifications are broadcasted from this module: + +| Notification Identifier | Description +| ----------------------- | ----------- +| `NEWS_FEED` | Broadcast the current list of news items. +| `NEWS_FEED_UPDATE` | Broadcasts the list of updates news items. + Note the payload of the sent notification event is ignored. #### Example @@ -68,6 +76,8 @@ The following properties can be configured: | `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` +| `broadcastNewsFeeds` | Gives the ability to broadcast news feeds to all modules, by using ```sendNotification()``` when set to `true`, rather than ```sendSocketNotification()``` when `false`

**Possible values:** `true` or `false`
**Default value:** `true` +| `broadcastNewsUpdates` | Gives the ability to broadcast news feed updates to all modules

**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` diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 3bb38d0a..5c048810 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -20,6 +20,8 @@ Module.register("newsfeed",{ ], showSourceTitle: true, showPublishDate: true, + broadcastNewsFeeds: true, + broadcastNewsUpdates: true, showDescription: false, wrapTitle: true, wrapDescription: true, @@ -266,6 +268,20 @@ Module.register("newsfeed",{ }, this); } + // get updated news items and broadcast them + var updatedItems = []; + newsItems.forEach(value => { + if (this.newsItems.findIndex(value1 => value1 === value) === -1) { + // Add item to updated items list + updatedItems.push(value) + } + }); + + // check if updated items exist, if so and if we should broadcast these updates, then lets do so + if (this.config.broadcastNewsUpdates && updatedItems.length > 0) { + this.sendNotification("NEWS_FEED_UPDATE", {items: updatedItems}) + } + this.newsItems = newsItems; }, @@ -314,6 +330,11 @@ Module.register("newsfeed",{ timer = setInterval(function() { self.activeItem++; self.updateDom(self.config.animationSpeed); + + // Broadcast NewsFeed if needed + if (self.config.broadcastNewsFeeds) { + self.sendNotification("NEWS_FEED", {items: self.newsItems}); + } }, this.config.updateInterval); }, From c7d79bb89335d5a08e80960301383b1c99cbc04d Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Fri, 31 May 2019 19:45:58 +0200 Subject: [PATCH 3/4] Updated config.js.sample with new configuration entries Added `broadcastNewsFeeds: true` and `broadcastNewsUpdates: true` to the `config.js.sample` file --- config/config.js.sample | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/config.js.sample b/config/config.js.sample index 8ec8622f..790ada34 100644 --- a/config/config.js.sample +++ b/config/config.js.sample @@ -83,7 +83,9 @@ var config = { } ], showSourceTitle: true, - showPublishDate: true + showPublishDate: true, + broadcastNewsFeeds: true, + broadcastNewsUpdates: true } }, ] From b2f59d68135e130076cc369435abb924b10dc33f Mon Sep 17 00:00:00 2001 From: Charles Dyason Date: Mon, 3 Jun 2019 14:01:27 +0200 Subject: [PATCH 4/4] Added clock notifications for elapsed time. Added notifications to default `clock` module to broadcast: - `CLOCK_SECOND` for a clock second, and - `CLOCK_MINUTE` for a clock minute having elapsed. Each notification is broadcasted with the corresponding value i.e. `CLOCK_SECOND` -> `30` and `CLOCK_MINUTE` -> `5` . --- CHANGELOG.md | 1 + modules/default/clock/README.md | 11 +++++++++++ modules/default/clock/clock.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d9eea9..2dab4880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Calendar module: added `nextDaysRelative` config option - Add `broadcastPastEvents` config option for calendars to include events from the past `maximumNumberOfDays` in event broadcasts - Added feature to broadcast news feed items `NEWS_FEED` and updated news items `NEWS_FEED_UPDATED` in default [newsfeed](https://github.com/MichMich/MagicMirror/tree/develop/modules/default/newsfeed) module (when news is updated) with documented default and `config.js` options in [README.md](https://github.com/MichMich/MagicMirror/blob/develop/modules/default/newsfeed/README.md) +- Added notifications to default `clock` module broadcasting `CLOCK_SECOND` and `CLOCK_MINUTE` for the respective time elapsed. ### Updated - English translation for "Feels" to "Feels like" diff --git a/modules/default/clock/README.md b/modules/default/clock/README.md index 27e2ca5d..19e6a005 100644 --- a/modules/default/clock/README.md +++ b/modules/default/clock/README.md @@ -44,3 +44,14 @@ The following properties can be configured: | `analogPlacement` | **Specific to the analog clock. _(requires displayType set to `'both'`)_** Specifies where the analog clock is in relation to the digital clock

**Possible values:** `top`, `right`, `bottom`, or `left`
**Default value:** `bottom` | `analogShowDate` | **Specific to the analog clock.** If the clock is used as a separate module and set to analog only, this configures whether a date is also displayed with the clock.

**Possible values:** `false`, `top`, or `bottom`
**Default value:** `top` | `timezone` | Specific a timezone to show clock.

**Possible examples values:** `America/New_York`, `America/Santiago`, `Etc/GMT+10`
**Default value:** `none`. See more informations about configuration value [here](https://momentjs.com/timezone/docs/#/data-formats/packed-format/) + +## Notifications + +The clock makes use of the built-in [Notification Mechanism](https://github.com/michMich/MagicMirror/wiki/notifications) to relay notifications to all modules. + +Current notifications are: + +| Notification | Description +| ----------------- | ----------- +| `CLOCK_SECOND` | A second has elapsed.
*Parameter*: second value +| `CLOCK_MINUTE` | A minute has elapsed
*Parameter*: minute value \ No newline at end of file diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index e4942076..a6855aff 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -41,11 +41,25 @@ Module.register("clock",{ // Schedule update interval. var self = this; + self.second = 0; + self.minute = 0; self.lastDisplayedMinute = null; setInterval(function() { if (self.config.displaySeconds || self.lastDisplayedMinute !== moment().minute()) { self.updateDom(); } + if (self.second === 59) { + self.second = 0; + if (self.minute === 59){ + self.minute = 0; + } else { + self.minute++; + } + self.sendNotification("CLOCK_MINUTE", self.minute); + } else { + self.second++; + self.sendNotification("CLOCK_SECOND", self.second); + } }, 1000); // Set locale.