From 98855de71fc7d2f2bcb1f47087237d840484ae0a Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Sat, 31 Dec 2016 21:25:49 +0100 Subject: [PATCH 01/32] Changes in preperation of 2.1.1 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9551b79..94fc3495 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.1.1] - Unreleased + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` diff --git a/package.json b/package.json index 118c9837..54c60f92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "magicmirror", - "version": "2.1.0", + "version": "2.1.1", "description": "A modular interface for smart mirrors.", "main": "js/electron.js", "scripts": { From 3947deb7bdedba7b4e43690c49d00866319ae282 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Wed, 7 Dec 2016 17:19:05 +0100 Subject: [PATCH 02/32] Add async callback to module when loaded --- js/app.js | 54 ++++++++++++++--------- modules/README.md | 15 +++++++ modules/node_modules/node_helper/index.js | 5 +++ 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/js/app.js b/js/app.js index ba6cd1a9..91149906 100644 --- a/js/app.js +++ b/js/app.js @@ -66,7 +66,7 @@ var App = function() { * * argument module string - The name of the module (including subpath). */ - var loadModule = function(module) { + var loadModule = function(module, callback) { var elements = module.split("/"); var moduleName = elements[elements.length - 1]; @@ -103,6 +103,10 @@ var App = function() { m.setName(moduleName); m.setPath(path.resolve(moduleFolder)); nodeHelpers.push(m); + + m.loaded(callback); + } else { + callback(); } }; @@ -111,14 +115,24 @@ var App = function() { * * argument module string - The name of the module (including subpath). */ - var loadModules = function(modules) { + var loadModules = function(modules, callback) { console.log("Loading module helpers ..."); - for (var m in modules) { - loadModule(modules[m]); - } + var loadNextModule = function() { + if (modules.length > 0) { + var nextModule = modules[0]; + loadModule(nextModule, function() { + modules = modules.slice(1); + loadNextModule(); + }); + } else { + // All modules are loaded + console.log("All module helpers loaded."); + callback(); + } + }; - console.log("All module helpers loaded."); + loadNextModule(); }; /* cmpVersions(a,b) @@ -164,24 +178,24 @@ var App = function() { } } - loadModules(modules); + loadModules(modules, function() { + var server = new Server(config, function(app, io) { + console.log("Server started ..."); - var server = new Server(config, function(app, io) { - console.log("Server started ..."); + for (var h in nodeHelpers) { + var nodeHelper = nodeHelpers[h]; + nodeHelper.setExpressApp(app); + nodeHelper.setSocketIO(io); + nodeHelper.start(); + } - for (var h in nodeHelpers) { - var nodeHelper = nodeHelpers[h]; - nodeHelper.setExpressApp(app); - nodeHelper.setSocketIO(io); - nodeHelper.start(); - } + console.log("Sockets connected & modules started ..."); - console.log("Sockets connected & modules started ..."); - - if (typeof callback === "function") { - callback(config); - } + if (typeof callback === "function") { + callback(config); + } + }); }); }); }; diff --git a/modules/README.md b/modules/README.md index 42a31dfa..03664b15 100644 --- a/modules/README.md +++ b/modules/README.md @@ -96,6 +96,21 @@ requiresVersion: "2.1.0", ####`init()` This method is called when a module gets instantiated. In most cases you do not need to subclass this method. +####`loaded(callback)` + +*Introduced in version: 2.1.1.* + +This method is called when a module is loaded. Subsequent modules in the config are not yet loaded. The `callback` function MUST be called when the module is done loading. In most cases you do not need to subclass this method. + +**Example:** +````javascript +loaded: function(callback) { + this.finishLoading(); + Log.log(this.name + ' is loaded!'); + callback(); +} +```` + ####`start()` This method is called when all modules are loaded an the system is ready to boot up. Keep in mind that the dom object for the module is not yet created. The start method is a perfect place to define any additional module properties: diff --git a/modules/node_modules/node_helper/index.js b/modules/node_modules/node_helper/index.js index dc57ef36..bdeccf8b 100644 --- a/modules/node_modules/node_helper/index.js +++ b/modules/node_modules/node_helper/index.js @@ -14,6 +14,11 @@ NodeHelper = Class.extend({ console.log("Initializing new module helper ..."); }, + loaded: function(callback) { + console.log("Module helper loaded: " + this.name); + callback(); + }, + start: function() { console.log("Staring module helper: " + this.name); }, From a7619771a637e165dc706f56a992e1e6ea6cec46 Mon Sep 17 00:00:00 2001 From: Ben Brosnahan Date: Mon, 2 Jan 2017 21:31:21 +0000 Subject: [PATCH 03/32] Add error handling to newsfeed --- modules/default/newsfeed/fetcher.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/default/newsfeed/fetcher.js b/modules/default/newsfeed/fetcher.js index b7511de9..f4fb44d9 100644 --- a/modules/default/newsfeed/fetcher.js +++ b/modules/default/newsfeed/fetcher.js @@ -85,7 +85,12 @@ 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/)"} - request({uri: url, encoding: null, headers: headers}).pipe(iconv.decodeStream(encoding)).pipe(parser); + request({uri: url, encoding: null, headers: headers}) + .on("error", function(error) { + fetchFailedCallback(self, error); + scheduleTimer(); + }) + .pipe(iconv.decodeStream(encoding)).pipe(parser); }; From 4882a801d252bfdd8ab46c067eed0e612678f293 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Tue, 3 Jan 2017 17:46:41 +0100 Subject: [PATCH 04/32] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94fc3495..e4e8687f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [2.1.1] - Unreleased +- Add loaded function to modules, providing an async callback. ## [2.1.0] - 2016-12-31 From 8ac8b666bf435f90dc81c980b170b13e7f63c53a Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Wed, 4 Jan 2017 08:59:37 +0100 Subject: [PATCH 05/32] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4e8687f..6408d1d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [2.1.1] - Unreleased + +### Added - Add loaded function to modules, providing an async callback. ## [2.1.0] - 2016-12-31 From adb8de97546a6dd07773717d6380ea1a8f7a7f56 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Wed, 4 Jan 2017 10:46:31 +0100 Subject: [PATCH 06/32] Enabled newsfeed default module for gesture events from https://github.com/thobach/MMM-Gestures --- modules/default/newsfeed/newsfeed.js | 101 ++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 8 deletions(-) diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 74014208..152505dc 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -89,7 +89,8 @@ Module.register("newsfeed",{ if (this.newsItems.length > 0) { - if (this.config.showSourceTitle || this.config.showPublishDate) { + // this.config.showFullArticle is a run-time configuration, triggered by optional gestures + if (!this.config.showFullArticle && (this.config.showSourceTitle || this.config.showPublishDate)) { var sourceAndTimestamp = document.createElement("div"); sourceAndTimestamp.className = "light small dimmed"; @@ -151,18 +152,32 @@ Module.register("newsfeed",{ } } - - var title = document.createElement("div"); - title.className = "bright medium light"; - title.innerHTML = this.newsItems[this.activeItem].title; - wrapper.appendChild(title); - + + if(!this.config.showFullArticle){ + var title = document.createElement("div"); + title.className = "bright medium light"; + title.innerHTML = this.newsItems[this.activeItem].title; + wrapper.appendChild(title); + } + if (this.config.showDescription) { var description = document.createElement("div"); description.className = "small light"; description.innerHTML = this.newsItems[this.activeItem].description; wrapper.appendChild(description); } + + if (this.config.showFullArticle) { + var fullArticle = document.createElement("iframe"); + fullArticle.className = ""; + fullArticle.style.width = "100%"; + fullArticle.style.height = "1735px"; + fullArticle.style.border = "none"; + fullArticle.src = this.newsItems[this.activeItem].url; + wrapper.appendChild(fullArticle); + } + + } else { wrapper.innerHTML = this.translate("LOADING"); @@ -256,7 +271,7 @@ Module.register("newsfeed",{ self.updateDom(self.config.animationSpeed); - setInterval(function() { + timer = setInterval(function() { self.activeItem++; self.updateDom(self.config.animationSpeed); }, this.config.updateInterval); @@ -272,6 +287,76 @@ Module.register("newsfeed",{ capitalizeFirstLetter: function(string) { return string.charAt(0).toUpperCase() + string.slice(1); }, + + notificationReceived: function(notification, payload, sender) { + Log.info(this.name + " - received event"); + if(notification == 'GESTURE'){ + Log.info(this.name + " - received gesture"); + var gesture = payload.gesture; + // actually RIGHT, because gesture sensor is built in upside down + if(gesture == 'LEFT'){ + Log.info(this.name + " - received right"); + var before = this.activeItem; + this.activeItem++; + if (this.activeItem >= this.newsItems.length) { + this.activeItem = 0; + } + this.config.showDescription = false; + this.config.showFullArticle = false; + if(!timer){ + this.scheduleUpdateInterval(); + } + Log.info(this.name + " - going from " + before + " to " + this.activeItem + " (of " + this.newsItems.length + ")"); + this.updateDom(100); + } + // actually LEFT, because gesture sensor is built in upside down + else if(gesture == 'RIGHT'){ + Log.info(this.name + " - received left"); + var before = this.activeItem; + this.activeItem--; + if (this.activeItem < 0) { + this.activeItem = this.newsItems.length - 1; + } + this.config.showDescription = false; + this.config.showFullArticle = false; + if(!timer){ + this.scheduleUpdateInterval(); + } + Log.info(this.name + " - going from " + before + " to " + this.activeItem + " (of " + this.newsItems.length + ")"); + this.updateDom(100); + } + // actually UP, because gesture sensor is built in upside down + else if(gesture == 'DOWN' && !this.config.showDescription){ + Log.info(this.name + " - received up"); + this.config.showDescription = true; + this.config.showFullArticle = false; + clearInterval(timer); + timer = null; + this.updateDom(100); + } + // actually DOWN, because gesture sensor is built in upside down + else if(gesture == 'UP'){ + Log.info(this.name + " - received down"); + this.config.showDescription = false; + this.config.showFullArticle = false; + if(!timer){ + this.scheduleUpdateInterval(); + } + this.updateDom(100); + } + // actually UP, because gesture sensor is built in upside down + else if(gesture == 'DOWN' && this.config.showDescription){ + Log.info(this.name + " - received up again"); + this.config.showFullArticle = true; + this.config.showDescription = false; + clearInterval(timer); + timer = null; + this.updateDom(100); + } else { + Log.info(this.name + " - received other: " + gesture); + } + } + }, }); From 0099b6d4a2df5f9741560a237420b57f98cde343 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Wed, 4 Jan 2017 10:56:03 +0100 Subject: [PATCH 07/32] Added change to CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9551b79..fea09a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [develop] - release date to be defined +- Made default newsfeed module aware of gesture events from https://github.com/thobach/MMM-Gestures + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` From 6251b77b288c43e235ba6b0e6baacc20073bcf64 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Wed, 4 Jan 2017 11:01:07 +0100 Subject: [PATCH 08/32] Fixed code formatting issues --- modules/default/newsfeed/newsfeed.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 152505dc..0fdc9220 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -152,21 +152,21 @@ Module.register("newsfeed",{ } } - + if(!this.config.showFullArticle){ var title = document.createElement("div"); title.className = "bright medium light"; title.innerHTML = this.newsItems[this.activeItem].title; wrapper.appendChild(title); } - + if (this.config.showDescription) { var description = document.createElement("div"); description.className = "small light"; description.innerHTML = this.newsItems[this.activeItem].description; wrapper.appendChild(description); } - + if (this.config.showFullArticle) { var fullArticle = document.createElement("iframe"); fullArticle.className = ""; @@ -176,8 +176,8 @@ Module.register("newsfeed",{ fullArticle.src = this.newsItems[this.activeItem].url; wrapper.appendChild(fullArticle); } - - + + } else { wrapper.innerHTML = this.translate("LOADING"); @@ -287,14 +287,14 @@ Module.register("newsfeed",{ capitalizeFirstLetter: function(string) { return string.charAt(0).toUpperCase() + string.slice(1); }, - + notificationReceived: function(notification, payload, sender) { Log.info(this.name + " - received event"); - if(notification == 'GESTURE'){ + if(notification == "GESTURE"){ Log.info(this.name + " - received gesture"); var gesture = payload.gesture; // actually RIGHT, because gesture sensor is built in upside down - if(gesture == 'LEFT'){ + if(gesture == "LEFT"){ Log.info(this.name + " - received right"); var before = this.activeItem; this.activeItem++; @@ -310,7 +310,7 @@ Module.register("newsfeed",{ this.updateDom(100); } // actually LEFT, because gesture sensor is built in upside down - else if(gesture == 'RIGHT'){ + else if(gesture == "RIGHT"){ Log.info(this.name + " - received left"); var before = this.activeItem; this.activeItem--; @@ -326,7 +326,7 @@ Module.register("newsfeed",{ this.updateDom(100); } // actually UP, because gesture sensor is built in upside down - else if(gesture == 'DOWN' && !this.config.showDescription){ + else if(gesture == "DOWN" && !this.config.showDescription){ Log.info(this.name + " - received up"); this.config.showDescription = true; this.config.showFullArticle = false; @@ -335,7 +335,7 @@ Module.register("newsfeed",{ this.updateDom(100); } // actually DOWN, because gesture sensor is built in upside down - else if(gesture == 'UP'){ + else if(gesture == "UP"){ Log.info(this.name + " - received down"); this.config.showDescription = false; this.config.showFullArticle = false; @@ -345,7 +345,7 @@ Module.register("newsfeed",{ this.updateDom(100); } // actually UP, because gesture sensor is built in upside down - else if(gesture == 'DOWN' && this.config.showDescription){ + else if(gesture == "DOWN" && this.config.showDescription){ Log.info(this.name + " - received up again"); this.config.showFullArticle = true; this.config.showDescription = false; From 09531b399a5b992b9c7080c0371487ae899ffcb7 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Wed, 4 Jan 2017 11:04:33 +0100 Subject: [PATCH 09/32] Fixed Link formatting in MD --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fea09a07..bcb6b70a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [develop] - release date to be defined -- Made default newsfeed module aware of gesture events from https://github.com/thobach/MMM-Gestures +- Made default newsfeed module aware of gesture events from [MMM-Gestures](https://github.com/thobach/MMM-Gestures) ## [2.1.0] - 2016-12-31 From af41e4892ff3d7b7aa8ee9620fd62650c69331c1 Mon Sep 17 00:00:00 2001 From: IgniparousTempest Date: Wed, 4 Jan 2017 16:26:49 +0200 Subject: [PATCH 10/32] Afrikaans language translation --- translations/af.json | 34 ++++++++++++++++++++++++++++++++++ translations/translations.js | 1 + 2 files changed, 35 insertions(+) create mode 100644 translations/af.json diff --git a/translations/af.json b/translations/af.json new file mode 100644 index 00000000..894b14ea --- /dev/null +++ b/translations/af.json @@ -0,0 +1,34 @@ +{ + /* GENERAL */ + "LOADING": "Besig om te laai …", + + /* CALENDAR */ + "TODAY": "Vandag", + "TOMORROW": "Môre", + "DAYAFTERTOMORROW": "Oormôre", + "RUNNING": "Eindig in", + "EMPTY": "Geen komende gebeurtenisse.", + + /* WEATHER */ + "N": "N", + "NNE": "NNO", + "NE": "NO", + "ENE": "ONO", + "E": "O", + "ESE": "OSO", + "SE": "SO", + "SSE": "SSO", + "S": "S", + "SSW": "SSW", + "SW": "SW", + "WSW": "WSW", + "W": "W", + "WNW": "WNW", + "NW": "NW", + "NNW": "NNW", + + /* UPDATE INFO */ + "UPDATE_NOTIFICATION": "MagicMirror² update beskikbaar.", + "UPDATE_NOTIFICATION_MODULE": "Update beskikbaar vir MODULE_NAME module.", + "UPDATE_INFO": "Die huidige installasie is COMMIT_COUNT agter op die BRANCH_NAME branch." +} diff --git a/translations/translations.js b/translations/translations.js index d572c803..d5e74882 100644 --- a/translations/translations.js +++ b/translations/translations.js @@ -26,4 +26,5 @@ var translations = { "gr" : "translations/gr.json", // Greek "da" : "translations/da.json", // Danish "tr" : "translations/tr.json", // Turkish + "af" : "translations/af.json", // Afrikaans }; From 6552157894e6047b72dbbdf7339bedd96dea96fe Mon Sep 17 00:00:00 2001 From: Rodrigo Ramez Norambuena Date: Wed, 4 Jan 2017 12:52:21 -0300 Subject: [PATCH 11/32] Remove white flash on boot up When the electron app is started appear a white flash before show the MagicMirror system. This patch remove the white flash on boot up. --- CHANGELOG.md | 3 +++ js/electron.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6408d1d2..cefc49c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add loaded function to modules, providing an async callback. +### Fixed +- Remove white flash on boot up + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` diff --git a/js/electron.js b/js/electron.js index 173abe68..1f16092b 100644 --- a/js/electron.js +++ b/js/electron.js @@ -28,7 +28,8 @@ function createWindow() { webPreferences: { nodeIntegration: false, zoomFactor: config.zoom - } + }, + backgroundColor: "#000000" } // DEPRECATED: "kioskmode" backwards compatibility, to be removed From 92e0affb85df7f920524ebc0bcd2a82068c31626 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Wed, 4 Jan 2017 19:22:59 +0100 Subject: [PATCH 12/32] Disable pointer-events on fullscreen overlay --- CHANGELOG.md | 1 + css/main.css | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94fc3495..dc97e5ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [2.1.1] - Unreleased +- Make mouse events pass through the region fullscreen_above to modules below. ## [2.1.0] - 2016-12-31 diff --git a/css/main.css b/css/main.css index 5e63e596..f1c07fa0 100644 --- a/css/main.css +++ b/css/main.css @@ -135,6 +135,11 @@ sup { left: -60px; right: -60px; bottom: -60px; + pointer-events: none; +} + +.region.fullscreen * { + pointer-events: auto; } .region.right { From 396bbd83c8bbee6d92a892cfdb7c5e958427b8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Sun, 1 Jan 2017 19:51:50 -0300 Subject: [PATCH 13/32] modified installer to use config.js.sample for init config. --- CHANGELOG.md | 3 +++ installers/raspberry.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6408d1d2..852df9c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [2.1.1] - Unreleased +### Changed +- Installer: Use init config.js from config.js.sample. + ### Added - Add loaded function to modules, providing an async callback. diff --git a/installers/raspberry.sh b/installers/raspberry.sh index cd995a1e..b970d02e 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -113,6 +113,9 @@ else exit; fi +# Use sample config for start MagicMirror +cp config/config.js.sample config/config.js + # Check if plymouth is installed (default with PIXEL desktop environment), then install custom splashscreen. echo -e "\e[96mCheck plymouth installation ...\e[0m" if command_exists plymouth; then From 01cf4cc1ed4dcf26eeb8a9722bc828ef9664778b Mon Sep 17 00:00:00 2001 From: Sergey Morozov Date: Fri, 6 Jan 2017 11:21:20 -0800 Subject: [PATCH 14/32] Added Russian Translations Redo of the PR #598 **Added:** - Russian Translations **Fixed:** - corrected .gitignore rules for default modules (Reasoning behind change: when I added translation for `alert` module `git add` was telling me that `.gitignore` rule excludes files and folders under `modules/default`) I also noticed that `.gitignore:56` has following declaration: ``` !/modules/node_helper !/modules/node_helper/** ``` but I don't think this directory structure exists today (also there is a small typo) --- .gitignore | 5 ++-- CHANGELOG.md | 8 +++++ modules/default/alert/translations/ru.json | 4 +++ translations/ru.json | 34 ++++++++++++++++++++++ translations/translations.js | 1 + 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 modules/default/alert/translations/ru.json create mode 100644 translations/ru.json diff --git a/.gitignore b/.gitignore index 67feae54..9e51215c 100644 --- a/.gitignore +++ b/.gitignore @@ -58,8 +58,9 @@ Temporary Items !/modules/node_helper/** # Ignore all modules except the default modules. -/modules/** -!/modules/default/** +!/modules/ +/modules/* +!/modules/default/ !/modules/README.md** # Ignore changes to the custom css files. diff --git a/CHANGELOG.md b/CHANGELOG.md index b9551b79..bc627832 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.1.1] - Unreleased + +### Added +- Russian Translation + +### Fixed +- corrected .gitignore rules for default modules + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` diff --git a/modules/default/alert/translations/ru.json b/modules/default/alert/translations/ru.json new file mode 100644 index 00000000..ef7ee708 --- /dev/null +++ b/modules/default/alert/translations/ru.json @@ -0,0 +1,4 @@ +{ + "sysTitle": "MagicMirror Уведомление", + "welcome": "Добро пожаловать, старт был успешным!"" +} diff --git a/translations/ru.json b/translations/ru.json new file mode 100644 index 00000000..053385ee --- /dev/null +++ b/translations/ru.json @@ -0,0 +1,34 @@ +{ + /* GENERAL */ + "LOADING": "Загрузка …", + + /* CALENDAR */ + "TODAY": "Сегодня", + "TOMORROW": "Завтра", + "DAYAFTERTOMORROW": "Послезавтра", + "RUNNING": "Заканчивается через", + "EMPTY": "Нет предстоящих событий", + + /* WEATHER */ + "N": "С", + "NNE": "ССВ", + "NE": "СВ", + "ENE": "ВСВ", + "E": "В", + "ESE": "ВЮВ", + "SE": "ЮВ", + "SSE": "ЮЮВ", + "S": "Ю", + "SSW": "ЮЮЗ", + "SW": "ЮЗ", + "WSW": "ЗЮЗ", + "W": "З", + "WNW": "ЗСЗ", + "NW": "СЗ", + "NNW": "ССЗ", + + /* UPDATE INFO */ + "UPDATE_NOTIFICATION": "Есть обновление для MagicMirror².", + "UPDATE_NOTIFICATION_MODULE": "Есть обновление для MODULE_NAME модуля.", + "UPDATE_INFO": "Данная инсталляция позади BRANCH_NAME ветки на COMMIT_COUNT коммитов." +} diff --git a/translations/translations.js b/translations/translations.js index d572c803..71d086f5 100644 --- a/translations/translations.js +++ b/translations/translations.js @@ -26,4 +26,5 @@ var translations = { "gr" : "translations/gr.json", // Greek "da" : "translations/da.json", // Danish "tr" : "translations/tr.json", // Turkish + "ru" : "translations/ru.json", // Russian }; From b8a72245dc93d59f026a499dfe76883e877a21e2 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Fri, 6 Jan 2017 21:57:30 +0100 Subject: [PATCH 15/32] Using generic news feed events as notifications, instead of more implementation specific gestures from sensor --- modules/default/newsfeed/newsfeed.js | 114 ++++++++++++--------------- 1 file changed, 51 insertions(+), 63 deletions(-) diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 0fdc9220..28bc4a0e 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -89,7 +89,7 @@ Module.register("newsfeed",{ if (this.newsItems.length > 0) { - // this.config.showFullArticle is a run-time configuration, triggered by optional gestures + // 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"); sourceAndTimestamp.className = "light small dimmed"; @@ -289,74 +289,62 @@ Module.register("newsfeed",{ }, notificationReceived: function(notification, payload, sender) { - Log.info(this.name + " - received event"); - if(notification == "GESTURE"){ - Log.info(this.name + " - received gesture"); - var gesture = payload.gesture; - // actually RIGHT, because gesture sensor is built in upside down - if(gesture == "LEFT"){ - Log.info(this.name + " - received right"); - var before = this.activeItem; - this.activeItem++; - if (this.activeItem >= this.newsItems.length) { - this.activeItem = 0; - } - this.config.showDescription = false; - this.config.showFullArticle = false; - if(!timer){ - this.scheduleUpdateInterval(); - } - Log.info(this.name + " - going from " + before + " to " + this.activeItem + " (of " + this.newsItems.length + ")"); - this.updateDom(100); + 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; } - // actually LEFT, because gesture sensor is built in upside down - else if(gesture == "RIGHT"){ - Log.info(this.name + " - received left"); - var before = this.activeItem; - this.activeItem--; - if (this.activeItem < 0) { - this.activeItem = this.newsItems.length - 1; - } - this.config.showDescription = false; - this.config.showFullArticle = false; - if(!timer){ - this.scheduleUpdateInterval(); - } - Log.info(this.name + " - going from " + before + " to " + this.activeItem + " (of " + this.newsItems.length + ")"); - this.updateDom(100); + this.config.showDescription = false; + this.config.showFullArticle = false; + if(!timer){ + this.scheduleUpdateInterval(); } - // actually UP, because gesture sensor is built in upside down - else if(gesture == "DOWN" && !this.config.showDescription){ - Log.info(this.name + " - received up"); - this.config.showDescription = true; - this.config.showFullArticle = false; - clearInterval(timer); - timer = null; - this.updateDom(100); + 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; } - // actually DOWN, because gesture sensor is built in upside down - else if(gesture == "UP"){ - Log.info(this.name + " - received down"); - this.config.showDescription = false; - this.config.showFullArticle = false; - if(!timer){ - this.scheduleUpdateInterval(); - } - this.updateDom(100); + this.config.showDescription = false; + this.config.showFullArticle = false; + if(!timer){ + this.scheduleUpdateInterval(); } - // actually UP, because gesture sensor is built in upside down - else if(gesture == "DOWN" && this.config.showDescription){ - Log.info(this.name + " - received up again"); - this.config.showFullArticle = true; - this.config.showDescription = false; - clearInterval(timer); - timer = null; - this.updateDom(100); - } else { - Log.info(this.name + " - received other: " + gesture); + Log.info(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")"); + this.updateDom(100); + } + // received "more details" the first time, so showing article summary + else if(notification == "ARTICLE_MORE_DETAILS" && !this.config.showDescription){ + this.config.showDescription = true; + this.config.showFullArticle = false; + clearInterval(timer); + timer = null; + Log.info(this.name + " - showing article description"); + this.updateDom(100); + } else if(notification == "ARTICLE_LESS_DETAILS"){ + this.config.showDescription = false; + this.config.showFullArticle = false; + if(!timer){ + this.scheduleUpdateInterval(); } + Log.info(this.name + " - showing only article titles again"); + this.updateDom(100); + } + // received "more details" a second time, so showing full article + else if(notification == "ARTICLE_MORE_DETAILS" && this.config.showDescription){ + this.config.showFullArticle = true; + this.config.showDescription = false; + clearInterval(timer); + timer = null; + Log.info(this.name + " - showing full article"); + this.updateDom(100); + } else { + Log.info(this.name + " - unknown notification, ignoring: " + notification); } }, - }); From 443a90c7baec08f3254912ba428e2eea717eb887 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Sat, 7 Jan 2017 22:42:11 +0100 Subject: [PATCH 16/32] Made full article view of news full-screen on any screen size --- modules/default/newsfeed/newsfeed.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 28bc4a0e..55f2de58 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -171,7 +171,10 @@ Module.register("newsfeed",{ var fullArticle = document.createElement("iframe"); fullArticle.className = ""; fullArticle.style.width = "100%"; - fullArticle.style.height = "1735px"; + 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); From 456502893ca94234bba8965b04e86db61158edd4 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Sun, 8 Jan 2017 14:38:16 +0100 Subject: [PATCH 17/32] Addressed code review comments to reduce redundant lines --- modules/default/newsfeed/newsfeed.js | 45 ++++++++++------------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/modules/default/newsfeed/newsfeed.js b/modules/default/newsfeed/newsfeed.js index 55f2de58..aed917f8 100644 --- a/modules/default/newsfeed/newsfeed.js +++ b/modules/default/newsfeed/newsfeed.js @@ -291,6 +291,14 @@ Module.register("newsfeed",{ 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"){ @@ -299,11 +307,7 @@ Module.register("newsfeed",{ if (this.activeItem >= this.newsItems.length) { this.activeItem = 0; } - this.config.showDescription = false; - this.config.showFullArticle = false; - if(!timer){ - this.scheduleUpdateInterval(); - } + 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"){ @@ -312,39 +316,22 @@ Module.register("newsfeed",{ if (this.activeItem < 0) { this.activeItem = this.newsItems.length - 1; } - this.config.showDescription = false; - this.config.showFullArticle = false; - if(!timer){ - this.scheduleUpdateInterval(); - } + this.resetDescrOrFullArticleAndTimer(); Log.info(this.name + " - going from article #" + before + " to #" + this.activeItem + " (of " + this.newsItems.length + ")"); this.updateDom(100); } - // received "more details" the first time, so showing article summary - else if(notification == "ARTICLE_MORE_DETAILS" && !this.config.showDescription){ - this.config.showDescription = true; - this.config.showFullArticle = false; + // 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 article description"); + Log.info(this.name + " - showing " + this.config.showDescription ? "article description" : "full article"); this.updateDom(100); } else if(notification == "ARTICLE_LESS_DETAILS"){ - this.config.showDescription = false; - this.config.showFullArticle = false; - if(!timer){ - this.scheduleUpdateInterval(); - } + this.resetDescrOrFullArticleAndTimer(); Log.info(this.name + " - showing only article titles again"); this.updateDom(100); - } - // received "more details" a second time, so showing full article - else if(notification == "ARTICLE_MORE_DETAILS" && this.config.showDescription){ - this.config.showFullArticle = true; - this.config.showDescription = false; - clearInterval(timer); - timer = null; - Log.info(this.name + " - showing full article"); - this.updateDom(100); } else { Log.info(this.name + " - unknown notification, ignoring: " + notification); } From d71fd0ff2d85e6b96f2602b05a8ae6b0a4bff47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Mon, 9 Jan 2017 20:39:48 -0300 Subject: [PATCH 18/32] Add pm2 configuration for manager MagicMirror in script installer --- CHANGELOG.md | 1 + installers/mm.sh | 2 ++ installers/pm2_MagicMirror.json | 7 +++++++ installers/raspberry.sh | 6 ++++++ 4 files changed, 16 insertions(+) create mode 100755 installers/mm.sh create mode 100644 installers/pm2_MagicMirror.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 6408d1d2..8f6205eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add loaded function to modules, providing an async callback. +- Add use pm2 for manager process into Installer RaspberryPi script ## [2.1.0] - 2016-12-31 diff --git a/installers/mm.sh b/installers/mm.sh new file mode 100755 index 00000000..cc6c4bb3 --- /dev/null +++ b/installers/mm.sh @@ -0,0 +1,2 @@ +cd ~/MagicMirror +DISPLAY=:0 npm start diff --git a/installers/pm2_MagicMirror.json b/installers/pm2_MagicMirror.json new file mode 100644 index 00000000..55f8df31 --- /dev/null +++ b/installers/pm2_MagicMirror.json @@ -0,0 +1,7 @@ +{ + apps : [{ + name : "MagicMirror", + script : "/home/pi/MagicMirror/installer/mm.sh", + watch : ["/home/pi/MagicMirror/config/config.js"] + }] +} diff --git a/installers/raspberry.sh b/installers/raspberry.sh index cd995a1e..df3994bc 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -141,6 +141,12 @@ else echo -e "\e[93mplymouth is not installed.\e[0m"; fi +# Use pm2 control like a service MagicMirror +sudo npm install -g pm2 +sudo su -c "env PATH=$PATH:/usr/bin pm2 startup linux -u pi --hp /home/pi" +pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json +pm2 save + echo " " echo -e "\e[92mWe're ready! Run \e[1m\e[97mDISPLAY=:0 npm start\e[0m\e[92m from the ~/MagicMirror directory to start your MagicMirror.\e[0m" echo " " From 2e9b6ead2e18be7187f171e4969481529ec26840 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Mon, 9 Jan 2017 17:31:01 +0100 Subject: [PATCH 19/32] Fix gitignore to not ignore default modules folder /modules/** makes git ignore all directories and files in /modules, so it's not even looking in /modules/default for changes. !/modules/default/** is therefore never used. By adding the new line !/modules/default, git is told to look in the /modules/default folder for changes and will find all sub files/dirs and match these on !/modules/default/**. --- .gitignore | 1 + CHANGELOG.md | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 67feae54..1e17ef8b 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ Temporary Items # Ignore all modules except the default modules. /modules/** +!/modules/default !/modules/default/** !/modules/README.md** diff --git a/CHANGELOG.md b/CHANGELOG.md index 6408d1d2..149b9644 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Add loaded function to modules, providing an async callback. +### Fixed +- Update .gitignore to not ignore default modules folder + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` From 831d8b6d362af7672a0e7f573ee75b11555025ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Tue, 10 Jan 2017 15:21:59 -0300 Subject: [PATCH 20/32] update year license for 2017 --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index d4765af2..09ac7e6f 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright © 2016 Michael Teeuw +Copyright © 2016-2017 Michael Teeuw Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation From 544e7fce8870843bc8e6c976ffafc32e68380875 Mon Sep 17 00:00:00 2001 From: Sergey Morozov Date: Tue, 10 Jan 2017 11:05:37 -0800 Subject: [PATCH 21/32] removing .gitignore changes and changelog notes about it --- .gitignore | 5 ++--- CHANGELOG.md | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 9e51215c..67feae54 100644 --- a/.gitignore +++ b/.gitignore @@ -58,9 +58,8 @@ Temporary Items !/modules/node_helper/** # Ignore all modules except the default modules. -!/modules/ -/modules/* -!/modules/default/ +/modules/** +!/modules/default/** !/modules/README.md** # Ignore changes to the custom css files. diff --git a/CHANGELOG.md b/CHANGELOG.md index 98876061..c046352c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,6 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Add loaded function to modules, providing an async callback. - Russian Translation -### Fixed -- corrected .gitignore rules for default modules - ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` From 49abe2b11f32034569f13de689fcfd0a71d9cee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Tue, 10 Jan 2017 16:11:29 -0300 Subject: [PATCH 22/32] Fix capitalize missing word Community --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c5286dd..126a1d7f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ MagicMirror² focuses on a modular plugin system and uses [Electron](http://elec - [Configuration](#configuration) - [Modules](#modules) - [Known Issues](#known-issues) -- [community](#community) +- [Community](#community) - [Contributing Guidelines](#contributing-guidelines) ## Usage From c302030301900c037e9bb089a819afc08608875c Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Wed, 11 Jan 2017 11:19:33 +0100 Subject: [PATCH 23/32] Added documentation on supported notifications and related third party modules --- modules/default/newsfeed/README.md | 48 +++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/modules/default/newsfeed/README.md b/modules/default/newsfeed/README.md index 58c7b9ae..8a0fec25 100644 --- a/modules/default/newsfeed/README.md +++ b/modules/default/newsfeed/README.md @@ -1,9 +1,10 @@ # Module: News Feed 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 +### Configuration To use this module, add it to the modules array in the `config/config.js` file: ````javascript 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: + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Notification IdentifierDescription
ARTICLE_NEXTShows the next news title (hiding the summary or previously fully displayed article)
ARTICLE_PREVIOUSShows 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````.
ARTICLE_LESS_DETAILSHides the summary or full news article and only displays the news title of the currently viewed news item.
+ +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 The following properties can be configured: From 3ba16f17734c7da7aa8505943dd03d155bb732e0 Mon Sep 17 00:00:00 2001 From: Thomas Bachmann Date: Wed, 11 Jan 2017 11:32:20 +0100 Subject: [PATCH 24/32] Merge remote-tracking branch 'MichMich/develop' --- .gitignore | 1 + CHANGELOG.md | 12 ++++- LICENSE.md | 2 +- installers/raspberry.sh | 3 ++ js/app.js | 54 ++++++++++++++--------- js/electron.js | 3 +- modules/README.md | 15 +++++++ modules/default/newsfeed/fetcher.js | 7 ++- modules/node_modules/node_helper/index.js | 5 +++ package.json | 2 +- 10 files changed, 79 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 67feae54..1e17ef8b 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ Temporary Items # Ignore all modules except the default modules. /modules/** +!/modules/default !/modules/default/** !/modules/README.md** diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb6b70a..65119703 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,19 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [develop] - release date to be defined +## [2.1.1] - Unreleased + +### Changed +- Installer: Use init config.js from config.js.sample. + +### Added +- 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) +### Fixed +- Update .gitignore to not ignore default modules folder. +- Remove white flash on boot up. + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` diff --git a/LICENSE.md b/LICENSE.md index d4765af2..09ac7e6f 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright © 2016 Michael Teeuw +Copyright © 2016-2017 Michael Teeuw Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/installers/raspberry.sh b/installers/raspberry.sh index cd995a1e..b970d02e 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -113,6 +113,9 @@ else exit; fi +# Use sample config for start MagicMirror +cp config/config.js.sample config/config.js + # Check if plymouth is installed (default with PIXEL desktop environment), then install custom splashscreen. echo -e "\e[96mCheck plymouth installation ...\e[0m" if command_exists plymouth; then diff --git a/js/app.js b/js/app.js index ba6cd1a9..91149906 100644 --- a/js/app.js +++ b/js/app.js @@ -66,7 +66,7 @@ var App = function() { * * argument module string - The name of the module (including subpath). */ - var loadModule = function(module) { + var loadModule = function(module, callback) { var elements = module.split("/"); var moduleName = elements[elements.length - 1]; @@ -103,6 +103,10 @@ var App = function() { m.setName(moduleName); m.setPath(path.resolve(moduleFolder)); nodeHelpers.push(m); + + m.loaded(callback); + } else { + callback(); } }; @@ -111,14 +115,24 @@ var App = function() { * * argument module string - The name of the module (including subpath). */ - var loadModules = function(modules) { + var loadModules = function(modules, callback) { console.log("Loading module helpers ..."); - for (var m in modules) { - loadModule(modules[m]); - } + var loadNextModule = function() { + if (modules.length > 0) { + var nextModule = modules[0]; + loadModule(nextModule, function() { + modules = modules.slice(1); + loadNextModule(); + }); + } else { + // All modules are loaded + console.log("All module helpers loaded."); + callback(); + } + }; - console.log("All module helpers loaded."); + loadNextModule(); }; /* cmpVersions(a,b) @@ -164,24 +178,24 @@ var App = function() { } } - loadModules(modules); + loadModules(modules, function() { + var server = new Server(config, function(app, io) { + console.log("Server started ..."); - var server = new Server(config, function(app, io) { - console.log("Server started ..."); + for (var h in nodeHelpers) { + var nodeHelper = nodeHelpers[h]; + nodeHelper.setExpressApp(app); + nodeHelper.setSocketIO(io); + nodeHelper.start(); + } - for (var h in nodeHelpers) { - var nodeHelper = nodeHelpers[h]; - nodeHelper.setExpressApp(app); - nodeHelper.setSocketIO(io); - nodeHelper.start(); - } + console.log("Sockets connected & modules started ..."); - console.log("Sockets connected & modules started ..."); - - if (typeof callback === "function") { - callback(config); - } + if (typeof callback === "function") { + callback(config); + } + }); }); }); }; diff --git a/js/electron.js b/js/electron.js index 173abe68..1f16092b 100644 --- a/js/electron.js +++ b/js/electron.js @@ -28,7 +28,8 @@ function createWindow() { webPreferences: { nodeIntegration: false, zoomFactor: config.zoom - } + }, + backgroundColor: "#000000" } // DEPRECATED: "kioskmode" backwards compatibility, to be removed diff --git a/modules/README.md b/modules/README.md index 42a31dfa..03664b15 100644 --- a/modules/README.md +++ b/modules/README.md @@ -96,6 +96,21 @@ requiresVersion: "2.1.0", ####`init()` This method is called when a module gets instantiated. In most cases you do not need to subclass this method. +####`loaded(callback)` + +*Introduced in version: 2.1.1.* + +This method is called when a module is loaded. Subsequent modules in the config are not yet loaded. The `callback` function MUST be called when the module is done loading. In most cases you do not need to subclass this method. + +**Example:** +````javascript +loaded: function(callback) { + this.finishLoading(); + Log.log(this.name + ' is loaded!'); + callback(); +} +```` + ####`start()` This method is called when all modules are loaded an the system is ready to boot up. Keep in mind that the dom object for the module is not yet created. The start method is a perfect place to define any additional module properties: diff --git a/modules/default/newsfeed/fetcher.js b/modules/default/newsfeed/fetcher.js index b7511de9..f4fb44d9 100644 --- a/modules/default/newsfeed/fetcher.js +++ b/modules/default/newsfeed/fetcher.js @@ -85,7 +85,12 @@ 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/)"} - request({uri: url, encoding: null, headers: headers}).pipe(iconv.decodeStream(encoding)).pipe(parser); + request({uri: url, encoding: null, headers: headers}) + .on("error", function(error) { + fetchFailedCallback(self, error); + scheduleTimer(); + }) + .pipe(iconv.decodeStream(encoding)).pipe(parser); }; diff --git a/modules/node_modules/node_helper/index.js b/modules/node_modules/node_helper/index.js index dc57ef36..bdeccf8b 100644 --- a/modules/node_modules/node_helper/index.js +++ b/modules/node_modules/node_helper/index.js @@ -14,6 +14,11 @@ NodeHelper = Class.extend({ console.log("Initializing new module helper ..."); }, + loaded: function(callback) { + console.log("Module helper loaded: " + this.name); + callback(); + }, + start: function() { console.log("Staring module helper: " + this.name); }, diff --git a/package.json b/package.json index 118c9837..54c60f92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "magicmirror", - "version": "2.1.0", + "version": "2.1.1", "description": "A modular interface for smart mirrors.", "main": "js/electron.js", "scripts": { From 4bb3d33907816b139e4fc4a3a174c17d12ea275d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Ram=C3=ADrez=20Norambuena?= Date: Wed, 11 Jan 2017 10:22:13 -0300 Subject: [PATCH 25/32] add choice to use pm2 for auto starting of MagicMirror --- installers/raspberry.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/installers/raspberry.sh b/installers/raspberry.sh index df3994bc..b6ab3435 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -142,10 +142,14 @@ else fi # Use pm2 control like a service MagicMirror -sudo npm install -g pm2 -sudo su -c "env PATH=$PATH:/usr/bin pm2 startup linux -u pi --hp /home/pi" -pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json -pm2 save +read -p "Do you want use pm2 for auto starting of your MagicMirror (y/n)?" choice +if [[ $choice =~ ^[Yy]$ ]] +then + sudo npm install -g pm2 + sudo su -c "env PATH=$PATH:/usr/bin pm2 startup linux -u pi --hp /home/pi" + pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json + pm2 save +fi echo " " echo -e "\e[92mWe're ready! Run \e[1m\e[97mDISPLAY=:0 npm start\e[0m\e[92m from the ~/MagicMirror directory to start your MagicMirror.\e[0m" From d542c063d7e7fd4165bf31de6084c34ec67dd50d Mon Sep 17 00:00:00 2001 From: IgniparousTempest Date: Wed, 11 Jan 2017 21:42:31 +0200 Subject: [PATCH 26/32] Updated CHANGELOG.md to include Afrikkans translation --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9551b79..b5573bc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.1.1] - Unreleased + +### Added +- Add loaded function to modules, providing an async callback. +- Afrikaans translation. + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` From 07d5b0774833110197f638fb04fbc5249f99e15c Mon Sep 17 00:00:00 2001 From: Courtney Pitcher Date: Wed, 11 Jan 2017 21:48:33 +0200 Subject: [PATCH 27/32] Update Changelog.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a3b4dd3..982ecf4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Update .gitignore to not ignore default modules folder. - Remove white flash on boot up. + ## [2.1.0] - 2016-12-31 **Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` From 6d1b0ae498f38e9efee66a32db935ca7f01f3695 Mon Sep 17 00:00:00 2001 From: Greg Dev Date: Thu, 12 Jan 2017 01:33:13 +0100 Subject: [PATCH 28/32] Add Polish translation for UPDATE_INFO --- translations/pl.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translations/pl.json b/translations/pl.json index 7a47745b..06bf3b5c 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -24,10 +24,10 @@ "W": "W", "WNW": "WNW", "NW": "NW", - "NNW": "NNW" - + "NNW": "NNW", + /* UPDATE INFO */ "UPDATE_NOTIFICATION": "Dostępna jest aktualizacja MagicMirror².", "UPDATE_NOTIFICATION_MODULE": "Dostępna jest aktualizacja modułu MODULE_NAME.", - "UPDATE_INFO": "The current installation is COMMIT_COUNT behind on the BRANCH_NAME branch." + "UPDATE_INFO": "Zainstalowana wersja odbiega o COMMIT_COUNT commitów od gałęzi BRANCH_NAME." } From 3cea6e5d0cea7b4e927e7182c29d0b0b1b1f01f3 Mon Sep 17 00:00:00 2001 From: Alex Barcelo Date: Thu, 12 Jan 2017 09:58:02 +0100 Subject: [PATCH 29/32] Add apt-get update in raspberry.sh script Just tried this script and realized that it is likely that it will fail because the apt index is not up to date. The trivial fix seems to be to add an `apt-get update` before the package installation. It should be harmless also. --- installers/raspberry.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/installers/raspberry.sh b/installers/raspberry.sh index b970d02e..e91c2850 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -36,6 +36,10 @@ fi function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } function command_exists () { type "$1" &> /dev/null ;} +# Update before first apt-get +echo -e "\e[96mUpdating packages ...\e[90m" +sudo apt-get update || exit + # Installing helper tools echo -e "\e[96mInstalling helper tools ...\e[90m" sudo apt-get install curl wget git build-essential unzip || exit From af85ef8cfbd2aaf99556302e5834500b6bacb997 Mon Sep 17 00:00:00 2001 From: Alex Barcelo Date: Thu, 12 Jan 2017 17:15:58 +0100 Subject: [PATCH 30/32] removing unnecessary exit, leaving a warning --- installers/raspberry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installers/raspberry.sh b/installers/raspberry.sh index e91c2850..3ba16795 100644 --- a/installers/raspberry.sh +++ b/installers/raspberry.sh @@ -38,7 +38,7 @@ function command_exists () { type "$1" &> /dev/null ;} # Update before first apt-get echo -e "\e[96mUpdating packages ...\e[90m" -sudo apt-get update || exit +sudo apt-get update || echo -e "\e[91mUpdate failed, carrying on installation ...\e[90m" # Installing helper tools echo -e "\e[96mInstalling helper tools ...\e[90m" From ab9e0f891ab035904c733b7085a30fa9f7b71ba2 Mon Sep 17 00:00:00 2001 From: Alex Barcelo Date: Thu, 12 Jan 2017 17:25:33 +0100 Subject: [PATCH 31/32] updating CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b061f6f..aead7517 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Update .gitignore to not ignore default modules folder. - Remove white flash on boot up. +- Added `update` in Raspberry Pi installation script. ## [2.1.0] - 2016-12-31 From 2f7be0559a00a65071a133388d82978ac58cea9a Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Sat, 14 Jan 2017 19:31:24 +0100 Subject: [PATCH 32/32] Switch to rrule-alt. Issue: #565 --- CHANGELOG.md | 7 +++++-- modules/default/calendar/vendor/ical.js/node-ical.js | 2 +- package.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a06df56..09c1d13d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,13 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). ## [2.1.1] - Unreleased -- Make mouse events pass through the region fullscreen_above to modules below. + +**Note:** This update uses new dependencies. Please update using the following command: `git pull && npm install` ### Changed - Installer: Use init config.js from config.js.sample. +- Switched out `rrule` package for `rrule-alt` in order to improve calendar issues. (Experimental: [#565](https://github.com/MichMich/MagicMirror/issues/565)) +- Make mouse events pass through the region fullscreen_above to modules below. ### Added - Add loaded function to modules, providing an async callback. @@ -136,7 +139,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Added reference to Italian Translation. -- Added the missing NE translation to all languages. [#334](https://github.com/MichMich/MagicMirror/issues/344) +- Added the missing NE translation to all languages. [#565](https://github.com/MichMich/MagicMirror/issues/344) - Added proper User-Agent string to calendar call. ### Changed diff --git a/modules/default/calendar/vendor/ical.js/node-ical.js b/modules/default/calendar/vendor/ical.js/node-ical.js index 2f6ef3ef..e2c4a319 100644 --- a/modules/default/calendar/vendor/ical.js/node-ical.js +++ b/modules/default/calendar/vendor/ical.js/node-ical.js @@ -17,7 +17,7 @@ exports.parseFile = function(filename){ } -var rrule = require('rrule').RRule +var rrule = require('rrule-alt').RRule ical.objectHandlers['RRULE'] = function(val, params, curr, stack, line){ curr.rrule = line; diff --git a/package.json b/package.json index 54c60f92..37ebbf0f 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "iconv-lite": "latest", "moment": "latest", "request": "^2.78.0", - "rrule": "latest", + "rrule-alt": "^2.2.3", "simple-git": "^1.62.0", "socket.io": "^1.5.1", "valid-url": "latest",