Skip to content

Commit 8343945

Browse files
author
Igor Chepurnoy
committed
update mail layout, update tests.
1 parent e5009da commit 8343945

File tree

5 files changed

+84
-63
lines changed

5 files changed

+84
-63
lines changed

tests/codeception/acceptance/HomeCept.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
$I = new AcceptanceTester($scenario);
44
$I->wantTo('ensure that home page works');
55
$I->amOnPage(Yii::$app->homeUrl);
6-
$I->see('Congratulations');
6+
$I->see('Yii2 Basic Template');
77
$I->seeLink('About');
88
$I->click('About');
99
$I->see('About Us');

tests/codeception/config/config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
*/
55
return [
66
'components' => [
7-
'db' => [
7+
/*'db' => [
88
'dsn' => 'mysql:host=localhost;dbname=yii2base',
99
'username' => 'root',
1010
'password' => '',
11-
],
11+
],*/
1212
'mailer' => [
1313
'useFileTransport' => true,
1414
],

tests/codeception/functional/HomeCept.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
$I = new FunctionalTester($scenario);
66
$I->wantTo('ensure that home page works');
77
$I->amOnPage(Yii::$app->homeUrl);
8-
$I->see('My Company');
8+
$I->see('Yii2 Basic Template');
99
$I->seeLink('About');
1010
$I->click('About');
1111
$I->see('About us content');

views/layouts/main.php

Lines changed: 73 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,93 @@
11
<?php
2+
23
use app\widgets\Alert;
34
use kartik\alert\AlertBlock;
45
use yii\helpers\Html;
56
use yii\bootstrap\Nav;
67
use yii\bootstrap\NavBar;
78
use yii\widgets\Breadcrumbs;
89
use app\assets\AppAsset;
10+
911
/* @var $this \yii\web\View */
1012
/* @var $content string */
13+
1114
AppAsset::register($this);
1215
?>
1316
<?php $this->beginPage() ?>
14-
<!DOCTYPE html>
15-
<html lang="<?php echo Yii::$app->language; ?>">
16-
<head>
17-
<meta charset="<?php echo Yii::$app->charset; ?>"/>
18-
<meta name="viewport" content="width=device-width, initial-scale=1">
19-
<?php echo Html::csrfMetaTags(); ?>
20-
<title><?php echo Html::encode($this->title); ?></title>
21-
<?php $this->head() ?>
22-
</head>
23-
<body>
24-
<?php $this->beginBody() ?>
25-
<?php echo AlertBlock::widget([
26-
'type' => AlertBlock::TYPE_GROWL,
27-
'useSessionFlash' => true,
28-
'delay' => false
17+
<!DOCTYPE html>
18+
<html lang="<?php echo Yii::$app->language; ?>">
19+
<head>
20+
<meta charset="<?php echo Yii::$app->charset; ?>"/>
21+
<meta name="viewport" content="width=device-width, initial-scale=1">
22+
<?php echo Html::csrfMetaTags(); ?>
23+
<title><?php echo Html::encode($this->title); ?></title>
24+
<?php $this->head() ?>
25+
</head>
26+
<body>
27+
<?php $this->beginBody() ?>
28+
<?php echo AlertBlock::widget([
29+
'type' => AlertBlock::TYPE_GROWL,
30+
'useSessionFlash' => true,
31+
'delay' => false
32+
]);
33+
?>
34+
<div class="wrap">
35+
<?php NavBar::begin([
36+
'brandLabel' => 'Yii2 Basic Template',
37+
'brandUrl' => Yii::$app->homeUrl,
38+
'options' => [
39+
'class' => 'navbar-inverse navbar-fixed-top',
40+
],
41+
]);
42+
$menuItems = [
43+
['label' => 'Home', 'url' => ['/site/index']],
44+
['label' => 'About Us', 'url' => ['/about-us']],
45+
['label' => 'Contact', 'url' => ['/site/contact']],
46+
];
47+
if (Yii::$app->user->isGuest) {
48+
$menuItems[] = ['label' => 'Signup', 'url' => ['/site/signup']];
49+
$menuItems[] = ['label' => 'Login', 'url' => ['/site/login']];
50+
} else {
51+
$menuItems[] = ['label' => 'Administration', 'url' => ['/admin'], 'visible' => Yii::$app->getUser()->can('admin')];
52+
$menuItems[] = '<li>'
53+
. Html::beginForm(['/site/logout'], 'post')
54+
. Html::submitButton(
55+
'Logout (' . Yii::$app->user->identity->username . ')',
56+
['class' => 'btn btn-link']
57+
)
58+
. Html::endForm()
59+
. '</li>';
60+
}
61+
echo Nav::widget([
62+
'options' => ['class' => 'navbar-nav navbar-right'],
63+
'items' => $menuItems,
2964
]);
65+
NavBar::end();
3066
?>
31-
<div class="wrap">
32-
<?php
33-
NavBar::begin([
34-
'brandLabel' => 'Yii2 Basic Template',
35-
'brandUrl' => Yii::$app->homeUrl,
36-
'options' => [
37-
'class' => 'navbar-inverse navbar-fixed-top',
38-
],
39-
]);
40-
echo Nav::widget([
41-
'options' => ['class' => 'navbar-nav navbar-right'],
42-
'items' => [
43-
['label' => 'Home', 'url' => ['/site/index']],
44-
['label' => 'About Us', 'url' => ['/about-us']],
45-
['label' => 'Contact', 'url' => ['/site/contact']],
46-
['label' => 'Signup', 'url' => ['/site/signup'], 'visible' => Yii::$app->user->isGuest],
47-
['label' => 'Login', 'url' => ['/site/login'], 'visible' => Yii::$app->user->isGuest],
48-
['label' => 'Administration', 'url' => ['/admin'], 'visible' => Yii::$app->getUser()->can('admin')],
49-
['label' => 'Logout', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post'], 'visible' => !Yii::$app->user->isGuest],
50-
],
51-
]);
52-
NavBar::end();
53-
?>
5467

55-
<div class="container">
56-
<?php echo Breadcrumbs::widget([
57-
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
58-
]); ?>
59-
<?php echo $content; ?>
60-
</div>
68+
<div class="container">
69+
<?php echo Breadcrumbs::widget([
70+
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
71+
]); ?>
72+
<?php echo $content; ?>
6173
</div>
74+
</div>
6275

63-
<footer class="footer">
64-
<div class="container">
65-
<p class="pull-left">&copy; Yii2 Basic Template <?php echo date('Y'); ?></p>
66-
<p class="pull-right"><?php echo \yii\widgets\Menu::widget([
67-
'items' => [
68-
['label' => 'Terms & Conditions', 'url' => ['/terms-and-conditions']],
69-
['label' => 'Privacy Policy', 'url' => ['/privacy-policy']],
70-
],
71-
]);
72-
?></p>
73-
</div>
74-
</footer>
76+
<footer class="footer">
77+
<div class="container">
78+
<p class="pull-left">&copy; Yii2 Basic Template <?php echo date('Y'); ?></p>
79+
<p class="pull-right"><?php echo \yii\widgets\Menu::widget([
80+
'items' => [
81+
['label' => 'Terms & Conditions', 'url' => ['/terms-and-conditions']],
82+
['label' => 'Privacy Policy', 'url' => ['/privacy-policy']],
83+
],
84+
]);
85+
?>
86+
</p>
87+
</div>
88+
</footer>
7589

76-
<?php $this->endBody() ?>
77-
</body>
78-
</html>
90+
<?php $this->endBody() ?>
91+
</body>
92+
</html>
7993
<?php $this->endPage() ?>

web/css/site.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,11 @@ a.desc:after {
120120
border-left-width: 5px;
121121
border-radius: 3px;
122122
}
123+
/* align the logout "link" (button in form) of the navbar */
124+
.nav > li > form {
125+
padding: 8px;
126+
}
123127

128+
.nav > li > form > button:hover {
129+
text-decoration: none;
130+
}

0 commit comments

Comments
 (0)