Skip to content

Commit

Permalink
More fixes (#2)
Browse files Browse the repository at this point in the history
* Fix console config
* Clean up ignore patterns
* Export .editorconfig and .gitignore
* Fix readme and typo
* Hint $params in configs
* Update .htaccess
* Cleanup views
* More cleanup and parameter renaming
* Fix changelog
* Add security advisories package
* Fix image path in readme
  • Loading branch information
samdark authored Jun 3, 2020
1 parent 6f73264 commit 8be5420
Show file tree
Hide file tree
Showing 26 changed files with 101 additions and 99 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@

# Ignore some meta files when creating an archive of this repository
/.github export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore

# CHANGELOG
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# _____ Change Log
# Yii 3 Application Template Change Log

## 1.0.0 under development

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<p align="center">
<a href="https://github.com/yiisoft/app" target="_blank">
<img src="docs\images\home.png" >
<img src="docs/images/home.png" >
</a>
</p>

Expand Down Expand Up @@ -76,7 +76,7 @@ return [
'@views' => '@root/resources/views'
],

'yiisoft/app' => [
'app' => [
'brandurl' => '/',
'charset' => 'UTF-8',
'hero.options' => ['class' => 'hero is-fullheight is-light'],
Expand All @@ -89,8 +89,8 @@ return [
'hero.footer.column.left.options' => ['class' => 'column has-text-left has-text-light'],
'hero.footer.column.center' => 'Center',
'hero.footer.column.center.options' => ['class' => 'column has-text-centered has-text-light'],
'hero.footer.column.rigth' => 'Rigth',
'hero.footer.column.rigth.options' => ['class' => 'column has-text-right has-text-light'],
'hero.footer.column.right' => 'Right',
'hero.footer.column.right.options' => ['class' => 'column has-text-right has-text-light'],
'language' => 'en',
'logo' => '/images/yii-logo.jpg',
'name' => 'My Project',
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"yiisoft/yii-web": "@dev"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"codeception/codeception": "^4.1.5",
"codeception/module-asserts": "@dev",
"codeception/module-phpbrowser": "@dev",
Expand Down
2 changes: 2 additions & 0 deletions config/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Psr\Container\ContainerInterface;
use Yiisoft\Aliases\Aliases;

/* @var array $params */

return [
ContainerInterface::class => static function (ContainerInterface $container) {
return $container;
Expand Down
7 changes: 7 additions & 0 deletions config/console.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

return [

];
4 changes: 2 additions & 2 deletions config/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
'hero.footer.column.left.options' => ['class' => 'column has-text-left has-text-light'],
'hero.footer.column.center' => 'Center',
'hero.footer.column.center.options' => ['class' => 'column has-text-centered has-text-light'],
'hero.footer.column.rigth' => 'Rigth',
'hero.footer.column.rigth.options' => ['class' => 'column has-text-right has-text-light'],
'hero.footer.column.right' => 'Right',
'hero.footer.column.right.options' => ['class' => 'column has-text-right has-text-light'],
'language' => 'en',
'logo' => '/images/yii-logo.jpg',
'name' => 'My Project',
Expand Down
14 changes: 8 additions & 6 deletions config/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

declare(strict_types=1);

use App\LayoutParameters;
use App\ApplicationParameters;
use Yiisoft\Yii\Web\Session\Session;
use Yiisoft\Yii\Web\Session\SessionInterface;

/* @var array $params */

return [
SessionInterface::class => [
'__class' => Session::class,
Expand All @@ -15,10 +17,10 @@
],
],

LayoutParameters::class => static function () use ($params) {
$layoutParameters = new LayoutParameters();
ApplicationParameters::class => static function () use ($params) {
$applicationParameters = new ApplicationParameters();

return $layoutParameters
return $applicationParameters
->brandUrl($params['app']['brandurl'])
->charset($params['app']['charset'])
->heroOptions($params['app']['hero.options'])
Expand All @@ -31,8 +33,8 @@
->heroFooterColumnLeftOptions($params['app']['hero.footer.column.left.options'])
->heroFooterColumnCenter($params['app']['hero.footer.column.center'])
->heroFooterColumnCenterOptions($params['app']['hero.footer.column.center.options'])
->heroFooterColumnRigth($params['app']['hero.footer.column.rigth'])
->heroFooterColumnRigthOptions($params['app']['hero.footer.column.rigth.options'])
->heroFooterColumnRight($params['app']['hero.footer.column.right'])
->heroFooterColumnRightOptions($params['app']['hero.footer.column.right.options'])
->language($params['app']['language'])
->logo($params['app']['logo'])
->name($params['app']['name'])
Expand Down
19 changes: 9 additions & 10 deletions public/.htaccess
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# rewrite ^/(.*)/$ /$1 permanent;
# use mod_rewrite for pretty URL support
RewriteEngine on

# if (!-d $request_filename && !-f $request_filename) {
# rewrite ^/ index.php last;
# }
# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
# Otherwise forward the request to index.php
RewriteRule . index.php
2 changes: 2 additions & 0 deletions public/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
20 changes: 9 additions & 11 deletions resources/layout/_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

use Yiisoft\Html\Html;

/** @var \App\LayoutParameters $layoutParameters */
/** @var \App\ApplicationParameters $applicationParameters */
?>
<?= Html::beginTag('div', $applicationParameters->getHeroFooterColumnOptions()) ?>

<?= Html::beginTag('div', $layoutParameters->getHeroFooterColumnOptions()) ?>

<?= Html::beginTag('div', $layoutParameters->getHeroFooterColumnLeftOptions()) ?>
<?= $layoutParameters->getHeroFooterColumnLeft() ?>
<?= Html::beginTag('div', $applicationParameters->getHeroFooterColumnLeftOptions()) ?>
<?= $applicationParameters->getHeroFooterColumnLeft() ?>
<?= Html::endTag('div') ?>

<?= Html::beginTag('div', $layoutParameters->getHeroFooterColumnCenterOptions()) ?>
<?= $layoutParameters->getHeroFooterColumnCenter() ?>
<?= Html::beginTag('div', $applicationParameters->getHeroFooterColumnCenterOptions()) ?>
<?= $applicationParameters->getHeroFooterColumnCenter() ?>
<?= Html::endTag('div') ?>

<?= Html::beginTag('div', $layoutParameters->getHeroFooterColumnRigthOptions()) ?>
<?= $layoutParameters->getHeroFooterColumnRigth() ?>
<?= Html::beginTag('div', $applicationParameters->getHeroFooterColumnRightOptions()) ?>
<?= $applicationParameters->getHeroFooterColumnRight() ?>
<?= Html::endTag('div') ?>

<?= Html::tag('div');
<?= Html::endTag('div') ?>
10 changes: 4 additions & 6 deletions resources/layout/_head.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
use Yiisoft\Html\Html;

/**
* @var \App\LayoutParameters $layoutParameters
* @var \App\ApplicationParameters $applicationParameters
* @var string $csrf
*/
?>

<?= Html::beginTag('head') ?>
<?= Html::tag('meta', '', ['charset' => $layoutParameters->getCharset()]) ?>
<head>
<?= Html::tag('meta', '', ['charset' => $applicationParameters->getCharset()]) ?>
<?= Html::tag('meta', '', ['http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge']) ?>
<?= Html::tag('meta', '', ['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1']) ?>
<?= Html::tag('meta', '', ['name' => 'csrf', 'content' => $csrf]) ?>
<?= Html::tag('title', Html::encode($this->getTitle())) ?>

<?php $this->head() ?>

<?= Html::endTag('head');
</head>
21 changes: 9 additions & 12 deletions resources/layout/_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@

use Yiisoft\Html\Html;

/** @var \App\LayoutParameters $layoutParameters */
/** @var \App\ApplicationParameters $applicationParameters */
?>

<?= Html::beginTag('div', $layoutParameters->getNavBarOptions()) ?>

<?= Html::beginTag('div', $layoutParameters->getNavBarBrandOptions()) ?>
<?= Html::beginTag('div', $applicationParameters->getNavBarOptions()) ?>
<?= Html::beginTag('div', $applicationParameters->getNavBarBrandOptions()) ?>
<?= Html::tag(
'span',
Html::img($layoutParameters->getLogo()),
$layoutParameters->getNavBarBrandLogoOptions()
Html::img($applicationParameters->getLogo()),
$applicationParameters->getNavBarBrandLogoOptions()
) ?>
<?= Html::a(
$layoutParameters->getName(),
$layoutParameters->getbrandUrl(),
$layoutParameters->getNavBarBrandTitleOptions()
$applicationParameters->getName(),
$applicationParameters->getbrandUrl(),
$applicationParameters->getNavBarBrandTitleOptions()
) ?>
<?= Html::endTag('div') ?>

<?= Html::endTag('div');
<?= Html::endTag('div') ?>
25 changes: 12 additions & 13 deletions resources/layout/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
use Yiisoft\Html\Html;

/**
* @var \Yiisoft\Assets\AssetsManager $assetManager
* @var \App\LayoutParameters $layoutParameters
* @var \Yiisoft\Assets\AssetManager $assetManager
* @var \App\ApplicationParameters $applicationParameters
* @var string $csrf
* @var string $content
*/

$assetManager->register([
Expand All @@ -18,36 +20,33 @@
$this->setJsFiles($assetManager->getJsFiles());

?>

<?php $this->beginPage() ?>
<!DOCTYPE html>
<?= Html::beginTag('html', ['lang' => $layoutParameters->getLanguage()]) ?>
<?= Html::beginTag('html', ['lang' => $applicationParameters->getLanguage()]) ?>

<?= $this->render('_head', ['csrf' => $csrf]) ?>

<?php $this->beginBody() ?>

<?= Html::beginTag('body') ?>

<?= Html::beginTag('section', $layoutParameters->getHeroOptions()) ?>
<body>
<?= Html::beginTag('section', $applicationParameters->getHeroOptions()) ?>

<?= Html::beginTag('div', $layoutParameters->getHeroHeadOptions()) ?>
<?= Html::beginTag('div', $applicationParameters->getHeroHeadOptions()) ?>
<?= $this->render('_menu') ?>
<?= Html::endTag('div') ?>

<?= Html::beginTag('div', $layoutParameters->getHeroBodyOptions()) ?>
<?= Html::beginTag('div', $layoutParameters->getHeroContainerOptions()) ?>
<?= Html::beginTag('div', $applicationParameters->getHeroBodyOptions()) ?>
<?= Html::beginTag('div', $applicationParameters->getHeroContainerOptions()) ?>
<?= $content ?>
<?= Html::endTag('div') ?>
<?= Html::endTag('div') ?>

<?= Html::beginTag('div', $layoutParameters->getHeroFooterOptions()) ?>
<?= Html::beginTag('div', $applicationParameters->getHeroFooterOptions()) ?>
<?= $this->render('_footer') ?>
<?= Html::endTag('div') ?>

<?= Html::endTag('section') ?>

<?= Html::endTag('body') ?>
</body>

<?php $this->endBody() ?>

Expand Down
11 changes: 5 additions & 6 deletions resources/views/site/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

declare(strict_types=1);

use Yiisoft\Html\Html;

/** @var \App\LayoutParameters $layoutParameters */
/** @var \App\ApplicationParameters $applicationParameters */

$this->params['breadcrumbs'] = '/';

$this->setTitle($layoutParameters->getName());
$this->setTitle($applicationParameters->getName());
?>

<?= Html::tag('h1', 'Hello World', ['class' => 'title']) ?>
<?= Html::tag('p', 'My first website with <strong>Yii 3.0</strong>!', ['class' => 'subtitle']);
<h1 class="title">Hello World</h1>

<p class="subtitle">My first website with <strong>Yii 3.0</strong>!</p>
2 changes: 2 additions & 0 deletions runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Empty file removed runtime/cache/.gitignore
Empty file.
Empty file removed runtime/debug/.gitignore
Empty file.
Empty file removed runtime/logs/.gitignore
Empty file.
22 changes: 11 additions & 11 deletions src/LayoutParameters.php → src/ApplicationParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Yiisoft\Assets\AssetBundle;

final class LayoutParameters extends AssetBundle
final class ApplicationParameters extends AssetBundle
{
private string $brandUrl;
private string $charset;
Expand All @@ -20,8 +20,8 @@ final class LayoutParameters extends AssetBundle
private array $heroFooterColumnCenterOptions = [];
private string $heroFooterColumnLeft;
private array $heroFooterColumnLeftOptions = [];
private string $heroFooterColumnRigth;
private array $heroFooterColumnRigthOptions = [];
private string $heroFooterColumnRight;
private array $heroFooterColumnRightOptions = [];
private string $language;
private string $logo;
private array $menu = [];
Expand Down Expand Up @@ -97,14 +97,14 @@ public function getHeroFooterColumnLeftOptions(): array
return $this->heroFooterColumnLeftOptions;
}

public function getHeroFooterColumnRigth(): string
public function getHeroFooterColumnRight(): string
{
return $this->heroFooterColumnRigth;
return $this->heroFooterColumnRight;
}

public function getHeroFooterColumnRigthOptions(): array
public function getHeroFooterColumnRightOptions(): array
{
return $this->heroFooterColumnRigthOptions;
return $this->heroFooterColumnRightOptions;
}

public function getLanguage(): string
Expand Down Expand Up @@ -254,17 +254,17 @@ public function heroFooterColumnLeftOptions(array $value): self
return $new;
}

public function heroFooterColumnRigth(string $value): self
public function heroFooterColumnRight(string $value): self
{
$new = clone $this;
$new->heroFooterColumnRigth = $value;
$new->heroFooterColumnRight = $value;
return $new;
}

public function heroFooterColumnRigthOptions(array $value): self
public function heroFooterColumnRightOptions(array $value): self
{
$new = clone $this;
$new->heroFooterColumnRigthOptions = $value;
$new->heroFooterColumnRightOptions = $value;
return $new;
}

Expand Down
1 change: 0 additions & 1 deletion src/Provider/EventDispatcherProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace App\Provider;

use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\EventDispatcher\ListenerProviderInterface;
use Yiisoft\Di\Container;
Expand Down
Loading

0 comments on commit 8be5420

Please sign in to comment.