Merge branch 'develop' into weather-refactor

This commit is contained in:
Michael Teeuw 2017-10-18 11:59:29 +02:00
commit d567fd4842
31 changed files with 208 additions and 43 deletions

View File

@ -5,7 +5,7 @@
"max-len": ["error", 250], "max-len": ["error", 250],
"curly": "error", "curly": "error",
"camelcase": ["error", {"properties": "never"}], "camelcase": ["error", {"properties": "never"}],
"no-trailing-spaces": ["error"], "no-trailing-spaces": ["error", {"ignoreComments": false }],
"no-irregular-whitespace": ["error"] "no-irregular-whitespace": ["error"]
}, },
"env": { "env": {

View File

@ -7,12 +7,22 @@ This project adheres to [Semantic Versioning](http://semver.org/).
**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`
### Changed ### Changed
- calender week is now handled with a variable translation in order to move number language specific
### Added ### Added
- Add option to use [Nunjucks](https://mozilla.github.io/nunjucks/) templates in modules. (See `helloworld` module as an example.) - Add option to use [Nunjucks](https://mozilla.github.io/nunjucks/) templates in modules. (See `helloworld` module as an example.)
- Add Bulgarian translations for MagicMirror² and Alert module.
- Add graceful shutdown of modules by calling `stop` function of each `node_helper` on SIGINT before exiting.
- Link update subtext to Github diff of current version versus tracking branch.
- Add Catalan translation.
### Updated ### Updated
### Fixed
- Fixed issue with calendar module showing more than `maximumEntries` allows
- WeatherForecast and CurrentWeather are now using HTTPS instead of HTTP
- Correcting translation for Indonesian language
## [2.1.3] - 2017-10-01 ## [2.1.3] - 2017-10-01
**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`

View File

@ -122,7 +122,7 @@ The following properties can be configured:
| **Option** | **Description** | | **Option** | **Description** |
| --- | --- | | --- | --- |
| `port` | The port on which the MagicMirror² server will run on. The default value is `8080`. | | `port` | The port on which the MagicMirror² server will run on. The default value is `8080`. |
| `address` | The ip address the accept connections. The default open bind `::` is IPv6 is available or `0.0.0.0` IPv4 run on. Example config: `192.168.10.100`. | | `address` | The ip address the accept connections. The default open bind `localhost`. Example config: `192.168.10.100`. |
| `ipWhitelist` | The list of IPs from which you are allowed to access the MagicMirror². The default value is `["127.0.0.1", "::ffff:127.0.0.1", "::1"]`. It is possible to specify IPs with subnet masks (`["127.0.0.1", "127.0.0.1/24"]`) or define ip ranges (`["127.0.0.1", ["192.168.0.1", "192.168.0.100"]]`). Set `[]` to allow all IP addresses. For more information about how configure this directive see the [follow post ipWhitelist HowTo](https://forum.magicmirror.builders/topic/1326/ipwhitelist-howto) | | `ipWhitelist` | The list of IPs from which you are allowed to access the MagicMirror². The default value is `["127.0.0.1", "::ffff:127.0.0.1", "::1"]`. It is possible to specify IPs with subnet masks (`["127.0.0.1", "127.0.0.1/24"]`) or define ip ranges (`["127.0.0.1", ["192.168.0.1", "192.168.0.100"]]`). Set `[]` to allow all IP addresses. For more information about how configure this directive see the [follow post ipWhitelist HowTo](https://forum.magicmirror.builders/topic/1326/ipwhitelist-howto) |
| `zoom` | This allows to scale the mirror contents with a given zoom factor. The default value is `1.0`| | `zoom` | This allows to scale the mirror contents with a given zoom factor. The default value is `1.0`|
| `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`. | | `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`. |

View File

@ -236,6 +236,33 @@ var App = function() {
}); });
}); });
}; };
/* stop()
* This methods stops the core app.
* This calls each node_helper's STOP() function, if it exists.
* Added to fix #1056
*/
this.stop = function() {
for (var h in nodeHelpers) {
var nodeHelper = nodeHelpers[h];
if (typeof nodeHelper.stop === "function") {
nodeHelper.stop();
}
}
};
/* Listen for SIGINT signal and call stop() function.
*
* Added to fix #1056
* Note: this is only used if running `server-only`. Otherwise
* this.stop() is called by app.on("before-quit"... in `electron.js`
*/
process.on("SIGINT", () => {
console.log("[SIGINT] Received. Shutting down server...");
setTimeout(() => { process.exit(0); }, 3000); // Force quit after 3 seconds
this.stop();
process.exit(0);
});
}; };
module.exports = new App(); module.exports = new App();

