Skip to content

Commit

Permalink
Merge pull request #39 from dappur/dshimkoski-master
Browse files Browse the repository at this point in the history
Add Vagrant Support to Framework
  • Loading branch information
edwardteach42 authored Sep 15, 2018
2 parents e18df07 + 5c65707 commit d0c56cf
Show file tree
Hide file tree
Showing 22 changed files with 408 additions and 198 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ settings.json
bower_components
node_modules

.phpintel
.phpintel

.vagrant
19 changes: 13 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Changelog

## [Unreleased]
### Added
- `.` to allowed scope characters in admin
- `realpath()` to asset path fixes bug on certain server configs
- Path validation for retriving public view assets
###No Changes

## [3.0.3] - 2018-09-14
### Notes
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:
- **Web Frontend:** http://localhost:8181
- **PhpmyAdmin:** http://localhost:8181/phpmyadmin
- **Raw Mysql:** localhost:8306
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.

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

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


[Unreleased]: https://github.com/dappur/framework/compare/v3.0.2...HEAD
[Unreleased]: https://github.com/dappur/framework/compare/v3.0.3...HEAD
[3.0.3]: https://github.com/dappur/framework/compare/v3.0.2...v3.0.3
[3.0.2]: https://github.com/dappur/framework/compare/v3.0.1...v3.0.2
[3.0.1]: https://github.com/dappur/framework/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/dappur/framework/compare/v2.5.0...v3.0.0
Expand Down
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The blog addon has now been integrated into the main repo and template files. I
**[Demo](https://demo.dappur.io)**
**[Documentation](https://docs.dappur.io)**
**[Changelog](https://github.com/dappur/framework/blob/master/CHANGELOG.md)**
**[Dapp CLI](https://github.com/dappur/dapp)**
**[Dapp CLI](https://github.com/dappur/dapp)**

----------

Expand All @@ -30,26 +30,31 @@ The blog addon has now been integrated into the main repo and template files. I
* [Slim Validation](https://github.com/awurth/slim-validation) - A validator for Slim micro-framework using [Respect\Validation](https://github.com/Respect/Validation)
* [Cartalyst Sentinel](https://github.com/cartalyst/sentinel) - PHP 5.4+ Fully-featured Authentication & Authorization System
* [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.
* [Monolog Logging](https://github.com/Seldaek/monolog) - Send logs to files, sockets, inboxes, databases and various web services.
* [Monolog Logging](https://github.com/Seldaek/monolog) - Send logs to files, sockets, inboxes, databases and various web services.
* [Fig Cookies](https://github.com/dflydev/dflydev-fig-cookies) - Cookies for PSR-7 HTTP Message Interface.
* [Phinx Database Migrations](https://github.com/robmorgan/phinx) - Phinx makes it ridiculously easy to manage the database migrations for your PHP app.
* [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.
* [PHPMailer](https://github.com/PHPMailer/PHPMailer) - A full-featured email creation and transfer class for PHP.
* [Paginator](https://github.com/jasongrimes/php-paginator) - A lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr.
* [UUID](https://github.com/ramsey/uuid) - A PHP library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).
* [Jobby](https://github.com/jobbyphp/jobby) - Manage all your cron jobs without modifying crontab. Handles locking, logging, error emails, and more.
* [TwoFactorAuth](https://github.com/RobThree/TwoFactorAuth) - PHP library for Two Factor Authentication (TFA / 2FA)


----------

### //TODO
* Create Documentation
* Update Dappur CLI for v2
* Update Default Theme to an open source Bootstrap 4
* Update Dashboard theme to an open source Bootstrap 4
* Update Dappur CLI for v3
* Add Unit Testing

----------

### Pre-Requisites
[PHP](https://secure.php.net/) - PHP is a popular general-purpose scripting language that is especially suited to web development

[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.

[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).

[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:
Expand All @@ -68,7 +73,21 @@ This will clone the Dappur Framework into a new project directory called `new_ap

----------

### Configure Project and Database
### Quick Start Via Vagrant
Once installed, run `vagrant up` in the project root to provision a box that contains:

- Ubuntu 18
- PHP 7.2
- Composer
- Phinx
- MariaDB 10.3
- Apache 2

The script will also fetch dependencies, create a `dev` database, and run the initial migration for you.

----------

### Manually Configure
Configuring your new project is simple. Rename `settings.dist.json` to `settings.json` and configure the following options at a minimum:
```
db->development->host
Expand Down
51 changes: 51 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Globals
hostHttpPort = 8181
hostMysqlPort = 8306
rootPass = "rootpass"

# Check if settings json file exists or create
if not File.file?('settings.json')
IO.copy_stream('settings.json.dist', 'settings.json')
end

# Get Database From settings.json
settings = JSON.parse(File.read('settings.json'))
env = settings['environment']
database = settings['db'][env]
dbName = database['database']
dbUser = database['username']
dbPass = database['password']

Vagrant.configure("2") do |config|
# ubuntu 18.04
config.vm.box = "bento/ubuntu-18.04"
# forward http port
config.vm.network "forwarded_port",
guest: 80,
host: hostHttpPort
# forward mysql port
config.vm.network "forwarded_port",
guest: 3306,
host: hostMysqlPort
# provision
config.vm.provision "shell",
path: "storage/vagrant/provision.sh",
privileged: false,
args: [
hostHttpPort,
rootPass,
dbName,
dbUser,
dbPass,
]
# migrate push command
config.push.define "migrate", strategy: "local-exec" do |push|
push.script = "storage/vagrant/push.migrate.sh"
end
# rollback push command
config.push.define "rollback", strategy: "local-exec" do |push|
push.script = "storage/vagrant/push.rollback.sh"
end
end
18 changes: 10 additions & 8 deletions app/bootstrap/dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,16 @@
case 'phpmail':
break;

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

default:
Expand Down
13 changes: 8 additions & 5 deletions app/src/Controller/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ public function contact(Request $request, Response $response)
);
$this->validator->validate($request, $validateData);

// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
if ($this->config['recaptcha-enabled']) {
// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
}
}


if ($this->validator->isValid()) {
$add = new ContactRequests;
Expand Down
36 changes: 21 additions & 15 deletions app/src/Controller/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ public function forgotPassword(Request $request, Response $response)
);
$this->validator->validate($request, $validateData);

// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
if ($this->config['recaptcha-enabled']) {
// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
}
}

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

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

// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
if ($this->config['recaptcha-enabled']) {
// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
}
}

if ($this->validator->isValid()) {
Expand Down Expand Up @@ -369,11 +373,13 @@ private function validateNewUser()
);
$this->validator->validate($this->request, $validateData);

// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($this->request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
if ($this->config['recaptcha-enabled']) {
// Validate Recaptcha
$recaptcha = new Recaptcha($this->container);
$recaptcha = $recaptcha->validate($this->request->getParam('g-recaptcha-response'));
if (!$recaptcha) {
$this->validator->addError('recaptcha', 'Recaptcha was invalid.');
}
}

// Validate Username
Expand Down
18 changes: 12 additions & 6 deletions app/views/AdminLTE/blog-add.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2-bootstrap-theme/0.1.0-beta.10/select2-bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/daterangepicker.min.css" />
<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{{asset('AdminLTE/css/grideditor.min.css')}}" />
{% endblock %}

{% block body %}
Expand Down Expand Up @@ -49,9 +50,10 @@

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

Expand Down Expand Up @@ -192,15 +194,16 @@
{% endblock %}

{% block javascript %}
<!-- Select2 Dropdowns -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/daterangepicker.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.1/tinymce.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.7.1/jquery.tinymce.min.js" type="text/javascript"></script>
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
<script src="{{ asset('AdminLTE/js/tinymce-init.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('AdminLTE/js/video-parser.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('AdminLTE/js/blog.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('AdminLTE/js/jquery.grideditor.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('AdminLTE/js/dappur.grideditor.min.js') }}" type="text/javascript"></script>
{% if hasCloudinary %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/cloudinary-jquery-file-upload/2.3.0/cloudinary-jquery-file-upload.min.js"></script>
<script src="//widget.cloudinary.com/global/all.js" type="text/javascript"></script>
Expand All @@ -217,8 +220,11 @@ $(document).ready(function() {
format: 'MM/DD/YYYY h:mm A'
}
});
{% if requestParams.video_id and requestParams.video_provider == "youtube" %}
video_id = '{{ requestParams.video_id }}';
video_id = '{{ requestParams.video_id }}';
{% elseif post.video_id and post.video_provider == "youtube" %}
video_id = '{{ post.video_id }}';
{% endif %}
});
</script>
Expand Down
1 change: 0 additions & 1 deletion app/views/AdminLTE/blog-edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@
{% endblock %}

{% block javascript %}
<!-- Select2 Dropdowns -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-daterangepicker/2.1.25/daterangepicker.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion app/views/dappur/blog-post.twig
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
{% endblock %}

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

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

Expand Down
2 changes: 1 addition & 1 deletion app/views/dappur/blog.twig
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@
{% endblock %}

{% block javascript %}
{{ recaptchaJs() }}
{% if config['recaptcha-enabled'] %}{{ recaptchaJs() }}{% endif %}
{% endblock %}
10 changes: 6 additions & 4 deletions app/views/dappur/contact.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
{{ form.textarea('comment', requestParams.comment, 'comment', 'Comments/Feedback', null, 6, null)}}

<div class="row">
<div class="col-sm-6">
{{ form.custom('recaptcha', recaptcha()) }}
</div>
{% if config['recaptcha-enabled'] %}
<div class="col-sm-6">
{{ form.custom('recaptcha', recaptcha()) }}
</div>
{% endif %}
<div class="col-sm-6">
<div class="form-group text-center">
<button type="submit" class="btn btn-default btn-send"><span class="fa fa-send"></span> Send</button>
Expand Down Expand Up @@ -114,5 +116,5 @@
{% endblock %}

{% block javascript %}
{{ recaptchaJs() }}
{% if config['recaptcha-enabled'] %}{{ recaptchaJs() }}{% endif %}
{% endblock %}
6 changes: 4 additions & 2 deletions app/views/dappur/forgot-password.twig
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
{{ form.text('email', null, 'email', 'Email Address') }}
{{ csrf() }}

{{ form.custom('recaptcha', recaptcha()) }}
{% if config['recaptcha-enabled'] %}
{{ form.custom('recaptcha', recaptcha()) }}
{% endif %}
<input type="submit" value="Reset Password" class="btn btn-primary">
</form>
</div>
Expand All @@ -33,5 +35,5 @@
{% endblock %}

{% block javascript %}
{{ recaptchaJs() }}
{% if config['recaptcha-enabled'] %}{{ recaptchaJs() }}{% endif %}
{% endblock %}
Loading

0 comments on commit d0c56cf

Please sign in to comment.