Merge branch 'develop' into feature/indoorHumidity

* develop: (71 commits)
  Update sample address
  set version of express-ipfilter:
  Describe default in comment of sample config
  More secure defaults.
  Fix grunt errors
  Weather forecast settings match current weather
  Fix JavaScript error in weatherforecast
  Update fr.json
  TestSuite: Show the missing strings for translations files.
  Update fr.json with added translations
  Added e2e test for font files
  Fix issue #986
  Fix extra tab file translations/zh_cn.json
  Add Changelog entry for new e2e test for helloworld module
  Small change for re-running Travis CI
  Change Two Conditionals to UpperCase-If
  Fix linting?
  Show Scale of Temperature if config flag is set
  Change to install Roboto fonts by npm
  Update stylelint package
  ...

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Ricardo Gonzalez
2017-09-17 16:32:37 +01:00
105 changed files with 1319 additions and 711 deletions

View File

@@ -472,7 +472,7 @@ this.translate("RUNNING", {
{
"RUNNING": "Slutar",
}
````
In this case the `translate`-function will not find any variables in the translation, will look for `fallback` variable and use that if possible to create the translation.
## The Node Helper: node_helper.js

View File

@@ -67,30 +67,7 @@ Module.register("calendar", {
Log.log("Starting module: " + this.name);
// Set locale.
moment.locale(config.language);
switch (config.timeFormat) {
case 12: {
moment.updateLocale(config.language, {
longDateFormat: {
LT: "h:mm A"
}
});
break;
}
case 24: {
moment.updateLocale(config.language, {
longDateFormat: {
LT: "hh:mm"
}
});
break;
}
// If config.timeFormat was not given (or has invalid format) default to locale default
default: {
break;
}
}
moment.updateLocale(config.language, this.getLocaleSpecification(config.timeFormat));
for (var c in this.config.calendars) {
var calendar = this.config.calendars[c];
@@ -102,7 +79,9 @@ Module.register("calendar", {
};
// we check user and password here for backwards compatibility with old configs
if(calendar.user && calendar.pass){
if(calendar.user && calendar.pass) {
Log.warn("Deprecation warning: Please update your calendar authentication configuration.");
Log.warn("https://github.com/MichMich/MagicMirror/tree/v2.1.2/modules/default/calendar#calendar-authentication-options");
calendar.auth = {
user: calendar.user,
pass: calendar.pass
@@ -153,20 +132,6 @@ Module.register("calendar", {
for (var e in events) {
var event = events[e];
var excluded = false;
for (var f in this.config.excludedEvents) {
var filter = this.config.excludedEvents[f];
if (event.title.toLowerCase().includes(filter.toLowerCase())) {
excluded = true;
break;
}
}
if (excluded) {
continue;
}
var eventWrapper = document.createElement("tr");
if (this.config.colored) {
@@ -320,6 +285,31 @@ Module.register("calendar", {
return wrapper;
},
/**
* This function accepts a number (either 12 or 24) and returns a moment.js LocaleSpecification with the
* corresponding timeformat to be used in the calendar display. If no number is given (or otherwise invalid input)
* it will a localeSpecification object with the system locale time format.
*
* @param {number} timeFormat Specifies either 12 or 24 hour time format
* @returns {moment.LocaleSpecification}
*/
getLocaleSpecification: function(timeFormat) {
switch (timeFormat) {
case 12: {
return { longDateFormat: {LT: "h:mm A"} };
break;
}
case 24: {
return { longDateFormat: {LT: "HH:mm"} };
break;
}
default: {
return { longDateFormat: {LT: moment.localeData().longDateFormat("LT")} };
break;
}
}
},
/* hasCalendarURL(url)
* Check if this config contains the calendar url.
*
@@ -366,7 +356,7 @@ Module.register("calendar", {
return a.startDate - b.startDate;
});
return events.slice(0, this.config.maximumEntries);
return events;
},
/* createEventList(url)
@@ -377,6 +367,7 @@ Module.register("calendar", {
addCalendar: function (url, auth, calendarConfig) {
this.sendSocketNotification("ADD_CALENDAR", {
url: url,
excludedEvents: calendarConfig.excludedEvents || this.config.excludedEvents,
maximumEntries: calendarConfig.maximumEntries || this.config.maximumEntries,
maximumNumberOfDays: calendarConfig.maximumNumberOfDays || this.config.maximumNumberOfDays,
fetchInterval: this.config.fetchInterval,
@@ -437,25 +428,27 @@ Module.register("calendar", {
return defaultValue;
},
/* shorten(string, maxLength)
* Shortens a string if it's longer than maxLength.
* Adds an ellipsis to the end.
*
* argument string string - The string to shorten.
* argument maxLength number - The max length of the string.
* argument wrapEvents - Wrap the text after the line has reached maxLength
*
* return string - The shortened string.
/**
* Shortens a string if it's longer than maxLength and add a ellipsis to the end
*
* @param {string} string Text string to shorten
* @param {number} maxLength The max length of the string
* @param {boolean} wrapEvents Wrap the text after the line has reached maxLength
* @returns {string} The shortened string
*/
shorten: function (string, maxLength, wrapEvents) {
if (wrapEvents) {
if (typeof string !== "string") {
return "";
}
if (wrapEvents === true) {
var temp = "";
var currentLine = "";
var words = string.split(" ");
for (var i = 0; i < words.length; i++) {
var word = words[i];
if (currentLine.length + word.length < 25 - 1) { // max - 1 to account for a space
if (currentLine.length + word.length < (typeof maxLength === "number" ? maxLength : 25) - 1) { // max - 1 to account for a space
currentLine += (word + " ");
} else {
if (currentLine.length > 0) {
@@ -467,12 +460,12 @@ Module.register("calendar", {
}
}
return temp + currentLine;
return (temp + currentLine).trim();
} else {
if (string.length > maxLength) {
return string.slice(0, maxLength) + "&hellip;";
if (maxLength && typeof maxLength === "number" && string.length > maxLength) {
return string.trim().slice(0, maxLength) + "&hellip;";
} else {
return string;
return string.trim();
}
}
},
@@ -522,6 +515,8 @@ Module.register("calendar", {
var calendar = this.calendarData[url];
for (var e in calendar) {
var event = cloneObject(calendar[e]);
event.symbol = this.symbolsForUrl(url);
event.color = this.colorForUrl(url);
delete event.url;
eventList.push(event);
}

View File

@@ -8,7 +8,7 @@
var ical = require("./vendor/ical.js");
var moment = require("moment");
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays, auth) {
var CalendarFetcher = function(url, reloadInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth) {
var self = this;
var reloadTimer = null;
@@ -113,6 +113,19 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
title = event.description;
}
var excluded = false;
for (var f in excludedEvents) {
var filter = excludedEvents[f];
if (title.toLowerCase().includes(filter.toLowerCase())) {
excluded = true;
break;
}
}
if (excluded) {
continue;
}
var location = event.location || false;
var geo = event.geo || false;
var description = event.description || false;

View File

@@ -24,7 +24,7 @@ module.exports = NodeHelper.create({
socketNotificationReceived: function(notification, payload) {
if (notification === "ADD_CALENDAR") {
//console.log('ADD_CALENDAR: ');
this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth);
this.createFetcher(payload.url, payload.fetchInterval, payload.excludedEvents, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth);
}
},
@@ -36,7 +36,7 @@ module.exports = NodeHelper.create({
* attribute reloadInterval number - Reload interval in milliseconds.
*/
createFetcher: function(url, fetchInterval, maximumEntries, maximumNumberOfDays, auth) {
createFetcher: function(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth) {
var self = this;
if (!validUrl.isUri(url)) {
@@ -47,7 +47,7 @@ module.exports = NodeHelper.create({
var fetcher;
if (typeof self.fetchers[url] === "undefined") {
console.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval);
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays, auth);
fetcher = new CalendarFetcher(url, fetchInterval, excludedEvents, maximumEntries, maximumNumberOfDays, auth);
fetcher.onReceive(function(fetcher) {
//console.log('Broadcast events.');

View File

@@ -1,5 +1,5 @@
.clockCircle {
margin: 0;
margin: 0 auto;
position: relative;
border-radius: 50%;
background-size: 100%;

View File

@@ -486,7 +486,7 @@ Module.register("currentweather",{
*
* argument temperature number - Temperature.
*
* return number - Rounded Temperature.
* return string - Rounded Temperature.
*/
roundValue: function(temperature) {
var decimals = this.config.roundTemp ? 0 : 1;

View File

@@ -11,11 +11,11 @@ Module.register("updatenotification", {
},
notificationReceived: function(notification, payload, sender) {
notificationReceived: function (notification, payload, sender) {
if (notification === "DOM_OBJECTS_CREATED") {
this.sendSocketNotification("CONFIG", this.config);
this.sendSocketNotification("MODULES", Module.definitions);
this.hide(0,{lockString: self.identifier});
this.hide(0, { lockString: self.identifier });
}
},
@@ -26,11 +26,11 @@ Module.register("updatenotification", {
}
},
updateUI: function() {
updateUI: function () {
var self = this;
if (this.status && this.status.behind > 0) {
self.updateDom(0);
self.show(1000, {lockString: self.identifier});
self.show(1000, { lockString: self.identifier });
}
},
@@ -59,8 +59,8 @@ Module.register("updatenotification", {
var subtext = document.createElement("div");
subtext.innerHTML = this.translate("UPDATE_INFO")
.replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1)? "commit" : "commits"))
.replace("BRANCH_NAME", this.status.current);
.replace("COMMIT_COUNT", this.status.behind + " " + ((this.status.behind == 1) ? "commit" : "commits"))
.replace("BRANCH_NAME", this.status.current);
subtext.className = "xsmall dimmed";
wrapper.appendChild(subtext);
}

View File

@@ -24,6 +24,7 @@ Module.register("weatherforecast",{
fade: true,
fadePoint: 0.25, // Start on 1/4th of the list.
colored: false,
scale: false,
initialLoadDelay: 2500, // 2.5 seconds delay. This delay is used to keep the OpenWeather API happy.
retryDelay: 2500,
@@ -139,13 +140,28 @@ Module.register("weatherforecast",{
icon.className = "wi weathericon " + forecast.icon;
iconCell.appendChild(icon);
var degreeLabel = "";
if(this.config.scale) {
switch(this.config.units) {
case "metric":
degreeLabel = " &deg;C";
break;
case "imperial":
degreeLabel = " &deg;F";
break;
case "default":
degreeLabel = "K";
break;
}
}
var maxTempCell = document.createElement("td");
maxTempCell.innerHTML = forecast.maxTemp;
maxTempCell.innerHTML = forecast.maxTemp + degreeLabel;
maxTempCell.className = "align-right bright max-temp";
row.appendChild(maxTempCell);
var minTempCell = document.createElement("td");
minTempCell.innerHTML = forecast.minTemp;
minTempCell.innerHTML = forecast.minTemp + degreeLabel;
minTempCell.className = "align-right min-temp";
row.appendChild(minTempCell);
@@ -358,7 +374,7 @@ Module.register("weatherforecast",{
*
* argument temperature number - Temperature.
*
* return number - Rounded Temperature.
* return string - Rounded Temperature.
*/
roundValue: function(temperature) {
var decimals = this.config.roundTemp ? 0 : 1;