View File

@ -96,6 +96,20 @@ app.on("activate", function() {
} }
}); });
/* This method will be called when SIGINT is received and will call
* each node_helper's stop function if it exists. Added to fix #1056
*
* Note: this is only used if running Electron. Otherwise
* core.stop() is called by process.on("SIGINT"... in `app.js`
*/
app.on("before-quit", (event) => {
console.log("Shutting down server...");
event.preventDefault();
setTimeout(() => { process.exit(0); }, 3000); // Force-quit after 3 seconds.
core.stop();
process.exit(0);
});
// Start the core application if server is run on localhost // Start the core application if server is run on localhost
// This starts all node helpers and starts the webserver. // This starts all node helpers and starts the webserver.
if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].indexOf(config.address) > -1) { if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].indexOf(config.address) > -1) {

View File

@ -89,6 +89,10 @@ var Module = Class.extend({
if (/^.*(\.html)$/.test(template)) { if (/^.*(\.html)$/.test(template)) {
// the template is a filename // the template is a filename
this.nunjucksEnvironment().render(template, templateData, function (err, res) { this.nunjucksEnvironment().render(template, templateData, function (err, res) {
if (err) {
Log.error(err)
}
// The inner content of the div will be set after the template is received. // The inner content of the div will be set after the template is received.
// This isn't the most optimal way, but since it's near instant // This isn't the most optimal way, but since it's near instant
// it probably won't be an issue. // it probably won't be an issue.
@ -156,7 +160,7 @@ var Module = Class.extend({
/** nunjucksEnvironment() /** nunjucksEnvironment()
* Returns the nunjucks environment for the current module. * Returns the nunjucks environment for the current module.
* The environment is checked in the _nunjucksEnvironment instance variable. * The environment is checked in the _nunjucksEnvironment instance variable.
*
* @returns Nunjucks Environment * @returns Nunjucks Environment
*/ */
nunjucksEnvironment: function() { nunjucksEnvironment: function() {

View File

@ -555,6 +555,17 @@ start: function() {
} }
```` ````
#### `stop()`
This method is called when the MagicMirror server receives a `SIGINT` command and is shutting down. This method should include any commands needed to close any open connections, stop any sub-processes and gracefully exit the module.
**Example:**
````javascript
stop: function() {
console.log("Shutting down MyModule");
this.connection.close();
}
````
#### `socketNotificationReceived: function(notification, payload)` #### `socketNotificationReceived: function(notification, payload)`
With this method, your node helper can receive notifications from your modules. When this method is called, it has 2 arguments: With this method, your node helper can receive notifications from your modules. When this method is called, it has 2 arguments:

View File

@ -0,0 +1,4 @@
{
"sysTitle": "MagicMirror нотификация",
"welcome": "Добре дошли, стартирането беше успешно"
}

View File

@ -356,7 +356,7 @@ Module.register("calendar", {
return a.startDate - b.startDate; return a.startDate - b.startDate;
}); });
return events; return events.slice(0, this.config.maximumEntries);
}, },
/* createEventList(url) /* createEventList(url)

View File

@ -94,7 +94,7 @@ Module.register("clock",{
dateWrapper.innerHTML = now.format(this.config.dateFormat); dateWrapper.innerHTML = now.format(this.config.dateFormat);
} }
if (this.config.showWeek) { if (this.config.showWeek) {
weekWrapper.innerHTML = this.translate("WEEK") + " " + now.week(); weekWrapper.innerHTML = this.translate("WEEK", { weekNumber: now.week() });
} }
timeWrapper.innerHTML = timeString; timeWrapper.innerHTML = timeString;
secondsWrapper.innerHTML = now.format("ss"); secondsWrapper.innerHTML = now.format("ss");

View File

@ -33,7 +33,7 @@ Module.register("currentweather",{
retryDelay: 2500, retryDelay: 2500,
apiVersion: "2.5", apiVersion: "2.5",
apiBase: "http://api.openweathermap.org/data/", apiBase: "https://api.openweathermap.org/data/",
weatherEndpoint: "weather", weatherEndpoint: "weather",
appendLocationNameToHeader: true, appendLocationNameToHeader: true,

View File

@ -64,7 +64,10 @@ module.exports = NodeHelper.create({
sg.git.fetch().status(function(err, data) { sg.git.fetch().status(function(err, data) {
data.module = sg.module; data.module = sg.module;
if (!err) { if (!err) {
self.sendSocketNotification("STATUS", data); sg.git.log({"-1": null}, function(err, data2) {
data.hash = data2.latest.hash;
self.sendSocketNotification("STATUS", data);
});
} }
}); });
}); });

View File

@ -34,6 +34,17 @@ Module.register("updatenotification", {
} }
}, },
diffLink: function(text) {
var localRef = this.status.hash;
var remoteRef = this.status.tracking.replace(/.*\//, "");
return "<a href=\"https://github.com/MichMich/MagicMirror/compare/"+localRef+"..."+remoteRef+"\" "+
"class=\"xsmall dimmed\" "+
"style=\"text-decoration: none;\" "+
"target=\"_blank\" >" +
text +
"</a>";
},
// Override dom generator. // Override dom generator.
getDom: function () { getDom: function () {
var wrapper = document.createElement("div"); var wrapper = document.createElement("div");
@ -47,9 +58,14 @@ Module.register("updatenotification", {
icon.innerHTML = "&nbsp;"; icon.innerHTML = "&nbsp;";
message.appendChild(icon); message.appendChild(icon);
var subtextHtml = this.translate("UPDATE_INFO")
.replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits"))
.replace("BRANCH_NAME", this.status.current);
var text = document.createElement("span"); var text = document.createElement("span");
if (this.status.module == "default") { if (this.status.module == "default") {
text.innerHTML = this.translate("UPDATE_NOTIFICATION"); text.innerHTML = this.translate("UPDATE_NOTIFICATION");
subtextHtml = this.diffLink(subtextHtml);
} else { } else {
text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE").replace("MODULE_NAME", this.status.module); text.innerHTML = this.translate("UPDATE_NOTIFICATION_MODULE").replace("MODULE_NAME", this.status.module);
} }
@ -58,9 +74,7 @@ Module.register("updatenotification", {
wrapper.appendChild(message); wrapper.appendChild(message);
var subtext = document.createElement("div"); var subtext = document.createElement("div");
subtext.innerHTML = this.translate("UPDATE_INFO") subtext.innerHTML = subtextHtml;
.replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits"))
.replace("BRANCH_NAME", this.status.current);
subtext.className = "xsmall dimmed"; subtext.className = "xsmall dimmed";
wrapper.appendChild(subtext); wrapper.appendChild(subtext);
} }

View File

@ -30,7 +30,7 @@ Module.register("weatherforecast",{
retryDelay: 2500, retryDelay: 2500,
apiVersion: "2.5", apiVersion: "2.5",
apiBase: "http://api.openweathermap.org/data/", apiBase: "https://api.openweathermap.org/data/",
forecastEndpoint: "forecast/daily", forecastEndpoint: "forecast/daily",
appendLocationNameToHeader: true, appendLocationNameToHeader: true,

View File

@ -23,6 +23,16 @@ NodeHelper = Class.extend({
console.log("Starting module helper: " + this.name); console.log("Starting module helper: " + this.name);
}, },
/* stop()
* Called when the MagicMirror server receives a `SIGINT`
* Close any open connections, stop any sub-processes and
* gracefully exit the module.
*
*/
stop: function() {
console.log("Stopping module helper: " + this.name);
},
/* socketNotificationReceived(notification, payload) /* socketNotificationReceived(notification, payload)
* This method is called when a socket notification arrives. * This method is called when a socket notification arrives.
* *

32
translations/bg.json Normal file
View File

@ -0,0 +1,32 @@
{
"LOADING": "Зареждане &hellip;",
"TODAY": "Днес",
"TOMORROW": "Утре",
"DAYAFTERTOMORROW": "Вдругиден",
"RUNNING": "Свършва на",
"EMPTY": "Няма предстоящи събития.",
"WEEK": "Седмица {weekNumber}",
"N": "С",
"NNE": "ССИ",
"NE": "СИ",
"ENE": "ИСИ",
"E": "И",
"ESE": "ИЮИ",
"SE": "ЮИ",
"SSE": "ЮЮИ",
"S": "Ю",
"SSW": "ЮЮЗ",
"SW": "ЮЗ",
"WSW": "ЗЮЗ",
"W": "З",
"WNW": "ЗСЗ",
"NW": "СЗ",
"NNW": "ССЗ",
"UPDATE_NOTIFICATION": "Налична актуализация за MagicMirror².",
"UPDATE_NOTIFICATION_MODULE": "Налична актуализация за MODULE_NAME модул.",
"UPDATE_INFO": "Текущата инсталация е изостанала с COMMIT_COUNT къмита на клон BRANCH_NAME."
}

32
translations/ca.json Normal file
View File

@ -0,0 +1,32 @@
{
"LOADING": "Carregant &hellip;",
"TODAY": "Avui",
"TOMORROW": "Demà",
"DAYAFTERTOMORROW": "Demà passat",
"RUNNING": "Acaba en",
"EMPTY": "No hi ha esdeveniments programats.",
"WEEK": "Setmana",
"N": "N",
"NNE": "NNE",
"NE": "NE",
"ENE": "ENE",
"E": "E",
"ESE": "ESE",
"SE": "SE",
"SSE": "SSE",
"S": "S",
"SSW": "SSO",
"SW": "SO",
"WSW": "OSO",
"W": "O",
"WNW": "ONO",
"NW": "NO",
"NNW": "NNO",
"UPDATE_NOTIFICATION": "MagicMirror² actualizació disponible.",
"UPDATE_NOTIFICATION_MODULE": "Disponible una actualizació per al mòdul MODULE_NAME.",
"UPDATE_INFO": "La teva instal·lació actual està COMMIT_COUNT canvis darrere de la branca BRANCH_NAME."
}

View File

@ -7,7 +7,7 @@
"RUNNING": "Gorffen mewn", "RUNNING": "Gorffen mewn",
"EMPTY": "Dim digwyddiadau.", "EMPTY": "Dim digwyddiadau.",
"WEEK": "Wythnos", "WEEK": "Wythnos {weekNumber}",
"N": "Go", "N": "Go",
"NNE": "GoGoDw", "NNE": "GoGoDw",

View File

@ -7,7 +7,7 @@
"RUNNING": "noch", "RUNNING": "noch",
"EMPTY": "Keine Termine.", "EMPTY": "Keine Termine.",
"WEEK": "Woche", "WEEK": "{weekNumber}. Kalenderwoche",
"N": "N", "N": "N",
"NNE": "NNO", "NNE": "NNO",

View File

@ -7,7 +7,7 @@
"RUNNING": "Ends in", "RUNNING": "Ends in",
"EMPTY": "No upcoming events.", "EMPTY": "No upcoming events.",
"WEEK": "Week", "WEEK": "Week {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",

View File

@ -7,7 +7,7 @@
"RUNNING": "Termina en", "RUNNING": "Termina en",
"EMPTY": "No hay eventos programados.", "EMPTY": "No hay eventos programados.",
"WEEK": "Semana", "WEEK": "Semana {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",

View File

@ -7,7 +7,7 @@
"RUNNING": "Se termine dans", "RUNNING": "Se termine dans",
"EMPTY": "Aucun RDV à venir.", "EMPTY": "Aucun RDV à venir.",
"WEEK": "Semaine", "WEEK": "Semaine {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",

View File

@ -7,24 +7,26 @@
"RUNNING": "Berakhir dalam", "RUNNING": "Berakhir dalam",
"EMPTY": "Tidak ada agenda", "EMPTY": "Tidak ada agenda",
"N": "U", "WEEK": "Pekan",
"NNE": "UUT",
"NE": "NE",
"ENE": "TUT",
"E": "T",
"ESE": "TST",
"SE": "ST",
"SSE": "SST",
"S": "S",
"SSW": "SSB",
"SW": "SB",
"WSW": "BSB",
"W": "B",
"WNW": "BUB",
"NW": "UB",
"NNW": "UUB",
"UPDATE_NOTIFICATION": "Update MagicMirror² tersedia.", "N": "U",
"UPDATE_NOTIFICATION_MODULE": "Update tersedia untuk modul MODULE_NAME.", "NNE": "UTL",
"NE": "TL",
"ENE": "TTL",
"E": "T",
"ESE": "TMg",
"SE": "TG",
"SSE": "SMg",
"S": "S",
"SSW": "SBD",
"SW": "BD",
"WSW": "BBD",
"W": "B",
"WNW": "BBL",
"NW": "BL",
"NNW": "UBL",
"UPDATE_NOTIFICATION": "Memperbarui MagicMirror² tersedia.",
"UPDATE_NOTIFICATION_MODULE": "Memperbarui tersedia untuk modul MODULE_NAME.",
"UPDATE_INFO": "Instalasi saat ini tertinggal COMMIT_COUNT pada cabang BRANCH_NAME." "UPDATE_INFO": "Instalasi saat ini tertinggal COMMIT_COUNT pada cabang BRANCH_NAME."
} }

View File

@ -7,7 +7,7 @@
"RUNNING": "Slutter om", "RUNNING": "Slutter om",
"EMPTY": "Ingen kommende arrangementer.", "EMPTY": "Ingen kommende arrangementer.",
"WEEK": "Uke", "WEEK": "Uke {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNØ", "NNE": "NNØ",

View File

@ -7,7 +7,7 @@
"RUNNING": "Koniec za", "RUNNING": "Koniec za",
"EMPTY": "Brak wydarzeń.", "EMPTY": "Brak wydarzeń.",
"WEEK": "Tydzień", "WEEK": "Tydzień {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",

View File

@ -6,7 +6,7 @@
"RUNNING": "Termina em", "RUNNING": "Termina em",
"EMPTY": "Sem eventos programados.", "EMPTY": "Sem eventos programados.",
"WEEK": "Semana", "WEEK": "Semana {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",

View File

@ -7,7 +7,7 @@
"RUNNING": "Se termină în", "RUNNING": "Se termină în",
"EMPTY": "Nici un eveniment.", "EMPTY": "Nici un eveniment.",
"WEEK": "Săptămâna", "WEEK": "Săptămâna {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNE", "NNE": "NNE",

View File

@ -7,7 +7,7 @@
"RUNNING": "Заканчивается через", "RUNNING": "Заканчивается через",
"EMPTY": "Нет предстоящих событий", "EMPTY": "Нет предстоящих событий",
"WEEK": "Неделя", "WEEK": "Неделя {weekNumber}",
"N": "С", "N": "С",
"NNE": "ССВ", "NNE": "ССВ",

View File

@ -7,7 +7,7 @@
"RUNNING": "Slutar", "RUNNING": "Slutar",
"EMPTY": "Inga kommande händelser.", "EMPTY": "Inga kommande händelser.",
"WEEK": "Vecka", "WEEK": "Vecka {weekNumber}",
"N": "N", "N": "N",
"NNE": "NNO", "NNE": "NNO",

View File

@ -13,6 +13,7 @@ var translations = {
"fr" : "translations/fr.json", // French "fr" : "translations/fr.json", // French
"fy" : "translations/fy.json", // Frysk "fy" : "translations/fy.json", // Frysk
"es" : "translations/es.json", // Spanish "es" : "translations/es.json", // Spanish
"ca" : "translations/ca.json", // Catalan
"nb" : "translations/nb.json", // Norsk bokmål "nb" : "translations/nb.json", // Norsk bokmål
"nn" : "translations/nn.json", // Norsk nynorsk "nn" : "translations/nn.json", // Norsk nynorsk
"pt" : "translations/pt.json", // Português "pt" : "translations/pt.json", // Português
@ -34,7 +35,8 @@ var translations = {
"et" : "translations/et.json", // Estonian "et" : "translations/et.json", // Estonian
"kr" : "translations/kr.json", // Korean "kr" : "translations/kr.json", // Korean
"ro" : "translations/ro.json", // Romanian "ro" : "translations/ro.json", // Romanian
"cy" : "translations/cy.json" // Welsh (Cymraeg) "cy" : "translations/cy.json", // Welsh (Cymraeg)
"bg" : "translations/bg.json" // Bulgarian
}; };
if (typeof module !== "undefined") {module.exports = translations;} if (typeof module !== "undefined") {module.exports = translations;}