From ea83f72981086433f0a25c90a1e3b3bfac2495ae Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 31 Jan 2019 15:45:31 +0100 Subject: [PATCH] [Web] Minify more resources, fix missing JS --- data/web/admin.php | 2 +- data/web/debug.php | 2 +- data/web/edit.php | 3 +-- data/web/inc/footer.inc.php | 2 +- data/web/inc/header.inc.php | 31 +++++++++++++++++++++--------- data/web/inc/prerequisites.inc.php | 2 -- data/web/index.php | 2 +- data/web/mailbox.php | 2 +- data/web/quarantine.php | 2 +- data/web/user.php | 7 +++---- 10 files changed, 32 insertions(+), 23 deletions(-) diff --git a/data/web/admin.php b/data/web/admin.php index d2c4b91f..cd10f6d4 100644 --- a/data/web/admin.php +++ b/data/web/admin.php @@ -1009,8 +1009,8 @@ echo "var pagination_size = '". $PAGINATION_SIZE . "';\n"; echo "var log_pagination_size = '". $LOG_PAGINATION_SIZE . "';\n"; ?> - add('/web/js/site/admin.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; } else { header('Location: /'); diff --git a/data/web/debug.php b/data/web/debug.php index 00a28277..bbeda91c 100644 --- a/data/web/debug.php +++ b/data/web/debug.php @@ -341,8 +341,8 @@ echo "var log_pagination_size = '". $LOG_PAGINATION_SIZE . "';\n"; ?> - add('/web/js/site/debug.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; } else { diff --git a/data/web/edit.php b/data/web/edit.php index 6e1e0630..c44464df 100644 --- a/data/web/edit.php +++ b/data/web/edit.php @@ -1226,8 +1226,7 @@ echo "var csrf_token = '". $_SESSION['CSRF']['TOKEN'] . "';\n"; echo "var pagination_size = '". $PAGINATION_SIZE . "';\n"; ?> - - add('/web/js/site/edit.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; ?> diff --git a/data/web/inc/footer.inc.php b/data/web/inc/footer.inc.php index d235bd4c..365cf7da 100644 --- a/data/web/inc/footer.inc.php +++ b/data/web/inc/footer.inc.php @@ -3,7 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/modals/footer.php'; logger(); ?>
- + - - + - - ' : null; ?> - ' : null; ?> - ' : null; ?> - ' : null; ?> - ' : null; ?> - ' : null; ?> + add('/web/css/site/mailbox.css'); + } + if (preg_match("/admin/i", $_SERVER['REQUEST_URI'])) { + $css_minifier->add('/web/css/site/admin.css'); + } + if (preg_match("/user/i", $_SERVER['REQUEST_URI'])) { + $css_minifier->add('/web/css/site/user.css'); + } + if (preg_match("/edit/i", $_SERVER['REQUEST_URI'])) { + $css_minifier->add('/web/css/site/edit.css'); + } + if (preg_match("/quarantine/i", $_SERVER['REQUEST_URI'])) { + $css_minifier->add('/web/css/site/quarantine.css'); + } + if (preg_match("/debug/i", $_SERVER['REQUEST_URI'])) { + $css_minifier->add('/web/css/site/debug.css'); + } + ?> + diff --git a/data/web/inc/prerequisites.inc.php b/data/web/inc/prerequisites.inc.php index cc8da030..a16ecc48 100644 --- a/data/web/inc/prerequisites.inc.php +++ b/data/web/inc/prerequisites.inc.php @@ -24,7 +24,6 @@ $js_dir = array_diff(scandir('/web/js/build'), array('..', '.')); foreach ($js_dir as $js_file) { $js_minifier->add('/web/js/build/' . $js_file); } -$js_footer = $js_minifier->minify(); // Minify CSS $css_minifier = new Minify\CSS(); @@ -32,7 +31,6 @@ $css_dir = array_diff(scandir('/web/css/build'), array('..', '.')); foreach ($css_dir as $css_file) { $css_minifier->add('/web/css/build/' . $css_file); } -$css_header = $css_minifier->minify(); // U2F API + T/HOTP API $u2f = new u2flib_server\U2F('https://' . $_SERVER['HTTP_HOST']); diff --git a/data/web/index.php b/data/web/index.php index ea6bb8ea..19372351 100644 --- a/data/web/index.php +++ b/data/web/index.php @@ -108,6 +108,6 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI']; - add('/web/js/site/index.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; diff --git a/data/web/mailbox.php b/data/web/mailbox.php index 60695d42..61d75b32 100644 --- a/data/web/mailbox.php +++ b/data/web/mailbox.php @@ -336,8 +336,8 @@ echo "var is_dual = " . $is_dual . ";\n"; echo "var pagination_size = '". $PAGINATION_SIZE . "';\n"; ?> - add('/web/js/site/mailbox.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; } else { diff --git a/data/web/quarantine.php b/data/web/quarantine.php index c16057ca..60c323d9 100644 --- a/data/web/quarantine.php +++ b/data/web/quarantine.php @@ -62,8 +62,8 @@ echo "var role = '". $role . "';\n"; echo "var pagination_size = '". $PAGINATION_SIZE . "';\n"; ?> - add('/web/js/site/quarantine.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; } else { header('Location: /'); diff --git a/data/web/user.php b/data/web/user.php index f65e20f6..b1a442aa 100644 --- a/data/web/user.php +++ b/data/web/user.php @@ -412,7 +412,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
- + @@ -435,7 +435,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
- + @@ -485,9 +485,8 @@ echo "var mailcow_cc_username = '". $_SESSION['mailcow_cc_username'] . "';\n"; echo "var pagination_size = '". $PAGINATION_SIZE . "';\n"; ?> - - add('/web/js/site/user.js'); require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php'; } else {