Commit 89f55ef8f49e53fe3b5d1511d1c3e0b981167cad
Merge remote-tracking branch 'origin/master'
Showing
2 changed files
with
74 additions
and
5 deletions
Show diff stats
frontend/config/main.php
| ... | ... | @@ -9,10 +9,21 @@ |
| 9 | 9 | ); |
| 10 | 10 | |
| 11 | 11 | return [ |
| 12 | + 'on beforeRequest' => function () { | |
| 13 | + $pathInfo = Yii::$app->request->pathInfo; | |
| 14 | + $query = Yii::$app->request->queryString; | |
| 15 | + if (!empty($pathInfo) && substr($pathInfo, -1) === '/') { | |
| 16 | + $url = '/' . substr($pathInfo, 0, -1); | |
| 17 | + if ($query) { | |
| 18 | + $url .= '?' . $query; | |
| 19 | + } | |
| 20 | + Yii::$app->response->redirect($url, 301); | |
| 21 | + } | |
| 22 | + }, | |
| 12 | 23 | 'id' => 'app-frontend', |
| 13 | 24 | 'homeUrl' => '/', |
| 14 | 25 | 'basePath' => dirname(__DIR__), |
| 15 | - 'bootstrap' => [ 'log' ], | |
| 26 | + 'bootstrap' => [ 'log','assetsAutoCompress' ], | |
| 16 | 27 | 'controllerNamespace' => 'frontend\controllers', |
| 17 | 28 | 'container' => [ |
| 18 | 29 | 'singletons' => [ |
| ... | ... | @@ -362,9 +373,58 @@ |
| 362 | 373 | 'baseUrl' => '/', |
| 363 | 374 | 'enablePrettyUrl' => true, |
| 364 | 375 | 'showScriptName' => false, |
| 365 | - 'rules' => [], | |
| 376 | + 'rules' => [ | |
| 377 | + | |
| 378 | + ], | |
| 366 | 379 | 'hideDefaultLanguagePrefix' => true, |
| 367 | 380 | ], |
| 381 | + 'assetsAutoCompress' => [ | |
| 382 | + 'class' => '\skeeks\yii2\assetsAuto\AssetsAutoCompressComponent', | |
| 383 | + 'enabled' => true, | |
| 384 | + | |
| 385 | + 'readFileTimeout' => 3, | |
| 386 | + //Time in seconds for reading each asset file | |
| 387 | + | |
| 388 | + 'jsCompress' => true, | |
| 389 | + //Enable minification js in html code | |
| 390 | + 'jsCompressFlaggedComments' => true, | |
| 391 | + //Cut comments during processing js | |
| 392 | + | |
| 393 | + 'cssCompress' => true, | |
| 394 | + //Enable minification css in html code | |
| 395 | + | |
| 396 | + 'cssFileCompile' => true, | |
| 397 | + //Turning association css files | |
| 398 | + 'cssFileRemouteCompile' => false, | |
| 399 | + //Trying to get css files to which the specified path as the remote file, skchat him to her. | |
| 400 | + 'cssFileCompress' => true, | |
| 401 | + //Enable compression and processing before being stored in the css file | |
| 402 | + 'cssFileBottom' => false, | |
| 403 | + //Moving down the page css files | |
| 404 | + 'cssFileBottomLoadOnJs' => false, | |
| 405 | + //Transfer css file down the page and uploading them using js | |
| 406 | + | |
| 407 | + 'jsFileCompile' => true, | |
| 408 | + //Turning association js files | |
| 409 | + 'jsFileRemouteCompile' => false, | |
| 410 | + //Trying to get a js files to which the specified path as the remote file, skchat him to her. | |
| 411 | + 'jsFileCompress' => true, | |
| 412 | + //Enable compression and processing js before saving a file | |
| 413 | + 'jsFileCompressFlaggedComments' => true, | |
| 414 | + //Cut comments during processing js | |
| 415 | + | |
| 416 | + 'htmlCompress' => true, | |
| 417 | + //Enable compression html | |
| 418 | + 'noIncludeJsFilesOnPjax' => true, | |
| 419 | + //Do not connect the js files when all pjax requests | |
| 420 | + 'htmlCompressOptions' => //options for compressing output result | |
| 421 | + [ | |
| 422 | + 'extra' => false, | |
| 423 | + //use more compact algorithm | |
| 424 | + 'no-comments' => true | |
| 425 | + //cut all the html comments | |
| 426 | + ], | |
| 427 | + ], | |
| 368 | 428 | ], |
| 369 | 429 | |
| 370 | 430 | 'params' => $params, | ... | ... |
frontend/views/layouts/main.php
| ... | ... | @@ -28,6 +28,7 @@ |
| 28 | 28 | use yii\db\ActiveQuery; |
| 29 | 29 | use yii\helpers\Html; |
| 30 | 30 | use yii\web\View; |
| 31 | + use yii\helpers\Url as DefaultUrl; | |
| 31 | 32 | |
| 32 | 33 | AppAsset::register($this); |
| 33 | 34 | SliderAsset::register($this); |
| ... | ... | @@ -103,7 +104,14 @@ |
| 103 | 104 | <div class="container"> |
| 104 | 105 | <div class="row"> |
| 105 | 106 | <div class="col-xs-7 col-sm-3 col-md-2 col-lg-2 logo-wrapp"> |
| 106 | - <a href="<?php echo \frontend\helpers\Url::home(); ?>"> | |
| 107 | + | |
| 108 | + <a | |
| 109 | + <?php if(DefaultUrl::current()!=='/site/index'): ?> | |
| 110 | + href= "<?php echo \frontend\helpers\Url::home(); ?>"> | |
| 111 | + <?php else: ?> | |
| 112 | + > | |
| 113 | + <?php endif;?> | |
| 114 | + | |
| 107 | 115 | <?php |
| 108 | 116 | if ($settings->logo != null){ |
| 109 | 117 | echo '<img src="/storage/logo/'.$settings->logo.'" alt="">'; |
| ... | ... | @@ -118,6 +126,7 @@ |
| 118 | 126 | } |
| 119 | 127 | |
| 120 | 128 | ?> |
| 129 | + | |
| 121 | 130 | |
| 122 | 131 | </a> |
| 123 | 132 | </div> |
| ... | ... | @@ -342,8 +351,8 @@ |
| 342 | 351 | <div class="col-xs-9 col-sm-2"> |
| 343 | 352 | <ul class="footer-menu"> |
| 344 | 353 | <li><a href="<?=Url::to(['site/about'])?>"><?=\Yii::t('app','About us')?></a></li> |
| 345 | - <li><a href="#" class="new"><span><?=\Yii::t('app','Contacts');?></span></a></li> | |
| 346 | - <li><a href="<?=Url::to(['site/questions'])?>"><?=\Yii::t('app','Second thing');?></a></li> | |
| 354 | + <li><a href="#" ><?=\Yii::t('app','Contacts');?></a></li> | |
| 355 | + <li><a href="<?=Url::to(['site/questions'])?>" class="new"><span><?=\Yii::t('app','Second thing');?></span></a></li> | |
| 347 | 356 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Quest/Answer');?></a></li> |
| 348 | 357 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks');?></a></li> |
| 349 | 358 | </ul> | ... | ... |