Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit 371bd45

Browse files
author
David Yell
committed
Merge branch 'templates'
2 parents e3a01cc + e5f5d9d commit 371bd45

14 files changed

+640
-7
lines changed

README.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ You should install this plugin into your CakePHP application using [composer](ht
1919
The recommended way to install composer packages is using,
2020

2121
```bash
22-
composer require 'davidyell/nice-admin-bake-scripts:3.0.x-dev'
22+
composer require 'davidyell/nice-admin-bake-scripts:dev-master'
2323
```
2424

2525
## Setup
@@ -70,6 +70,20 @@ bin/cake bake template --theme=NiceAdminBakeTheme Examples
7070
bin/cake bake template --theme=NiceAdminBakeTheme --prefix=Admin Examples
7171
```
7272

73+
## Example layout, elements and dashboard
74+
A basic admin layout, dashboard and navigation elements are included in the plugin. Which you can symlink, extend, or
75+
copy into your project as you see fit.
76+
77+
If you want to link to the styles. `echo $this->Html->css(['NiceAdminBakeTheme.nice-admin']);`
78+
79+
However it's preferable to use a symlink.
80+
```bash
81+
$ bin/cake plugin assets symlink NiceAdminBakeTheme
82+
```
83+
84+
:warning: These elements are optional, and do not provide a completed admin. You will need to customise
85+
this to suit your needs.
86+
7387
## Changes to standard bake
7488
* Removed the `_serialize` from the controllers
7589
* Removed the actions sidebar from all templates
+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<div class="dashboards home">
2+
<h1>My administration dashboard</h1>
3+
4+
<div class="search">
5+
<?php
6+
echo $this->Form->create(null, ['class' => 'form-inline', 'url' => ['controller' => 'Examples', 'action' => 'index']]);
7+
echo $this->Form->input('example_id');
8+
echo $this->Form->button(__('Search examples'), ['class' => 'btn btn-sm btn-primary']);
9+
echo $this->Form->end();
10+
?>
11+
</div>
12+
<div class="clearfix"><!-- blank --></div>
13+
14+
<div class="row">
15+
<div class="col-md-12">
16+
<div class="panel blue"><!-- You can put a graph here perhaps --></div>
17+
</div>
18+
</div>
19+
<div class="row">
20+
<div class="col-md-4">
21+
<div class="recent panel green">
22+
<h3>Recent stuff</h3>
23+
<?php foreach ($examples as $example): ?>
24+
<div class="item">
25+
<img src="">
26+
<span class="label">Example</span>
27+
<span class="modified">DateTime</span>
28+
</div>
29+
<?php endforeach?>
30+
31+
<p><?= $this->Html->link('View all things', ['controller' => 'Things', 'action' => 'index']);?></p>
32+
</div>
33+
</div>
34+
<div class="col-md-4">
35+
<div class="recent panel orange">
36+
<h3>Recent stuff</h3>
37+
38+
<p><?= $this->Html->link('View all things', ['controller' => 'Things', 'action' => 'index']);?></p>
39+
</div>
40+
</div>
41+
<div class="col-md-4">
42+
<div class="recent-prices panel purple">
43+
<h3>Recent stuff</h3>
44+
45+
<p><?= $this->Html->link('View all things', ['controller' => 'Things', 'action' => 'index']);?></p>
46+
</div>
47+
</div>
48+
</div>
49+
<div class="row">
50+
<div class="col-md-12">
51+
<div class="latestLogins panel">
52+
<h3>Last logins</h3>
53+
<ul>
54+
<?php
55+
foreach ($lastUsersLogin as $user) {
56+
?><li>
57+
<?= $this->Gravatar->avatar($user->email, 70);?>
58+
<p><?= $user->get('FullName');?></p>
59+
<p class="last-login"><?= $this->Time->timeAgoInWords($user->last_login);?></p>
60+
</li><?php
61+
}
62+
?>
63+
</ul>
64+
<div class="clearfix"><!-- blank --></div>
65+
<p><?= $this->Html->link('View all users', ['controller' => 'Users', 'action' => 'index']);?></p>
66+
</div>
67+
</div>
68+
</div>
69+
</div>
70+
71+
72+
73+
74+
<?php $this->append('script');?>
75+
<script type="text/javascript">
76+
// Add your graph javascript
77+
</script>
78+
<?php $this->end();?>

src/Template/Element/navigation.ctp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<div class="user">
2+
<?= $this->Gravatar->avatar($this->request->session()->read('Auth.User.email'), 40);?>
3+
<p>
4+
<?= $this->request->session()->read('Auth.User.first_name') . ' ' . $this->request->session()->read('Auth.User.last_name')?><br>
5+
<span class="status online"><i class="glyphicon glyphicon-ok-sign"></i></span> Online
6+
</p>
7+
</div>
8+
9+
<nav id="accordion">
10+
<h3><i class="glyphicon glyphicon-flag"></i> First item <i class="glyphicon glyphicon-chevron-left"></i></h3>
11+
<div>
12+
<ul>
13+
<li <?php echo ($this->request->controller == 'Examples')? 'class="active"' : '' ?>><?php echo $this->Html->link('Examples', ['controller' => 'Examples', 'action' => 'index', 'plugin' => false], ['escape' => false]); ?></li>
14+
<li <?php echo ($this->request->controller == 'Placeholders')? 'class="active"' : '' ?>><?php echo $this->Html->link('Placeholders', ['controller' => 'Placeholders', 'action' => 'index', 'plugin' => false]); ?></li>
15+
</ul>
16+
</div>
17+
18+
<h3><i class="glyphicon glyphicon-list-alt"></i> Second item <i class="glyphicon glyphicon-chevron-left"></i></h3>
19+
<div>
20+
<ul>
21+
<li <?php echo ($this->request->controller == 'Examples')? 'class="active"' : '' ?>><?php echo $this->Html->link('Examples', ['controller' => 'Examples', 'action' => 'index', 'plugin' => false], ['escape' => false]); ?></li>
22+
<li <?php echo ($this->request->controller == 'Placeholders')? 'class="active"' : '' ?>><?php echo $this->Html->link('Placeholders', ['controller' => 'Placeholders', 'action' => 'index', 'plugin' => false]); ?></li>
23+
</ul>
24+
</div>
25+
26+
</nav>
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<nav class="navbar navbar-inverse navbar-fixed-top">
2+
<div class="container-fluid">
3+
<div class="navbar-header">
4+
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
5+
<span class="sr-only">Toggle navigation</span>
6+
<span class="icon-bar"></span>
7+
<span class="icon-bar"></span>
8+
<span class="icon-bar"></span>
9+
</button>
10+
<a class="navbar-brand" href="/">Your project name</a>
11+
</div>
12+
<div id="navbar" class="navbar-collapse collapse">
13+
<ul class="nav navbar-nav navbar-right">
14+
<li <?php echo ($this->request->controller == 'Dashboards')? "class='active'" : '';?>><?php echo $this->Html->link('<i class="glyphicon glyphicon-home"></i> Dashboard', ['controller' => 'Dashboards', 'action' => 'home', 'plugin' => false], ['escape' => false]); ?></li>
15+
<li <?php echo (isset($this->request->params['pass'][0]) && $this->request->params['pass'][0] == 'help')? "class='active'" : '';?>><?php echo $this->Html->link('<i class="glyphicon glyphicon-question-sign"></i> Help', ['controller' => 'Pages', 'action' => 'display', 'help', 'prefix' => 'admin', 'plugin' => false], ['escape' => false]); ?></li>
16+
<li><?php echo $this->Html->link('<i class="glyphicon glyphicon-off"></i> Logout', ['controller' => 'Users', 'action' => 'logout', 'plugin' => false, 'prefix' => false], ['escape' => false]); ?></li>
17+
</ul>
18+
</div>
19+
</div>
20+
</nav>

src/Template/Layout/admin.ctp

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php $this->Html->docType();?>
2+
<html>
3+
<head>
4+
<?php echo $this->Html->charset(); ?>
5+
<title><?php echo $this->fetch('title');?></title>
6+
<?php
7+
echo $this->Html->meta('icon');
8+
9+
echo $this->fetch('meta');
10+
11+
echo $this->Html->css(array(
12+
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css',
13+
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css',
14+
'nice-admin'
15+
));
16+
echo $this->fetch('css');
17+
?>
18+
</head>
19+
<body>
20+
<?php echo $this->element('NiceAdminBakeTheme.top-navigation');?>
21+
22+
<div class="container-fluid admin">
23+
<div class="row">
24+
<div class="col-sm-3 col-md-2 sidebar">
25+
<?php echo $this->element('NiceAdminBakeTheme.navigation');?>
26+
</div>
27+
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
28+
<?php echo $this->Flash->render();?>
29+
<?php echo $this->fetch('content');?>
30+
<footer><p>Copyright &copy; <?php echo date('Y');?> My Company</p></footer>
31+
</div>
32+
</div>
33+
</div>
34+
35+
<?php
36+
echo $this->Html->script(array(
37+
'//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js',
38+
'//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js',
39+
'//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js',
40+
'https://www.google.com/jsapi',
41+
'common'
42+
));
43+
echo $this->fetch('script');
44+
?>
45+
</body>
46+
</html>

src/View/Helper/GravatarHelper.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/**
4+
* @package GravatarHelper.php
5+
*
6+
* @author David Yell <neon1024@gmail.com>
7+
* @when 20/05/15
8+
*
9+
*/
10+
11+
namespace App\View\Helper;
12+
13+
use Cake\View\Helper;
14+
15+
class GravatarHelper extends Helper {
16+
17+
/**
18+
* Generate a gravatar avatar image
19+
*
20+
* @param string $email Users email address
21+
* @param int $size Pixel size of avatar
22+
* @param string $class A css class attribute for the image
23+
* @return string
24+
*/
25+
public function avatar($email, $size = 50, $class = 'user-avatar')
26+
{
27+
$hash = md5(strtolower(trim($email)));
28+
return "<img class='$class' src='http://www.gravatar.com/avatar/$hash?s=$size&d=mm'>";
29+
}
30+
31+
}

webroot/css/nice-admin.css

+2-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webroot/css/nice-admin.css.map

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webroot/sass/nice-admin.scss

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Messages
2+
$good: #bfea83;
3+
$bad: #e88181;
4+
5+
// Panels
6+
$panelBgColor: #f4f4f4;
7+
8+
// Sidebar nav
9+
$sidebarBg: #222D32;
10+
$activeLink: #fff;
11+
$inactiveLink: #b8c7ce;
12+
$navbarBg: #00A65A;
13+
14+
// Partials
15+
@import "partials/typography";
16+
@import "partials/forms";
17+
@import "partials/bootstrap-theme";
18+
@import "partials/dashboard";
19+
@import "partials/navigation";
20+
21+
// Boolean glyphicons
22+
.glyphicon {
23+
&.bool-false {
24+
color: $bad;
25+
}
26+
&.bool-true {
27+
color: darken($good, 25%);
28+
}
29+
}
30+
31+
td.actions {
32+
white-space: nowrap;
33+
a {
34+
margin: 0 3px;
35+
}
36+
}
37+
38+
.index {
39+
a.add-button {
40+
margin: 16px 0 0 16px;
41+
}
42+
a.purge-button {
43+
float: right;
44+
margin: 18px 0 0 0;
45+
}
46+
a.deleted-button {
47+
float: right;
48+
margin: 18px 10px 0 0;
49+
}
50+
}
51+
52+
div.buttons {
53+
margin-bottom: 10px;
54+
}
55+
div.form-group.required label:after {
56+
content: " *";
57+
}

0 commit comments

Comments
 (0)