Skip to content

Commit

Permalink
Merge pull request #394 from MichMich/develop
Browse files Browse the repository at this point in the history
Release 2.0.4
  • Loading branch information
MichMich committed Aug 7, 2016
2 parents 5d9d71d + f311982 commit cf465a1
Show file tree
Hide file tree
Showing 32 changed files with 7,661 additions and 516 deletions.
15 changes: 14 additions & 1 deletion .snyk
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
version: v1
version: v1.5.2
ignore: {}
patch:
'npm:minimatch:20160620':
- snyk > recursive-readdir > minimatch:
patched: '2016-07-30T14:02:31.280Z'
'npm:negotiator:20160616':
- socket.io > engine.io > accepts > negotiator:
patched: '2016-07-30T14:02:31.280Z'
'npm:ws:20160624':
- socket.io > engine.io > ws:
patched: '2016-07-30T14:02:31.280Z'
- socket.io > socket.io-client > engine.io-client > ws:
patched: '2016-07-30T14:02:31.280Z'
27 changes: 25 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.4] - 2016-08-07

### Added
- Brazilian Portuguese Translation.
- Option to enable Kios mode.
- Added ability to start the app with Dev Tools.
- Added ability to turn off the date display in `clock.js` when in analog mode.
- Greek Translation

### Fixed
- Prevent `getModules()` selectors from returning duplicate entries.
- Append endpoints of weather modules with `/` to retreive the correct data. (Issue [#337](https://github.com/MichMich/MagicMirror/issues/337))
- Corrected grammer in `module.js` from 'suspend' to 'suspended'.
- Fixed openweathermap.org URL in config sample.
- Prevent currentweather module from crashing when received data object is incorrect.
- Fix issue where translation loading prevented the UI start-up when the language was set to 'en'. (Issue [#388](https://github.com/MichMich/MagicMirror/issues/388))

### Updated
- Updated package.json to fix possible vulnerabilities. (Using Snyk)
- Updated weathericons
- Updated default weatherforecast to work with the new icons.
- More detailed error message in case config file couldn't be loaded.

## [2.0.3] - 2016-07-12
### Added
- Add max newsitems parameter to the newsfeed module.
Expand All @@ -10,8 +33,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Add an analog clock in addition to the digital one.

### Fixed
- Edit Alert Module to display title & message if they are provided in the notification (Issue #300)
- Removed 'null' reference from updateModuleContent(). This fixes recent Edge and Internet Explorer browser displays (Issue #319)
- Edit Alert Module to display title & message if they are provided in the notification (Issue [#300](https://github.com/MichMich/MagicMirror/issues/300))
- Removed 'null' reference from updateModuleContent(). This fixes recent Edge and Internet Explorer browser displays (Issue [#319](https://github.com/MichMich/MagicMirror/issues/319))

### Changed
- Added default string to calendar titleReplace.
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<a href="https://snyk.io/test/github/MichMich/MagicMirror"><img src="https://snyk.io/test/github/MichMich/MagicMirror/badge.svg" alt="Known Vulnerabilities" data-canonical-src="https://snyk.io/test/github/MichMich/MagicMirror" style="max-width:100%;"></a>
</p>

**MagicMirror²** is an open source modular smart mirror platform. With a growing list of installable modules, the **MagicMirror²** allows you to convert your hallway or bathroom mirror into your personal assistant. **MagicMirror²** is built by the creator of [the original MagicMirror](http://michaelteeuw.nl/tagged/magicmirror) with the incredible help of a [growing community of contributors](https://github.com/MichMich/MagicMirror/graphs/contributors).
**MagicMirror²** is an open source modular smart mirror platform. With a growing list of installable modules, the **MagicMirror²** allows you to convert your hallway or bathroom mirror into your personal assistant. **MagicMirror²** is built by the creator of [the original MagicMirror](http://michaelteeuw.nl/tagged/magicmirror) with the incredible help of a [growing community of contributors](https://github.com/MichMich/MagicMirror/graphs/contributors).

MagicMirror² focuses on a modular plugin system and uses [Electron](http://electron.atom.io/) as an application wrapper. So no more web server or browser installs necessary!

Expand All @@ -22,7 +22,7 @@ MagicMirror² focuses on a modular plugin system and uses [Electron](http://elec
- [community](#community)
- [Contributing Guidelines](#contributing-guidelines)

## Usage
## Usage

#### Raspberry Pi Support
Electron, the app wrapper around MagicMirror², only supports the Raspberry Pi 2 & 3. The Raspberry Pi 1 is currently **not** supported. If you want to run this on a Raspberry Pi 1, use the [server only](#server-only) feature and setup a fullscreen browser yourself.
Expand All @@ -43,6 +43,8 @@ curl -sL https://raw.githubusercontent.com/MichMich/MagicMirror/master/installer

**Important:** `npm start` does **not** work via SSH, use `DISPLAY=:0 nohup npm start &` instead. This starts the mirror on the remote display.

**Note:** if you want to debug on Raspberry Pi you can use `npm start dev` which will start the MagicMirror app with Dev Tools enabled.

#### Server Only

In some cases, you want to start the application without an actual app window. In this case, execute the following command from the MagicMirror folder: `node serveronly`. This will start the server, after which you can open the application in your browser of choice.
Expand All @@ -59,9 +61,9 @@ If you want to update your MagicMirror² to the latest version, use your termina

````
git pull
````
````

If you changed nothing more than the config or the modules, this should work without any problems.
If you changed nothing more than the config or the modules, this should work without any problems.
Type `git status` to see your changes, if there are any, you can reset them with `git reset --hard`. After that, git pull should be possible.

## Configuration
Expand All @@ -75,6 +77,7 @@ The following properties can be configured:
| **Option** | **Description** |
| --- | --- |
| `port` | The port on which the MagicMirror² server will run on. The default value is `8080`. |
| `kioskmode` | This allows MagicMirror² to run in Kiosk Mode. It protects from other programs popping on top of your screen. The default value is `false`|
| `language` | The language of the interface. (Note: Not all elements will be localized.) Possible values are `en`, `nl`, `ru`, `fr`, etc., but the default value is `en`. |
| `timeFormat` | The form of time notation that will be used. Possible values are `12` or `24`. The default is `24`. |
| `units` | The units that will be used in the default weather modules. Possible values are `metric` or `imperial`. The default is `metric`. |
Expand Down Expand Up @@ -108,7 +111,7 @@ For more available modules, check out out the wiki page: [MagicMirror² Modules]
## Known issues

- Electron seems to have some issues on certain Raspberry Pi 2's. See [#145](https://github.com/MichMich/MagicMirror/issues/145).
- MagicMirror² (Electron) sometimes quits without an error after an extended period of use. See [#150](https://github.com/MichMich/MagicMirror/issues/150).
- MagicMirror² (Electron) sometimes quits without an error after an extended period of use. See [#150](https://github.com/MichMich/MagicMirror/issues/150).

## Community

Expand All @@ -120,10 +123,9 @@ Contributions of all kinds are welcome, not only in the form of code but also wi

Please keep the following in mind:

- **Bug Reports**: Make sure you're running the latest version. If the issue(s) still persist: please open a clearly documented issue with a clear title.
- **Bug Reports**: Make sure you're running the latest version. If the issue(s) still persist: please open a clearly documented issue with a clear title.
- **Minor Bug Fixes**: Please send a pull request with a clear explanation of the issue or a link to the issue it solves.
- **Major Bug Fixes**: please discuss your approach in an GitHub issue before you start to alter a big part of the code.
- **New Features**: please please discuss in a GitHub issue before you start to alter a big part of the code. Without discussion upfront, the pull request will not be accepted / merged.

Thanks for your help in making MagicMirror² better!

Thanks for your help in making MagicMirror² better!
4 changes: 2 additions & 2 deletions config/config.js.sample
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var config = {
position: 'top_right',
config: {
location: 'New York',
locationID: '', //ID from bulk.openweather.org/sample/
locationID: '', //ID from http://www.openweathermap.org
appid: 'YOUR_OPENWEATHER_API_KEY'
}
},
Expand All @@ -51,7 +51,7 @@ var config = {
header: 'Weather Forecast',
config: {
location: 'New York',
locationID: '5128581', //ID from bulk.openweather.org/sample/
locationID: '5128581', //ID from http://www.openweathermap.org
appid: 'YOUR_OPENWEATHER_API_KEY'
}
},
Expand Down
12 changes: 10 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ var App = function() {
var config = Object.assign(defaults, c);
callback(config);
} catch (e) {
console.error("WARNING! Could not find config. Please create one.");
callback(defaults);
if (e.code == "ENOENT") {
console.error("WARNING! Could not find config file. Please create one. Starting with default configuration.");
callback(defaults);
} else if (e instanceof ReferenceError || e instanceof SyntaxError) {
console.error("WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.");
callback(defaults);
} else {
console.error("WARNING! Could not load config file. Starting with default configuration. Error found: " + e);
callback(defaults);
}
}
};

Expand Down
3 changes: 2 additions & 1 deletion js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

var defaults = {
port: 8080,
kioskmode: false,

language: "en",
timeFormat: 24,
units: "metric",

modules: [
{
module: "helloworld",
Expand Down
12 changes: 9 additions & 3 deletions js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ let mainWindow;

function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600, fullscreen: true, autoHideMenuBar: true, darkTheme: true, webPreferences: {nodeIntegration: false}});
if (config.kioskmode) {
mainWindow = new BrowserWindow({width: 800, height: 600, x: 0, y: 0, kiosk:true, darkTheme: true, webPreferences: {nodeIntegration: false}});
} else {
mainWindow = new BrowserWindow({width: 800, height: 600, x: 0, y: 0, fullscreen: true, autoHideMenuBar: true, darkTheme: true, webPreferences: {nodeIntegration: false}});
}

// and load the index.html of the app.
//mainWindow.loadURL('file://' + __dirname + '../../index.html');
mainWindow.loadURL("http://localhost:" + config.port);

// Open the DevTools.
//mainWindow.webContents.openDevTools();
// Open the DevTools if run with "npm start dev"
if(process.argv[2] == "dev"){
mainWindow.webContents.openDevTools();
}

// Emitted when the window is closed.
mainWindow.on("closed", function() {
Expand Down
45 changes: 17 additions & 28 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* global Log, Loader, Module, config, defaults */
/* jshint -W020 */

/* Magic Mirror
* Main System
Expand Down Expand Up @@ -225,24 +226,23 @@ var MM = (function() {
* return array - Filtered collection of modules.
*/
var withClass = function(className) {
var newModules = [];

var searchClasses = className;
if (typeof className === "string") {
searchClasses = className.split(" ");
}

for (var m in modules) {
var module = modules[m];
var newModules = modules.filter(function(module) {
var classes = module.data.classes.toLowerCase().split(" ");

for (var c in searchClasses) {
var searchClass = searchClasses[c];
if (classes.indexOf(searchClass.toLowerCase()) !== -1) {
newModules.push(module);
return true;
}
}
}

return false;
});

setSelectionMethodsForModules(newModules);
return newModules;
Expand All @@ -256,28 +256,23 @@ var MM = (function() {
* return array - Filtered collection of modules.
*/
var exceptWithClass = function(className) {
var newModules = [];

var searchClasses = className;
if (typeof className === "string") {
searchClasses = className.split(" ");
}

for (var m in modules) {
var module = modules[m];
var newModules = modules.filter(function(module) {
var classes = module.data.classes.toLowerCase().split(" ");
var foundClass = false;

for (var c in searchClasses) {
var searchClass = searchClasses[c];
if (classes.indexOf(searchClass.toLowerCase()) !== -1) {
foundClass = true;
break;
return false;
}
}
if (!foundClass) {
newModules.push(module);
}
}

return true;
});

setSelectionMethodsForModules(newModules);
return newModules;
Expand All @@ -291,14 +286,9 @@ var MM = (function() {
* return array - Filtered collection of modules.
*/
var exceptModule = function(module) {
var newModules = [];

for (var m in modules) {
var mod = modules[m];
if (mod.identifier !== module.identifier) {
newModules.push(mod);
}
}
var newModules = modules.filter(function(mod) {
return mod.identifier !== module.identifier;
});

setSelectionMethodsForModules(newModules);
return newModules;
Expand All @@ -310,10 +300,9 @@ var MM = (function() {
* argument callback function - The function to execute with the module as an argument.
*/
var enumerate = function(callback) {
for (var m in modules) {
var module = modules[m];
modules.map(function(module) {
callback(module);
}
});
};

if (typeof modules.withClass === "undefined") { Object.defineProperty(modules, "withClass", {value: withClass, enumerable: false}); }
Expand Down
4 changes: 2 additions & 2 deletions js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var Module = Class.extend({
* This method is called when a module is hidden.
*/
suspend: function() {
Log.log(this.name + " is suspend.");
Log.log(this.name + " is suspended.");
},

/* resume()
Expand Down Expand Up @@ -247,7 +247,7 @@ var Module = Class.extend({

// If a translation file is set, load it and then also load the fallback translation file.
// Otherwise only load the fallback translation file.
if (translationFile !== undefined) {
if (translationFile !== undefined && translationFile !== translationsFallbackFile) {
Translator.load(self, translationFile, false, function() {
Translator.load(self, translationsFallbackFile, true, callback);
});
Expand Down
7 changes: 7 additions & 0 deletions modules/default/clock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,12 @@ The following properties can be configured:
<br><b>Default value:</b> <code>bottom</code>
</td>
</tr>
<tr>
<td><code>analogShowDate</code></td>
<td><strong>Specific to the analog clock.</strong> 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.<br>
<br><b>Possible values:</b> <code>false</code>, <code>top</code>, or <code>bottom</code>
<br><b>Default value:</b> <code>top</code>
</td>
</tr>
</tbody>
</table>
14 changes: 11 additions & 3 deletions modules/default/clock/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Module.register("clock",{
/* specific to the analog clock */
analogSize: '200px',
analogFace: 'simple', // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive)
analogPlacement: 'bottom', // options: top, bottom, left, right
analogPlacement: 'bottom', // options: 'top', 'bottom', 'left', 'right'
analogShowDate: 'top', // options: false, 'top', or 'bottom'
secondsColor: '#888888',
},
// Define required scripts.
Expand Down Expand Up @@ -170,8 +171,15 @@ Module.register("clock",{
// Display only an analog clock
dateWrapper.style.textAlign = "center";
dateWrapper.style.paddingBottom = "15px";
wrapper.appendChild(dateWrapper);
wrapper.appendChild(clockCircle);
if (this.config.analogShowDate === 'top') {
wrapper.appendChild(dateWrapper);
wrapper.appendChild(clockCircle);
} else if (this.config.analogShowDate === 'bottom') {
wrapper.appendChild(clockCircle);
wrapper.appendChild(dateWrapper);
} else {
wrapper.appendChild(clockCircle);
}
} else {
// Both clocks have been configured, check position
var placement = this.config.analogPlacement;
Expand Down
11 changes: 9 additions & 2 deletions modules/default/currentweather/currentweather.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Module.register("currentweather",{
* Calls processWeather on succesfull response.
*/
updateWeather: function() {
var url = this.config.apiBase + this.config.apiVersion + "/" + this.config.weatherEndpoint + this.getParams();
var url = this.config.apiBase + this.config.apiVersion + "/" + this.config.weatherEndpoint + '/' + this.getParams();
var self = this;
var retry = true;

Expand Down Expand Up @@ -201,7 +201,7 @@ Module.register("currentweather",{
var params = "?";
if(this.config.locationID !== "") {
params += "id=" + this.config.locationID;
} else {
} else {
params += "q=" + this.config.location;
}
params += "&units=" + this.config.units;
Expand All @@ -217,6 +217,13 @@ Module.register("currentweather",{
* argument data object - Weather information received form openweather.org.
*/
processWeather: function(data) {

if (!data || !data.main || !data.main.temp) {
// Did not receive usable new data.
// Maybe this needs a better check?
return;
}

this.temperature = this.roundValue(data.main.temp);

if (this.config.useBeaufort){
Expand Down
Loading

0 comments on commit cf465a1

Please sign in to comment.