File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -192,16 +192,26 @@ private function getMustacheTemplates()
192192 // add templates and load less files from block plugins
193193 $ plugin_template_files = array ();
194194
195- foreach (\Courseware::$ registered_blocks as $ path ) {
195+ foreach (\Courseware::$ registered_blocks as $ block ) {
196196 $ plugin_template_files = array_merge (
197197 $ plugin_template_files ,
198- glob ($ path . '/* /templates/*.mustache ' )
198+ glob ($ block [ ' path ' ] . '/templates/*.mustache ' )
199199 );
200200
201- foreach (glob ($ path . '/*/css/*.less ' ) as $ source ) {
202- PageLayout::addHeadElement ('style ' ,
203- ['type ' => 'text/less ' ], file_get_contents ($ source ));
201+ // add stylesheets for block to page
202+ foreach (glob ($ block ['path ' ] . '/css/*.less ' ) as $ source ) {
203+ PageLayout::addHeadElement ('link ' , [
204+ 'rel ' => 'stylesheet/less ' ,
205+ 'type ' => 'text/css ' ,
206+ 'href ' => UrlHelper::getURL ($ source , ['cid ' => null ])
207+ ]);
204208 }
209+
210+ // add base js for block to page
211+ PageLayout::addHeadElement ('script ' , [
212+ 'src ' => URLHelper::getUrl ($ block ['path ' ] .'/js/ ' . basename ($ block ['path ' ]) .'.js ' ),
213+ 'type ' => 'module '
214+ ], '' );
205215 }
206216
207217 // add base templates, integrating plugin templates
Original file line number Diff line number Diff line change @@ -46,11 +46,11 @@ public function getBlockClasses()
4646 if (!isset ($ classes )) {
4747 $ classes = array_map ("basename " , glob ($ this ->getPluginDir () . '/blocks/* ' ));
4848
49- foreach (\Courseware::$ registered_blocks as $ path ) {
50- $ classes = array_merge ( $ classes , array_map ( " basename " , glob ( $ path . ' /* ' )) );
49+ foreach (\Courseware::$ registered_blocks as $ block ) {
50+ $ classes[] = basename ( $ block [ ' path ' ] );
5151
5252 // load classes in blocks
53- foreach (glob ($ path . '/* /*.php ' ) as $ class ) {
53+ foreach (glob ($ block [ ' path ' ] . '/*.php ' ) as $ class ) {
5454 require_once ($ class );
5555 }
5656 }
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ module.exports = {
1717 chunkFilename : '[name].chunk.js' ,
1818 filename : '[name].js' ,
1919 pathinfo : ! isProd ,
20- publicPath : ! isProd ? 'http://localhost:8081/' : undefined
20+ publicPath : ! isProd ? 'http://localhost:8081/' : undefined ,
21+ library : '[name]'
2122 } ,
2223 module : {
2324 rules : [
You can’t perform that action at this time.
0 commit comments