-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor improvements #17
base: master
Are you sure you want to change the base?
Changes from 3 commits
b3a5875
90a1ba8
b4ba3af
7426709
6e0404a
547f347
1edb4cc
e093c0e
226ca7c
9be5f7e
3676145
eba5c59
13b6154
b50b628
f41851f
c70634c
0b9a05c
0f405f6
3fad43c
86b94bf
fb29d6b
9ba5638
cd5c648
3e0f67a
ae5cdc0
037e6b6
c5b011b
ae9ffe4
7a6adde
630ba5c
b3e9347
bb21623
eea41e9
a0a743a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,84 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use Cake\Controller\Controller; | ||
use Crud\Controller\ControllerTrait; | ||
|
||
class AppController extends Controller | ||
{ | ||
use ControllerTrait; | ||
|
||
/** | ||
* Tells if the CRUD listeners should be enabled. | ||
* | ||
* @var bool | ||
*/ | ||
public $isCrudEnabled = true; | ||
|
||
/** | ||
* Tells if CRUD view listener and view should be used. | ||
* | ||
* @var bool | ||
*/ | ||
public $isCrudViewEnabled = true; | ||
|
||
/** | ||
* Tells if the CRUD API listeners should be enabled. | ||
* | ||
* @var bool | ||
*/ | ||
public $isCrudApiEnabled = false; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function initialize() | ||
{ | ||
parent::initialize(); | ||
|
||
$this->loadComponent('Flash'); | ||
$this->loadComponent('RequestHandler'); | ||
|
||
$this->_setupCrud(); | ||
} | ||
|
||
protected function _setupCrud() | ||
{ | ||
if (!$this->isCrudEnabled) { | ||
return; | ||
} | ||
|
||
$this->loadComponent('Crud.Crud', [ | ||
'listeners' => [ | ||
'Crud.Redirect', | ||
'Crud.RelatedModels', | ||
] | ||
]); | ||
|
||
$this->_setupCrudView(); | ||
$this->_setupCrudApi(); | ||
} | ||
|
||
protected function _setupCrudView() | ||
{ | ||
if (!$this->isCrudViewEnabled) { | ||
return; | ||
} | ||
|
||
$this->Crud->addListener('CrudView.View'); | ||
$this->viewBuilder() | ||
->className('CrudView.Crud') | ||
->layout('default'); | ||
} | ||
|
||
protected function _setupCrudApi() | ||
{ | ||
if (!$this->isCrudApiEnabled) { | ||
return; | ||
} | ||
|
||
$this->Crud->addListener('Crud.Api'); | ||
$this->Crud->addListener('Crud.ApiPagination'); | ||
$this->Crud->addListener('Crud.ApiQueryLog'); | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
<!DOCTYPE html> | ||
|
||
<?php | ||
echo $this->fetch( | ||
'html', | ||
sprintf('<html lang="%s" class="no-js">', read('App.language')) | ||
); | ||
?> | ||
<html lang="<?= \Locale::getPrimaryLanguage(\Cake\I18n\I18n::locale()) ?>"> | ||
|
||
<head> | ||
|
||
|
@@ -15,38 +9,20 @@ echo $this->fetch( | |
<?= $this->fetch('title', read('App.title', env('HTTP_HOST'))) ?> | ||
</title> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="author" content="<?= read('App.author') ?>"> | ||
<?= $this->Html->meta('icon') ?> | ||
<?= $this->fetch('meta') ?> | ||
|
||
|
||
<?= $this->AssetCompress->css('platform') ?> | ||
<?= $this->fetch('css'); ?> | ||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements --> | ||
<!--[if lt IE 9]> | ||
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> | ||
<script src="//oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script> | ||
<![endif]--> | ||
<?= $this->fetch('css') ?> | ||
<?= $this->fetch('headjs') ?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not work with CRUD since CakePHP2 / CRUDv3 (custom build crud view). So bear with me if this comment has more the form of an RFC. I don't know what I suggest adding the following:
E.g.
Usually you should by doing so go well with one application-top.css, one application-bottom.css, one application-bottom.js, one action-bottom.css and one action-bottom.js. 5 requests but those allow What I suggest here should work well with eager-loading, but also lazy-loading and decoupling, with preprocessor pipelines and tries to strike limiting download size of css/js files as well as the amount of request (request-overhead). It works with conventions out of the box and if you don't use certain files (because they either don't exist or are not relevant to the request) those files won't even appear. What happens with elements/cells and css/js is not part of this suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another point would be to also add a controller level e.g., to sum it up:
... each... top and bottom. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The The rest of the suggestion are nice, bit heavy, but nice. And yes, they look fitting into a separate plugin, not even an RFC (if you ask me). Something that people could use in this application template or the official one or any other. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I ll let you know if I have a working copy - maybe you or someone in the community can help me with test cases (by help I mean, help me write them myself). |
||
|
||
</head> | ||
|
||
<?= $this->fetch('body', '<body' . $this->fetch('bodyAttributes') . '>') ?> | ||
|
||
<?= $this->fetch('content'); ?> | ||
|
||
<footer id="footer" class="footer"> | ||
|
||
<?= $this->fetch( | ||
'footer', | ||
sprintf( | ||
'©%s %s', | ||
date('Y'), | ||
read('App.title', env('HTTP_HOST')) | ||
) | ||
); | ||
?> | ||
|
||
</footer> | ||
|
||
<?= $this->fetch('content') ?> | ||
<?= $this->fetch('footer') ?> | ||
<?= $this->AssetCompress->script('platform') ?> | ||
<?= $this->fetch('script'); ?> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,7 @@ | ||
<?php | ||
namespace App\View; | ||
|
||
use Cake\View\View; | ||
|
||
class AppView extends View | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @return void | ||
*/ | ||
public function initialize() | ||
{ | ||
$this->_setupAssetCompress(); | ||
$this->_setupBootstrapUI(); | ||
} | ||
|
||
/** | ||
* Load the AssetCompress helper. | ||
* | ||
* @return void | ||
*/ | ||
protected function _setupAssetCompress() | ||
{ | ||
$this->loadHelper('AssetCompress.AssetCompress'); | ||
} | ||
|
||
/** | ||
* Load the BootstrapUI helpers. | ||
* | ||
* @return void | ||
*/ | ||
protected function _setupBootstrapUI() | ||
{ | ||
$helpers = ['Flash', 'Form']; | ||
foreach ($helpers as $helper) { | ||
$this->loadHelper($helper, [ | ||
'className' => 'BootstrapUI.' . $helper, | ||
]); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting Content Language Header and this is very imporant fir the browser nowadays, css hyphens uses those. Great stuff.