mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 12:12:20 +00:00
Added module loader for external modules
A simple module loader to load modules dropped into the modules folder.
This commit is contained in:
parent
5ca05a3e34
commit
c7974e4fa0
11
controllers/modules.php
Normal file
11
controllers/modules.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$modules = array_filter(glob('modules/*'), 'is_dir');
|
||||
foreach ($modules as &$module) {
|
||||
//Add JS file of module
|
||||
print_r('<script src="'.$module.'/main.js" type="text/javascript"></script>'."\xA");
|
||||
//Add CSS file of module
|
||||
print_r('<link rel="stylesheet" type="text/css" href="'.$module.'/style.css">'."\xA");
|
||||
//Get and add HTML Elements
|
||||
print_r(file_get_contents($module.'/elements.html'));
|
||||
}
|
||||
?>
|
@ -36,5 +36,6 @@
|
||||
<script src="js/news/news.js"></script>
|
||||
<script src="js/main.js?nocache=<?php echo md5(microtime()) ?>"></script>
|
||||
<!-- <script src="js/socket.io.min.js"></script> -->
|
||||
<?php include($_SERVER['DOCUMENT_ROOT'].'/controllers/modules.php');?>
|
||||
</body>
|
||||
</html>
|
||||
|
15
modules/README.md
Normal file
15
modules/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
MagicMirror
|
||||
===========
|
||||
|
||||
##Modules
|
||||
A module has to contain three files: main.js, style.css and elements.html
|
||||
Other files can be loaded from within those.
|
||||
|
||||
### elements.html
|
||||
Put your custom divs and other html elements in this file (don't include any body or header tags)
|
||||
|
||||
### main.js
|
||||
Your plugins JavaScript.
|
||||
|
||||
### style.css
|
||||
CSS for your HTML elements.
|
1
modules/test-module/elements.html
Normal file
1
modules/test-module/elements.html
Normal file
@ -0,0 +1 @@
|
||||
<!--<div id="example"> </div>-->
|
1
modules/test-module/main.js
Normal file
1
modules/test-module/main.js
Normal file
@ -0,0 +1 @@
|
||||
console.log("Hello from test-module")
|
0
modules/test-module/style.css
Normal file
0
modules/test-module/style.css
Normal file
Loading…
x
Reference in New Issue
Block a user