diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index c93b1f6..43d9e6c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,5 +1,12 @@ -Thank you for contributing. -We're trying to keep the module up to date and we're adding new features everytime. +# Contributing + +Thank you for contributing! + +We're trying to keep the module up to date and we're adding new features every time. Your contribution help us so much in a lot of ways. -We ask you to keep contributing, and feel free to open as many issues and PR as you need. \ No newline at end of file +We ask you to keep contributing, and feel free to open as many issues and PR as you need. + +## Developer commands + +- `npm run test` - Run spelling check. diff --git a/API/README.md b/API/README.md index 72bfa2c..716230a 100644 --- a/API/README.md +++ b/API/README.md @@ -2,11 +2,11 @@ ## Introduction -The MMM-Remote-Control Module for MagicMirror² implements a RESTful(-ish) API to control the MagicMirror² using the existing functionality built-in to MMM-Remote-Control, as well as the notifications commands built into most modules. In addition, the API creates a basic framework which allows for each module to expand or customize their own API by a simple notificiation. +The MMM-Remote-Control Module for MagicMirror² implements a RESTful(-ish) API to control the MagicMirror² using the existing functionality built-in to MMM-Remote-Control, as well as the notifications commands built into most modules. In addition, the API creates a basic framework which allows for each module to expand or customize their own API by a simple notification. This expansion was developed by [shbatm](https://github.com/shbatm) using [juzim's MMM-Api](https://github.com/juzim/MMM-Api) and of-course, [jopyth's MMM-Remote-Control](https://github.com/jopyth/MMM-Remote-Control). -Modified by [ezeholz](https://github.com/ezeholz) in the 2.2.0+, in the efford of making a more simplified version for everyone to use it. +Modified by [ezeholz](https://github.com/ezeholz) in the 2.2.0+, in the effort of making a more simplified version for everyone to use it. ## Overview @@ -49,7 +49,7 @@ $ curl -X POST http://magicmirrorip:8080/api/notification/HELLO_WORLD \ Providing an API key is recommended; however, remains optional. If you wish to use an API key to authenticate, add an `apiKey:` option to the config section for this module. -If you ran the `installer.sh` script when you installed the module, a non-canoical UUID is generated for you to use; you can use this unique code, or use any string you wish. +If you ran the `installer.sh` script when you installed the module, a non-canonical UUID is generated for you to use; you can use this unique code, or use any string you wish. ### Example Config Section @@ -185,14 +185,14 @@ curl -X GET http://magicmirrorip:8080/api/module/newsfeed ### 3. External APIs (Explicit) - Extending Another Module with this API -For module developers, you can extend the API to accomodate your needs by sending a "REGISTER_API" module notification. Below is an example and details. +For module developers, you can extend the API to accommodate your needs by sending a "REGISTER_API" module notification. Below is an example and details. -If correctly formated, any details sent here will override the "guessed" action by #2 above. +If correctly formatted, any details sent here will override the "guessed" action by #2 above. ```js let payload = { module: this.name, - path: "modulename", + path: "mymodulename", actions: { actionName: { method: "GET", @@ -220,12 +220,12 @@ this.sendNotification("REGISTER_API", payload); | `prettyName` | *Optional:* You can specify a Formatted Name to use in dynamic menus, like the MMM-Remote-Control Module Control menu, otherwise one will be guessed based on the Notification text. | `payload` | *Optional:* If you always want the module to send the same `payload`, you can provide an `Object` here. It will be merged into the `payload` sent with the notification, which will also include:
1. URL Parameter, if used. See notes on `payload` Object below.
2. Query String, if used. API key will be removed.
3. Request body, if `POST` method is used and a body sent.
4. Finally, this parameter. -#### About the `payload` Object +#### About the `payload` object Your module will be sent a `payload` with the notification, depending on the request details, and if you provided a `payload` Object to send. It is a merged object, containing one or more of the following inputs. -1. URL Parameter. (e.g. `/api/module/mymodulename/action/:p`, where `:p` is the parameter). If nothing else below is passed or provided, this will be returned as a string. If anything else below is sent, this will be provided at `payload.param` in the notification's `payload` Object. -2. Query String. Anything passed to the query string, except the API Key (if used) will be passed through `payload`. For example, `/api/module/mymodulename/action?param1=Something¶m2=Else` will be passed in `payload` as `{ param1: "Something", param2: "Else" }` +1. URL parameter. (e.g. `/api/module/mymodulename/action/:p`, where `:p` is the parameter). If nothing else below is passed or provided, this will be returned as a string. If anything else below is sent, this will be provided at `payload.param` in the notification's `payload` Object. +2. Query String. Anything passed to the query string, except the API key (if used) will be passed through `payload`. For example, `/api/module/mymodulename/action?param1=Something¶m2=Else` will be passed in `payload` as `{ param1: "Something", param2: "Else" }` 3. `POST` Body. Same as query string above. 4. Custom Payload. Any `Object` provided with the `payload:` key when you send the initial "REGISTER_API" notification. diff --git a/API/api.js b/API/api.js index ba362ed..7130116 100644 --- a/API/api.js +++ b/API/api.js @@ -4,7 +4,6 @@ * By shbatm * MIT Licensed. */ -/* jshint node: true, esversion: 6 */ const path = require("path"); const url = require("url"); @@ -51,7 +50,7 @@ module.exports = { let getActions = function(content) { let re = /notification \=\=\=? (?:"|')([A-Z_-]+?)(?:"|')|case (?:"|')([A-Z_-]+)(?:"|')/g; let m; - let availabeActions = []; + let availableActions = []; if (re.test(content)) { content.match(re).forEach((match) => { let n = match.replace(re, '$1'); @@ -62,11 +61,11 @@ module.exports = { 'KEYPRESS_MODE_CHANGED', 'USER_PRESENCE' ].indexOf(n) === -1) { - availabeActions.push(n); + availableActions.push(n); } }); } - return availabeActions; + return availableActions; }; let skippedModules = ['clock', 'compliments', 'MMM-Remote-Control']; @@ -118,7 +117,7 @@ module.exports = { // Route for testing the api at http://mirror:8080/api/test this.expressRouter.route(['/test','/']) // Test without apiKey .get((req, res) => { - if (!this.checkInititialized(res)) { return; } + if (!this.checkInitialized(res)) { return; } res.json({ success: true }); }); @@ -342,7 +341,7 @@ module.exports = { }, answerModuleApi(req, res) { - if (!this.checkInititialized(res)) { return; } + if (!this.checkInitialized(res)) { return; } var dataMerged = this.mergeData().data if (!req.params.moduleName) { @@ -427,7 +426,7 @@ module.exports = { } // If only a URL Parameter is passed, it will be sent as a string // If we have either a query string or a payload already provided w the action, - // then the paramteter will be inside the payload.param property. + // then the parameter will be inside the payload.param property. delete req.query.apiKey; let query = { notification: n }; if (req.params.p && req.params.p === "delay") { @@ -478,7 +477,7 @@ module.exports = { return; }, - checkInititialized(res) { + checkInitialized(res) { if (!this.initialized) { this.sendResponse(res, "Not initialized, have you opened or refreshed your browser since the last time you started MagicMirror²?"); return false; diff --git a/CHANGELOG.md b/CHANGELOG.md index 76f8830..7335ffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,14 @@ All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](http://keepachangelog.com/) -and this project adheres to [Semantic Versioning](http://semver.org/). +The format is based on [Keep a Changelog](https://keepachangelog.com/) +and this project adheres to [Semantic Versioning](https://semver.org/). + +## [2.5.0] - Unreleased (`develop` branch) + +### Added + +- Added a spell checker and fixed problems that were found. ## [2.4.0] - 2024-10-08 @@ -120,7 +126,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Updates now show if there's an update available every day (#52) -- Templates for issues and PRs, and also stale for automanagement of issues. +- Templates for issues and PRs, and also stale for auto management of issues. - Close Dev Tools (#119) - Undo Config Implementation [Beta] - Classes to show, hide or toggle multiple modules at once (#34) @@ -150,7 +156,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [2.1.0] - 2020-11-01 -Hello! Ezequiel here. Just wanted to say thanks for trust in me, in the past days I made a lot of changes into the code, adding some functions that'll surely be in a future release, and also putting everything together in my fork. I answered almost every issue raised, and tried to help every person that use this module. Today, I'm glad to be able to share everything I learned to all of you. I apologize for some fast and uncommented commits, I just thinked that some things needed to be fixed ASAP. +Hello! Ezequiel here. Just wanted to say thanks for trust in me, in the past days I made a lot of changes into the code, adding some functions that'll surely be in a future release, and also putting everything together in my fork. I answered almost every issue raised, and tried to help every person that use this module. Today, I'm glad to be able to share everything I learned to all of you. I apologize for some fast and uncommented commits, I just thought that some things needed to be fixed ASAP. See you in future commits, issues and PRs :D ### Fixed @@ -162,7 +168,7 @@ See you in future commits, issues and PRs :D - IP now showing (#194) - MM restart button don't just stop anymore (#126) - Saving config should work as expected now (#153) -- installer.sh now detects where's the node instalation (#222) +- installer.sh now detects where's the node installation (#222) ### Added @@ -178,7 +184,7 @@ See you in future commits, issues and PRs :D ## [2.0.1] - 2020-10-28 -**Huge thanks to [@ezeholz](https://github.com/ezeholz)** who has offered to maintain the module fron now on! +**Huge thanks to [@ezeholz](https://github.com/ezeholz)** who has offered to maintain the module from now on! Credit for this (and future) versions and releases goes to @ezeholz (unless noted otherwise). Now requires MagicMirror² version 2.7. @@ -191,7 +197,7 @@ Now requires MagicMirror² version 2.7. ## [2.0.0] - 2019-02-21 -Huge shoutout to [shbatm](https://github.com/shbatm) for his work on this new major version, which brings a new API, custom menus and commands and lots of other stuff: +Huge shout out to [shbatm](https://github.com/shbatm) for his work on this new major version, which brings a new API, custom menus and commands and lots of other stuff: ### Added @@ -307,7 +313,7 @@ Huge shoutout to [shbatm](https://github.com/shbatm) for his work on this new ma - Menu to change the `config.js` - Modules can be installed, added, removed, configured - There will be backups of the five last versions of the `config.js` in the `config` folder - - Some of these parts are hidden behind an "exprimental" warning, do **not** ignore that warning + - Some of these parts are hidden behind an "experimental" warning, do **not** ignore that warning - NOTIFICATION action, see [README.md](README.md#notification-request) for details ### Changed diff --git a/MMM-Remote-Control.js b/MMM-Remote-Control.js index 03584ab..a6043c6 100644 --- a/MMM-Remote-Control.js +++ b/MMM-Remote-Control.js @@ -7,8 +7,6 @@ * MIT Licensed. */ -/* jshint esversion:6 */ - Module.register("MMM-Remote-Control", { requiresVersion: "2.12.0", diff --git a/README.md b/README.md index 8abcfe5..141e62d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This module for the [MagicMirror²](https://github.com/MagicMirrorOrg/MagicMirror) allows you to quickly shutdown your mirror through a web browser. The website should work fine on any device (desktop, smart phone, tablet, ...). -Since we all want our [SD cards to live a long and prosper life](http://raspberrypi.stackexchange.com/a/383) we properly shut down before pulling the power plug everytime, am I right? +Since we all want our [SD cards to live a long and prosper life](http://raspberrypi.stackexchange.com/a/383) we properly shut down before pulling the power plug every time, am I right? Additionally you can hide and show modules on your mirror and do other cool stuff. ![The Main Menu](.github/main.png) @@ -55,7 +55,7 @@ npm install - (3) For security reasons, the MagicMirror² (and therefore the Remote Control) is *not* reachable externally. To change this, configure `address`, and `ipWhitelist` in your `config.js` (see [these lines in the sample config](https://github.com/MagicMirrorOrg/MagicMirror/blob/master/config/config.js.sample#L12-L22)). -For example change `address` to `0.0.0.0` and add two allowed devices with IP-Adresses `192.168.0.42` and `192.168.0.50`: +For example change `address` to `0.0.0.0` and add two allowed devices with IP addresses `192.168.0.42` and `192.168.0.50`: ```js address : '0.0.0.0', @@ -122,7 +122,7 @@ If this happens, simply reconfigure and save it again. ## Call methods from other modules You can call any of the methods provided in the UI directly through a GET request, or a module notification. -For example you can use [MMM-ModuleScheduler](https://forum.magicmirror.builders/topic/691/mmm-modulescheduler) to automatically shutdown your RasberryPi at a certain time, or integrate it with home automation systems. Or use [MMM-Navigate](https://github.com/Ax-LED/MMM-Navigate) to allow direct actions from your Mirror by using a rotating button. +For example you can use [MMM-ModuleScheduler](https://forum.magicmirror.builders/topic/691/mmm-modulescheduler) to automatically shutdown your RaspberryPi at a certain time, or integrate it with home automation systems. Or use [MMM-Navigate](https://github.com/Ax-LED/MMM-Navigate) to allow direct actions from your Mirror by using a rotating button. ### Examples @@ -177,7 +177,7 @@ See some specific examples for controlling your mirror from other modules and ad | :-: | ------------- | | HIDE | Hide a module, with the name (or identifier--see `MODULE_DATA` action) specified by `module` in the payload. You can also send `module: "all"` to hide all modules. | | SHOW | Show a module (see above for how to specify which one). | -| TOGGLE | Toggle a module's visiblity (see above for how to specify which one). | +| TOGGLE | Toggle a module's visibility (see above for how to specify which one). | | FORCE | Force a module to show (see above for how to specify which one). | | MODULE_DATA | Returns a JSON format of the data displayed in the UI, including all valid identifiers for the `HIDE` and `SHOW` action. | @@ -243,7 +243,7 @@ Depending on your installation, some `shell` commands used by this module are no ### Custom Classes You probably wanna hide or show some modules at the same time, right? It's everything that we want this module for, of course. -Well, now you can add as many classes as you like, and define whether they show themself, hide or toggle between the two stages! +Well, now you can add as many classes as you like, and define whether they show themselves, hide or toggle between the two stages! ```js classes: { diff --git a/cspell.config.json b/cspell.config.json new file mode 100644 index 0000000..efea7da --- /dev/null +++ b/cspell.config.json @@ -0,0 +1,77 @@ +{ + "version": "0.2", + "language": "en", + "words": [ + "apikey", + "articlelessdetails", + "articlemoredetails", + "articlenext", + "articleprevious", + "articlescrollup", + "articletogglefull", + "Ausschalten", + "Bethge", + "bokmål", + "cambio", + "chlog", + "defaultmodules", + "Energieoptionen", + "extdocs", + "ezeholz", + "Ezequiel", + "Flickr", + "FULLSCREEN", + "HIDEALERT", + "HIDEALL", + "jopyth", + "juzim", + "kapsolas", + "Keyport", + "khassel", + "Kristjan", + "kvpairs", + "listname", + "LOCKSTRING", + "lockstrings", + "longname", + "MODULEAPI", + "MONITOROFF", + "MONITORON", + "MONITORSTATUS", + "MONITORTIMED", + "MONITORTOGGLE", + "mymodulename", + "mypayload", + "Mysh", + "navicon", + "newsfeed", + "newsitems", + "Norsk", + "plusplus", + "REFRESHMM", + "remotecontrol", + "RESTARTMM", + "revparse", + "SENDALERT", + "shbatm", + "showalert", + "SHOWALL", + "somthingelse", + "TOGGLEFULLSCREEN", + "UPDATEMM", + "userpresence", + "vcgencmd", + "Wooo", + "xsmall", + "YOURAPIKEY" + ], + "ignorePaths": [ + "modules.json", + "node_modules/**", + "translations/**", + "*.min.js" + ], + "dictionaries": [ + "node" + ] +} diff --git a/custom_menu.example.json b/custom_menu.example.json index e487573..cd8f6e7 100644 --- a/custom_menu.example.json +++ b/custom_menu.example.json @@ -10,7 +10,7 @@ "text": "Menu Item 1", "action": "NOTIFICATION", "content": { - "notification": "NOTIFCATION_TEXT_1", + "notification": "NOTIFICATION_TEXT_1", "payload": "This notification requires a string payload" } }, @@ -21,7 +21,7 @@ "text": "Menu Item 2", "action": "NOTIFICATION", "content": { - "notification": "NOTIFCATION_TEXT_2", + "notification": "NOTIFICATION_TEXT_2", "payload": { "title": "Payload Object", "message": "This notification requires a payload object" @@ -35,7 +35,7 @@ "text": "Menu Item 3", "action": "NOTIFICATION", "content": { - "notification": "NOTIFCATION_TEXT_3", + "notification": "NOTIFICATION_TEXT_3", "payload": null } }, @@ -52,7 +52,7 @@ "text": "Sub-Menu Item 1", "action": "NOTIFICATION", "content": { - "notification": "NOTIFCATION_TEXT_4", + "notification": "NOTIFICATION_TEXT_4", "payload": "This notification requires a string payload" } }, @@ -63,7 +63,7 @@ "text": "Sub-Menu Item 2", "action": "NOTIFICATION", "content": { - "notification": "NOTIFCATION_TEXT_5", + "notification": "NOTIFICATION_TEXT_5", "payload": { "title": "Payload Object", "message": "This notification requires a payload object" diff --git a/docs/swagger.json b/docs/swagger.json index b56b378..ebb569d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -700,7 +700,7 @@ "NO_RISK_NO_FUN": "No risk no fun!", "CONFIRM_SHUTDOWN": "The system will shut down.", "CONFIRM_RESTART": "The system will restart.", - "LOAD_ERROR": "If you see this message, an errror occured when loading the javascript file. Please go to the following link and see if this a known problem with your browser:", + "LOAD_ERROR": "If you see this message, an error occurred when loading the javascript file. Please go to the following link and see if this a known problem with your browser:", "ISSUE_LINK": "Github issue page", "DONE": "Done.", "ERROR": "Error!", diff --git a/node_helper.js b/node_helper.js index f98d970..b599246 100644 --- a/node_helper.js +++ b/node_helper.js @@ -4,7 +4,6 @@ * By Joseph Bethge * MIT Licensed. */ -/* jshint node: true, esversion: 6 */ const NodeHelper = require("node_helper"); const path = require("path"); @@ -315,7 +314,7 @@ module.exports = NodeHelper.create(Object.assign({ var filename = path.resolve(modulePath + "/" + module.longname + ".js"); try { fs.accessSync(filename, fs.F_OK); - var jsfile = require(filename); + var jsFile = require(filename); /* Defaults are stored when Module.register is called during require(filename); */ } catch (e) { if (e.code == "ENOENT") { @@ -524,8 +523,8 @@ module.exports = NodeHelper.create(Object.assign({ return; } if (query.data === "classes") { - var thisconfig = this.getConfig().modules.find(m => m.module === "MMM-Remote-Control").config || {}; - this.sendResponse(res, undefined, { query: query, data: thisconfig.classes ? thisconfig.classes : {} }); + var thisConfig = this.getConfig().modules.find(m => m.module === "MMM-Remote-Control").config || {}; + this.sendResponse(res, undefined, { query: query, data: thisConfig.classes ? thisConfig.classes : {} }); return; } if (query.data === "saves") { @@ -553,14 +552,14 @@ module.exports = NodeHelper.create(Object.assign({ return; } if (query.data === "modules") { - if (!this.checkInititialized(res)) { return; } + if (!this.checkInitialized(res)) { return; } this.callAfterUpdate(() => { this.sendResponse(res, undefined, { query: query, data: self.configData.moduleData }); }); return; } if (query.data === "brightness") { - if (!this.checkInititialized(res)) { return; } + if (!this.checkInitialized(res)) { return; } this.callAfterUpdate(() => { this.sendResponse(res, undefined, { query: query, result: self.configData.brightness }); }); diff --git a/package.json b/package.json index 6bf35ca..04a00eb 100644 --- a/package.json +++ b/package.json @@ -26,5 +26,11 @@ "node-fetch": "^2.7.0", "simple-git": "latest", "uuid": "^3.3.2" + }, + "devDependencies": { + "cspell": "^8.15.7" + }, + "scripts": { + "test": "cspell ." } } diff --git a/remote.js b/remote.js index 013adb0..1e06950 100644 --- a/remote.js +++ b/remote.js @@ -1,5 +1,4 @@ // main javascript file for the remote control page -/* jshint esversion: 6 */ var Remote = { name: "MMM-Remote-Control", @@ -26,7 +25,7 @@ var Remote = { autoHideDelay: 1000, // ms /* socket() - * Returns a socket object. If it doesn"t exist, it"s created. + * Returns a socket object. If it doesn't exist, it's created. * It also registers the notification callback. */ socket() { diff --git a/scripts/download_modules.js b/scripts/download_modules.js index 14cfbb6..054cb9a 100644 --- a/scripts/download_modules.js +++ b/scripts/download_modules.js @@ -11,7 +11,6 @@ * MIT Licensed. */ -/* jshint esversion:6, node: true */ const fetch = require("node-fetch"); const path = require("path"); const fs = require("fs");