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,10 +9,21 @@ | ||
9 | ); | 9 | ); |
10 | 10 | ||
11 | return [ | 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 | 'id' => 'app-frontend', | 23 | 'id' => 'app-frontend', |
13 | 'homeUrl' => '/', | 24 | 'homeUrl' => '/', |
14 | 'basePath' => dirname(__DIR__), | 25 | 'basePath' => dirname(__DIR__), |
15 | - 'bootstrap' => [ 'log' ], | 26 | + 'bootstrap' => [ 'log','assetsAutoCompress' ], |
16 | 'controllerNamespace' => 'frontend\controllers', | 27 | 'controllerNamespace' => 'frontend\controllers', |
17 | 'container' => [ | 28 | 'container' => [ |
18 | 'singletons' => [ | 29 | 'singletons' => [ |
@@ -362,9 +373,58 @@ | @@ -362,9 +373,58 @@ | ||
362 | 'baseUrl' => '/', | 373 | 'baseUrl' => '/', |
363 | 'enablePrettyUrl' => true, | 374 | 'enablePrettyUrl' => true, |
364 | 'showScriptName' => false, | 375 | 'showScriptName' => false, |
365 | - 'rules' => [], | 376 | + 'rules' => [ |
377 | + | ||
378 | + ], | ||
366 | 'hideDefaultLanguagePrefix' => true, | 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 | 'params' => $params, | 430 | 'params' => $params, |
frontend/views/layouts/main.php
@@ -28,6 +28,7 @@ | @@ -28,6 +28,7 @@ | ||
28 | use yii\db\ActiveQuery; | 28 | use yii\db\ActiveQuery; |
29 | use yii\helpers\Html; | 29 | use yii\helpers\Html; |
30 | use yii\web\View; | 30 | use yii\web\View; |
31 | + use yii\helpers\Url as DefaultUrl; | ||
31 | 32 | ||
32 | AppAsset::register($this); | 33 | AppAsset::register($this); |
33 | SliderAsset::register($this); | 34 | SliderAsset::register($this); |
@@ -103,7 +104,14 @@ | @@ -103,7 +104,14 @@ | ||
103 | <div class="container"> | 104 | <div class="container"> |
104 | <div class="row"> | 105 | <div class="row"> |
105 | <div class="col-xs-7 col-sm-3 col-md-2 col-lg-2 logo-wrapp"> | 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 | <?php | 115 | <?php |
108 | if ($settings->logo != null){ | 116 | if ($settings->logo != null){ |
109 | echo '<img src="/storage/logo/'.$settings->logo.'" alt="">'; | 117 | echo '<img src="/storage/logo/'.$settings->logo.'" alt="">'; |
@@ -118,6 +126,7 @@ | @@ -118,6 +126,7 @@ | ||
118 | } | 126 | } |
119 | 127 | ||
120 | ?> | 128 | ?> |
129 | + | ||
121 | 130 | ||
122 | </a> | 131 | </a> |
123 | </div> | 132 | </div> |
@@ -342,8 +351,8 @@ | @@ -342,8 +351,8 @@ | ||
342 | <div class="col-xs-9 col-sm-2"> | 351 | <div class="col-xs-9 col-sm-2"> |
343 | <ul class="footer-menu"> | 352 | <ul class="footer-menu"> |
344 | <li><a href="<?=Url::to(['site/about'])?>"><?=\Yii::t('app','About us')?></a></li> | 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 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Quest/Answer');?></a></li> | 356 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Quest/Answer');?></a></li> |
348 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks');?></a></li> | 357 | <li><a href="<?=Url::to(['site/comments'])?>"><?=\Yii::t('app','Callbacks');?></a></li> |
349 | </ul> | 358 | </ul> |