From 6ee1412b9876507489fe294ad813aecddd7d1090 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 17 Aug 2018 13:35:31 +0200 Subject: [PATCH] Create new build file that generates only bootstrap + font awesome This is needed for some ckeditor calls Add api_* function in order to call that file. --- assets/css/bootstrap.scss | 2 ++ assets/js/bootstrap.js | 2 ++ main/admin/settings.lib.php | 2 +- main/inc/lib/api.lib.php | 10 ++++++++++ main/inc/lib/javascript/ckeditor/config_js.php | 4 ++-- main/inc/lib/pdf.lib.php | 2 +- main/inc/lib/template.lib.php | 2 +- .../Component/Editor/CkEditor/CkEditor.php | 4 ++-- webpack.config.js | 15 +++++++++++---- 9 files changed, 32 insertions(+), 11 deletions(-) create mode 100644 assets/css/bootstrap.scss create mode 100644 assets/js/bootstrap.js diff --git a/assets/css/bootstrap.scss b/assets/css/bootstrap.scss new file mode 100644 index 0000000000..350f25eabc --- /dev/null +++ b/assets/css/bootstrap.scss @@ -0,0 +1,2 @@ +@import "~bootstrap/scss/bootstrap"; +@import "~@fortawesome/fontawesome-free/css/all.css"; \ No newline at end of file diff --git a/assets/js/bootstrap.js b/assets/js/bootstrap.js new file mode 100644 index 0000000000..f9f69c67ae --- /dev/null +++ b/assets/js/bootstrap.js @@ -0,0 +1,2 @@ +import 'bootstrap'; +import '@fortawesome/fontawesome-free'; \ No newline at end of file diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index eaac34e33e..c39501b48b 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -1214,7 +1214,7 @@ function addEditTemplate() } // Store the information in the database (as insert or as update). - $bootstrap = api_get_css(api_get_path(WEB_PUBLIC_PATH).'assets/bootstrap/dist/css/bootstrap.min.css'); + $bootstrap = api_get_bootstrap_and_font_awesome(); $viewport = ''; if ($_GET['action'] == 'add') { diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index d17f590ed6..9688884884 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -7231,6 +7231,16 @@ function api_get_css($file, $media = 'screen') return ''."\n"; } +function api_get_bootstrap_and_font_awesome($returnOnlyPath = false) +{ + $url = api_get_path(WEB_PUBLIC_PATH).'build/css/bootstrap.css'; + if ($returnOnlyPath) { + return $url; + } + + return ''."\n"; +} + /** * Returns the js header to include the jquery library. */ diff --git a/main/inc/lib/javascript/ckeditor/config_js.php b/main/inc/lib/javascript/ckeditor/config_js.php index 813ef10e3f..a68a068157 100644 --- a/main/inc/lib/javascript/ckeditor/config_js.php +++ b/main/inc/lib/javascript/ckeditor/config_js.php @@ -13,11 +13,11 @@ if (api_get_setting('more_buttons_maximized_mode') === 'true') { $template = new Template(); $template->assign( 'bootstrap_css', - api_get_path(WEB_PUBLIC_PATH).'assets/bootstrap/dist/css/bootstrap.min.css' + api_get_bootstrap_and_font_awesome(true) ); $template->assign( 'font_awesome_css', - api_get_path(WEB_PUBLIC_PATH).'assets/fontawesome/css/font-awesome.min.css' + '' ); $template->assign( 'css_editor', diff --git a/main/inc/lib/pdf.lib.php b/main/inc/lib/pdf.lib.php index 9d06778388..003258be09 100755 --- a/main/inc/lib/pdf.lib.php +++ b/main/inc/lib/pdf.lib.php @@ -460,7 +460,7 @@ class PDF if ($addDefaultCss) { $basicStyles = [ - api_get_path(SYS_PATH).'web/assets/bootstrap/dist/css/bootstrap.min.css', + api_get_bootstrap_and_font_awesome(true), api_get_path(SYS_PATH).'web/css/base.css', api_get_path(SYS_PATH).'web/css/themes/'.api_get_visual_theme().'/default.css', ]; diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 9ae75d675c..546e1aa75d 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -677,7 +677,7 @@ class Template /** * Set theme, include mainstream CSS files. - * + * @deprecated * @see setCssCustomFiles() for additional CSS sheets */ public function setCssFiles() diff --git a/src/CoreBundle/Component/Editor/CkEditor/CkEditor.php b/src/CoreBundle/Component/Editor/CkEditor/CkEditor.php index 918746669e..4d0d82a605 100644 --- a/src/CoreBundle/Component/Editor/CkEditor/CkEditor.php +++ b/src/CoreBundle/Component/Editor/CkEditor/CkEditor.php @@ -56,8 +56,8 @@ class CkEditor extends Editor { $style = ''; if (trim($this->value) == '' || $this->value == '') { - $style = api_get_css_asset('bootstrap/dist/css/bootstrap.min.css'); - $style .= api_get_css_asset('fontawesome/css/font-awesome.min.css'); + $style = api_get_bootstrap_and_font_awesome(); + //$style .= api_get_css_asset('fontawesome/css/font-awesome.min.css'); $style .= api_get_css(ChamiloApi::getEditorDocStylePath()); } diff --git a/webpack.config.js b/webpack.config.js index b4e07daf43..83f882a299 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -18,10 +18,18 @@ Encore // Reads the "assets/js/vendor.js" file and it will generate the file public/build/vendor.js file .addEntry('vendor', './assets/js/vendor.js') .addEntry('app', './assets/js/app.js') + .addEntry('bootstrap', './assets/js/bootstrap.js') // Reads app.scss -> output as web/build/css/base.css .addStyleEntry('css/app', './assets/css/app.scss') + .addStyleEntry('css/bootstrap', './assets/css/bootstrap.scss') + + .addStyleEntry('css/chat', './assets/css/chat.css') + .addStyleEntry('css/document', './assets/css/document.css') .addStyleEntry('css/editor', './assets/css/editor.css') + .addStyleEntry('css/editor_content', './assets/css/editor_content.css') + .addStyleEntry('css/markdown', './assets/css/markdown.css') .addStyleEntry('css/print', './assets/css/print.css') + .addStyleEntry('css/responsive', './assets/css/responsive.css') .addStyleEntry('css/scorm', './assets/css/scorm.css') .enableSourceMaps(!Encore.isProduction()) @@ -66,13 +74,12 @@ var themes = [ // Add Chamilo themes themes.forEach(function (theme) { - Encore.addStyleEntry('css/themes/'+theme+'/default', './assets/css/themes/'+theme+'/default.css') - ; + Encore.addStyleEntry('css/themes/' + theme + '/default', './assets/css/themes/' + theme + '/default.css'); // Copy images from themes into public/build Encore.addPlugin(new copyWebpackPlugin([{ - from: 'assets/css/themes/'+theme+'/images', - to: 'css/themes/'+theme+'/images' + from: 'assets/css/themes/' + theme + '/images', + to: 'css/themes/' + theme + '/images' }, ])); });