Merge branch 'develop' of https://github.com/nhubbard/MagicMirror into develop

This merge is necessary to make Git happy.
This commit is contained in:
Nicholas Hubbard 2017-01-14 15:34:23 -05:00
commit a459f8b84c
No known key found for this signature in database
GPG Key ID: D5C5AC27D251DC4A
22 changed files with 314 additions and 38 deletions

1
.gitignore vendored
View File

@ -59,6 +59,7 @@ Temporary Items
# Ignore all modules except the default modules. # Ignore all modules except the default modules.
/modules/** /modules/**
!/modules/default
!/modules/default/** !/modules/default/**
!/modules/README.md** !/modules/README.md**

View File

@ -2,6 +2,27 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## [2.1.1] - Unreleased
**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.
- 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
- Russian Translation
- Afrikaans Translation
### 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 ## [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`
@ -118,7 +139,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed ### Fixed
- Added reference to Italian Translation. - 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. - Added proper User-Agent string to calendar call.
### Changed ### Changed

View File

@ -1,7 +1,7 @@
The MIT License (MIT) The MIT License (MIT)
===================== =====================
Copyright © 2016 Michael Teeuw Copyright © 2016-2017 Michael Teeuw
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation

View File

@ -19,7 +19,7 @@ MagicMirror² focuses on a modular plugin system and uses [Electron](http://elec
- [Configuration](#configuration) - [Configuration](#configuration)
- [Modules](#modules) - [Modules](#modules)
- [Known Issues](#known-issues) - [Known Issues](#known-issues)
- [community](#community) - [Community](#community)
- [Contributing Guidelines](#contributing-guidelines) - [Contributing Guidelines](#contributing-guidelines)
## Usage ## Usage

View File

@ -135,6 +135,11 @@ sup {
left: -60px; left: -60px;
right: -60px; right: -60px;
bottom: -60px; bottom: -60px;
pointer-events: none;
}
.region.fullscreen * {
pointer-events: auto;
} }
.region.right { .region.right {

2
installers/mm.sh Executable file
View File

@ -0,0 +1,2 @@
cd ~/MagicMirror
DISPLAY=:0 npm start

View File

@ -0,0 +1,7 @@
{
apps : [{
name : "MagicMirror",
script : "/home/pi/MagicMirror/installer/mm.sh",
watch : ["/home/pi/MagicMirror/config/config.js"]
}]
}

View File

@ -36,6 +36,10 @@ fi
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; }
function command_exists () { type "$1" &> /dev/null ;} function command_exists () { type "$1" &> /dev/null ;}
# Update before first apt-get
echo -e "\e[96mUpdating packages ...\e[90m"
sudo apt-get update || echo -e "\e[91mUpdate failed, carrying on installation ...\e[90m"
# Installing helper tools # Installing helper tools
echo -e "\e[96mInstalling helper tools ...\e[90m" echo -e "\e[96mInstalling helper tools ...\e[90m"
sudo apt-get install curl wget git build-essential unzip || exit sudo apt-get install curl wget git build-essential unzip || exit
@ -113,6 +117,9 @@ else
exit; exit;
fi 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. # Check if plymouth is installed (default with PIXEL desktop environment), then install custom splashscreen.
echo -e "\e[96mCheck plymouth installation ...\e[0m" echo -e "\e[96mCheck plymouth installation ...\e[0m"
if command_exists plymouth; then if command_exists plymouth; then
@ -141,6 +148,16 @@ else
echo -e "\e[93mplymouth is not installed.\e[0m"; echo -e "\e[93mplymouth is not installed.\e[0m";
fi fi
# Use pm2 control like a service MagicMirror
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 " "
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 -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 " " echo " "

View File

@ -66,7 +66,7 @@ var App = function() {
* *
* argument module string - The name of the module (including subpath). * argument module string - The name of the module (including subpath).
*/ */
var loadModule = function(module) { var loadModule = function(module, callback) {
var elements = module.split("/"); var elements = module.split("/");
var moduleName = elements[elements.length - 1]; var moduleName = elements[elements.length - 1];
@ -103,6 +103,10 @@ var App = function() {
m.setName(moduleName); m.setName(moduleName);
m.setPath(path.resolve(moduleFolder)); m.setPath(path.resolve(moduleFolder));
nodeHelpers.push(m); 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). * argument module string - The name of the module (including subpath).
*/ */
var loadModules = function(modules) { var loadModules = function(modules, callback) {
console.log("Loading module helpers ..."); console.log("Loading module helpers ...");
for (var m in modules) { var loadNextModule = function() {
loadModule(modules[m]); 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) /* 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) { for (var h in nodeHelpers) {
console.log("Server started ..."); var nodeHelper = nodeHelpers[h];
nodeHelper.setExpressApp(app);
nodeHelper.setSocketIO(io);
nodeHelper.start();
}
for (var h in nodeHelpers) { console.log("Sockets connected & modules started ...");
var nodeHelper = nodeHelpers[h];
nodeHelper.setExpressApp(app);
nodeHelper.setSocketIO(io);
nodeHelper.start();
}
console.log("Sockets connected & modules started ..."); if (typeof callback === "function") {
callback(config);
if (typeof callback === "function") { }
callback(config);
}
});
}); });
}); });
}; };

View File

@ -28,7 +28,8 @@ function createWindow() {
webPreferences: { webPreferences: {
nodeIntegration: false, nodeIntegration: false,
zoomFactor: config.zoom zoomFactor: config.zoom
} },
backgroundColor: "#000000"
} }
// DEPRECATED: "kioskmode" backwards compatibility, to be removed // DEPRECATED: "kioskmode" backwards compatibility, to be removed

View File

@ -96,6 +96,21 @@ requiresVersion: "2.1.0",
####`init()` ####`init()`
This method is called when a module gets instantiated. In most cases you do not need to subclass this method. 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()` ####`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: 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:

View File

@ -0,0 +1,4 @@
{
"sysTitle": "MagicMirror Уведомление",
"welcome": "Добро пожаловать, старт был успешным!""
}

View File

@ -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){ ical.objectHandlers['RRULE'] = function(val, params, curr, stack, line){
curr.rrule = line; curr.rrule = line;

View File

@ -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:

View File

@ -85,7 +85,12 @@ var Fetcher = function(url, reloadInterval, encoding) {
nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]); 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/)"}
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);
}; };

View File

@ -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",{
} }
var title = document.createElement("div"); if(!this.config.showFullArticle){
title.className = "bright medium light"; var title = document.createElement("div");
title.innerHTML = this.newsItems[this.activeItem].title; title.className = "bright medium light";
wrapper.appendChild(title); title.innerHTML = this.newsItems[this.activeItem].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);
}
},
}); });

View File

@ -14,6 +14,11 @@ NodeHelper = Class.extend({
console.log("Initializing new module helper ..."); console.log("Initializing new module helper ...");
}, },
loaded: function(callback) {
console.log("Module helper loaded: " + this.name);
callback();
},
start: function() { start: function() {
console.log("Staring module helper: " + this.name); console.log("Staring module helper: " + this.name);
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "magicmirror", "name": "magicmirror",
"version": "2.1.0", "version": "2.1.1",
"description": "A modular interface for smart mirrors.", "description": "A modular interface for smart mirrors.",
"main": "js/electron.js", "main": "js/electron.js",
"scripts": { "scripts": {
@ -45,7 +45,7 @@
"iconv-lite": "latest", "iconv-lite": "latest",
"moment": "latest", "moment": "latest",
"request": "^2.78.0", "request": "^2.78.0",
"rrule": "latest", "rrule-alt": "^2.2.3",
"simple-git": "^1.62.0", "simple-git": "^1.62.0",
"socket.io": "^1.5.1", "socket.io": "^1.5.1",
"valid-url": "latest", "valid-url": "latest",

34
translations/af.json Normal file
View File

@ -0,0 +1,34 @@
{
/* GENERAL */
"LOADING": "Besig om te laai &hellip;",
/* 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."
}

View File

@ -24,10 +24,10 @@
"W": "W", "W": "W",
"WNW": "WNW", "WNW": "WNW",
"NW": "NW", "NW": "NW",
"NNW": "NNW" "NNW": "NNW",
/* UPDATE INFO */ /* UPDATE INFO */
"UPDATE_NOTIFICATION": "Dostępna jest aktualizacja MagicMirror².", "UPDATE_NOTIFICATION": "Dostępna jest aktualizacja MagicMirror².",
"UPDATE_NOTIFICATION_MODULE": "Dostępna jest aktualizacja modułu MODULE_NAME.", "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."
} }

34
translations/ru.json Normal file
View File

@ -0,0 +1,34 @@
{
/* GENERAL */
"LOADING": "Загрузка &hellip;",
/* 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 коммитов."
}

View File

@ -26,4 +26,6 @@ var translations = {
"gr" : "translations/gr.json", // Greek "gr" : "translations/gr.json", // Greek
"da" : "translations/da.json", // Danish "da" : "translations/da.json", // Danish
"tr" : "translations/tr.json", // Turkish "tr" : "translations/tr.json", // Turkish
"ru" : "translations/ru.json", // Russian
"af" : "translations/af.json", // Afrikaans
}; };