Skip to content

Commit d0c56cf

Browse files
Merge pull request #39 from dappur/dshimkoski-master
Add Vagrant Support to Framework
2 parents e18df07 + 5c65707 commit d0c56cf

22 files changed

+408
-198
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ settings.json
1515
bower_components
1616
node_modules
1717

18-
.phpintel
18+
.phpintel
19+
20+
.vagrant

CHANGELOG.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# Changelog
2-
32
## [Unreleased]
4-
### Added
5-
- `.` to allowed scope characters in admin
6-
- `realpath()` to asset path fixes bug on certain server configs
7-
- Path validation for retriving public view assets
3+
###No Changes
4+
5+
## [3.0.3] - 2018-09-14
6+
### Notes
7+
This version includes support for Vagrant initially submitted by [dshimkoski](https://github.com/dshimkoski). By using vagrant, you have instant access to a set up dev environment including:
8+
- **Web Frontend:** http://localhost:8181
9+
- **PhpmyAdmin:** http://localhost:8181/phpmyadmin
10+
- **Raw Mysql:** localhost:8306
11+
I couldn't get the `vagrant push` commands to work on my setup (Windows 10), but the goal of that would be to migrate and rollback the dev environment. For now, those commands can be passed via `vagrant ssh -c "cd /vagrant && phinx migrate"` and `vagrant ssh -c "cd /vagrant && phinx rollback"`. I have also changed the Vagrant `provision.sh` file so that you can re-run the provision script to migrate the database up.
812

913
### Changed
14+
- Recaptcha is not configurable as on or off in the global settings. Default is off.
15+
- Changed mail settings for more generic smtp settings
1016
- `token_secret` and `refresh_token` to text()
1117
- `page_config` variable to `pageConfig`
1218

@@ -246,7 +252,8 @@ Once those items are complete, focus will be shifted to feature enhancements. T
246252
- Internalized all assets, they are now served from the view folder and not from the public dir.
247253

248254

249-
[Unreleased]: https://github.com/dappur/framework/compare/v3.0.2...HEAD
255+
[Unreleased]: https://github.com/dappur/framework/compare/v3.0.3...HEAD
256+
[3.0.3]: https://github.com/dappur/framework/compare/v3.0.2...v3.0.3
250257
[3.0.2]: https://github.com/dappur/framework/compare/v3.0.1...v3.0.2
251258
[3.0.1]: https://github.com/dappur/framework/compare/v3.0.0...v3.0.1
252259
[3.0.0]: https://github.com/dappur/framework/compare/v2.5.0...v3.0.0

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The blog addon has now been integrated into the main repo and template files. I
1414
**[Demo](https://demo.dappur.io)**
1515
**[Documentation](https://docs.dappur.io)**
1616
**[Changelog](https://github.com/dappur/framework/blob/master/CHANGELOG.md)**
17-
**[Dapp CLI](https://github.com/dappur/dapp)**
17+
**[Dapp CLI](https://github.com/dappur/dapp)**
1818

1919
----------
2020

@@ -30,26 +30,31 @@ The blog addon has now been integrated into the main repo and template files. I
3030
* [Slim Validation](https://github.com/awurth/slim-validation) - A validator for Slim micro-framework using [Respect\Validation](https://github.com/Respect/Validation)
3131
* [Cartalyst Sentinel](https://github.com/cartalyst/sentinel) - PHP 5.4+ Fully-featured Authentication & Authorization System
3232
* [Illuminate Database](https://github.com/illuminate/database) - The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style ORM, and schema builder.
33-
* [Monolog Logging](https://github.com/Seldaek/monolog) - Send logs to files, sockets, inboxes, databases and various web services.
33+
* [Monolog Logging](https://github.com/Seldaek/monolog) - Send logs to files, sockets, inboxes, databases and various web services.
3434
* [Fig Cookies](https://github.com/dflydev/dflydev-fig-cookies) - Cookies for PSR-7 HTTP Message Interface.
3535
* [Phinx Database Migrations](https://github.com/robmorgan/phinx) - Phinx makes it ridiculously easy to manage the database migrations for your PHP app.
3636
* [Cloudinary Image CDN](https://github.com/cloudinary/cloudinary_php) - Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline.
3737
* [PHPMailer](https://github.com/PHPMailer/PHPMailer) - A full-featured email creation and transfer class for PHP.
3838
* [Paginator](https://github.com/jasongrimes/php-paginator) - A lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr.
39+
* [UUID](https://github.com/ramsey/uuid) - A PHP library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).
40+
* [Jobby](https://github.com/jobbyphp/jobby) - Manage all your cron jobs without modifying crontab. Handles locking, logging, error emails, and more.
41+
* [TwoFactorAuth](https://github.com/RobThree/TwoFactorAuth) - PHP library for Two Factor Authentication (TFA / 2FA)
3942

4043

4144
----------
4245

4346
### //TODO
4447
* Create Documentation
45-
* Update Dappur CLI for v2
46-
* Update Default Theme to an open source Bootstrap 4
47-
* Update Dashboard theme to an open source Bootstrap 4
48+
* Update Dappur CLI for v3
4849
* Add Unit Testing
4950

5051
----------
5152

5253
### Pre-Requisites
54+
[PHP](https://secure.php.net/) - PHP is a popular general-purpose scripting language that is especially suited to web development
55+
56+
[MySQL Server](https://github.com/mysql/mysql-server) - MySQL Server, the world's most popular open source database, and MySQL Cluster, a real-time, open source transactional database.
57+
5358
[Composer](https://getcomposer.org/) - Dependency manager is required in order to use the Dappur PHP Framework. Installation instructions are [located here](https://getcomposer.org/doc/00-intro.md).
5459

5560
[Phinx](https://phinx.org/) - Phinx is required in order to utilize the database migrations. It is recommended that you install Phinx globally via composer by running:
@@ -68,7 +73,21 @@ This will clone the Dappur Framework into a new project directory called `new_ap
6873

6974
----------
7075

71-
### Configure Project and Database
76+
### Quick Start Via Vagrant
77+
Once installed, run `vagrant up` in the project root to provision a box that contains:
78+
79+
- Ubuntu 18
80+
- PHP 7.2
81+
- Composer
82+
- Phinx
83+
- MariaDB 10.3
84+
- Apache 2
85+
86+
The script will also fetch dependencies, create a `dev` database, and run the initial migration for you.
87+
88+
----------
89+
90+
### Manually Configure
7291
Configuring your new project is simple. Rename `settings.dist.json` to `settings.json` and configure the following options at a minimum:
7392
```
7493
db->development->host

Vagrantfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
# Globals
4+
hostHttpPort = 8181
5+
hostMysqlPort = 8306
6+
rootPass = "rootpass"
7+
8+
# Check if settings json file exists or create
9+
if not File.file?('settings.json')
10+
IO.copy_stream('settings.json.dist', 'settings.json')
11+
end
12+
13+
# Get Database From settings.json
14+
settings = JSON.parse(File.read('settings.json'))
15+
env = settings['environment']
16+
database = settings['db'][env]
17+
dbName = database['database']
18+
dbUser = database['username']
19+
dbPass = database['password']
20+
21+
Vagrant.configure("2") do |config|
22+
# ubuntu 18.04
23+
config.vm.box = "bento/ubuntu-18.04"
24+
# forward http port
25+
config.vm.network "forwarded_port",
26+
guest: 80,
27+
host: hostHttpPort
28+
# forward mysql port
29+
config.vm.network "forwarded_port",
30+
guest: 3306,
31+
host: hostMysqlPort
32+
# provision
33+
config.vm.provision "shell",
34+
path: "storage/vagrant/provision.sh",
35+
privileged: false,
36+
args: [
37+
hostHttpPort,
38+
rootPass,
39+
dbName,
40+
dbUser,
41+
dbPass,
42+
]
43+
# migrate push command
44+
config.push.define "migrate", strategy: "local-exec" do |push|
45+
push.script = "storage/vagrant/push.migrate.sh"
46+
end
47+
# rollback push command
48+
config.push.define "rollback", strategy: "local-exec" do |push|
49+
push.script = "storage/vagrant/push.rollback.sh"
50+
end
51+
end

app/bootstrap/dependencies.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,16 @@
253253
case 'phpmail':
254254
break;
255255

256-
case 'mailgun':
257-
$mail->isSMTP(); // Set mailer to use SMTP
258-
$mail->Host = 'smtp.mailgun.org'; // Specify main and backup server
259-
$mail->Port = 587; // Set the SMTP port
260-
$mail->SMTPAuth = true; // SMTP Auth
261-
$mail->Username = $mail_settings['mailgun']['username']; // SMTP Username
262-
$mail->Password = $mail_settings['mailgun']['password']; // SMTP Password
263-
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl'
256+
case 'smtp':
257+
$mail->isSMTP();
258+
$mail->Host = $mail_settings['smtp']['host'];
259+
$mail->Port = $mail_settings['smtp']['port'];
260+
if ($mail_settings['smtp']['smtp_auth']) {
261+
$mail->SMTPAuth = true;
262+
$mail->Username = $mail_settings['smtp']['username'];
263+
$mail->Password = $mail_settings['smtp']['password'];
264+
}
265+
$mail->SMTPSecure = $mail_settings['smtp']['smtp_secure'];
264266
break;
265267

266268
default:

app/src/Controller/App.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ public function contact(Request $request, Response $response)
7070
);
7171
$this->validator->validate($request, $validateData);
7272

73-
// Validate Recaptcha
74-
$recaptcha = new Recaptcha($this->container);
75-
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
76-
if (!$recaptcha) {
77-
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
73+
if ($this->config['recaptcha-enabled']) {
74+
// Validate Recaptcha
75+
$recaptcha = new Recaptcha($this->container);
76+
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
77+
if (!$recaptcha) {
78+
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
79+
}
7880
}
81+
7982

8083
if ($this->validator->isValid()) {
8184
$add = new ContactRequests;

app/src/Controller/Auth.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ public function forgotPassword(Request $request, Response $response)
6262
);
6363
$this->validator->validate($request, $validateData);
6464

65-
// Validate Recaptcha
66-
$recaptcha = new Recaptcha($this->container);
67-
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
68-
if (!$recaptcha) {
69-
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
65+
if ($this->config['recaptcha-enabled']) {
66+
// Validate Recaptcha
67+
$recaptcha = new Recaptcha($this->container);
68+
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
69+
if (!$recaptcha) {
70+
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
71+
}
7072
}
7173

7274
$credentials = [
@@ -129,11 +131,13 @@ public function login(Request $request, Response $response)
129131

130132
$remember = $request->getParam('remember') ? true : false;
131133

132-
// Validate Recaptcha
133-
$recaptcha = new Recaptcha($this->container);
134-
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
135-
if (!$recaptcha) {
136-
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
134+
if ($this->config['recaptcha-enabled']) {
135+
// Validate Recaptcha
136+
$recaptcha = new Recaptcha($this->container);
137+
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
138+
if (!$recaptcha) {
139+
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
140+
}
137141
}
138142

139143
if ($this->validator->isValid()) {
@@ -369,11 +373,13 @@ private function validateNewUser()
369373
);
370374
$this->validator->validate($this->request, $validateData);
371375

372-
// Validate Recaptcha
373-
$recaptcha = new Recaptcha($this->container);
374-
$recaptcha = $recaptcha->validate($this->request->getParam('g-recaptcha-response'));
375-
if (!$recaptcha) {
376-
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
376+
if ($this->config['recaptcha-enabled']) {
377+
// Validate Recaptcha
378+
$recaptcha = new Recaptcha($this->container);
379+
$recaptcha = $recaptcha->validate($this->request->getParam('g-recaptcha-response'));
380+
if (!$recaptcha) {
381+
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
382+
}
377383
}
378384

379385
// Validate Username

app/views/AdminLTE/blog-add.twig

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2-bootstrap-theme/0.1.0-beta.10/select2-bootstrap.min.css">
88
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/daterangepicker.min.css" />
99
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
10+
<link rel="stylesheet" type="text/css" href="{{asset('AdminLTE/css/grideditor.min.css')}}" />
1011
{% endblock %}
1112

1213
{% block body %}
@@ -49,9 +50,10 @@
4950

5051
<div class="form-group{% if has_error('post_content') %} has-error{% endif %}">
5152
<label for="post_content">Content</label>
52-
<textarea name="post_content" class="form-control tinymce" id="post_content" placeholder="Post Content" required="required">
53-
{% if requestParams.post_content %}{{requestParams.post_content}}{% endif %}
54-
</textarea>
53+
<div id="contentRow">{% if requestParams.post_content %}{{requestParams.post_content|raw}}{% else %}{{ post.content|raw }}{% endif %}</div>
54+
<textarea name="post_content" class="form-control" id="content" style="display: none;">
55+
{% if requestParams.post_content %}{{requestParams.post_content|raw}}{% else %}{{ post.content|raw }}{% endif %}
56+
</textarea>
5557
<span class="help-block">{{ error('post_content') }}</span>
5658
</div>
5759

@@ -192,15 +194,16 @@
192194
{% endblock %}
193195

194196
{% block javascript %}
195-
<!-- Select2 Dropdowns -->
196197
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js" type="text/javascript"></script>
197198
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/moment.min.js"></script>
198199
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/daterangepicker.min.js"></script>
199200
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.1/tinymce.min.js" type="text/javascript"></script>
201+
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.1/jquery.tinymce.min.js" type="text/javascript"></script>
200202
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
201-
<script src="{{ asset('AdminLTE/js/tinymce-init.min.js') }}" type="text/javascript"></script>
202203
<script src="{{ asset('AdminLTE/js/video-parser.min.js') }}" type="text/javascript"></script>
203204
<script src="{{ asset('AdminLTE/js/blog.min.js') }}" type="text/javascript"></script>
205+
<script src="{{ asset('AdminLTE/js/jquery.grideditor.min.js') }}" type="text/javascript"></script>
206+
<script src="{{ asset('AdminLTE/js/dappur.grideditor.min.js') }}" type="text/javascript"></script>
204207
{% if hasCloudinary %}
205208
<script src="https://cdnjs.cloudflare.com/ajax/libs/cloudinary-jquery-file-upload/2.3.0/cloudinary-jquery-file-upload.min.js"></script>
206209
<script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script>
@@ -217,8 +220,11 @@ $(document).ready(function() {
217220
format: 'MM/DD/YYYY h:mm A'
218221
}
219222
});
223+
220224
{% if requestParams.video_id and requestParams.video_provider == "youtube" %}
221-
video_id = '{{ requestParams.video_id }}';
225+
video_id = '{{ requestParams.video_id }}';
226+
{% elseif post.video_id and post.video_provider == "youtube" %}
227+
video_id = '{{ post.video_id }}';
222228
{% endif %}
223229
});
224230
</script>

app/views/AdminLTE/blog-edit.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@
203203
{% endblock %}
204204

205205
{% block javascript %}
206-
<!-- Select2 Dropdowns -->
207206
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js" type="text/javascript"></script>
208207
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/moment.min.js"></script>
209208
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/daterangepicker.min.js"></script>

app/views/dappur/blog-post.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
{% endblock %}
108108

109109
{% block javascript %}
110-
{{ recaptchaJs() }}
110+
{% if config['recaptcha-enabled'] %}{{ recaptchaJs() }}{% endif %}
111111

112112
<script src="{{ asset('dappur/js/blog-comments.js') }}"></script>
113113

app/views/dappur/blog.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,5 @@
111111
{% endblock %}
112112

113113
{% block javascript %}
114-
{{ recaptchaJs() }}
114+
{% if config['recaptcha-enabled'] %}{{ recaptchaJs() }}{% endif %}
115115
{% endblock %}

app/views/dappur/contact.twig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
{{ form.textarea('comment', requestParams.comment, 'comment', 'Comments/Feedback', null, 6, null)}}
3838

3939
<div class="row">
40-
<div class="col-sm-6">
41-
{{ form.custom('recaptcha', recaptcha()) }}
42-
</div>
40+
{% if config['recaptcha-enabled'] %}
41+
<div class="col-sm-6">
42+
{{ form.custom('recaptcha', recaptcha()) }}
43+
</div>
44+
{% endif %}
4345
<div class="col-sm-6">
4446
<div class="form-group text-center">
4547
<button type="submit" class="btn btn-default btn-send"><span class="fa fa-send"></span> Send</button>
@@ -114,5 +116,5 @@
114116
{% endblock %}
115117

116118
{% block javascript %}
117-
{{ recaptchaJs() }}
119+
{% if config['recaptcha-enabled'] %}{{ recaptchaJs() }}{% endif %}
118120
{% endblock %}

app/views/dappur/forgot-password.twig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
{{ form.text('email', null, 'email', 'Email Address') }}
2222
{{ csrf() }}
2323

24-
{{ form.custom('recaptcha', recaptcha()) }}
24+
{% if config['recaptcha-enabled'] %}
25+
{{ form.custom('recaptcha', recaptcha()) }}
26+
{% endif %}
2527
<input type="submit" value="Reset Password" class="btn btn-primary">
2628
</form>
2729
</div>
@@ -33,5 +35,5 @@
3335
{% endblock %}
3436

3537
{% block javascript %}
36-
{{ recaptchaJs() }}
38+
{% if config['recaptcha-enabled'] %}{{ recaptchaJs() }}{% endif %}
3739
{% endblock %}

0 commit comments

Comments
 (0)