├── LICENSE ├── MMM-Remote-Control-Repository.js ├── README.md └── node_helper.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Seongnoh Sean Yi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MMM-Remote-Control-Repository.js: -------------------------------------------------------------------------------- 1 | /* MagicMirror² 2 | * Module: repository updater plugin for MMM-Remote-Control 3 | * 4 | * By eouia 5 | * MIT Licensed. 6 | */ 7 | 8 | Module.register("MMM-Remote-Control-Repository", { 9 | start: function() { 10 | //do nothing 11 | }, 12 | 13 | notificationReceived: function(noti, payload, sender) { 14 | if (noti === "DOM_OBJECTS_CREATED") { 15 | var self = this 16 | var modules = MM.getModules().enumerate(function(m) { 17 | if (m.name === "MMM-Remote-Control") { 18 | self.sendSocketNotification("START") 19 | } 20 | }) 21 | } 22 | } 23 | }) 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MMM-Remote-Control-Repository 2 | 3 | Plugin for [MMM-Remote-Control](https://github.com/Jopyth/MMM-Remote-Control) to update `modules.json` automatically. 4 | 5 | This module updates `modules.json` of `MMM-Remote-Control` automatically with . 6 | 7 | ## Install 8 | 9 | ```sh 10 | cd /modules 11 | git clone https://github.com/MMRIZE/MMM-Remote-Control-Repository 12 | ``` 13 | 14 | ## Configuration 15 | 16 | ```js 17 | { 18 | module: "MMM-Remote-Control-Repository", 19 | }, 20 | ``` 21 | 22 | ## How to Use 23 | 24 | Nothing to do by yourself. Just after installation, when MagicMirror² is restarted, `modules.json` is updated automatically, so you can install new modules with MMM-Remote-Control. 25 | 26 | This plugin doesn't do anything without `MMM-Remote-Control`. 27 | 28 | ## Misc 29 | 30 | Updated `modules.json` will be affected from **NEXT** execution of MagicMirror². 31 | 32 | Thanks to @Jopyth for great module `MMM-Remote-Control`. 33 | -------------------------------------------------------------------------------- /node_helper.js: -------------------------------------------------------------------------------- 1 | /* MagicMirror² 2 | * Module: repository updater plugin for MMM-Remote-Control 3 | * 4 | * By eouia 5 | * MIT Licensed. 6 | */ 7 | 8 | const path = require("path") 9 | const fs = require("fs") 10 | const https = require("https") 11 | const NodeHelper = require("node_helper") 12 | 13 | const repository = "https://github.com/MichMich/MagicMirror/wiki/3rd-Party-Modules" 14 | const moduleJson = "modules.json" 15 | 16 | module.exports = NodeHelper.create({ 17 | start: function() { 18 | // do nothing 19 | }, 20 | 21 | socketNotificationReceived: function(message, payload) { 22 | if (message === "START") { 23 | this.readRepository() 24 | } 25 | }, 26 | 27 | readRepository: function() { 28 | console.log("[RCREPO] Repository scanning...") 29 | var modules = [] 30 | var body = "" 31 | https.get(repository, function(res) { 32 | res.setEncoding("utf8") 33 | res.on("data", function(chunk) { 34 | body += chunk 35 | }) 36 | res.on("end", function() { 37 | var pattern = /\s(.*)<\/a><\/td>\s(.*)<\/td>\s]*>(.*)<\/td>\s<\/tr>/gm 38 | var result 39 | while ((result = pattern.exec(body)) !== null) { 40 | var module = { 41 | url: result[1], 42 | longname: result[2], 43 | author: result[3], 44 | desc: result[4], 45 | id: `${result[3]}/${result[2]}` 46 | } 47 | modules.push(module) 48 | } 49 | var json = JSON.stringify(modules) 50 | var jsonPath = path.resolve(__dirname, "../MMM-Remote-Control", moduleJson) 51 | fs.writeFile(jsonPath, json, "utf8", function(err, data) { 52 | if (err) { 53 | console.log(`[RCREPO] modules.json updating fail: ${err.message}`) 54 | } else { 55 | console.log("[RCREPO] modules.json is updated.") 56 | } 57 | }) 58 | }) 59 | }).on("error", function(e) { 60 | console.log(`[RCREPO] Repository reading error: ${e.message}`) 61 | }) 62 | } 63 | }) 64 | --------------------------------------------------------------------------------