mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 04:45:17 +00:00
Merge branch 'develop' of https://github.com/MichMich/MagicMirror into develop
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* Magic Mirror
|
||||
* The Core App (Server)
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
var fs = require("fs");
|
||||
@@ -61,7 +61,7 @@ var App = function() {
|
||||
// https://forum.magicmirror.builders/topic/1456/test-suite-for-magicmirror/8
|
||||
var configFilename = path.resolve(global.root_path + "/config/config.js");
|
||||
if (typeof(global.configuration_file) !== "undefined") {
|
||||
configFilename = path.resolve(global.configuration_file);
|
||||
configFilename = path.resolve(global.configuration_file);
|
||||
}
|
||||
|
||||
try {
|
||||
|
69
js/check_config.js
Normal file
69
js/check_config.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Magic Mirror
|
||||
*
|
||||
* Checker configuration file
|
||||
*
|
||||
* By Rodrigo Ramírez Norambuena
|
||||
* https://rodrigoramirez.com
|
||||
*
|
||||
* MIT Licensed.
|
||||
*
|
||||
*/
|
||||
|
||||
const Linter = require("eslint").Linter;
|
||||
const linter = new Linter();
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const rootPath = path.resolve(__dirname + "/../");
|
||||
const config = require(rootPath + "/.eslintrc.json");
|
||||
const Utils = require(rootPath + "/js/utils.js");
|
||||
|
||||
/* getConfigFile()
|
||||
* Return string with path of configuration file
|
||||
* Check if set by environment variable MM_CONFIG_FILE
|
||||
*/
|
||||
function getConfigFile() {
|
||||
// FIXME: This function should be in core. Do you want refactor me ;) ?, be good!
|
||||
let configFileName = path.resolve(rootPath + "/config/config.js");
|
||||
if (process.env.MM_CONFIG_FILE) {
|
||||
configFileName = path.resolve(process.env.MM_CONFIG_FILE);
|
||||
}
|
||||
return configFileName;
|
||||
}
|
||||
|
||||
function checkConfigFile() {
|
||||
const configFileName = getConfigFile();
|
||||
// Check if file is present
|
||||
if (fs.existsSync(configFileName) === false) {
|
||||
console.error(Utils.colors.error("File not found: "), configFileName);
|
||||
return;
|
||||
}
|
||||
// check permission
|
||||
try {
|
||||
fs.accessSync(configFileName, fs.F_OK);
|
||||
} catch (e) {
|
||||
console.log(Utils.colors.error(e));
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate syntax of the configuration file.
|
||||
// In case the there errors show messages and
|
||||
// return
|
||||
console.info(Utils.colors.info("Checking file... "), configFileName);
|
||||
// I'm not sure if all ever is utf-8
|
||||
fs.readFile(configFileName, "utf-8", function (err, data) {
|
||||
if (err) { throw err; }
|
||||
const messages = linter.verify(data, config);
|
||||
if (messages.length === 0) {
|
||||
console.log("Your configuration file doesn't contain syntax errors :)");
|
||||
return true;
|
||||
} else {
|
||||
messages.forEach(error => {
|
||||
console.log("Line", error.line, "col", error.column, error.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
checkConfigFile();
|
@@ -1,5 +1,5 @@
|
||||
/* Simple JavaScript Inheritance
|
||||
* By John Resig http://ejohn.org/
|
||||
* By John Resig https://johnresig.com/
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
initializing = false;
|
||||
|
||||
// Make a copy of all prototype properties, to prevent reference issues.
|
||||
for (var name in prototype) {
|
||||
prototype[name] = cloneObject(prototype[name]);
|
||||
for (var p in prototype) {
|
||||
prototype[p] = cloneObject(prototype[p]);
|
||||
}
|
||||
|
||||
// Copy the properties over onto the new prototype
|
||||
|
@@ -1,9 +1,9 @@
|
||||
/* exported defaults */
|
||||
|
||||
/* Magic Mirror
|
||||
* Config Defauls
|
||||
* Config Defaults
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,7 @@ if (typeof(mmPort) !== "undefined") {
|
||||
var defaults = {
|
||||
address: address,
|
||||
port: port,
|
||||
basePath: "/",
|
||||
kioskmode: false,
|
||||
electronOptions: {},
|
||||
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* Magic Mirror Deprecated Config Options List
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*
|
||||
* Olex S. original idea this deprecated option
|
||||
|
@@ -45,8 +45,16 @@ function createWindow() {
|
||||
|
||||
// and load the index.html of the app.
|
||||
// If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost
|
||||
|
||||
var prefix;
|
||||
if (config["tls"] !== null && config["tls"]) {
|
||||
prefix = "https://";
|
||||
} else {
|
||||
prefix = "http://";
|
||||
}
|
||||
|
||||
var address = (config.address === void 0) | (config.address === "") ? (config.address = "localhost") : config.address;
|
||||
mainWindow.loadURL(`http://${address}:${config.port}`);
|
||||
mainWindow.loadURL(`${prefix}${address}:${config.port}`);
|
||||
|
||||
// Open the DevTools if run with "npm start dev"
|
||||
if (process.argv.includes("dev")) {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
/* global config, vendor, MM, Log, Module */
|
||||
|
||||
/* Magic Mirror
|
||||
* Module and File loaders.
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
var Loader = (function() {
|
||||
|
||||
/* Create helper variables */
|
||||
|
@@ -1,10 +1,9 @@
|
||||
/* global console */
|
||||
/* exported Log */
|
||||
|
||||
/* Magic Mirror
|
||||
* Logger
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
|
@@ -1,12 +1,11 @@
|
||||
/* global Log, Loader, Module, config, defaults */
|
||||
/* global Log, Loader, Module, config, defaults */
|
||||
|
||||
/* Magic Mirror
|
||||
* Main System
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
var MM = (function() {
|
||||
|
||||
var modules = [];
|
||||
@@ -344,6 +343,8 @@ var MM = (function() {
|
||||
* Loads the core config and combines it with de system defaults.
|
||||
*/
|
||||
var loadConfig = function() {
|
||||
// FIXME: Think about how to pass config around without breaking tests
|
||||
/* eslint-disable */
|
||||
if (typeof config === "undefined") {
|
||||
config = defaults;
|
||||
Log.error("Config file is missing! Please create a config file.");
|
||||
@@ -351,6 +352,7 @@ var MM = (function() {
|
||||
}
|
||||
|
||||
config = Object.assign({}, defaults, config);
|
||||
/* eslint-enable */
|
||||
};
|
||||
|
||||
/* setSelectionMethodsForModules()
|
||||
|
@@ -1,10 +1,9 @@
|
||||
/* global Log, Class, Loader, Class , MM */
|
||||
/* exported Module */
|
||||
|
||||
/* Magic Mirror
|
||||
* Module Blueprint.
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* Magic Mirror
|
||||
* Node Helper Superclass
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/* Magic Mirror
|
||||
* Server
|
||||
*
|
||||
* By Michael Teeuw http://michaelteeuw.nl
|
||||
* By Michael Teeuw https://michaelteeuw.nl
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
||||
@@ -73,7 +73,7 @@ var Server = function(config, callback) {
|
||||
|
||||
configFile = "config/config.js";
|
||||
if (typeof(global.configuration_file) !== "undefined") {
|
||||
configFile = global.configuration_file;
|
||||
configFile = global.configuration_file;
|
||||
}
|
||||
html = html.replace("#CONFIG_FILE#", configFile);
|
||||
|
||||
|
@@ -8,8 +8,12 @@ var MMSocket = function(moduleName) {
|
||||
self.moduleName = moduleName;
|
||||
|
||||
// Private Methods
|
||||
var base = "/";
|
||||
if ((typeof config !== "undefined") && (typeof config.basePath !== "undefined")) {
|
||||
base = config.basePath;
|
||||
}
|
||||
self.socket = io("/" + self.moduleName, {
|
||||
path: window.location.pathname + "socket.io"
|
||||
path: base + "socket.io"
|
||||
});
|
||||
var notificationCallback = function() {};
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
/* exported Translator */
|
||||
|
||||
/* Magic Mirror
|
||||
* Translator (l10n)
|
||||
*
|
||||
* By Christopher Fenner http://github.com/CFenner
|
||||
* By Christopher Fenner https://github.com/CFenner
|
||||
* MIT Licensed.
|
||||
*/
|
||||
var Translator = (function() {
|
||||
@@ -129,10 +130,10 @@ var Translator = (function() {
|
||||
if(Object.prototype.toString.call(template) !== "[object String]") {
|
||||
return template;
|
||||
}
|
||||
if(variables.fallback && !template.match(new RegExp("\{.+\}"))) {
|
||||
if(variables.fallback && !template.match(new RegExp("{.+}"))) {
|
||||
template = variables.fallback;
|
||||
}
|
||||
return template.replace(new RegExp("\{([^\}]+)\}", "g"), function(_unused, varName){
|
||||
return template.replace(new RegExp("{([^}]+)}", "g"), function(_unused, varName){
|
||||
return variables[varName] || "{"+varName+"}";
|
||||
});
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
/* exported Utils */
|
||||
|
||||
/* Magic Mirror
|
||||
* Utils
|
||||
*
|
||||
|
Reference in New Issue
Block a user