Browse Source

basic app WIP

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
0d182ace40
  1. 78
      app/css/site.css
  2. 19
      app/protected/config/assets.php
  3. 5
      app/protected/config/main.php
  4. 10
      app/protected/controllers/SiteController.php
  5. 43
      app/protected/views/layouts/main.php
  6. 8
      app/protected/views/site/about.php
  7. 10
      app/protected/views/site/contact.php
  8. 54
      app/protected/views/site/index.php
  9. 3
      app/protected/views/site/login.php

78
app/css/site.css

@ -0,0 +1,78 @@
body {
padding-top: 20px;
padding-bottom: 60px;
}
/* Custom container */
.container {
margin: 0 auto;
max-width: 1000px;
}
.container > hr {
margin: 60px 0;
}
/* Main marketing message and sign up button */
.jumbotron {
margin: 80px 0;
text-align: center;
}
.jumbotron h1 {
font-size: 100px;
line-height: 1;
}
.jumbotron .lead {
font-size: 24px;
line-height: 1.25;
}
.jumbotron .btn {
font-size: 21px;
padding: 14px 24px;
}
/* Supporting marketing content */
.marketing {
margin: 60px 0;
}
.marketing p + h4 {
margin-top: 28px;
}
/* Customize the navbar links to be fill the entire space of the .navbar */
.navbar .navbar-inner {
padding: 0;
}
.navbar .nav {
margin: 0;
display: table;
width: 100%;
}
.navbar .nav li {
display: table-cell;
width: 1%;
float: none;
}
.navbar .nav li a {
font-weight: bold;
text-align: center;
border-left: 1px solid rgba(255, 255, 255, .75);
border-right: 1px solid rgba(0, 0, 0, .1);
}
.navbar .nav li:first-child a {
border-left: 0;
border-radius: 3px 0 0 3px;
}
.navbar .nav li:last-child a {
border-right: 0;
border-radius: 0 3px 3px 0;
}

19
app/protected/config/assets.php

@ -0,0 +1,19 @@
<?php
return array(
'app' => array(
'basePath' => '@wwwroot',
'baseUrl' => '@www',
'css' => array(
'css/bootstrap.min.css',
'css/bootstrap-responsive.min.css',
'css/site.css',
),
'js' => array(
),
'depends' => array(
'yii',
),
),
);

5
app/protected/config/main.php

@ -10,6 +10,9 @@ return array(
'user' => array(
'class' => 'yii\web\User',
'identityClass' => 'app\models\User',
)
),
'assetManager' => array(
'bundles' => require(__DIR__ . '/assets.php'),
),
),
);

10
app/protected/controllers/SiteController.php

@ -27,4 +27,14 @@ class SiteController extends Controller
Yii::$app->getUser()->logout();
Yii::$app->getResponse()->redirect(array('site/index'));
}
public function actionContact()
{
echo $this->render('contact');
}
public function actionAbout()
{
echo $this->render('about');
}
}

43
app/protected/views/layouts/main.php

@ -4,23 +4,52 @@
* @var $content string
*/
use yii\helpers\Html;
$this->registerAssetBundle('app');
?>
<?php $this->beginPage(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta charset="utf-8"/>
<title><?php echo Html::encode($this->title); ?></title>
<?php echo Html::cssFile("css/bootstrap.min.css", array('media' => 'screen')); ?>
<?php $this->head(); ?>
</head>
<body>
<div class="container">
<h1>Welcome</h1>
<?php $this->beginBody(); ?>
<?php echo $content; ?>
<?php $this->endBody(); ?>
<div class="container">
<?php $this->beginBody(); ?>
<div class="masthead">
<h3 class="muted">My Company</h3>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li><?php echo Html::a('Home', Yii::$app->homeUrl); ?></li>
<li><?php echo Html::a('About', array('/site/about')); ?></li>
<li><?php echo Html::a('Contact', array('/site/contact')); ?></li>
<?php if (Yii::$app->user->isGuest): ?>
<li><?php echo Html::a('Login', array('/site/login')); ?></li>
<?php else: ?>
<li><?php echo Html::a('Logout (' . Html::encode(Yii::$app->user->identity->username) . ')', array('/site/logout')); ?></li>
<?php endif; ?>
</ul>
</div>
</div>
</div>
<!-- /.navbar -->
</div>
<?php echo $content; ?>
<div class="footer">
<p>&copy; My Company <?php echo date('Y'); ?></p>
<p>
<?php echo Yii::powered(); ?>
Template by <a href="http://twitter.github.io/bootstrap/">Twitter Bootstrap</a>
</p>
</div>
<?php $this->endBody(); ?>
</div>
</body>
</html>
<?php $this->endPage(); ?>

8
app/protected/views/site/about.php

@ -0,0 +1,8 @@
<?php
use yii\helpers\Html;
/**
* @var yii\base\View $this
*/
$this->title = 'About';
?>
<h1><?php echo Html::encode($this->title); ?></h1>

10
app/protected/views/site/contact.php

@ -0,0 +1,10 @@
<?php
use yii\helpers\Html;
/**
* @var yii\base\View $this
* @var yii\widgets\ActiveForm $form
* @var app\models\ContactForm $model
*/
$this->title = 'Contact';
?>
<h1><?php echo Html::encode($this->title); ?></h1>

54
app/protected/views/site/index.php

@ -1,17 +1,49 @@
<?php
/** @var $this \yii\base\View */
/**
* @var yii\base\View $this
*/
$this->title = 'Welcome';
?>
<div class="jumbotron">
<h1>Marketing stuff!</h1>
use yii\helpers\Html;
<p class="lead">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Fusce dapibus, tellus ac cursus
commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<a class="btn btn-large btn-success" href="http://www.yiiframework.com">Get started today</a>
</div>
$this->title = 'Hello World';
<hr>
$user = Yii::$app->getUser();
if ($user->isGuest) {
echo Html::a('login', array('login'));
} else {
echo "You are logged in as " . $user->identity->username . "<br/>";
echo Html::a('logout', array('logout'));
}
?>
<!-- Example row of columns -->
<div class="row-fluid">
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod.
Donec sed odio dui. </p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
<div class="span4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta
felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum
massa.</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
</div>
</div>
<hr>

3
app/protected/views/site/login.php

@ -5,8 +5,9 @@ use yii\helpers\Html;
* @var yii\widgets\ActiveForm $form
* @var app\models\LoginForm $model
*/
$this->title = 'Login';
?>
<h1>Login</h1>
<h1><?php echo Html::encode($this->title); ?></h1>
<p>Please fill out the following fields to login:</p>

Loading…
Cancel
Save