From 01ee51e0274e4ca69ee2381507552361c11ff7ab Mon Sep 17 00:00:00 2001 From: Paul-Vincent Roll Date: Thu, 28 Jan 2016 11:13:27 +0100 Subject: [PATCH] Added [module] shortcut [module] in elements.html get replaced by the modules path. --- controllers/modules.php | 2 +- modules/README.md | 10 +++++----- modules/test-module/elements.html | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/controllers/modules.php b/controllers/modules.php index e61f8e68..249f218d 100644 --- a/controllers/modules.php +++ b/controllers/modules.php @@ -31,6 +31,6 @@ //Add the modules CSS file print_r(''."\xA"); //Get and add HTML Elements - print_r(file_get_contents($module.'/elements.html')); + print_r(str_replace("[module]",$module ,file_get_contents($module.'/elements.html'))); } ?> \ No newline at end of file diff --git a/modules/README.md b/modules/README.md index 7ce11bec..5b280f04 100644 --- a/modules/README.md +++ b/modules/README.md @@ -2,18 +2,18 @@ MagicMirror =========== ##Modules -A module has to contain four files: main.js, style.css, elements.html and include.php +A module has to contain four files: `main.js`, `style.css`, `elements.html` and `include.php`. Other files can be loaded from within those. ### include.php -If you happen to need any other css or js file from remote host or a local file you can add it in include.php. +If you happen to need any other css or js file from remote host or a local file you can add it in `include.php`. It will be loaded before the plugins main javascript, the plugins css and the plugins elements. -Local files starting without http or https will be loaded from the root of the module folder. -If you have a file called test.js in your module just add test.js if you have the same file but in a folder called js inside your module folder add js/test.js. Same is valid for css files. Remote files will be loaded normally from the remote host, no need to specify anything. +Local files starting without `http` or `https` will be loaded from the `root` of the module folder. +If you have a file called `test.js` in your module just add `test.js` if you have the same file but in a folder called `js` inside your module folder add `js/test.js`. Same is valid for css files. Remote files will be loaded normally from the remote host, no need to specify anything. ### elements.html -Put your custom divs and other html elements in this file (don't include any body or header tags) +Put your custom divs and other html elements in this file (don't include any body or header tags). Any refrence of `[module]` will be replaced with the path to the modules root. `[module]/img/test.png` becomes `modules/name_of_module/img/test.png`. ### main.js Your plugins JavaScript. diff --git a/modules/test-module/elements.html b/modules/test-module/elements.html index 0934126a..2bf9bdef 100644 --- a/modules/test-module/elements.html +++ b/modules/test-module/elements.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file