[Web] Minify more resources, fix missing JS

master
andryyy 2019-01-31 15:45:31 +01:00
parent 61cd2c0353
commit ea83f72981
No known key found for this signature in database
GPG Key ID: 8EC34FF2794E25EF
10 changed files with 32 additions and 23 deletions

View File

@ -1009,8 +1009,8 @@ echo "var pagination_size = '". $PAGINATION_SIZE . "';\n";
echo "var log_pagination_size = '". $LOG_PAGINATION_SIZE . "';\n";
?>
</script>
<script src="/js/site/admin.js"></script>
<?php
$js_minifier->add('/web/js/site/admin.js');
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
} else {
header('Location: /');

View File

@ -341,8 +341,8 @@ echo "var log_pagination_size = '". $LOG_PAGINATION_SIZE . "';\n";
?>
</script>
<script src="/js/site/debug.js"></script>
<?php
$js_minifier->add('/web/js/site/debug.js');
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
}
else {

View File

@ -1226,8 +1226,7 @@ echo "var csrf_token = '". $_SESSION['CSRF']['TOKEN'] . "';\n";
echo "var pagination_size = '". $PAGINATION_SIZE . "';\n";
?>
</script>
<script src="/js/footable.min.js"></script>
<script src="/js/edit.js"></script>
<?php
$js_minifier->add('/web/js/site/edit.js');
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
?>

View File

@ -3,7 +3,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/modals/footer.php';
logger();
?>
<div style="margin-bottom: 100px;"></div>
<script><?=$js_footer;?></script>
<script type='text/javascript'><?=$js_minifier->minify();?></script>
<script>
<?php
$lang_footer = json_encode($lang['footer']);

View File

@ -11,17 +11,30 @@
<script src="/js/html5shiv.min.js"></script>
<script src="/js/respond.min.js"></script>
<![endif]-->
<script src="/js/jquery-1.12.4.min.js"></script>
<style><?=$css_header;?></style>
<script type='text/javascript' src="/js/jquery-1.12.4.min.js"></script>
<?php if (strtolower(trim($DEFAULT_THEME)) != "lumen"): ?>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/<?= strtolower(trim($DEFAULT_THEME)); ?>/bootstrap.min.css">
<?php endif; ?>
<?= (preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/site/mailbox.css">' : null; ?>
<?= (preg_match("/admin/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/site/admin.css">' : null; ?>
<?= (preg_match("/user/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/site/user.css">' : null; ?>
<?= (preg_match("/edit/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/site/edit.css">' : null; ?>
<?= (preg_match("/quarantine/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/site/quarantine.css">' : null; ?>
<?= (preg_match("/debug/i", $_SERVER['REQUEST_URI'])) ? '<link rel="stylesheet" href="/css/site/debug.css">' : null; ?>
<?php endif;
if (preg_match("/mailbox/i", $_SERVER['REQUEST_URI'])) {
$css_minifier->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');
}
?>
<style><?=$css_minifier->minify();?></style>
<link rel="shortcut icon" href="/favicon.png" type="image/png">
<link rel="icon" href="/favicon.png" type="image/png">
</head>

View File

@ -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']);

View File

@ -108,6 +108,6 @@ $_SESSION['return_to'] = $_SERVER['REQUEST_URI'];
</div>
</div>
</div><!-- /.container -->
<script src="/js/site/index.js"></script>
<?php
$js_minifier->add('/web/js/site/index.js');
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';

View File

@ -336,8 +336,8 @@ echo "var is_dual = " . $is_dual . ";\n";
echo "var pagination_size = '". $PAGINATION_SIZE . "';\n";
?>
</script>
<script src="/js/site/mailbox.js"></script>
<?php
$js_minifier->add('/web/js/site/mailbox.js');
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
}
else {

View File

@ -62,8 +62,8 @@ echo "var role = '". $role . "';\n";
echo "var pagination_size = '". $PAGINATION_SIZE . "';\n";
?>
</script>
<script src="/js/site/quarantine.js"></script>
<?php
$js_minifier->add('/web/js/site/quarantine.js');
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
} else {
header('Location: /');

View File

@ -412,7 +412,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
</div>
<form class="form-inline" data-id="add_wl_policy_mailbox">
<div class="input-group" data-acl="<?=$_SESSION['acl']['spam_policy'];?>">
<input type="text" class="form-control" name="object_from" id="object_from" placeholder="*@example.org" required>
<input type="text" class="form-control" name="object_from" placeholder="*@example.org" required>
<span class="input-group-btn">
<button class="btn btn-default" data-action="add_item" data-id="add_wl_policy_mailbox" data-api-url='add/mailbox-policy' data-api-attr='{"username":<?= json_encode($username); ?>,"object_list":"wl"}' href="#"><span class="glyphicon glyphicon-plus"></span> <?=$lang['user']['spamfilter_table_add'];?></button>
</span>
@ -435,7 +435,7 @@ elseif (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == '
</div>
<form class="form-inline" data-id="add_bl_policy_mailbox">
<div class="input-group" data-acl="<?=$_SESSION['acl']['spam_policy'];?>">
<input type="text" class="form-control" name="object_from" id="object_from" placeholder="*@example.org" required>
<input type="text" class="form-control" name="object_from" placeholder="*@example.org" required>
<span class="input-group-btn">
<button class="btn btn-default" data-action="add_item" data-id="add_bl_policy_mailbox" data-api-url='add/mailbox-policy' data-api-attr='{"username":<?= json_encode($username); ?>,"object_list":"bl"}' href="#"><span class="glyphicon glyphicon-plus"></span> <?=$lang['user']['spamfilter_table_add'];?></button>
</span>
@ -485,9 +485,8 @@ echo "var mailcow_cc_username = '". $_SESSION['mailcow_cc_username'] . "';\n";
echo "var pagination_size = '". $PAGINATION_SIZE . "';\n";
?>
</script>
<script src="/js/footable.min.js"></script>
<script src="/js/user.js"></script>
<?php
$js_minifier->add('/web/js/site/user.js');
require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/footer.inc.php';
}
else {