Clean up JavaScript and CSS loaders, prepare for minimized delivery
This commit is contained in:
parent
127b7ad389
commit
af7ca57b41
|
@ -1,19 +1,6 @@
|
|||
<?php
|
||||
|
||||
$jsfiles = array(
|
||||
'js/vendor/jquery-2.1.0.min.js',
|
||||
'js/vendor/jquery.sparkline.min.js',
|
||||
'js/helpers.js',
|
||||
'js/icinga.js',
|
||||
'js/icinga/logger.js',
|
||||
'js/icinga/utils.js',
|
||||
'js/icinga/ui.js',
|
||||
'js/icinga/timer.js',
|
||||
'js/icinga/loader.js',
|
||||
'js/icinga/events.js',
|
||||
'js/icinga/history.js',
|
||||
'js/icinga/module.js',
|
||||
);
|
||||
use Icinga\Web\JavaScript;
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<!--[if lt IE 7]>
|
||||
|
@ -46,7 +33,7 @@ $jsfiles = array(
|
|||
<div id="layout" class="default-layout">
|
||||
<?= $this->render('body.phtml') ?>
|
||||
</div>
|
||||
<?php foreach ($jsfiles as $file): ?>
|
||||
<?php foreach (JavaScript::listFiles() as $file): ?>
|
||||
<script type="text/javascript" src="<?= $this->href($file) ?>"></script>
|
||||
<?php endforeach ?>
|
||||
<script type="text/javascript">
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Web;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use JShrink\Minifier;
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
require_once ICINGA_LIBDIR . '/vendor/JShrink/Minifier.php';
|
||||
// @codingStandardsIgnoreStop
|
||||
|
||||
class JavaScript
|
||||
{
|
||||
protected static $jsFiles = array(
|
||||
'js/helpers.js',
|
||||
'js/icinga.js',
|
||||
'js/icinga/logger.js',
|
||||
'js/icinga/utils.js',
|
||||
'js/icinga/ui.js',
|
||||
'js/icinga/timer.js',
|
||||
'js/icinga/loader.js',
|
||||
'js/icinga/events.js',
|
||||
'js/icinga/history.js',
|
||||
'js/icinga/module.js',
|
||||
);
|
||||
|
||||
protected static $vendorFiles = array(
|
||||
'js/vendor/jquery-2.1.0.min.js',
|
||||
'js/vendor/jquery.sparkline.min.js'
|
||||
);
|
||||
|
||||
public static function listFiles()
|
||||
{
|
||||
return array_merge(self::$vendorFiles, self::$jsFiles);
|
||||
}
|
||||
|
||||
public static function sendMinified()
|
||||
{
|
||||
header('Content-Type: application/javascript');
|
||||
$basedir = Icinga::app()->getBootstrapDirecory();
|
||||
|
||||
$js = $out = '';
|
||||
|
||||
// TODO: Cache header
|
||||
header('Content-Type: text/css');
|
||||
foreach (self::$vendorFiles as $file) {
|
||||
$out .= file_get_contents($basedir . '/' . $file);
|
||||
}
|
||||
|
||||
foreach (self::$jsFiles as $file) {
|
||||
$js .= file_get_contents($basedir . '/' . $file);
|
||||
}
|
||||
$out .= Minifier::minify($js, array('flaggedComments' => false));
|
||||
echo $out;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Web;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Web\LessCompiler;
|
||||
|
||||
class StyleSheet
|
||||
{
|
||||
protected static $lessFiles = array(
|
||||
'css/icinga/defaults.less',
|
||||
'css/icinga/layout-colors.less',
|
||||
'css/icinga/layout-structure.less',
|
||||
'css/icinga/menu.less',
|
||||
'css/icinga/header-elements.less',
|
||||
'css/icinga/main-content.less',
|
||||
'css/icinga/tabs.less',
|
||||
'css/icinga/forms.less',
|
||||
'css/icinga/pagination.less',
|
||||
'css/icinga/monitoring-colors.less',
|
||||
'css/icinga/login.less',
|
||||
);
|
||||
|
||||
public static function send()
|
||||
{
|
||||
header('Content-Type: text/css');
|
||||
$less = new LessCompiler();
|
||||
$basedir = Icinga::app()->getBootstrapDirecory();
|
||||
foreach (self::$lessFiles as $file) {
|
||||
$less->addFile($basedir . '/' . $file);
|
||||
}
|
||||
echo $less->addLoadedModules()->compile();
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ SetEnv APPLICATION_ENV development
|
|||
RewriteEngine on
|
||||
RewriteBase @web_path@
|
||||
RewriteRule ^css/icinga.css css.php
|
||||
RewriteRule ^js/icinga.min.js js.php
|
||||
RewriteCond %{REQUEST_FILENAME} -s [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -l [OR]
|
||||
RewriteCond %{REQUEST_FILENAME} -d
|
||||
|
|
|
@ -1,32 +1,8 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Application\EmbeddedWeb;
|
||||
use Icinga\Web\LessCompiler;
|
||||
use Icinga\Web\StyleSheet;
|
||||
|
||||
require_once dirname(__FILE__). '/../library/Icinga/Application/ApplicationBootstrap.php';
|
||||
require_once dirname(__FILE__). '/../library/Icinga/Application/EmbeddedWeb.php';
|
||||
$app = EmbeddedWeb::start('@icingaweb_config_path@');
|
||||
$less = new LessCompiler();
|
||||
|
||||
header('Content-Type: text/css');
|
||||
// TODO: Cache header
|
||||
|
||||
$lessfiles = array(
|
||||
'css/icinga/defaults.less',
|
||||
'css/icinga/layout-colors.less',
|
||||
'css/icinga/layout-structure.less',
|
||||
'css/icinga/menu.less',
|
||||
'css/icinga/header-elements.less',
|
||||
'css/icinga/main-content.less',
|
||||
'css/icinga/tabs.less',
|
||||
'css/icinga/forms.less',
|
||||
'css/icinga/pagination.less',
|
||||
'css/icinga/monitoring-colors.less',
|
||||
'css/icinga/login.less',
|
||||
);
|
||||
|
||||
$basedir = dirname(__FILE__);
|
||||
foreach ($lessfiles as $file) {
|
||||
$less->addFile($basedir . '/' . $file);
|
||||
}
|
||||
echo $less->addLoadedModules()->compile();
|
||||
EmbeddedWeb::start('@icingaweb_config_path@');
|
||||
Stylesheet::send();
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
use Icinga\Application\EmbeddedWeb;
|
||||
use Icinga\Web\JavaScript;
|
||||
|
||||
require_once dirname(__FILE__). '/../library/Icinga/Application/EmbeddedWeb.php';
|
||||
$app = EmbeddedWeb::start('@icingaweb_config_path@');
|
||||
JavaScript::sendMinified();
|
Loading…
Reference in New Issue