diff --git a/composer.json b/composer.json index f39e0f45932..7854a687151 100644 --- a/composer.json +++ b/composer.json @@ -84,7 +84,7 @@ "bower-asset/punycode": ">=1.3.0", "bower-asset/yii2-pjax": ">=2.0.0", "bower-asset/bootstrap": ">=3.0.0", - "bower-asset/jquery.ui": ">=1.10.0" + "bower-asset/jquery-ui": ">=1.10.0" }, "require-dev": { "phpunit/phpunit": "3.7.*", diff --git a/extensions/debug/CHANGELOG.md b/extensions/debug/CHANGELOG.md index 9e1432c4d1c..ac8977a3660 100644 --- a/extensions/debug/CHANGELOG.md +++ b/extensions/debug/CHANGELOG.md @@ -13,6 +13,7 @@ Yii Framework 2 debug extension Change Log - Enh #3108: Added `yii\debug\Module::enableDebugLogs` to disable logging debug logs by default (qiangxue) - Enh #3810: Added "Latest" button on panels page (thiagotalma) - Enh #4031: Http status codes were hardcoded in filter (sdkiller) +- Enh #5089: Added asset debugger panel (arturf, qiangxue) 2.0.0-beta April 13, 2014 ------------------------- diff --git a/extensions/debug/Module.php b/extensions/debug/Module.php index f58d50409e9..d884d685974 100644 --- a/extensions/debug/Module.php +++ b/extensions/debug/Module.php @@ -209,8 +209,8 @@ protected function corePanels() 'log' => ['class' => 'yii\debug\panels\LogPanel'], 'profiling' => ['class' => 'yii\debug\panels\ProfilingPanel'], 'db' => ['class' => 'yii\debug\panels\DbPanel'], - 'mail' => ['class' => 'yii\debug\panels\MailPanel'], 'assets' => ['class' => 'yii\debug\panels\AssetPanel'], + 'mail' => ['class' => 'yii\debug\panels\MailPanel'], ]; } } diff --git a/extensions/debug/assets/main.css b/extensions/debug/assets/main.css index d3f3708439e..4381555ce38 100644 --- a/extensions/debug/assets/main.css +++ b/extensions/debug/assets/main.css @@ -11,6 +11,13 @@ ul.trace { white-space: normal; } +ul.assets { + margin: 2px 0 0 0; + padding: 0; + list-style: none; + white-space: normal; +} + .callout-danger { background-color: #fcf2f2; border-color: #dFb5b4; @@ -96,4 +103,4 @@ a.desc:after { .nowrap { white-space: nowrap; -} \ No newline at end of file +} diff --git a/extensions/debug/panels/AssetPanel.php b/extensions/debug/panels/AssetPanel.php index 3023bdf0dc2..8a3a2301eb1 100644 --- a/extensions/debug/panels/AssetPanel.php +++ b/extensions/debug/panels/AssetPanel.php @@ -23,35 +23,12 @@ */ class AssetPanel extends Panel { - /** - * @var integer - */ - private $cssCount = 0; - /** - * @var integer - */ - private $jsCount = 0; - /** - * @var AssetBundle[] - */ - private $bundles = []; - - /** - * @inheritdoc - */ - public function init() - { - parent::init(); - Event::on(Application::className(), Application::EVENT_AFTER_ACTION, function () { - $this->bundles = $this->format(Yii::$app->view->assetManager->bundles); - }); - } /** * @inheritdoc */ public function getName() { - return 'Asset bundles'; + return 'Asset Bundles'; } /** @@ -75,6 +52,42 @@ public function getDetail() */ public function save() { + $bundles = Yii::$app->view->assetManager->bundles; + if (empty($bundles)) { + return []; + } + $data = []; + foreach ($bundles as $name => $bundle) { + if ($bundle instanceof AssetBundle) { + $data[$name] = (array) $bundle; + } + } + return $data; + + $cssCount = 0; + $jsCount = 0; + foreach ($bundles as $bundle) { + + $cssCount += count($bundle->css); + $jsCount += count($bundle->js); + + array_walk($bundle->css, function(&$file, $key, $data) { + $file = Html::a($file, $data->baseUrl . '/' . $file, ['target' => '_blank']); + }, $bundle); + + array_walk($bundle->js, function(&$file, $key, $data) { + $file = Html::a($file, $data->baseUrl . '/' . $file, ['target' => '_blank']); + }, $bundle); + + array_walk($bundle->depends, function(&$depend) { + $depend = Html::a($depend, '#' . $depend); + }); + + $this->formatOptions($bundle->publishOptions); + $this->formatOptions($bundle->jsOptions); + $this->formatOptions($bundle->cssOptions); + } + $data = [ 'totalBundles' => count($this->bundles), 'totalCssFiles' => $this->cssCount, diff --git a/extensions/debug/views/default/panels/assets/detail.php b/extensions/debug/views/default/panels/assets/detail.php index aa2731062f1..0a1e18c7a40 100644 --- a/extensions/debug/views/default/panels/assets/detail.php +++ b/extensions/debug/views/default/panels/assets/detail.php @@ -1,62 +1,66 @@ -

Asset bundles

- +

Asset Bundles

+data)) { + echo '

No asset bundle was used.

'; + return; +} ?> data['bundles'] as $key => $bundle) { +foreach ($panel->data as $name => $bundle) { ?> - + - + + + + + + + + + + + + + + - + + + - + + + - - - - - - - - - - - - - - - - - - - - - + + data)): ?>
- Asset bundles data['totalBundles'] ?> + Asset Bundles data) ?>
+ diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 175ee5b4c48..58e70ce3f75 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -212,6 +212,7 @@ Yii Framework 2 Change Log - Enh #4740: Added `yii\web\Session::addFlash()` (restyler) - Enh #4897: Added `yii\helpers\FileHelper::mimeMagicFile` (qiangxue) - Enh #5058: Added `$pageSize` parameter to `Pagination::createUrl()` to allow creating URLs with arbitrary page sizes (cdcchen, qiangxue) +- Enh #5089: Added asset debugger panel (arturf, qiangxue) - Enh: Added support for using sub-queries when building a DB query with `IN` condition (qiangxue) - Enh: Supported adding a new response formatter without the need to reconfigure existing formatters (qiangxue) - Enh: Added `yii\web\UrlManager::addRules()` to simplify adding new URL rules (qiangxue)
-

Total bundles: data['totalBundles'] ?>.

-

CSS files: data['totalCssFiles'] ?>, JS files: data['totalJsFiles'] ?>

+

Total data) ?> asset bundles were loaded.

sourcePathsourcePath], ['class' => 'trace', 'encode' => false]) ?>
basePath
baseUrl
csscss, ['class' => 'trace', 'encode' => false]) ?> 'assets']) ?>
jsjs, ['class' => 'trace', 'encode' => false]) ?> 'assets']) ?>
dependsdepends, ['class' => 'trace', 'encode' => false]) ?>
publishOptionspublishOptions, ['class' => 'trace', 'encode' => false]) ?>
basePathbasePath], ['class' => 'trace', 'encode' => false]) ?>
baseUrlbaseUrl], ['class' => 'trace', 'encode' => false]) ?>
jsOptionsjsOptions, ['class' => 'trace']) ?>
cssOptionscssOptions, ['class' => 'trace']) ?>
    + +
  • + +