WordPress is used to power the blog and some of the other marketing pages. WordPress is enabled via the WordPressServiceProvider.
To enable WordPress, add the following variables to your .env file:
ENABLE_WP=true
CLEAR_VIEW_CACHE=true
WP_SITEURL=http://blog.cmv.local
In addition, ensure that you have all of the proper DB config variables defined in your .env file:
DB_HOST=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_CONNECTION=
Within your homestead environment, run the following commands to import the database for the WordPress installation:
cd ~/code/cmv.local/wp/
wp db import cmv_blog.sql
Next, you will need to set up the nginx config on homestead:
serve blog.cmv.local ~/code/cmv.local/wp
And finally, on your host computer, edit /etc/hosts:
192.168.35.40 blog.cmv.local
You should now be able to login to the WordPress site at: http://blog.cmv.local/wp-admin
In addition, all of the WordPress functionality that is used on the MarketingSite controllers will now function correctly.
Most logic is located in the API controllers (/app/Controllers/Http/API/). They response with json data.
If route operates with any entity, e.g. project you should name route parameter as plural form of entity name (projects).
There's a couple of handy middlewares to check the user permissions:
- CheckAccessByParameters.php - forbids request based off route parameters and route method (DELETE/POST/GET);
Example usege - add the following to the PHPDoc of the controller method -
@Middleware("param-access") - CheckAccessByReference.php - forbids request based off request payload, reference_type and reference_id . There're several models which use that approach, e.g. File, ToDo.
Example usege - add the following to the PHPDoc of the controller method -
@Middleware("ref-access")
Under the hood these middlewares utilize CMV\Misc\Acl class.
Javascript code are located in /resources/assets/js.
The directory contents:
- /codemyviews.js - main file. Everything we need on front-end are set up here;
- /init.js - is used in /codemyviews.js, a set of various init methods. E.g. pgax(), vue();
- /custom - global jQuery code. No addition code must be placed here. The existing one will eventially be moved to a custom Vue controllers or init.js.
- /extensions - the place to extend vendor libraries. E.g. Lodash, jQuery.
- /plugins - vendor javascript libraries.
- /vue - Vue.js-related code. controllers.js, filters.js, directives.js are just helper files to require the code we need to be required;
- /vue/controllers - components which are being mount to the dom on load.
[data-controller]attribute is used to set the controller (e.g. data-controller="project/new"). Due to Browserify restrictions every new controller must be required incontrollers.js; - /vue/directives - custom vue directives. Used to decrease the repetion in the controllers/components. Examples of usage may be found in each file;
- /vue/filters - custom vue filters. Are used to format the data;
- /vue/spark - Laravel Spark (https://github.com/laravel/spark). Basically it's NPM side of the Spark package. Moved to the repository due to conflicts in the js code and a possible need of altering the code for our needs in the future.
The code is managed by http://gulpjs.com/ and it's extension http://laravel.com/docs/5.1/elixir .
gulpfile.js is pretty straightforward:
- /js/vendor + /js/custom folders contents are being concatenated into vendor.js;
- /js/codemyviews.js is browserified into cmv-js.js;
- /css/cmv-app.less is translated to /public/css/cmv-app.css;
- /css/cmv-marketing.less is translated to /public/css/codemyviews.css.
To constantly watch the changes in js/css run the following in the codemyviews project: gulp; gulp watch.
Controller - /Http/Webhooks/Bitbucket.php .
To create a webhook visit https://bitbucket.org///admin/addon/admin/bitbucket-webhooks/bb-webhooks-repo-admin
To test webhooks locally use http://ultrahook.com
To setup Bitbucket API fill in the following variables in your .env file:
BITBUCKET_KEY=*****
BITBUCKET_SECRET=****
BITBUCKET_ACCNAME=****
Example of usage:
$bb = App::make('Bitbucket');
$issues = $bb->api('Repositories\Issues');
$response = $issues->create(\Config::get('services.bitbucket.accname'), $todo->project->bitbucket_slug, [
'title' => $todo->title,
'content' => $todo->content,
'kind' => 'task',
'priority' => 'major'
]);
$content = json_decode($response->getContent());