From a562026bd392f74f74c90966c6e6e15c178b5136 Mon Sep 17 00:00:00 2001 From: Josaphat Imani Date: Mon, 12 Feb 2024 17:47:18 +0200 Subject: [PATCH] Added bootstrap files to optimized css/js files --- modules/2fa/modules.php | 4 ++-- modules/core/functions.php | 6 +++--- modules/core/output_modules.php | 18 ++++++++--------- modules/core/site.css | 5 +---- scripts/config_gen.php | 28 ++++++++++++++++++++++++-- tests/phpunit/modules/core/modules.php | 6 +++--- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/modules/2fa/modules.php b/modules/2fa/modules.php index 21750235bb..05f7590559 100644 --- a/modules/2fa/modules.php +++ b/modules/2fa/modules.php @@ -244,7 +244,7 @@ protected function output() {
-
+

@@ -255,7 +255,7 @@ protected function output() {
- +
diff --git a/modules/core/functions.php b/modules/core/functions.php index 7946db60b5..8b529f383b 100644 --- a/modules/core/functions.php +++ b/modules/core/functions.php @@ -424,9 +424,9 @@ function setup_base_page($name, $source=false) { add_handler($name, 'http_headers', true, $source); add_output($name, 'header_start', false, $source); - add_output($name, 'header_css', true, $source); + add_output($name, 'header_css', false, $source); add_output($name, 'header_content', false, $source); - add_output($name, 'js_data', true, $source); + add_output($name, 'js_data', false, $source); add_output($name, 'js_search_data', true, $source); add_output($name, 'header_end', false, $source); add_output($name, 'content_start', false, $source); @@ -441,7 +441,7 @@ function setup_base_page($name, $source=false) { add_output($name, 'content_section_start', true, $source); add_output($name, 'content_section_end', true, $source); add_output($name, 'save_reminder', true, $source); - add_output($name, 'page_js', true, $source); + add_output($name, 'page_js', false, $source); add_output($name, 'content_end', false, $source); }} diff --git a/modules/core/output_modules.php b/modules/core/output_modules.php index a4c6352273..8bb669a345 100644 --- a/modules/core/output_modules.php +++ b/modules/core/output_modules.php @@ -236,7 +236,7 @@ protected function output() { $fancy_login = $this->get('fancy_login_allowed'); if(!$fancy_login){ return '
-
+

@@ -248,9 +248,9 @@ protected function output() {
'. - '
'.$stay_logged_in. + '
'.$stay_logged_in. ' - +
@@ -401,10 +401,7 @@ protected function output() { ''. ''. ''. - ''. - ''. - ''. - ''; + ''; if ($this->get('router_login_state')) { $res .= ''; @@ -506,10 +503,10 @@ class Hm_Output_header_css extends Hm_Output_Module { */ protected function output() { $res = ''; - $res .= ''; - $res .= ''; $mods = $this->get('router_module_list'); if (DEBUG_MODE) { + $res .= ''; + $res .= ''; foreach (glob(APP_PATH.'modules/**', GLOB_ONLYDIR | GLOB_MARK) as $name) { $rel_name = str_replace(APP_PATH, '', $name); $mod = str_replace(array('modules/', '/'), '', $rel_name); @@ -544,7 +541,8 @@ class Hm_Output_page_js extends Hm_Output_Module { protected function output() { if (DEBUG_MODE) { $res = ''; - $js_lib = ''; + $js_lib = ''; + $js_lib .= ''; $js_lib .= ''; $js_lib .= ''; $js_lib .= ''; diff --git a/modules/core/site.css b/modules/core/site.css index b877deff38..56bdf62cbc 100644 --- a/modules/core/site.css +++ b/modules/core/site.css @@ -62,10 +62,8 @@ td { vertical-align: top; } .disabled_input, input:disabled { color: #aaa !important; background-color: #ddd; } input, option, select, button { font-size: 100%; padding: 3px; } textarea, select, input, button { border: solid 1px #ddd; background-color: #fff; color: #333; border-radius: 3px; } -.login_form { float: left; font-size: 90%; padding-top: 60px; height: 300px; border-radius: 0px 0px 10px 0px; margin: 0px; background-color: #f5f5f5; width: 300px; padding-left: 20px; } + .screen_reader { position:absolute; top:auto; width:1px; height:1px; overflow:hidden; } -.login_form input { clear: both; float: left; padding: 4px; margin-left: 20px; margin-top: 10px; margin-bottom: 10px; } -#username, #password { width: 200px; } .err { color: red !important; } .debug { color: teal; font-size: 75%; float: right; clear: both; margin: 20px; } .inner_list a { padding-right: 5px; } @@ -260,7 +258,6 @@ div.unseen, .unseen .subject { font-weight: 700; } .mobile .checkbox_cell { width: 35px; } .mobile .checkbox_cell label { width: 30px; height: 30px; } .mobile .github_para { white-space: normal !important; } -.mobile .login_form { margin-top: 60px; display: block; float: none; width: 100%; background-color: #fff; font-size: 130%; height: auto; } .mobile .account_icon { width: 20px; height: 20px; } .mobile .imap_filter { display: none; } .mobile .list_controls { color: #777; background: linear-gradient(180deg, #fff, #fff, #f7f2ef); height: 48px; padding-left: 5px; padding-right: 5px; } diff --git a/scripts/config_gen.php b/scripts/config_gen.php index a77f84d091..7eb898bdc2 100644 --- a/scripts/config_gen.php +++ b/scripts/config_gen.php @@ -229,14 +229,18 @@ function combine_includes($js, $js_compress, $css, $css_compress, $settings) { $js_hash = ''; $css_hash = ''; if ($css) { - $css_out = compress($css, $css_compress); + $css_out = file_get_contents("vendor/twbs/bootstrap/dist/css/bootstrap.min.css"); + $css_out .= file_get_contents("vendor/twbs/bootstrap-icons/font/bootstrap-icons.css"); + $css_out .= compress($css, $css_compress); $css_hash = build_integrity_hash($css_out); file_put_contents('site.css', $css_out); printf("site.css file created\n"); } if ($js) { $mods = get_modules($settings); - $js_lib = file_get_contents("third_party/cash.min.js"); + $js_lib = file_get_contents("vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js") . "\n\n"; + $js_lib .= file_get_contents("vendor/twbs/bootstrap/dist/js/bootstrap.min.js") . "\n\n"; + $js_lib .= file_get_contents("third_party/cash.min.js"); if (in_array('sievefilters', $mods, true)) { $js_lib .= file_get_contents("third_party/tingle.min.js"); } @@ -290,6 +294,24 @@ function write_config_file($settings, $filters) { printf("dynamic.php file written\n"); } +/** + * Copies bootstrap icons fonts folder as it is + * referenced and needed by bootstrap icons css file + * + * @return void + */ +function append_bootstrap_icons_files() { + if (!is_dir("site/fonts")) { + mkdir('site/fonts', 0755); + } + $source_folder = 'vendor/twbs/bootstrap-icons/font/fonts/'; + $files = glob("$source_folder*.*"); + foreach($files as $file){ + $dest_forlder = str_replace($source_folder, "site/fonts/", $file); + copy($file, $dest_forlder); + } +} + /** * Copies the site.js and site.css files to the site/ directory, and creates * a production version of the index.php file. @@ -303,6 +325,8 @@ function create_production_site($assets, $settings, $hashes) { printf("creating production site\n"); copy('site.css', 'site/site.css'); copy('site.js', 'site/site.js'); + append_bootstrap_icons_files(); + $index_file = file_get_contents('index.php'); $index_file = preg_replace("/APP_PATH', ''/", "APP_PATH', '".APP_PATH."'", $index_file); $index_file = preg_replace("/CACHE_ID', ''/", "CACHE_ID', '".urlencode(Hm_Crypt::unique_id(32))."'", $index_file); diff --git a/tests/phpunit/modules/core/modules.php b/tests/phpunit/modules/core/modules.php index cfaceeffd6..56c7b7f23d 100644 --- a/tests/phpunit/modules/core/modules.php +++ b/tests/phpunit/modules/core/modules.php @@ -774,7 +774,7 @@ public function test_msgs() { public function test_header_start() { $test = new Output_Test('header_start', 'core'); $res = $test->run(); - $this->assertEquals(array(''), $res->output_response); + $this->assertEquals(array(''), $res->output_response); } /** * @preserveGlobalState disabled @@ -1530,10 +1530,10 @@ public function test_page_js_debug() { $test = new Output_Test('page_js', 'core'); $test->handler_response = array('encrypt_ajax_requests' => true, 'router_module_list' => array('foo', 'core')); $res = $test->run(); - $this->assertEquals(array(''), $res->output_response); + $this->assertEquals(array(''), $res->output_response); $test->handler_response = array('encrypt_ajax_requests' => true, 'router_module_list' => array('imap')); $res = $test->run(); - $this->assertEquals(array(''), $res->output_response); + $this->assertEquals(array(''), $res->output_response); } /** * @preserveGlobalState disabled