mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-01 21:43:26 +00:00
Merge pull request #754 from deg0nz/develop
Add support for more authentication methods for the default calendar module
This commit is contained in:
commit
ebe2a30463
3
CHANGELOG.md
Executable file → Normal file
3
CHANGELOG.md
Executable file → Normal file
@ -48,7 +48,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Add test for compliments module for parts of day
|
- Add test for compliments module for parts of day
|
||||||
- Korean Translation.
|
- Korean Translation.
|
||||||
- Added console warning on startup when deprecated config options are used
|
- Added console warning on startup when deprecated config options are used
|
||||||
- Added `DAYAFTERTOMORROW`, `UPDATE_NOTIFICATION`, `UPDATE_NOTIFICATION_MODULE`, `UPDATE_INFO` to Norwegian translations (`nn` and `nb`).
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Update .gitignore to not ignore default modules folder.
|
- Update .gitignore to not ignore default modules folder.
|
||||||
@ -59,7 +59,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Module currentWeather: check if temperature received from api is defined.
|
- Module currentWeather: check if temperature received from api is defined.
|
||||||
- Fix an issue with module hidden status changing to `true` although lock string prevented showing it
|
- Fix an issue with module hidden status changing to `true` although lock string prevented showing it
|
||||||
- Fix newsfeed module bug (removeStartTags)
|
- Fix newsfeed module bug (removeStartTags)
|
||||||
- Fixed missing animation on `this.show(speed)` when module is alone in a region.
|
|
||||||
|
|
||||||
## [2.1.0] - 2016-12-31
|
## [2.1.0] - 2016-12-31
|
||||||
|
|
||||||
|
@ -69,12 +69,14 @@ var App = function() {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.code == "ENOENT") {
|
if (e.code == "ENOENT") {
|
||||||
console.error("WARNING! Could not find config file. Please create one. Starting with default configuration.");
|
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) {
|
} else if (e instanceof ReferenceError || e instanceof SyntaxError) {
|
||||||
console.error("WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.");
|
console.error("WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.");
|
||||||
|
callback(defaults);
|
||||||
} else {
|
} else {
|
||||||
console.error("WARNING! Could not load config file. Starting with default configuration. Error found: " + e);
|
console.error("WARNING! Could not load config file. Starting with default configuration. Error found: " + e);
|
||||||
|
callback(defaults);
|
||||||
}
|
}
|
||||||
callback(defaults);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
7
js/main.js
Executable file → Normal file
7
js/main.js
Executable file → Normal file
@ -245,18 +245,15 @@ var MM = (function() {
|
|||||||
moduleWrapper.style.transition = "opacity " + speed / 1000 + "s";
|
moduleWrapper.style.transition = "opacity " + speed / 1000 + "s";
|
||||||
// Restore the postition. See hideModule() for more info.
|
// Restore the postition. See hideModule() for more info.
|
||||||
moduleWrapper.style.position = "static";
|
moduleWrapper.style.position = "static";
|
||||||
|
moduleWrapper.style.opacity = 1;
|
||||||
|
|
||||||
updateWrapperStates();
|
updateWrapperStates();
|
||||||
|
|
||||||
// Waiting for DOM-changes done in updateWrapperStates before we can start the animation.
|
|
||||||
var dummy = moduleWrapper.parentElement.parentElement.offsetHeight;
|
|
||||||
|
|
||||||
moduleWrapper.style.opacity = 1;
|
|
||||||
|
|
||||||
clearTimeout(module.showHideTimer);
|
clearTimeout(module.showHideTimer);
|
||||||
module.showHideTimer = setTimeout(function() {
|
module.showHideTimer = setTimeout(function() {
|
||||||
if (typeof callback === "function") { callback(); }
|
if (typeof callback === "function") { callback(); }
|
||||||
}, speed);
|
}, speed);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,25 +53,36 @@ The `colored` property gives the option for an individual color for each calenda
|
|||||||
#### Default value:
|
#### Default value:
|
||||||
````javascript
|
````javascript
|
||||||
config: {
|
config: {
|
||||||
colored: false,
|
colored: false,
|
||||||
calendars: [
|
calendars: [
|
||||||
{
|
{
|
||||||
url: 'http://www.calendarlabs.com/templates/ical/US-Holidays.ics',
|
url: 'http://www.calendarlabs.com/templates/ical/US-Holidays.ics',
|
||||||
symbol: 'calendar',
|
symbol: 'calendar',
|
||||||
|
auth: {
|
||||||
|
user: 'username',
|
||||||
|
pass: 'superstrongpassword',
|
||||||
|
method: 'basic'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
````
|
````
|
||||||
|
|
||||||
|
|
||||||
#### Calendar configuration options:
|
#### Calendar configuration options:
|
||||||
| Option | Description
|
| Option | Description
|
||||||
| --------------------- | -----------
|
| --------------------- | -----------
|
||||||
| `url` | The url of the calendar .ical. This property is required. <br><br> **Possible values:** Any public accessble .ical calendar.
|
| `url` | The url of the calendar .ical. This property is required. <br><br> **Possible values:** Any public accessble .ical calendar.
|
||||||
| `symbol` | The symbol to show in front of an event. This property is optional. <br><br> **Possible values:** See [Font Awesome](http://fontawesome.io/icons/) website.
|
| `symbol` | The symbol to show in front of an event. This property is optional. <br><br> **Possible values:** See [Font Awesome](http://fontawesome.io/icons/) website.
|
||||||
| `color` | The font color of an event from this calendar. This property should be set if the config is set to colored: true. <br><br> **Possible values:** HEX, RGB or RGBA values (#efefef, rgb(242,242,242), rgba(242,242,242,0.5)).
|
| `color` | The font color of an event from this calendar. This property should be set if the config is set to colored: true. <br><br> **Possible values:** HEX, RGB or RGBA values (#efefef, rgb(242,242,242), rgba(242,242,242,0.5)).
|
||||||
| `repeatingCountTitle` | The count title for yearly repating events in this calendar. <br><br> **Example:** `'Birthday'`
|
| `repeatingCountTitle` | The count title for yearly repating events in this calendar. <br><br> **Example:** `'Birthday'`
|
||||||
| `user` | The username for HTTP Basic authentication.
|
|
||||||
| `pass` | The password for HTTP Basic authentication.
|
|
||||||
| `maximumEntries` | The maximum number of events shown. Overrides global setting. **Possible values:** `0` - `100`
|
| `maximumEntries` | The maximum number of events shown. Overrides global setting. **Possible values:** `0` - `100`
|
||||||
| `maximumNumberOfDays` | The maximum number of days in the future. Overrides global setting
|
| `maximumNumberOfDays` | The maximum number of days in the future. Overrides global setting
|
||||||
|
| `auth` | The object containing options for authentication against the calendar.
|
||||||
|
|
||||||
|
|
||||||
|
#### Calendar authentication options:
|
||||||
|
| Option | Description
|
||||||
|
| --------------------- | -----------
|
||||||
|
| `user` | The username for HTTP authentication.
|
||||||
|
| `pass` | The password for HTTP authentication. (If you use Bearer authentication, this should be your BearerToken.)
|
||||||
|
| `method` | Which authentication method should be used. HTTP Basic, Digest and Bearer authentication methods are supported. Basic authentication is used by default if this option is omitted. **Possible values:** `digest`, `basic`, `bearer` **Default value:** `basic`
|
||||||
|
@ -72,10 +72,18 @@ Module.register("calendar", {
|
|||||||
|
|
||||||
var calendarConfig = {
|
var calendarConfig = {
|
||||||
maximumEntries: calendar.maximumEntries,
|
maximumEntries: calendar.maximumEntries,
|
||||||
maximumNumberOfDays: calendar.maximumNumberOfDays,
|
maximumNumberOfDays: calendar.maximumNumberOfDays
|
||||||
};
|
};
|
||||||
|
|
||||||
this.addCalendar(calendar.url, calendar.user, calendar.pass, calendarConfig);
|
// we check user and password here for backwards compatibility with old configs
|
||||||
|
if(calendar.user && calendar.pass){
|
||||||
|
calendar.auth = {
|
||||||
|
user: calendar.user,
|
||||||
|
pass: calendar.pass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addCalendar(calendar.url, calendar.auth, calendarConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.calendarData = {};
|
this.calendarData = {};
|
||||||
@ -313,14 +321,13 @@ Module.register("calendar", {
|
|||||||
*
|
*
|
||||||
* argument url string - Url to add.
|
* argument url string - Url to add.
|
||||||
*/
|
*/
|
||||||
addCalendar: function (url, user, pass, calendarConfig) {
|
addCalendar: function (url, auth, calendarConfig) {
|
||||||
this.sendSocketNotification("ADD_CALENDAR", {
|
this.sendSocketNotification("ADD_CALENDAR", {
|
||||||
url: url,
|
url: url,
|
||||||
maximumEntries: calendarConfig.maximumEntries || this.config.maximumEntries,
|
maximumEntries: calendarConfig.maximumEntries || this.config.maximumEntries,
|
||||||
maximumNumberOfDays: calendarConfig.maximumNumberOfDays || this.config.maximumNumberOfDays,
|
maximumNumberOfDays: calendarConfig.maximumNumberOfDays || this.config.maximumNumberOfDays,
|
||||||
fetchInterval: this.config.fetchInterval,
|
fetchInterval: this.config.fetchInterval,
|
||||||
user: user,
|
auth: auth
|
||||||
pass: pass
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
var ical = require("./vendor/ical.js");
|
var ical = require("./vendor/ical.js");
|
||||||
var moment = require("moment");
|
var moment = require("moment");
|
||||||
|
|
||||||
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays, user, pass) {
|
var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumberOfDays, auth) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var reloadTimer = null;
|
var reloadTimer = null;
|
||||||
@ -32,11 +32,23 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (user && pass) {
|
if (auth) {
|
||||||
opts.auth = {
|
if(auth.method === "bearer"){
|
||||||
user: user,
|
opts.auth = {
|
||||||
pass: pass,
|
bearer: auth.pass
|
||||||
sendImmediately: true
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
opts.auth = {
|
||||||
|
user: auth.user,
|
||||||
|
pass: auth.pass
|
||||||
|
};
|
||||||
|
|
||||||
|
if(auth.method === "digest"){
|
||||||
|
opts.auth.sendImmediately = false;
|
||||||
|
}else{
|
||||||
|
opts.auth.sendImmediately = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +59,7 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log(data);
|
// console.log(data);
|
||||||
newEvents = [];
|
newEvents = [];
|
||||||
|
|
||||||
var limitFunction = function(date, i) {return i < maximumEntries;};
|
var limitFunction = function(date, i) {return i < maximumEntries;};
|
||||||
|
@ -8,14 +8,22 @@
|
|||||||
|
|
||||||
var CalendarFetcher = require("./calendarfetcher.js");
|
var CalendarFetcher = require("./calendarfetcher.js");
|
||||||
|
|
||||||
var url = "https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics";
|
var url = "https://calendar.google.com/calendar/ical/pkm1t2uedjbp0uvq1o7oj1jouo%40group.calendar.google.com/private-08ba559f89eec70dd74bbd887d0a3598/basic.ics"; // Standard test URL
|
||||||
|
// var url = "https://www.googleapis.com/calendar/v3/calendars/primary/events/"; // URL for Bearer auth (must be configured in Google OAuth2 first)
|
||||||
var fetchInterval = 60 * 60 * 1000;
|
var fetchInterval = 60 * 60 * 1000;
|
||||||
var maximumEntries = 10;
|
var maximumEntries = 10;
|
||||||
var maximumNumberOfDays = 365;
|
var maximumNumberOfDays = 365;
|
||||||
|
var user = "magicmirror";
|
||||||
|
var pass = "MyStrongPass";
|
||||||
|
|
||||||
|
var auth = {
|
||||||
|
user: user,
|
||||||
|
pass: pass
|
||||||
|
};
|
||||||
|
|
||||||
console.log("Create fetcher ...");
|
console.log("Create fetcher ...");
|
||||||
|
|
||||||
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays);
|
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays, auth);
|
||||||
|
|
||||||
fetcher.onReceive(function(fetcher) {
|
fetcher.onReceive(function(fetcher) {
|
||||||
console.log(fetcher.events());
|
console.log(fetcher.events());
|
||||||
|
@ -24,7 +24,7 @@ module.exports = NodeHelper.create({
|
|||||||
socketNotificationReceived: function(notification, payload) {
|
socketNotificationReceived: function(notification, payload) {
|
||||||
if (notification === "ADD_CALENDAR") {
|
if (notification === "ADD_CALENDAR") {
|
||||||
//console.log('ADD_CALENDAR: ');
|
//console.log('ADD_CALENDAR: ');
|
||||||
this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries, payload.maximumNumberOfDays, payload.user, payload.pass);
|
this.createFetcher(payload.url, payload.fetchInterval, payload.maximumEntries, payload.maximumNumberOfDays, payload.auth);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ module.exports = NodeHelper.create({
|
|||||||
* attribute reloadInterval number - Reload interval in milliseconds.
|
* attribute reloadInterval number - Reload interval in milliseconds.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
createFetcher: function(url, fetchInterval, maximumEntries, maximumNumberOfDays, user, pass) {
|
createFetcher: function(url, fetchInterval, maximumEntries, maximumNumberOfDays, auth) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (!validUrl.isUri(url)) {
|
if (!validUrl.isUri(url)) {
|
||||||
@ -47,7 +47,7 @@ module.exports = NodeHelper.create({
|
|||||||
var fetcher;
|
var fetcher;
|
||||||
if (typeof self.fetchers[url] === "undefined") {
|
if (typeof self.fetchers[url] === "undefined") {
|
||||||
console.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval);
|
console.log("Create new calendar fetcher for url: " + url + " - Interval: " + fetchInterval);
|
||||||
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays, user, pass);
|
fetcher = new CalendarFetcher(url, fetchInterval, maximumEntries, maximumNumberOfDays, auth);
|
||||||
|
|
||||||
fetcher.onReceive(function(fetcher) {
|
fetcher.onReceive(function(fetcher) {
|
||||||
//console.log('Broadcast events.');
|
//console.log('Broadcast events.');
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
"NW": "ÉNy",
|
"NW": "ÉNy",
|
||||||
"NNW": "ÉÉNy",
|
"NNW": "ÉÉNy",
|
||||||
|
|
||||||
"UPDATE_NOTIFICATION": "Elérhető MagicMirror² frissítés.",
|
"UPDATE_NOTIFICATION": "MagicMirror² elérhető egy frissítés!",
|
||||||
"UPDATE_NOTIFICATION_MODULE": "Frissítés érhető el a MODULE_NAME modulhoz.",
|
"UPDATE_NOTIFICATION_MODULE": "A frissítés MODULE_NAME modul néven érhető el.",
|
||||||
"UPDATE_INFO": "A jelenlegi telepített verzió COMMIT_COUNT commit-al régebbi a BRANCH_NAME branch-en."
|
"UPDATE_INFO": "A jelenlegi telepítés COMMIT_COUNT mögött BRANCH_NAME ágon található."
|
||||||
}
|
}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"LOADING": "Memuat …",
|
|
||||||
|
|
||||||
"TODAY": "Hari ini",
|
|
||||||
"TOMORROW": "Besok",
|
|
||||||
"DAYAFTERTOMORROW": "Lusa",
|
|
||||||
"RUNNING": "Berakhir dalam",
|
|
||||||
"EMPTY": "Tidak ada agenda",
|
|
||||||
|
|
||||||
"N": "U",
|
|
||||||
"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.",
|
|
||||||
"UPDATE_NOTIFICATION_MODULE": "Update tersedia untuk modul MODULE_NAME.",
|
|
||||||
"UPDATE_INFO": "Instalasi saat ini tertinggal COMMIT_COUNT pada cabang BRANCH_NAME."
|
|
||||||
}
|
|
7
translations/nb.json
Executable file → Normal file
7
translations/nb.json
Executable file → Normal file
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
"TODAY": "I dag",
|
"TODAY": "I dag",
|
||||||
"TOMORROW": "I morgen",
|
"TOMORROW": "I morgen",
|
||||||
"DAYAFTERTOMORROW": "I overmorgen",
|
|
||||||
"RUNNING": "Slutter om",
|
"RUNNING": "Slutter om",
|
||||||
"EMPTY": "Ingen kommende arrangementer.",
|
"EMPTY": "Ingen kommende arrangementer.",
|
||||||
|
|
||||||
@ -22,9 +21,5 @@
|
|||||||
"W": "V",
|
"W": "V",
|
||||||
"WNW": "VNV",
|
"WNW": "VNV",
|
||||||
"NW": "NV",
|
"NW": "NV",
|
||||||
"NNW": "NNV",
|
"NNW": "NNV"
|
||||||
|
|
||||||
"UPDATE_NOTIFICATION": "MagicMirror² oppdatering er tilgjengelig.",
|
|
||||||
"UPDATE_NOTIFICATION_MODULE": "Oppdatering tilgjengelig for modulen MODULE_NAME.",
|
|
||||||
"UPDATE_INFO": "Nåværende installasjon er COMMIT_COUNT bak BRANCH_NAME grenen."
|
|
||||||
}
|
}
|
||||||
|
7
translations/nn.json
Executable file → Normal file
7
translations/nn.json
Executable file → Normal file
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
"TODAY": "I dag",
|
"TODAY": "I dag",
|
||||||
"TOMORROW": "I morgon",
|
"TOMORROW": "I morgon",
|
||||||
"DAYAFTERTOMORROW": "I overmorgon",
|
|
||||||
"RUNNING": "Sluttar om",
|
"RUNNING": "Sluttar om",
|
||||||
"EMPTY": "Ingen komande hendingar.",
|
"EMPTY": "Ingen komande hendingar.",
|
||||||
|
|
||||||
@ -22,9 +21,5 @@
|
|||||||
"W": "V",
|
"W": "V",
|
||||||
"WNW": "VNV",
|
"WNW": "VNV",
|
||||||
"NW": "NV",
|
"NW": "NV",
|
||||||
"NNW": "NNV",
|
"NNW": "NNV"
|
||||||
|
|
||||||
"UPDATE_NOTIFICATION": "MagicMirror² oppdatering er tilgjengeleg.",
|
|
||||||
"UPDATE_NOTIFICATION_MODULE": "Oppdatering tilgjengeleg for modulen MODULE_NAME.",
|
|
||||||
"UPDATE_INFO": "noverande installasjon er COMMIT_COUNT bak BRANCH_NAME greinen."
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ var translations = {
|
|||||||
"pt" : "translations/pt.json", // Português
|
"pt" : "translations/pt.json", // Português
|
||||||
"pt_br" : "translations/pt_br.json", // Português Brasileiro
|
"pt_br" : "translations/pt_br.json", // Português Brasileiro
|
||||||
"sv" : "translations/sv.json", // Svenska
|
"sv" : "translations/sv.json", // Svenska
|
||||||
"id" : "translations/id.json", // Indonesian
|
|
||||||
"it" : "translations/it.json", // Italian
|
"it" : "translations/it.json", // Italian
|
||||||
"zh_cn" : "translations/zh_cn.json", // Simplified Chinese
|
"zh_cn" : "translations/zh_cn.json", // Simplified Chinese
|
||||||
"zh_tw" : "translations/zh_tw.json", // Traditional Chinese
|
"zh_tw" : "translations/zh_tw.json", // Traditional Chinese
|
||||||
|
Loading…
x
Reference in New Issue
Block a user