From dd9f798f33364b366ad486838214004c1fac58fb Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 11:20:09 +0200 Subject: [PATCH 01/90] Making the original property private and adding getting to get it, making it immutable. Adding description on attributes --- Modules/User/Events/UserIsCreating.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Modules/User/Events/UserIsCreating.php b/Modules/User/Events/UserIsCreating.php index da576daa0..d15d3af98 100644 --- a/Modules/User/Events/UserIsCreating.php +++ b/Modules/User/Events/UserIsCreating.php @@ -5,10 +5,15 @@ final class UserIsCreating { /** + * Contains the attributes which can be changed by other listeners * @var array */ private $attributes; - public $original; + /** + * Contains the original attributes which cannot be changed + * @var array + */ + private $original; public function __construct(array $attributes) { @@ -31,4 +36,12 @@ public function setAttributes(array $attributes) { $this->attributes = array_merge($this->attributes, $attributes); } + + /** + * @return array + */ + public function getOriginal() + { + return $this->original; + } } From 92ab1dba3a6e984ecbbb36b75ba2c8a6f88780b9 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 11:43:56 +0200 Subject: [PATCH 02/90] Exclude views as well --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index ab7058adc..0889a65ee 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -10,6 +10,7 @@ $finder = PhpCsFixer\Finder::create() 'bootstrap', 'tests', 'node_modules', + 'views', ]) ->notPath('server.php') ; From 0e903c71d3c1e9ea0c79abf8388e40a0963002f5 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 11:44:37 +0200 Subject: [PATCH 03/90] Trigger event when user is updating, which allows data modification --- Modules/User/Events/UserIsUpdating.php | 51 +++++++++++++++- .../Sentinel/SentinelUserRepository.php | 10 ++-- .../User/Tests/SentinelUserRepositoryTest.php | 59 ++++++++++++++++++- 3 files changed, 109 insertions(+), 11 deletions(-) diff --git a/Modules/User/Events/UserIsUpdating.php b/Modules/User/Events/UserIsUpdating.php index 8560b681c..3f46def2b 100644 --- a/Modules/User/Events/UserIsUpdating.php +++ b/Modules/User/Events/UserIsUpdating.php @@ -2,12 +2,59 @@ namespace Modules\User\Events; +use Modules\User\Entities\UserInterface; + class UserIsUpdating { - public $user; + /** + * @var UserInterface + */ + private $user; + /** + * @var array + */ + private $attributes; + /** + * @var array + */ + private $original; - public function __construct($user) + public function __construct(UserInterface $user, array $data) { $this->user = $user; + $this->attributes = $data; + $this->original = $data; + } + + /** + * @return array + */ + public function getOriginal() + { + return $this->original; + } + + /** + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param array $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = array_merge($this->attributes, $attributes); + } + + /** + * @return UserInterface + */ + public function getUser() + { + return $this->user; } } diff --git a/Modules/User/Repositories/Sentinel/SentinelUserRepository.php b/Modules/User/Repositories/Sentinel/SentinelUserRepository.php index 963e544f2..ec1ce45de 100644 --- a/Modules/User/Repositories/Sentinel/SentinelUserRepository.php +++ b/Modules/User/Repositories/Sentinel/SentinelUserRepository.php @@ -126,10 +126,9 @@ public function update($user, $data) { $this->checkForNewPassword($data); - $user->fill($data); - - event(new UserIsUpdating($user)); + event($event = new UserIsUpdating($user, $data)); + $user->fill($event->getAttributes()); $user->save(); event(new UserWasUpdated($user)); @@ -152,10 +151,9 @@ public function updateAndSyncRoles($userId, $data, $roles) $this->checkForManualActivation($user, $data); - $user = $user->fill($data); - - event(new UserIsUpdating($user)); + event($event = new UserIsUpdating($user, $data)); + $user->fill($event->getAttributes()); $user->save(); event(new UserWasUpdated($user)); diff --git a/Modules/User/Tests/SentinelUserRepositoryTest.php b/Modules/User/Tests/SentinelUserRepositoryTest.php index 371daae24..6cbdf9422 100644 --- a/Modules/User/Tests/SentinelUserRepositoryTest.php +++ b/Modules/User/Tests/SentinelUserRepositoryTest.php @@ -104,7 +104,7 @@ public function it_makes_sure_the_event_contains_original_attributes() ]); Event::assertDispatched(UserIsCreating::class, function ($e) { - return $e->original['email'] === 'n.widart@gmail.com'; + return $e->getOriginal()['email'] === 'n.widart@gmail.com'; }); } @@ -237,10 +237,45 @@ public function it_triggers_events_on_user_update() return $e->user->id === $user->id; }); Event::assertDispatched(UserIsUpdating::class, function ($e) use ($user) { - return $e->user->id === $user->id; + return $e->getUser()->id === $user->id; + }); + } + + /** @test */ + public function it_triggers_event_when_user_is_updating() + { + $user = $this->user->create([ + 'email' => 'n.widart@gmail.com', + 'password' => 'demo1234', + ]); + + Event::fake(); + + $this->user->update($user, ['first_name' => 'John', 'last_name' => 'Doe']); + + Event::assertDispatched(UserIsUpdating::class, function ($e) use ($user) { + return $e->getUser()->id === $user->id && + $e->getAttributes()['first_name'] === 'John'; }); } + /** @test */ + public function it_can_change_properties_before_update() + { + Event::listen(UserIsUpdating::class, function (UserIsUpdating $event) { + $event->setAttributes(['first_name' => 'Jane']); + }); + + $user = $this->user->create([ + 'email' => 'n.widart@gmail.com', + 'password' => 'demo1234', + ]); + + $this->user->update($user, ['first_name' => 'John', 'last_name' => 'Doe']); + + $this->assertEquals('Jane', $this->user->find(1)->first_name); + } + /** @test */ public function it_updates_user_and_syncs_roles() { @@ -277,10 +312,28 @@ public function it_triggers_event_on_user_update_and_role_sync() return $e->user->id === $user->id; }); Event::assertDispatched(UserIsUpdating::class, function ($e) use ($user) { - return $e->user->id === $user->id; + return $e->getUser()->id === $user->id; }); } + /** @test */ + public function it_can_change_properties_before_update_and_sync_roles() + { + Event::listen(UserIsUpdating::class, function (UserIsUpdating $event) { + $event->setAttributes(['first_name' => 'Jane']); + }); + + $this->createRole('Admin'); + $user = $this->user->createWithRoles([ + 'email' => 'n.widart@gmail.com', + 'password' => 'demo1234', + ], [1]); + + $this->user->updateAndSyncRoles($user->id, ['first_name' => 'John', 'last_name' => 'Doe', 'activated' => 1], [1]); + + $this->assertEquals('Jane', $this->user->find(1)->first_name); + } + /** @test */ public function it_deletes_a_user() { From 2de03381c5bd033465580768ca23ee18c203ee7f Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 12:02:23 +0200 Subject: [PATCH 04/90] Create an interface for all "changing entities" events --- Modules/Core/Contracts/EntityIsChanging.php | 22 +++++++++++++++++++++ Modules/User/Events/UserIsCreating.php | 4 +++- Modules/User/Events/UserIsUpdating.php | 3 ++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Modules/Core/Contracts/EntityIsChanging.php diff --git a/Modules/Core/Contracts/EntityIsChanging.php b/Modules/Core/Contracts/EntityIsChanging.php new file mode 100644 index 000000000..302efa549 --- /dev/null +++ b/Modules/Core/Contracts/EntityIsChanging.php @@ -0,0 +1,22 @@ + Date: Tue, 11 Jul 2017 12:09:46 +0200 Subject: [PATCH 05/90] Adding more core modules. Preventing them to be disabled. --- Modules/Core/Config/config.php | 3 +++ config/asgard/core/config.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Modules/Core/Config/config.php b/Modules/Core/Config/config.php index 65324c45b..317144b00 100644 --- a/Modules/Core/Config/config.php +++ b/Modules/Core/Config/config.php @@ -13,6 +13,9 @@ 'workshop', 'setting', 'media', + 'tag', + 'page', + 'translation', ], /* diff --git a/config/asgard/core/config.php b/config/asgard/core/config.php index 65324c45b..317144b00 100644 --- a/config/asgard/core/config.php +++ b/config/asgard/core/config.php @@ -13,6 +13,9 @@ 'workshop', 'setting', 'media', + 'tag', + 'page', + 'translation', ], /* From c150e135aaa4d77c7b544b25dc3e9457df873dac Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 12:11:39 +0200 Subject: [PATCH 06/90] Preparing changelog items --- Modules/Core/changelog.yml | 5 +++++ Modules/User/changelog.yml | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Modules/Core/changelog.yml b/Modules/Core/changelog.yml index 1b1840106..2dce58b24 100644 --- a/Modules/Core/changelog.yml +++ b/Modules/Core/changelog.yml @@ -1,5 +1,10 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + added: + - Adding a EntityIsChanging interface to use on events which are triggered before a create / update action + changed: + - Adding more core modules (tag, translation and page). Preventing them to be disabled. "2.3.0": added: - New command php artisan asgard:download:module asgardcms/contact --migrations --seeds --assets diff --git a/Modules/User/changelog.yml b/Modules/User/changelog.yml index f5f888c72..aab4dffb9 100644 --- a/Modules/User/changelog.yml +++ b/Modules/User/changelog.yml @@ -1,5 +1,8 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + added: + - Trigger an event (UserIsUpdating) before a user is updated "2.4.0": added: - Trigger an event (UserIsCreating) before a user is created, allowing customising its data via listeners From 23c123f12469ed1b84ef6b16fdf294e4e6d36716 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 12:26:19 +0200 Subject: [PATCH 07/90] Trigger an event before a page is updated allowing data to be changed --- Modules/Page/Events/PageIsCreating.php | 49 +++++++++++++++++++ .../Eloquent/EloquentPageRepository.php | 5 +- Modules/Page/Tests/PagesTest.php | 38 ++++++++++++++ Modules/Page/changelog.yml | 3 ++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 Modules/Page/Events/PageIsCreating.php diff --git a/Modules/Page/Events/PageIsCreating.php b/Modules/Page/Events/PageIsCreating.php new file mode 100644 index 000000000..cf5fb4f30 --- /dev/null +++ b/Modules/Page/Events/PageIsCreating.php @@ -0,0 +1,49 @@ +attributes = $attributes; + $this->original = $attributes; + } + + /** + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param array $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = array_merge($this->attributes, $attributes); + } + + /** + * @return array + */ + public function getOriginal() + { + return $this->original; + } +} diff --git a/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php b/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php index 8d2088b0c..8b28ac769 100644 --- a/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php +++ b/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Builder; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; +use Modules\Page\Events\PageIsCreating; use Modules\Page\Events\PageWasCreated; use Modules\Page\Events\PageWasDeleted; use Modules\Page\Events\PageWasUpdated; @@ -38,7 +39,9 @@ public function create($data) if (array_get($data, 'is_home') === '1') { $this->removeOtherHomepage(); } - $page = $this->model->create($data); + + event($event = new PageIsCreating($data)); + $page = $this->model->create($event->getAttributes()); event(new PageWasCreated($page->id, $data)); diff --git a/Modules/Page/Tests/PagesTest.php b/Modules/Page/Tests/PagesTest.php index 93fabd4fa..6e0755392 100644 --- a/Modules/Page/Tests/PagesTest.php +++ b/Modules/Page/Tests/PagesTest.php @@ -3,6 +3,7 @@ namespace Modules\Page\Tests; use Illuminate\Support\Facades\Event; +use Modules\Page\Events\PageIsCreating; use Modules\Page\Events\PageWasCreated; use Modules\Page\Events\PageWasDeleted; use Modules\Page\Events\PageWasUpdated; @@ -93,6 +94,30 @@ public function it_triggers_event_when_page_was_created() }); } + /** @test */ + public function it_triggers_an_event_when_page_is_creating() + { + Event::fake(); + + $page = $this->createPage(); + + Event::assertDispatched(PageIsCreating::class, function ($e) use ($page) { + return $e->getAttributes()['template'] === $page->template; + }); + } + + /** @test */ + public function it_can_change_page_data_before_creating_page() + { + Event::listen(PageIsCreating::class, function (PageIsCreating $event) { + $event->setAttributes(['template' => 'better-tpl']); + }); + + $page = $this->createPage(); + + $this->assertEquals('better-tpl', $page->template); + } + /** @test */ public function it_triggers_event_when_page_was_updated() { @@ -135,4 +160,17 @@ public function it_triggers_event_when_page_was_deleted() return $e->page->id === $page->id; }); } + + private function createPage() + { + return $this->page->create([ + 'is_home' => '1', + 'template' => 'default', + 'en' => [ + 'title' => 'My Other Page', + 'slug' => 'my-other-page', + 'body' => 'My Page Body', + ], + ]); + } } diff --git a/Modules/Page/changelog.yml b/Modules/Page/changelog.yml index e591c7c7d..51a41bb9d 100644 --- a/Modules/Page/changelog.yml +++ b/Modules/Page/changelog.yml @@ -1,5 +1,8 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + added: + - Trigger event before a page is created (PageIsCreating) allow data to be changed "2.2.0": added: - Testing event trigger on page deletion From 5474ea54430bf1c1cfdcc35f127c7ede0bc3df90 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 12:31:03 +0200 Subject: [PATCH 08/90] Trigger an event before a page is updated allowing data to be changed --- Modules/Page/Events/PageIsUpdating.php | 63 +++++++++++++++++++ .../Eloquent/EloquentPageRepository.php | 5 +- Modules/Page/Tests/PagesTest.php | 28 +++++++++ Modules/Page/changelog.yml | 1 + 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 Modules/Page/Events/PageIsUpdating.php diff --git a/Modules/Page/Events/PageIsUpdating.php b/Modules/Page/Events/PageIsUpdating.php new file mode 100644 index 000000000..7713ac313 --- /dev/null +++ b/Modules/Page/Events/PageIsUpdating.php @@ -0,0 +1,63 @@ +attributes = $attributes; + $this->original = $attributes; + $this->page = $page; + } + + /** + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param array $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = array_merge($this->attributes, $attributes); + } + + /** + * @return array + */ + public function getOriginal() + { + return $this->original; + } + + /** + * @return Page + */ + public function getPage() + { + return $this->page; + } +} diff --git a/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php b/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php index 8b28ac769..6cb9d5951 100644 --- a/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php +++ b/Modules/Page/Repositories/Eloquent/EloquentPageRepository.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Builder; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; use Modules\Page\Events\PageIsCreating; +use Modules\Page\Events\PageIsUpdating; use Modules\Page\Events\PageWasCreated; use Modules\Page\Events\PageWasDeleted; use Modules\Page\Events\PageWasUpdated; @@ -60,7 +61,9 @@ public function update($model, $data) if (array_get($data, 'is_home') === '1') { $this->removeOtherHomepage($model->id); } - $model->update($data); + + event($event = new PageIsUpdating($model, $data)); + $model->update($event->getAttributes()); event(new PageWasUpdated($model->id, $data)); diff --git a/Modules/Page/Tests/PagesTest.php b/Modules/Page/Tests/PagesTest.php index 6e0755392..cd52547eb 100644 --- a/Modules/Page/Tests/PagesTest.php +++ b/Modules/Page/Tests/PagesTest.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Event; use Modules\Page\Events\PageIsCreating; +use Modules\Page\Events\PageIsUpdating; use Modules\Page\Events\PageWasCreated; use Modules\Page\Events\PageWasDeleted; use Modules\Page\Events\PageWasUpdated; @@ -118,6 +119,33 @@ public function it_can_change_page_data_before_creating_page() $this->assertEquals('better-tpl', $page->template); } + /** @test */ + public function it_triggers_an_event_when_page_is_updating() + { + Event::fake(); + $page = $this->createPage(); + + $this->page->update($page, ['en' => ['title' => 'Better!']]); + + Event::assertDispatched(PageIsUpdating::class, function ($e) use ($page) { + return $e->getPage()->id === $page->id; + }); + } + + /** @test */ + public function it_can_change_page_data_before_updating_page() + { + Event::listen(PageIsUpdating::class, function (PageIsUpdating $event) { + $event->setAttributes(['template' => 'better-tpl']); + }); + + $page = $this->createPage(); + $this->page->update($page, ['template' => 'my-template', 'en' => ['title' => 'Better!']]); + + $this->assertEquals('better-tpl', $page->template); + } + + /** @test */ public function it_triggers_event_when_page_was_updated() { diff --git a/Modules/Page/changelog.yml b/Modules/Page/changelog.yml index 51a41bb9d..c3c178a08 100644 --- a/Modules/Page/changelog.yml +++ b/Modules/Page/changelog.yml @@ -3,6 +3,7 @@ versions: "2.5.0@unreleased": added: - Trigger event before a page is created (PageIsCreating) allow data to be changed + - Trigger event before a page is updated (PageIsUpdating) allow data to be changed "2.2.0": added: - Testing event trigger on page deletion From 0a146571d957eee0dba979210925179a3a693a50 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 13:26:35 +0200 Subject: [PATCH 09/90] Using the updated bootstrap path --- Themes/Flatly/assets/js/all.js | 7 +++++++ Themes/Flatly/webpack.mix.js | 4 ++-- public/themes/flatly/js/all.js | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Themes/Flatly/assets/js/all.js b/Themes/Flatly/assets/js/all.js index dfac2eee3..d41c5f788 100644 --- a/Themes/Flatly/assets/js/all.js +++ b/Themes/Flatly/assets/js/all.js @@ -10252,6 +10252,13 @@ if ( !noGlobal ) { return jQuery; } ); +/*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2016 Twitter, Inc. + * Licensed under the MIT license + */ +if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.7",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a("#"===f?[]:f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.7",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c).prop(c,!0)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c).prop(c,!1))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target).closest(".btn");b.call(d,"toggle"),a(c.target).is('input[type="radio"], input[type="checkbox"]')||(c.preventDefault(),d.is("input,button")?d.trigger("focus"):d.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.7",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(a>this.$items.length-1||a<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.7",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.7",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);if(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),!c.isInStateTrue())return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null,a.$element=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;!e&&/destroy|hide/.test(b)||(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.7",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.7",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.7",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return e=a-d&&"bottom"},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); /* ********************************************** Begin prism-core.js diff --git a/Themes/Flatly/webpack.mix.js b/Themes/Flatly/webpack.mix.js index 3ad428509..aad8c6a7a 100644 --- a/Themes/Flatly/webpack.mix.js +++ b/Themes/Flatly/webpack.mix.js @@ -12,7 +12,7 @@ mix.less('resources/less/main.less', 'assets/css/main.css') */ mix.scripts([ 'node_modules/jquery/dist/jquery.js', - 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js', + 'node_modules/bootstrap/dist/js/bootstrap.min.js', 'node_modules/prismjs/prism.js', 'resources/js/bootswatch.js' ], 'assets/js/all.js'); @@ -32,4 +32,4 @@ mix.webpackConfig({ plugins: [ new WebpackShellPlugin({onBuildEnd:['php ../../artisan stylist:publish ' + themeInfo.name]}) ] -}); \ No newline at end of file +}); diff --git a/public/themes/flatly/js/all.js b/public/themes/flatly/js/all.js index dfac2eee3..d41c5f788 100644 --- a/public/themes/flatly/js/all.js +++ b/public/themes/flatly/js/all.js @@ -10252,6 +10252,13 @@ if ( !noGlobal ) { return jQuery; } ); +/*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2016 Twitter, Inc. + * Licensed under the MIT license + */ +if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.7",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a("#"===f?[]:f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.7",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c).prop(c,!0)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c).prop(c,!1))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target).closest(".btn");b.call(d,"toggle"),a(c.target).is('input[type="radio"], input[type="checkbox"]')||(c.preventDefault(),d.is("input,button")?d.trigger("focus"):d.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.7",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(a>this.$items.length-1||a<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.7",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.7",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);if(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),!c.isInStateTrue())return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null,a.$element=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;!e&&/destroy|hide/.test(b)||(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.7",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.7",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.7",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return e=a-d&&"bottom"},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); /* ********************************************** Begin prism-core.js From 52cd028e55c1dbf14ae7d876dea297017c44d6f2 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 20:57:38 +0200 Subject: [PATCH 10/90] Trigger event to allow page content to be altered before display --- Modules/Page/Entities/Page.php | 8 ++++ Modules/Page/Events/ContentIsRendering.php | 47 +++++++++++++++++++ Modules/Page/Tests/ContentIsRenderingTest.php | 42 +++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 Modules/Page/Events/ContentIsRendering.php create mode 100644 Modules/Page/Tests/ContentIsRenderingTest.php diff --git a/Modules/Page/Entities/Page.php b/Modules/Page/Entities/Page.php index 6b4fc9e9c..f3b21823e 100644 --- a/Modules/Page/Entities/Page.php +++ b/Modules/Page/Entities/Page.php @@ -5,6 +5,7 @@ use Dimsav\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; use Modules\Core\Traits\NamespacedEntity; +use Modules\Page\Events\ContentIsRendering; use Modules\Tag\Contracts\TaggableInterface; use Modules\Tag\Traits\TaggableTrait; @@ -47,6 +48,13 @@ class Page extends Model implements TaggableInterface ]; protected static $entityNamespace = 'asgardcms/page'; + public function getBodyAttribute($body) + { + event($event = new ContentIsRendering($body)); + + return $event->getBody(); + } + public function __call($method, $parameters) { #i: Convert array to dot notation diff --git a/Modules/Page/Events/ContentIsRendering.php b/Modules/Page/Events/ContentIsRendering.php new file mode 100644 index 000000000..5986a51bb --- /dev/null +++ b/Modules/Page/Events/ContentIsRendering.php @@ -0,0 +1,47 @@ +body = $body; + $this->original = $body; + } + + /** + * @return string + */ + public function getBody() + { + return $this->body; + } + + /** + * @param string $body + */ + public function setBody($body) + { + $this->body = $body; + } + + /** + * @return mixed + */ + public function getOriginal() + { + return $this->original; + } + + public function __toString() + { + return $this->getBody(); + } +} diff --git a/Modules/Page/Tests/ContentIsRenderingTest.php b/Modules/Page/Tests/ContentIsRenderingTest.php new file mode 100644 index 000000000..4d768ce17 --- /dev/null +++ b/Modules/Page/Tests/ContentIsRenderingTest.php @@ -0,0 +1,42 @@ +setBody('' . $event->getOriginal() . ''); + }); + + $page = $this->createPage(); + + $this->assertEquals('My Page Body', $page->body); + } + + /** @test */ + public function it_doesnt_alter_content_if_no_listeners() + { + $page = $this->createPage(); + + $this->assertEquals('My Page Body', $page->body); + } + + private function createPage() + { + return $this->page->create([ + 'is_home' => '1', + 'template' => 'default', + 'en' => [ + 'title' => 'My Other Page', + 'slug' => 'my-other-page', + 'body' => 'My Page Body', + ], + ]); + } +} From 3b8442343f40b2d2084b8018c3c9d861f7fb7a2d Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 20:59:31 +0200 Subject: [PATCH 11/90] Moving accessor to the proper entity --- Modules/Page/Entities/Page.php | 8 -------- Modules/Page/Entities/PageTranslation.php | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Modules/Page/Entities/Page.php b/Modules/Page/Entities/Page.php index f3b21823e..6b4fc9e9c 100644 --- a/Modules/Page/Entities/Page.php +++ b/Modules/Page/Entities/Page.php @@ -5,7 +5,6 @@ use Dimsav\Translatable\Translatable; use Illuminate\Database\Eloquent\Model; use Modules\Core\Traits\NamespacedEntity; -use Modules\Page\Events\ContentIsRendering; use Modules\Tag\Contracts\TaggableInterface; use Modules\Tag\Traits\TaggableTrait; @@ -48,13 +47,6 @@ class Page extends Model implements TaggableInterface ]; protected static $entityNamespace = 'asgardcms/page'; - public function getBodyAttribute($body) - { - event($event = new ContentIsRendering($body)); - - return $event->getBody(); - } - public function __call($method, $parameters) { #i: Convert array to dot notation diff --git a/Modules/Page/Entities/PageTranslation.php b/Modules/Page/Entities/PageTranslation.php index fd3ed17ab..bd73acb15 100644 --- a/Modules/Page/Entities/PageTranslation.php +++ b/Modules/Page/Entities/PageTranslation.php @@ -3,6 +3,7 @@ namespace Modules\Page\Entities; use Illuminate\Database\Eloquent\Model; +use Modules\Page\Events\ContentIsRendering; class PageTranslation extends Model { @@ -20,4 +21,11 @@ class PageTranslation extends Model 'og_image', 'og_type', ]; + + public function getBodyAttribute($body) + { + event($event = new ContentIsRendering($body)); + + return $event->getBody(); + } } From 17af3d587117c0ab8effcba583700e539b74d0ac Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 21:56:46 +0200 Subject: [PATCH 12/90] Trigger an event when a file was created --- Modules/Media/Events/FileWasCreated.php | 18 ++++++++++++++++++ .../Eloquent/EloquentFileRepository.php | 9 +++++++-- Modules/Media/Tests/FileRepositoryTest.php | 14 ++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 Modules/Media/Events/FileWasCreated.php diff --git a/Modules/Media/Events/FileWasCreated.php b/Modules/Media/Events/FileWasCreated.php new file mode 100644 index 000000000..4c2be45a5 --- /dev/null +++ b/Modules/Media/Events/FileWasCreated.php @@ -0,0 +1,18 @@ +file = $file; + } +} diff --git a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php index 4013e5dec..aff6abb9f 100644 --- a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php +++ b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Collection; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; use Modules\Media\Entities\File; +use Modules\Media\Events\FileWasCreated; use Modules\Media\Helpers\FileHelper; use Modules\Media\Repositories\FileRepository; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -41,14 +42,18 @@ public function createFromFile(UploadedFile $file) $fileName = $this->getNewUniqueFilename($fileName); } - return $this->model->create([ + $file = $this->model->create([ 'filename' => $fileName, 'path' => config('asgard.media.config.files-path') . "{$fileName}", - 'extension' => substr(strrchr($fileName, "."), 1), + 'extension' => substr(strrchr($fileName, '.'), 1), 'mimetype' => $file->getClientMimeType(), 'filesize' => $file->getFileInfo()->getSize(), 'folder_id' => 0, ]); + + event(new FileWasCreated($file)); + + return $file; } public function destroy($file) diff --git a/Modules/Media/Tests/FileRepositoryTest.php b/Modules/Media/Tests/FileRepositoryTest.php index 67755399a..e3632bebc 100644 --- a/Modules/Media/Tests/FileRepositoryTest.php +++ b/Modules/Media/Tests/FileRepositoryTest.php @@ -2,8 +2,11 @@ namespace Modules\Media\Tests; +use Illuminate\Support\Facades\Event; +use Illuminate\Support\Facades\Storage; use Mockery; use Modules\Media\Entities\File; +use Modules\Media\Events\FileWasCreated; use Modules\Media\Repositories\FileRepository; use Symfony\Component\Finder\SplFileInfo; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -114,6 +117,17 @@ public function it_can_delete_a_file() $this->assertCount(0, $this->file->all()); } + /** @test */ + public function it_triggers_event_when_file_was_created() + { + Event::fake(); + $file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('myfile.jpg')); + + Event::assertDispatched(FileWasCreated::class, function ($e) use ($file) { + return $e->file->id === $file->id; + }); + } + private function createFile($fileName = 'random/name.jpg') { return File::create([ From 510e0d29213c6f53c3165a90011a67e479f48e68 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:02:48 +0200 Subject: [PATCH 13/90] Adding an hookable event when a file is creating --- Modules/Media/Events/FileIsCreating.php | 49 +++++++++++++++++++ .../Eloquent/EloquentFileRepository.php | 8 ++- Modules/Media/Tests/FileRepositoryTest.php | 25 ++++++++++ 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 Modules/Media/Events/FileIsCreating.php diff --git a/Modules/Media/Events/FileIsCreating.php b/Modules/Media/Events/FileIsCreating.php new file mode 100644 index 000000000..d30459bf9 --- /dev/null +++ b/Modules/Media/Events/FileIsCreating.php @@ -0,0 +1,49 @@ +attributes = $attributes; + $this->original = $attributes; + } + + /** + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param array $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = array_merge($this->attributes, $attributes); + } + + /** + * @return array + */ + public function getOriginal() + { + return $this->original; + } +} diff --git a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php index aff6abb9f..8c0ac9108 100644 --- a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php +++ b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Collection; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; use Modules\Media\Entities\File; +use Modules\Media\Events\FileIsCreating; use Modules\Media\Events\FileWasCreated; use Modules\Media\Helpers\FileHelper; use Modules\Media\Repositories\FileRepository; @@ -42,15 +43,18 @@ public function createFromFile(UploadedFile $file) $fileName = $this->getNewUniqueFilename($fileName); } - $file = $this->model->create([ + $data = [ 'filename' => $fileName, 'path' => config('asgard.media.config.files-path') . "{$fileName}", 'extension' => substr(strrchr($fileName, '.'), 1), 'mimetype' => $file->getClientMimeType(), 'filesize' => $file->getFileInfo()->getSize(), 'folder_id' => 0, - ]); + ]; + event($event = new FileIsCreating($data)); + + $file = $this->model->create($event->getAttributes()); event(new FileWasCreated($file)); return $file; diff --git a/Modules/Media/Tests/FileRepositoryTest.php b/Modules/Media/Tests/FileRepositoryTest.php index e3632bebc..2b1117b5e 100644 --- a/Modules/Media/Tests/FileRepositoryTest.php +++ b/Modules/Media/Tests/FileRepositoryTest.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Storage; use Mockery; use Modules\Media\Entities\File; +use Modules\Media\Events\FileIsCreating; use Modules\Media\Events\FileWasCreated; use Modules\Media\Repositories\FileRepository; use Symfony\Component\Finder\SplFileInfo; @@ -128,6 +129,30 @@ public function it_triggers_event_when_file_was_created() }); } + /** @test */ + public function it_triggers_event_when_file_is_creating() + { + Event::fake(); + + $file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('myfile.jpg')); + + Event::assertDispatched(FileIsCreating::class, function ($e) use ($file) { + return $e->getAttributes()['filename'] === $file->filename; + }); + } + + /** @test */ + public function it_can_change_data_when_it_is_creating_event() + { + Event::listen(FileIsCreating::class, function (FileIsCreating $event) { + $event->setAttributes(['filename' => 'imabettername.jpg']); + }); + + $file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('myfile.jpg')); + + $this->assertEquals('imabettername.jpg', $file->filename); + } + private function createFile($fileName = 'random/name.jpg') { return File::create([ From d497de4bd56d5cf199bb7987bed6de0de98ac34b Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:21:10 +0200 Subject: [PATCH 14/90] Trigger an event when a file was updated --- Modules/Media/Events/FileWasUpdated.php | 18 ++++++++++++++++++ .../Eloquent/EloquentFileRepository.php | 3 +++ Modules/Media/Tests/FileRepositoryTest.php | 15 ++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Modules/Media/Events/FileWasUpdated.php diff --git a/Modules/Media/Events/FileWasUpdated.php b/Modules/Media/Events/FileWasUpdated.php new file mode 100644 index 000000000..ab4f416fb --- /dev/null +++ b/Modules/Media/Events/FileWasUpdated.php @@ -0,0 +1,18 @@ +file = $file; + } +} diff --git a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php index 8c0ac9108..d98d2b35d 100644 --- a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php +++ b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php @@ -7,6 +7,7 @@ use Modules\Media\Entities\File; use Modules\Media\Events\FileIsCreating; use Modules\Media\Events\FileWasCreated; +use Modules\Media\Events\FileWasUpdated; use Modules\Media\Helpers\FileHelper; use Modules\Media\Repositories\FileRepository; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -25,6 +26,8 @@ public function update($file, $data) $file->setTags(array_get($data, 'tags', [])); + event(new FileWasUpdated($file)); + return $file; } diff --git a/Modules/Media/Tests/FileRepositoryTest.php b/Modules/Media/Tests/FileRepositoryTest.php index 2b1117b5e..277a9da1d 100644 --- a/Modules/Media/Tests/FileRepositoryTest.php +++ b/Modules/Media/Tests/FileRepositoryTest.php @@ -3,11 +3,11 @@ namespace Modules\Media\Tests; use Illuminate\Support\Facades\Event; -use Illuminate\Support\Facades\Storage; use Mockery; use Modules\Media\Entities\File; use Modules\Media\Events\FileIsCreating; use Modules\Media\Events\FileWasCreated; +use Modules\Media\Events\FileWasUpdated; use Modules\Media\Repositories\FileRepository; use Symfony\Component\Finder\SplFileInfo; use Symfony\Component\HttpFoundation\File\UploadedFile; @@ -153,6 +153,19 @@ public function it_can_change_data_when_it_is_creating_event() $this->assertEquals('imabettername.jpg', $file->filename); } + /** @test */ + public function it_triggers_event_when_file_was_updated() + { + Event::fake(); + + $file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('myfile.jpg')); + $this->file->update($file, []); + + Event::assertDispatched(FileWasUpdated::class, function ($e) use ($file) { + return $e->file->id === $file->id; + }); + } + private function createFile($fileName = 'random/name.jpg') { return File::create([ From 7876e92b54f1a42bb43cfa70fc523d3c39751224 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:26:11 +0200 Subject: [PATCH 15/90] Updating filename to match the tested repository --- .../{FileRepositoryTest.php => EloquentFileRepositoryTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Modules/Media/Tests/{FileRepositoryTest.php => EloquentFileRepositoryTest.php} (99%) diff --git a/Modules/Media/Tests/FileRepositoryTest.php b/Modules/Media/Tests/EloquentFileRepositoryTest.php similarity index 99% rename from Modules/Media/Tests/FileRepositoryTest.php rename to Modules/Media/Tests/EloquentFileRepositoryTest.php index 277a9da1d..a6857ed25 100644 --- a/Modules/Media/Tests/FileRepositoryTest.php +++ b/Modules/Media/Tests/EloquentFileRepositoryTest.php @@ -12,7 +12,7 @@ use Symfony\Component\Finder\SplFileInfo; use Symfony\Component\HttpFoundation\File\UploadedFile; -class FileRepositoryTest extends MediaTestCase +class EloquentFileRepositoryTest extends MediaTestCase { /** * @var FileRepository From 2cce4a475283c31cb8b4bcbd1cfad29a9bd35c02 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:38:20 +0200 Subject: [PATCH 16/90] Adding event before a file is updated --- Modules/Media/Events/FileIsUpdating.php | 62 +++++++++++++++++++ .../Eloquent/EloquentFileRepository.php | 4 +- .../Tests/EloquentFileRepositoryTest.php | 45 ++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 Modules/Media/Events/FileIsUpdating.php diff --git a/Modules/Media/Events/FileIsUpdating.php b/Modules/Media/Events/FileIsUpdating.php new file mode 100644 index 000000000..f1c9305c2 --- /dev/null +++ b/Modules/Media/Events/FileIsUpdating.php @@ -0,0 +1,62 @@ +file = $file; + $this->attributes = $data; + $this->original = $data; + } + + /** + * @return array + */ + public function getOriginal() + { + return $this->original; + } + + /** + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param array $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes += $attributes; + } + + /** + * @return File + */ + public function getFile() + { + return $this->file; + } +} diff --git a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php index d98d2b35d..d925934d0 100644 --- a/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php +++ b/Modules/Media/Repositories/Eloquent/EloquentFileRepository.php @@ -6,6 +6,7 @@ use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; use Modules\Media\Entities\File; use Modules\Media\Events\FileIsCreating; +use Modules\Media\Events\FileIsUpdating; use Modules\Media\Events\FileWasCreated; use Modules\Media\Events\FileWasUpdated; use Modules\Media\Helpers\FileHelper; @@ -22,7 +23,8 @@ class EloquentFileRepository extends EloquentBaseRepository implements FileRepos */ public function update($file, $data) { - $file->update($data); + event($event = new FileIsUpdating($file, $data)); + $file->update($event->getAttributes()); $file->setTags(array_get($data, 'tags', [])); diff --git a/Modules/Media/Tests/EloquentFileRepositoryTest.php b/Modules/Media/Tests/EloquentFileRepositoryTest.php index a6857ed25..825254f65 100644 --- a/Modules/Media/Tests/EloquentFileRepositoryTest.php +++ b/Modules/Media/Tests/EloquentFileRepositoryTest.php @@ -6,6 +6,7 @@ use Mockery; use Modules\Media\Entities\File; use Modules\Media\Events\FileIsCreating; +use Modules\Media\Events\FileIsUpdating; use Modules\Media\Events\FileWasCreated; use Modules\Media\Events\FileWasUpdated; use Modules\Media\Repositories\FileRepository; @@ -166,6 +167,50 @@ public function it_triggers_event_when_file_was_updated() }); } + /** @test */ + public function it_triggers_event_when_file_is_updating() + { + Event::fake(); + + $file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('myfile.jpg')); + $this->file->update($file, [ + 'en' => [ + 'description' => 'My cool file!', + 'alt_attribute' => 'My cool file!', + 'keywords' => 'My cool file!', + ] + ]); + + Event::assertDispatched(FileIsUpdating::class, function ($e) use ($file) { + return $e->getFile()->id === $file->id && + $e->getAttributes()['en']['description'] === 'My cool file!'; + }); + } + + /** @test */ + public function it_can_change_properties_before_update() + { + Event::listen(FileIsUpdating::class, function (FileIsUpdating $event) { + $event->setAttributes([ + 'filename' => 'bettername.jpg', + 'en' => [ + 'description' => 'Hello World', + ] + ]); + }); + + $file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('myfile.jpg')); + $this->file->update($file, [ + 'en' => [ + 'description' => 'My cool file!', + 'alt_attribute' => 'My cool file!', + 'keywords' => 'My cool file!', + ] + ]); + + $this->assertEquals('bettername.jpg', $file->filename); + } + private function createFile($fileName = 'random/name.jpg') { return File::create([ From 57b6eb691f72e6af6e2113ffd4a179c463b7dd3e Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:39:07 +0200 Subject: [PATCH 17/90] Adding changelog items --- Modules/Media/changelog.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/Media/changelog.yml b/Modules/Media/changelog.yml index 0508c378a..d5659e913 100644 --- a/Modules/Media/changelog.yml +++ b/Modules/Media/changelog.yml @@ -1,5 +1,11 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + added: + - FileWasCreated event + - FileWasUpdated event + - FileIsCreating hookable event + - FileIsUpdating hookable event "2.4.0": added: - new blade directive for thumbnails @thumbnail('path', 'thumbnailName') From 893a3270a7764441d2f4a562d3d6ea4ab5b1cc19 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:40:33 +0200 Subject: [PATCH 18/90] Ussing + operator to merge arrays, allows multiple depths --- Modules/Media/Events/FileIsCreating.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Media/Events/FileIsCreating.php b/Modules/Media/Events/FileIsCreating.php index d30459bf9..63d495861 100644 --- a/Modules/Media/Events/FileIsCreating.php +++ b/Modules/Media/Events/FileIsCreating.php @@ -36,7 +36,7 @@ public function getAttributes() */ public function setAttributes(array $attributes) { - $this->attributes = array_merge($this->attributes, $attributes); + $this->attributes += $attributes; } /** From 23b249992846ed16d79e7a31bfd26b9d022f5965 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:53:41 +0200 Subject: [PATCH 19/90] Using array_replace_recursive to merge arrays instead --- Modules/Media/Events/FileIsCreating.php | 2 +- Modules/Media/Events/FileIsUpdating.php | 3 +-- Modules/Media/Tests/EloquentFileRepositoryTest.php | 1 + Modules/Page/Events/PageIsCreating.php | 2 +- Modules/Page/Events/PageIsUpdating.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Modules/Media/Events/FileIsCreating.php b/Modules/Media/Events/FileIsCreating.php index 63d495861..f23cceecb 100644 --- a/Modules/Media/Events/FileIsCreating.php +++ b/Modules/Media/Events/FileIsCreating.php @@ -36,7 +36,7 @@ public function getAttributes() */ public function setAttributes(array $attributes) { - $this->attributes += $attributes; + $this->attributes = array_replace_recursive($this->attributes, $attributes); } /** diff --git a/Modules/Media/Events/FileIsUpdating.php b/Modules/Media/Events/FileIsUpdating.php index f1c9305c2..b70de5e7f 100644 --- a/Modules/Media/Events/FileIsUpdating.php +++ b/Modules/Media/Events/FileIsUpdating.php @@ -7,7 +7,6 @@ final class FileIsUpdating implements EntityIsChanging { - /** * @var File */ @@ -49,7 +48,7 @@ public function getAttributes() */ public function setAttributes(array $attributes) { - $this->attributes += $attributes; + $this->attributes = array_replace_recursive($this->attributes, $attributes); } /** diff --git a/Modules/Media/Tests/EloquentFileRepositoryTest.php b/Modules/Media/Tests/EloquentFileRepositoryTest.php index 825254f65..dab6f44fa 100644 --- a/Modules/Media/Tests/EloquentFileRepositoryTest.php +++ b/Modules/Media/Tests/EloquentFileRepositoryTest.php @@ -209,6 +209,7 @@ public function it_can_change_properties_before_update() ]); $this->assertEquals('bettername.jpg', $file->filename); + $this->assertEquals('Hello World', $file->translate('en')->description); } private function createFile($fileName = 'random/name.jpg') diff --git a/Modules/Page/Events/PageIsCreating.php b/Modules/Page/Events/PageIsCreating.php index cf5fb4f30..e0c05a710 100644 --- a/Modules/Page/Events/PageIsCreating.php +++ b/Modules/Page/Events/PageIsCreating.php @@ -36,7 +36,7 @@ public function getAttributes() */ public function setAttributes(array $attributes) { - $this->attributes = array_merge($this->attributes, $attributes); + $this->attributes = array_replace_recursive($this->attributes, $attributes); } /** diff --git a/Modules/Page/Events/PageIsUpdating.php b/Modules/Page/Events/PageIsUpdating.php index 7713ac313..479225203 100644 --- a/Modules/Page/Events/PageIsUpdating.php +++ b/Modules/Page/Events/PageIsUpdating.php @@ -42,7 +42,7 @@ public function getAttributes() */ public function setAttributes(array $attributes) { - $this->attributes = array_merge($this->attributes, $attributes); + $this->attributes = array_replace_recursive($this->attributes, $attributes); } /** From 77c21dddc858d223ccfabe4e7d8da34eca7a9657 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 22:54:33 +0200 Subject: [PATCH 20/90] Using array_replace_recursive to merge arrays instead --- Modules/User/Events/UserIsCreating.php | 2 +- Modules/User/Events/UserIsUpdating.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/User/Events/UserIsCreating.php b/Modules/User/Events/UserIsCreating.php index dd9adda12..9f8cae221 100644 --- a/Modules/User/Events/UserIsCreating.php +++ b/Modules/User/Events/UserIsCreating.php @@ -36,7 +36,7 @@ public function getAttributes() */ public function setAttributes(array $attributes) { - $this->attributes = array_merge($this->attributes, $attributes); + $this->attributes = array_replace_recursive($this->attributes, $attributes); } /** diff --git a/Modules/User/Events/UserIsUpdating.php b/Modules/User/Events/UserIsUpdating.php index 2f7e46105..e266f732e 100644 --- a/Modules/User/Events/UserIsUpdating.php +++ b/Modules/User/Events/UserIsUpdating.php @@ -48,7 +48,7 @@ public function getAttributes() */ public function setAttributes(array $attributes) { - $this->attributes = array_merge($this->attributes, $attributes); + $this->attributes = array_replace_recursive($this->attributes, $attributes); } /** From ac633be26a3fbec0f2a3bd1e72d72781a3fb6be3 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 23:32:12 +0200 Subject: [PATCH 21/90] Create an AbstractEntityHook containing base logic for entity hooks --- Modules/Core/Abstracts/AbstractEntityHook.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Modules/Core/Abstracts/AbstractEntityHook.php diff --git a/Modules/Core/Abstracts/AbstractEntityHook.php b/Modules/Core/Abstracts/AbstractEntityHook.php new file mode 100644 index 000000000..82aeb52b8 --- /dev/null +++ b/Modules/Core/Abstracts/AbstractEntityHook.php @@ -0,0 +1,63 @@ +attributes = $attributes; + $this->original = $attributes; + } + + /** + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param string $attribute + * @param null $default + * @return string|null + */ + public function getAttribute($attribute, $default = null) + { + return data_get($this->attributes, $attribute, $default); + } + + /** + * @param array $attributes + */ + public function setAttributes(array $attributes) + { + $this->attributes = array_replace_recursive($this->attributes, $attributes); + } + + /** + * @param string|null $key + * @param string|null $default + * @return array + */ + public function getOriginal($key = null, $default = null) + { + if ($key !== null) { + return data_get($this->original, $key, $default); + } + + return $this->original; + } +} From e0a4043ffd481177c1aadeec5590b3134f6d688f Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 23:33:14 +0200 Subject: [PATCH 22/90] Adding changelog item --- Modules/Core/changelog.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Core/changelog.yml b/Modules/Core/changelog.yml index 2dce58b24..920750eca 100644 --- a/Modules/Core/changelog.yml +++ b/Modules/Core/changelog.yml @@ -3,6 +3,7 @@ versions: "2.5.0@unreleased": added: - Adding a EntityIsChanging interface to use on events which are triggered before a create / update action + - Create an AbstractEntityHook containing base logic for entity hooks changed: - Adding more core modules (tag, translation and page). Preventing them to be disabled. "2.3.0": From 12424bcac9ba5dc864a776507a3f1d7bf3a9ecc1 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Tue, 11 Jul 2017 23:33:29 +0200 Subject: [PATCH 23/90] Use the new abstract entity hook for user hooks --- Modules/User/Events/UserIsCreating.php | 43 +------------------ Modules/User/Events/UserIsUpdating.php | 38 ++-------------- .../User/Tests/SentinelUserRepositoryTest.php | 6 +-- 3 files changed, 8 insertions(+), 79 deletions(-) diff --git a/Modules/User/Events/UserIsCreating.php b/Modules/User/Events/UserIsCreating.php index 9f8cae221..79e1a173b 100644 --- a/Modules/User/Events/UserIsCreating.php +++ b/Modules/User/Events/UserIsCreating.php @@ -2,48 +2,9 @@ namespace Modules\User\Events; +use Modules\Core\Abstracts\AbstractEntityHook; use Modules\Core\Contracts\EntityIsChanging; -final class UserIsCreating implements EntityIsChanging +final class UserIsCreating extends AbstractEntityHook implements EntityIsChanging { - /** - * Contains the attributes which can be changed by other listeners - * @var array - */ - private $attributes; - /** - * Contains the original attributes which cannot be changed - * @var array - */ - private $original; - - public function __construct(array $attributes) - { - $this->attributes = $attributes; - $this->original = $attributes; - } - - /** - * @return array - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * @param array $attributes - */ - public function setAttributes(array $attributes) - { - $this->attributes = array_replace_recursive($this->attributes, $attributes); - } - - /** - * @return array - */ - public function getOriginal() - { - return $this->original; - } } diff --git a/Modules/User/Events/UserIsUpdating.php b/Modules/User/Events/UserIsUpdating.php index e266f732e..49075d977 100644 --- a/Modules/User/Events/UserIsUpdating.php +++ b/Modules/User/Events/UserIsUpdating.php @@ -2,53 +2,21 @@ namespace Modules\User\Events; +use Modules\Core\Abstracts\AbstractEntityHook; use Modules\Core\Contracts\EntityIsChanging; use Modules\User\Entities\UserInterface; -final class UserIsUpdating implements EntityIsChanging +final class UserIsUpdating extends AbstractEntityHook implements EntityIsChanging { /** * @var UserInterface */ private $user; - /** - * @var array - */ - private $attributes; - /** - * @var array - */ - private $original; public function __construct(UserInterface $user, array $data) { $this->user = $user; - $this->attributes = $data; - $this->original = $data; - } - - /** - * @return array - */ - public function getOriginal() - { - return $this->original; - } - - /** - * @return array - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * @param array $attributes - */ - public function setAttributes(array $attributes) - { - $this->attributes = array_replace_recursive($this->attributes, $attributes); + parent::__construct($data); } /** diff --git a/Modules/User/Tests/SentinelUserRepositoryTest.php b/Modules/User/Tests/SentinelUserRepositoryTest.php index 6cbdf9422..e97ee182d 100644 --- a/Modules/User/Tests/SentinelUserRepositoryTest.php +++ b/Modules/User/Tests/SentinelUserRepositoryTest.php @@ -56,7 +56,7 @@ public function it_fires_event_when_user_is_creating() ]); Event::assertDispatched(UserIsCreating::class, function ($e) use ($user) { - return $e->getAttributes()['email'] === $user->email; + return $e->getAttribute('email') === $user->email; }); } @@ -104,7 +104,7 @@ public function it_makes_sure_the_event_contains_original_attributes() ]); Event::assertDispatched(UserIsCreating::class, function ($e) { - return $e->getOriginal()['email'] === 'n.widart@gmail.com'; + return $e->getOriginal('email')=== 'n.widart@gmail.com'; }); } @@ -255,7 +255,7 @@ public function it_triggers_event_when_user_is_updating() Event::assertDispatched(UserIsUpdating::class, function ($e) use ($user) { return $e->getUser()->id === $user->id && - $e->getAttributes()['first_name'] === 'John'; + $e->getAttribute('first_name') === 'John'; }); } From 37a00fef7f9b802b54404fe3b8abd1fa5ee96e6a Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 11:46:22 +0200 Subject: [PATCH 24/90] Updating test file name, matching our tested class --- .../Tests/{PagesTest.php => EloquentPageRepositoryTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Modules/Page/Tests/{PagesTest.php => EloquentPageRepositoryTest.php} (99%) diff --git a/Modules/Page/Tests/PagesTest.php b/Modules/Page/Tests/EloquentPageRepositoryTest.php similarity index 99% rename from Modules/Page/Tests/PagesTest.php rename to Modules/Page/Tests/EloquentPageRepositoryTest.php index cd52547eb..c134091c9 100644 --- a/Modules/Page/Tests/PagesTest.php +++ b/Modules/Page/Tests/EloquentPageRepositoryTest.php @@ -9,7 +9,7 @@ use Modules\Page\Events\PageWasDeleted; use Modules\Page\Events\PageWasUpdated; -class PagesTest extends BasePageTest +class EloquentPageRepositoryTest extends BasePageTest { /** @test */ public function it_makes_page_as_homepage() From 1635b9776b234c674716025aaa7b274bc027f61d Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 11:52:45 +0200 Subject: [PATCH 25/90] Using the abstract entity class and using its helper methods in tests --- Modules/Media/Events/FileIsCreating.php | 43 +------------------ Modules/Media/Events/FileIsUpdating.php | 40 ++--------------- .../Tests/EloquentFileRepositoryTest.php | 4 +- Modules/Page/Events/PageIsCreating.php | 43 +------------------ Modules/Page/Events/PageIsUpdating.php | 40 ++--------------- .../Page/Tests/EloquentPageRepositoryTest.php | 2 +- 6 files changed, 14 insertions(+), 158 deletions(-) diff --git a/Modules/Media/Events/FileIsCreating.php b/Modules/Media/Events/FileIsCreating.php index f23cceecb..bf5404513 100644 --- a/Modules/Media/Events/FileIsCreating.php +++ b/Modules/Media/Events/FileIsCreating.php @@ -2,48 +2,9 @@ namespace Modules\Media\Events; +use Modules\Core\Abstracts\AbstractEntityHook; use Modules\Core\Contracts\EntityIsChanging; -final class FileIsCreating implements EntityIsChanging +final class FileIsCreating extends AbstractEntityHook implements EntityIsChanging { - /** - * Contains the attributes which can be changed by other listeners - * @var array - */ - private $attributes; - /** - * Contains the original attributes which cannot be changed - * @var array - */ - private $original; - - public function __construct(array $attributes) - { - $this->attributes = $attributes; - $this->original = $attributes; - } - - /** - * @return array - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * @param array $attributes - */ - public function setAttributes(array $attributes) - { - $this->attributes = array_replace_recursive($this->attributes, $attributes); - } - - /** - * @return array - */ - public function getOriginal() - { - return $this->original; - } } diff --git a/Modules/Media/Events/FileIsUpdating.php b/Modules/Media/Events/FileIsUpdating.php index b70de5e7f..d4a7d9f51 100644 --- a/Modules/Media/Events/FileIsUpdating.php +++ b/Modules/Media/Events/FileIsUpdating.php @@ -2,53 +2,21 @@ namespace Modules\Media\Events; +use Modules\Core\Abstracts\AbstractEntityHook; use Modules\Core\Contracts\EntityIsChanging; use Modules\Media\Entities\File; -final class FileIsUpdating implements EntityIsChanging +final class FileIsUpdating extends AbstractEntityHook implements EntityIsChanging { /** * @var File */ private $file; - /** - * @var array - */ - private $attributes; - /** - * @var array - */ - private $original; - public function __construct(File $file, array $data) + public function __construct(File $file, array $attributes) { $this->file = $file; - $this->attributes = $data; - $this->original = $data; - } - - /** - * @return array - */ - public function getOriginal() - { - return $this->original; - } - - /** - * @return array - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * @param array $attributes - */ - public function setAttributes(array $attributes) - { - $this->attributes = array_replace_recursive($this->attributes, $attributes); + parent::__construct($attributes); } /** diff --git a/Modules/Media/Tests/EloquentFileRepositoryTest.php b/Modules/Media/Tests/EloquentFileRepositoryTest.php index dab6f44fa..6837fe373 100644 --- a/Modules/Media/Tests/EloquentFileRepositoryTest.php +++ b/Modules/Media/Tests/EloquentFileRepositoryTest.php @@ -138,7 +138,7 @@ public function it_triggers_event_when_file_is_creating() $file = $this->file->createFromFile(\Illuminate\Http\UploadedFile::fake()->image('myfile.jpg')); Event::assertDispatched(FileIsCreating::class, function ($e) use ($file) { - return $e->getAttributes()['filename'] === $file->filename; + return $e->getAttribute('filename') === $file->filename; }); } @@ -183,7 +183,7 @@ public function it_triggers_event_when_file_is_updating() Event::assertDispatched(FileIsUpdating::class, function ($e) use ($file) { return $e->getFile()->id === $file->id && - $e->getAttributes()['en']['description'] === 'My cool file!'; + $e->getAttribute('en.description') === 'My cool file!'; }); } diff --git a/Modules/Page/Events/PageIsCreating.php b/Modules/Page/Events/PageIsCreating.php index e0c05a710..c6f15f553 100644 --- a/Modules/Page/Events/PageIsCreating.php +++ b/Modules/Page/Events/PageIsCreating.php @@ -2,48 +2,9 @@ namespace Modules\Page\Events; +use Modules\Core\Abstracts\AbstractEntityHook; use Modules\Core\Contracts\EntityIsChanging; -class PageIsCreating implements EntityIsChanging +class PageIsCreating extends AbstractEntityHook implements EntityIsChanging { - /** - * Contains the attributes which can be changed by other listeners - * @var array - */ - private $attributes; - /** - * Contains the original attributes which cannot be changed - * @var array - */ - private $original; - - public function __construct(array $attributes) - { - $this->attributes = $attributes; - $this->original = $attributes; - } - - /** - * @return array - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * @param array $attributes - */ - public function setAttributes(array $attributes) - { - $this->attributes = array_replace_recursive($this->attributes, $attributes); - } - - /** - * @return array - */ - public function getOriginal() - { - return $this->original; - } } diff --git a/Modules/Page/Events/PageIsUpdating.php b/Modules/Page/Events/PageIsUpdating.php index 479225203..3a6905a2c 100644 --- a/Modules/Page/Events/PageIsUpdating.php +++ b/Modules/Page/Events/PageIsUpdating.php @@ -2,21 +2,12 @@ namespace Modules\Page\Events; +use Modules\Core\Abstracts\AbstractEntityHook; use Modules\Core\Contracts\EntityIsChanging; use Modules\Page\Entities\Page; -class PageIsUpdating implements EntityIsChanging +class PageIsUpdating extends AbstractEntityHook implements EntityIsChanging { - /** - * Contains the attributes which can be changed by other listeners - * @var array - */ - private $attributes; - /** - * Contains the original attributes which cannot be changed - * @var array - */ - private $original; /** * @var Page */ @@ -24,33 +15,8 @@ class PageIsUpdating implements EntityIsChanging public function __construct(Page $page, array $attributes) { - $this->attributes = $attributes; - $this->original = $attributes; $this->page = $page; - } - - /** - * @return array - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * @param array $attributes - */ - public function setAttributes(array $attributes) - { - $this->attributes = array_replace_recursive($this->attributes, $attributes); - } - - /** - * @return array - */ - public function getOriginal() - { - return $this->original; + parent::__construct($attributes); } /** diff --git a/Modules/Page/Tests/EloquentPageRepositoryTest.php b/Modules/Page/Tests/EloquentPageRepositoryTest.php index c134091c9..0ad843c74 100644 --- a/Modules/Page/Tests/EloquentPageRepositoryTest.php +++ b/Modules/Page/Tests/EloquentPageRepositoryTest.php @@ -103,7 +103,7 @@ public function it_triggers_an_event_when_page_is_creating() $page = $this->createPage(); Event::assertDispatched(PageIsCreating::class, function ($e) use ($page) { - return $e->getAttributes()['template'] === $page->template; + return $e->getAttribute('template') === $page->template; }); } From 89a278c131405776bfe1d6e15c5c2c30ceddf390 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 12:23:56 +0200 Subject: [PATCH 26/90] Updating class name to match tested class --- .../{MenuRepositoryTest.php => EloquentMenuRepositoryTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Modules/Menu/Tests/{MenuRepositoryTest.php => EloquentMenuRepositoryTest.php} (90%) diff --git a/Modules/Menu/Tests/MenuRepositoryTest.php b/Modules/Menu/Tests/EloquentMenuRepositoryTest.php similarity index 90% rename from Modules/Menu/Tests/MenuRepositoryTest.php rename to Modules/Menu/Tests/EloquentMenuRepositoryTest.php index 9dc59c45b..a3990ee4c 100644 --- a/Modules/Menu/Tests/MenuRepositoryTest.php +++ b/Modules/Menu/Tests/EloquentMenuRepositoryTest.php @@ -2,7 +2,7 @@ namespace Modules\Menu\Tests; -class MenuRepositoryTest extends BaseMenuTest +class EloquentMenuRepositoryTest extends BaseMenuTest { /** @test */ public function it_creates_menu() From 64f7e4139e8788837dd10e46703ed995628a125d Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 12:39:57 +0200 Subject: [PATCH 27/90] Creating and triggering new (hookable) events for menu entity --- Modules/Menu/Events/MenuIsCreating.php | 10 +++ Modules/Menu/Events/MenuIsUpdating.php | 29 +++++++ Modules/Menu/Events/MenuWasUpdated.php | 18 ++++ .../Eloquent/EloquentMenuRepository.php | 11 ++- Modules/Menu/Tests/BaseMenuTest.php | 8 ++ .../Menu/Tests/EloquentMenuRepositoryTest.php | 87 +++++++++++++++++++ 6 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 Modules/Menu/Events/MenuIsCreating.php create mode 100644 Modules/Menu/Events/MenuIsUpdating.php create mode 100644 Modules/Menu/Events/MenuWasUpdated.php diff --git a/Modules/Menu/Events/MenuIsCreating.php b/Modules/Menu/Events/MenuIsCreating.php new file mode 100644 index 000000000..761bd619b --- /dev/null +++ b/Modules/Menu/Events/MenuIsCreating.php @@ -0,0 +1,10 @@ +menu = $menu; + parent::__construct($attributes); + } + + /** + * @return Menu + */ + public function getMenu() + { + return $this->menu; + } +} diff --git a/Modules/Menu/Events/MenuWasUpdated.php b/Modules/Menu/Events/MenuWasUpdated.php new file mode 100644 index 000000000..fbbe5b8e3 --- /dev/null +++ b/Modules/Menu/Events/MenuWasUpdated.php @@ -0,0 +1,18 @@ +menu = $menu; + } +} diff --git a/Modules/Menu/Repositories/Eloquent/EloquentMenuRepository.php b/Modules/Menu/Repositories/Eloquent/EloquentMenuRepository.php index 05e3ede6b..ff481ba98 100644 --- a/Modules/Menu/Repositories/Eloquent/EloquentMenuRepository.php +++ b/Modules/Menu/Repositories/Eloquent/EloquentMenuRepository.php @@ -5,14 +5,18 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Facades\App; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; +use Modules\Menu\Events\MenuIsCreating; +use Modules\Menu\Events\MenuIsUpdating; use Modules\Menu\Events\MenuWasCreated; +use Modules\Menu\Events\MenuWasUpdated; use Modules\Menu\Repositories\MenuRepository; class EloquentMenuRepository extends EloquentBaseRepository implements MenuRepository { public function create($data) { - $menu = $this->model->create($data); + event($event = new MenuIsCreating($data)); + $menu = $this->model->create($event->getAttributes()); event(new MenuWasCreated($menu)); @@ -21,7 +25,10 @@ public function create($data) public function update($menu, $data) { - $menu->update($data); + event($event = new MenuIsUpdating($menu, $data)); + $menu->update($event->getAttributes()); + + event(new MenuWasUpdated($menu)); return $menu; } diff --git a/Modules/Menu/Tests/BaseMenuTest.php b/Modules/Menu/Tests/BaseMenuTest.php index 6d0f6913b..577385893 100644 --- a/Modules/Menu/Tests/BaseMenuTest.php +++ b/Modules/Menu/Tests/BaseMenuTest.php @@ -9,10 +9,12 @@ use Mcamara\LaravelLocalization\Facades\LaravelLocalization; use Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider; use Modules\Core\Providers\CoreServiceProvider; +use Modules\Menu\Providers\EventServiceProvider; use Modules\Menu\Providers\MenuServiceProvider; use Modules\Menu\Repositories\MenuItemRepository; use Modules\Menu\Repositories\MenuRepository; use Modules\Page\Providers\PageServiceProvider; +use Modules\Setting\Providers\SettingServiceProvider; use Modules\Tag\Providers\TagServiceProvider; use Nwidart\Modules\LaravelModulesServiceProvider; use Orchestra\Testbench\TestCase; @@ -48,6 +50,8 @@ protected function getPackageProviders($app) CoreServiceProvider::class, TagServiceProvider::class, PageServiceProvider::class, + SettingServiceProvider::class, + EventServiceProvider::class, MenuServiceProvider::class, LaravelLocalizationServiceProvider::class, SidebarServiceProvider::class, @@ -96,6 +100,10 @@ private function resetDatabase() '--database' => 'sqlite', '--path' => 'Modules/Tag/Database/Migrations', ]); + $this->artisan('migrate', [ + '--database' => 'sqlite', + '--path' => 'Modules/Setting/Database/Migrations', + ]); } public function createMenu($name, $title) diff --git a/Modules/Menu/Tests/EloquentMenuRepositoryTest.php b/Modules/Menu/Tests/EloquentMenuRepositoryTest.php index a3990ee4c..0e06228b7 100644 --- a/Modules/Menu/Tests/EloquentMenuRepositoryTest.php +++ b/Modules/Menu/Tests/EloquentMenuRepositoryTest.php @@ -2,6 +2,13 @@ namespace Modules\Menu\Tests; +use Illuminate\Support\Facades\Event; +use Modules\Menu\Events\MenuIsCreating; +use Modules\Menu\Events\MenuIsUpdating; +use Modules\Menu\Events\MenuWasCreated; +use Modules\Menu\Events\MenuWasUpdated; +use Modules\Setting\Repositories\SettingRepository; + class EloquentMenuRepositoryTest extends BaseMenuTest { /** @test */ @@ -13,10 +20,90 @@ public function it_creates_menu() $this->assertEquals($menu->name, $this->menu->find($menu->id)->name); } + /** @test */ + public function it_triggers_event_when_menu_was_created() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + + Event::assertDispatched(MenuWasCreated::class, function ($e) use ($menu) { + return $e->menu->id === $menu->id; + }); + } + + /** @test */ + public function it_triggers_event_when_menu_is_creating() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + + Event::assertDispatched(MenuIsCreating::class, function ($e) use ($menu) { + return $e->getAttribute('name') === $menu->name; + }); + } + + /** @test */ + public function it_can_change_data_when_it_is_creating_event() + { + Event::listen(MenuIsCreating::class, function (MenuIsCreating $event) { + $event->setAttributes(['name' => 'MAIN']); + }); + + $menu = $this->createMenu('main', 'Main Menu'); + + $this->assertEquals('MAIN', $menu->name); + } + + /** @test */ + public function it_triggers_event_when_menu_item_was_updated() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + $this->menu->update($menu, []); + + Event::assertDispatched(MenuWasUpdated::class, function ($e) use ($menu) { + return $e->menu->id === $menu->id; + }); + } + + /** @test */ + public function it_triggers_event_when_menu_is_updating() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + $this->menu->update($menu, []); + + Event::assertDispatched(MenuIsUpdating::class, function ($e) use ($menu) { + return $e->getMenu()->id === $menu->id; + }); + } + + /** @test */ + public function it_can_change_attributes_before_update() + { + Event::listen(MenuIsUpdating::class, function (MenuIsUpdating $event) { + $event->setAttributes(['name' => 'MAIN']); + }); + + $menu = $this->createMenu('main', 'Main Menu'); + $this->menu->update($menu, ['name' => 'better-one']); + + $this->assertEquals('MAIN', $menu->name); + } + + /** @test */ public function it_should_create_root_item_when_creating_new_menu() { + app(SettingRepository::class)->createOrUpdate([ + 'core::locales' => ['en', 'fr',] + ]); $menu = $this->createMenu('main', 'Main Menu'); $items = $this->menuItem->allRootsForMenu($menu->id); + $this->assertCount(1, $items); } } From 0e4362397769173936bf7522d41794300271ca01 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 12:47:39 +0200 Subject: [PATCH 28/90] Don't run events --- Modules/Menu/Tests/MenuItemUriGeneratorTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/Menu/Tests/MenuItemUriGeneratorTest.php b/Modules/Menu/Tests/MenuItemUriGeneratorTest.php index 8612e4598..134f19f6a 100644 --- a/Modules/Menu/Tests/MenuItemUriGeneratorTest.php +++ b/Modules/Menu/Tests/MenuItemUriGeneratorTest.php @@ -2,6 +2,7 @@ namespace Modules\Menu\Tests; +use Illuminate\Support\Facades\Event; use Modules\Menu\Services\MenuItemUriGenerator; use Modules\Page\Repositories\PageRepository; @@ -42,6 +43,7 @@ public function it_generates_basic_uri_without_parent() /** @test */ public function it_generates_uri_with_the_parents_slug() { + Event::fake(); $this->page->create([ 'is_home' => 1, 'template' => 'default', @@ -80,6 +82,7 @@ public function it_generates_uri_with_the_parents_slug() /** @test */ public function it_generates_uri_with_multiple_parents() { + Event::fake(); $this->page->create([ 'is_home' => 1, 'template' => 'default', @@ -140,6 +143,7 @@ public function it_generates_uri_with_multiple_parents() /** @test */ public function it_generates_a_uri_if_parent_isnt_a_page() { + Event::fake(); $this->page->create([ 'is_home' => 0, 'template' => 'default', From 281f20ffc6d62ac88c03e750fa178557d3273c80 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 12:48:06 +0200 Subject: [PATCH 29/90] Fixing item count, taking into account the 2 root items --- Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php b/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php index 7db6f4754..635aaf38e 100644 --- a/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php +++ b/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php @@ -53,8 +53,8 @@ public function it_destroys_menu_item() $secondaryItem2 = $this->createMenuItemForMenu($menu2->id, 1); $secondaryItem3 = $this->createMenuItemForMenu($menu2->id, 3); - $this->assertEquals(6, $this->menuItem->all()->count()); + $this->assertEquals(8, $this->menuItem->all()->count()); $this->menuItem->destroy($item2); - $this->assertEquals(5, $this->menuItem->all()->count()); + $this->assertEquals(7, $this->menuItem->all()->count()); } } From 4389a2ed44141a9f10a79939dd37c0ecf263cb54 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 12:48:29 +0200 Subject: [PATCH 30/90] Loading and creating the locale setting for core module --- Modules/Menu/Tests/BaseMenuTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/Menu/Tests/BaseMenuTest.php b/Modules/Menu/Tests/BaseMenuTest.php index 577385893..57a7dbc53 100644 --- a/Modules/Menu/Tests/BaseMenuTest.php +++ b/Modules/Menu/Tests/BaseMenuTest.php @@ -15,6 +15,7 @@ use Modules\Menu\Repositories\MenuRepository; use Modules\Page\Providers\PageServiceProvider; use Modules\Setting\Providers\SettingServiceProvider; +use Modules\Setting\Repositories\SettingRepository; use Modules\Tag\Providers\TagServiceProvider; use Nwidart\Modules\LaravelModulesServiceProvider; use Orchestra\Testbench\TestCase; @@ -41,6 +42,9 @@ public function setUp() $this->menu = app(MenuRepository::class); $this->menuItem = app(MenuItemRepository::class); + app(SettingRepository::class)->createOrUpdate([ + 'core::locales' => ['en', 'fr',] + ]); } protected function getPackageProviders($app) From 60de6a52b17d1158e8bf9c5e88435836dd771247 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 12:48:57 +0200 Subject: [PATCH 31/90] Create the settings in the base test --- Modules/Menu/Tests/EloquentMenuRepositoryTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Modules/Menu/Tests/EloquentMenuRepositoryTest.php b/Modules/Menu/Tests/EloquentMenuRepositoryTest.php index 0e06228b7..9cd036510 100644 --- a/Modules/Menu/Tests/EloquentMenuRepositoryTest.php +++ b/Modules/Menu/Tests/EloquentMenuRepositoryTest.php @@ -7,7 +7,6 @@ use Modules\Menu\Events\MenuIsUpdating; use Modules\Menu\Events\MenuWasCreated; use Modules\Menu\Events\MenuWasUpdated; -use Modules\Setting\Repositories\SettingRepository; class EloquentMenuRepositoryTest extends BaseMenuTest { @@ -98,9 +97,6 @@ public function it_can_change_attributes_before_update() /** @test */ public function it_should_create_root_item_when_creating_new_menu() { - app(SettingRepository::class)->createOrUpdate([ - 'core::locales' => ['en', 'fr',] - ]); $menu = $this->createMenu('main', 'Main Menu'); $items = $this->menuItem->allRootsForMenu($menu->id); From 0121f995969b099f537ace650fb3b6499222cfd9 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 13:05:36 +0200 Subject: [PATCH 32/90] Creating and triggering new (hookable) events for menu item entity --- Modules/Menu/Events/MenuItemIsCreating.php | 10 ++ Modules/Menu/Events/MenuItemIsUpdating.php | 29 +++++ Modules/Menu/Events/MenuItemWasUpdated.php | 18 +++ .../Eloquent/EloquentMenuItemRepository.php | 11 +- .../Tests/EloquentMenuItemRepositoryTest.php | 103 ++++++++++++++++++ 5 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 Modules/Menu/Events/MenuItemIsCreating.php create mode 100644 Modules/Menu/Events/MenuItemIsUpdating.php create mode 100644 Modules/Menu/Events/MenuItemWasUpdated.php diff --git a/Modules/Menu/Events/MenuItemIsCreating.php b/Modules/Menu/Events/MenuItemIsCreating.php new file mode 100644 index 000000000..9dd6930e1 --- /dev/null +++ b/Modules/Menu/Events/MenuItemIsCreating.php @@ -0,0 +1,10 @@ +menuItem = $menuItem; + } + + /** + * @return Menuitem + */ + public function getMenuItem() + { + return $this->menuItem; + } +} diff --git a/Modules/Menu/Events/MenuItemWasUpdated.php b/Modules/Menu/Events/MenuItemWasUpdated.php new file mode 100644 index 000000000..025781725 --- /dev/null +++ b/Modules/Menu/Events/MenuItemWasUpdated.php @@ -0,0 +1,18 @@ +menuItem = $menuItem; + } +} diff --git a/Modules/Menu/Repositories/Eloquent/EloquentMenuItemRepository.php b/Modules/Menu/Repositories/Eloquent/EloquentMenuItemRepository.php index ca6468b7c..cfd56e3c7 100644 --- a/Modules/Menu/Repositories/Eloquent/EloquentMenuItemRepository.php +++ b/Modules/Menu/Repositories/Eloquent/EloquentMenuItemRepository.php @@ -6,14 +6,18 @@ use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; +use Modules\Menu\Events\MenuItemIsCreating; +use Modules\Menu\Events\MenuItemIsUpdating; use Modules\Menu\Events\MenuItemWasCreated; +use Modules\Menu\Events\MenuItemWasUpdated; use Modules\Menu\Repositories\MenuItemRepository; class EloquentMenuItemRepository extends EloquentBaseRepository implements MenuItemRepository { public function create($data) { - $menuItem = $this->model->create($data); + event($event = new MenuItemIsCreating($data)); + $menuItem = $this->model->create($event->getAttributes()); event(new MenuItemWasCreated($menuItem)); @@ -22,7 +26,10 @@ public function create($data) public function update($menuItem, $data) { - $menuItem->update($data); + event($event = new MenuItemIsUpdating($menuItem, $data)); + $menuItem->update($event->getAttributes()); + + event(new MenuItemWasUpdated($menuItem)); return $menuItem; } diff --git a/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php b/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php index 635aaf38e..d14b6f663 100644 --- a/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php +++ b/Modules/Menu/Tests/EloquentMenuItemRepositoryTest.php @@ -2,6 +2,12 @@ namespace Modules\Menu\Tests; +use Illuminate\Support\Facades\Event; +use Modules\Menu\Events\MenuItemIsCreating; +use Modules\Menu\Events\MenuItemIsUpdating; +use Modules\Menu\Events\MenuItemWasCreated; +use Modules\Menu\Events\MenuItemWasUpdated; + class EloquentMenuItemRepositoryTest extends BaseMenuTest { public function setUp() @@ -57,4 +63,101 @@ public function it_destroys_menu_item() $this->menuItem->destroy($item2); $this->assertEquals(7, $this->menuItem->all()->count()); } + + /** @test */ + public function it_triggers_event_when_menu_item_was_created() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + $item1 = $this->createMenuItemForMenu($menu->id, 0); + + Event::assertDispatched(MenuItemWasCreated::class, function ($e) use ($item1) { + return $e->menuItem->id === $item1->id; + }); + } + + /** @test */ + public function it_triggers_event_when_menu_item_is_creating() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + $item1 = $this->createMenuItemForMenu($menu->id, 0); + + Event::assertDispatched(MenuItemIsCreating::class, function ($e) use ($item1) { + return $e->getAttribute('target') === $item1->target; + }); + } + + /** @test */ + public function it_can_change_data_when_it_is_creating_event() + { + Event::listen(MenuItemIsCreating::class, function (MenuItemIsCreating $event) { + $event->setAttributes([ + 'target' => '_blank', + 'en' => [ + 'title' => 'My Title', + ], + ]); + }); + + $menu = $this->createMenu('main', 'Main Menu'); + $item = $this->createMenuItemForMenu($menu->id, 0); + + $this->assertEquals('_blank', $item->target); + $this->assertEquals('My Title', $item->translate('en')->title); + } + + /** @test */ + public function it_triggers_event_when_menu_item_is_updated() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + $item1 = $this->createMenuItemForMenu($menu->id, 0); + + $this->menuItem->update($item1, []); + + Event::assertDispatched(MenuItemWasUpdated::class, function ($e) use ($item1) { + return $e->menuItem->id === $item1->id; + }); + } + + /** @test */ + public function it_triggers_event_when_menu_item_is_updating() + { + Event::fake(); + + $menu = $this->createMenu('main', 'Main Menu'); + $item1 = $this->createMenuItemForMenu($menu->id, 0); + + $this->menuItem->update($item1, []); + + Event::assertDispatched(MenuItemIsUpdating::class, function ($e) use ($item1) { + return $e->getMenuItem()->id === $item1->id; + }); + } + + /** @test */ + public function it_can_change_data_before_updating_menu_item() + { + Event::listen(MenuItemIsUpdating::class, function (MenuItemIsUpdating $event) { + $event->setAttributes([ + 'target' => '_blank', + 'en' => [ + 'title' => 'My Title', + ], + ]); + }); + + $menu = $this->createMenu('main', 'Main Menu'); + $item1 = $this->createMenuItemForMenu($menu->id, 0); + + $this->menuItem->update($item1, [ + 'en' => ['title' => 'This one!'], + ]); + + $this->assertEquals('My Title', $item1->translate('en')->title); + } } From 875b402d617217a429ade29be971634ca05dd4e9 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 13:34:04 +0200 Subject: [PATCH 33/90] Creating and triggering new (hookable) events for Role entity --- Modules/User/Events/RoleIsCreating.php | 10 +++ Modules/User/Events/RoleIsUpdating.php | 29 +++++++++ Modules/User/Events/RoleWasCreated.php | 18 +++++ .../Sentinel/SentinelRoleRepository.php | 13 +++- .../User/Tests/SentinelRoleRepositoryTest.php | 65 +++++++++++++++++++ 5 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 Modules/User/Events/RoleIsCreating.php create mode 100644 Modules/User/Events/RoleIsUpdating.php create mode 100644 Modules/User/Events/RoleWasCreated.php diff --git a/Modules/User/Events/RoleIsCreating.php b/Modules/User/Events/RoleIsCreating.php new file mode 100644 index 000000000..998810769 --- /dev/null +++ b/Modules/User/Events/RoleIsCreating.php @@ -0,0 +1,10 @@ +role = $role; + parent::__construct($attributes); + } + + /** + * @return RoleInterface + */ + public function getRole() + { + return $this->role; + } +} diff --git a/Modules/User/Events/RoleWasCreated.php b/Modules/User/Events/RoleWasCreated.php new file mode 100644 index 000000000..1ed5997cb --- /dev/null +++ b/Modules/User/Events/RoleWasCreated.php @@ -0,0 +1,18 @@ +role = $role; + } +} diff --git a/Modules/User/Repositories/Sentinel/SentinelRoleRepository.php b/Modules/User/Repositories/Sentinel/SentinelRoleRepository.php index 7438b04a2..9f42f7cb1 100644 --- a/Modules/User/Repositories/Sentinel/SentinelRoleRepository.php +++ b/Modules/User/Repositories/Sentinel/SentinelRoleRepository.php @@ -3,6 +3,9 @@ namespace Modules\User\Repositories\Sentinel; use Cartalyst\Sentinel\Laravel\Facades\Sentinel; +use Modules\User\Events\RoleIsCreating; +use Modules\User\Events\RoleIsUpdating; +use Modules\User\Events\RoleWasCreated; use Modules\User\Events\RoleWasUpdated; use Modules\User\Repositories\RoleRepository; @@ -33,7 +36,12 @@ public function all() */ public function create($data) { - return $this->role->create($data); + event($event = new RoleIsCreating($data)); + $role = $this->role->create($event->getAttributes()); + + event(new RoleWasCreated($role)); + + return $role; } /** @@ -56,8 +64,9 @@ public function update($id, $data) { $role = $this->role->find($id); - $role->fill($data); + event($event = new RoleIsUpdating($role, $data)); + $role->fill($event->getAttributes()); $role->save(); event(new RoleWasUpdated($role)); diff --git a/Modules/User/Tests/SentinelRoleRepositoryTest.php b/Modules/User/Tests/SentinelRoleRepositoryTest.php index ed54b0dfd..adedc387f 100644 --- a/Modules/User/Tests/SentinelRoleRepositoryTest.php +++ b/Modules/User/Tests/SentinelRoleRepositoryTest.php @@ -3,6 +3,9 @@ namespace Modules\User\Tests; use Illuminate\Support\Facades\Event; +use Modules\User\Events\RoleIsCreating; +use Modules\User\Events\RoleIsUpdating; +use Modules\User\Events\RoleWasCreated; use Modules\User\Events\RoleWasUpdated; use Modules\User\Repositories\RoleRepository; @@ -27,6 +30,42 @@ public function it_creates_a_role() $this->assertCount(1, $this->role->all()); } + /** @test */ + public function it_triggers_event_when_role_was_created() + { + Event::fake(); + + $role = $this->role->create(['name' => 'Admin', 'slug' => 'admin']); + + Event::assertDispatched(RoleWasCreated::class, function ($e) use ($role) { + return $e->role->name === $role->name; + }); + } + + /** @test */ + public function it_triggers_event_when_role_is_creating() + { + Event::fake(); + + $role = $this->role->create(['name' => 'Admin', 'slug' => 'admin']); + + Event::assertDispatched(RoleIsCreating::class, function ($e) use ($role) { + return $e->getAttribute('name') === $role->name; + }); + } + + /** @test */ + public function it_can_change_data_when_it_is_creating_event() + { + Event::listen(RoleIsCreating::class, function (RoleIsCreating $event) { + $event->setAttributes(['name' => 'BETTER']); + }); + + $role = $this->role->create(['name' => 'Admin', 'slug' => 'admin']); + + $this->assertEquals('BETTER', $role->name); + } + /** @test */ public function it_finds_a_role_by_id() { @@ -63,6 +102,32 @@ public function it_triggers_role_updated_event() }); } + /** @test */ + public function it_fires_event_when_role_is_updating() + { + Event::fake(); + + $role = $this->role->create(['name' => 'Admin', 'slug' => 'admin']); + $this->role->update($role->id, ['name' => 'Better Admin']); + + Event::assertDispatched(RoleIsUpdating::class, function ($e) use ($role) { + return $e->getRole()->id === $role->id; + }); + } + + /** @test */ + public function it_can_change_data_before_role_is_updated() + { + Event::listen(RoleIsUpdating::class, function (RoleIsUpdating $event) { + $event->setAttributes(['name' => 'BETTER']); + }); + + $role = $this->role->create(['name' => 'Admin', 'slug' => 'admin']); + $role = $this->role->update($role->id, ['name' => 'Better Admin']); + + $this->assertEquals('BETTER', $role->name); + } + /** @test */ public function it_deletes_a_role() { From ac6bc7cd23849446954d4c058cdf4531d56ba565 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 14:49:44 +0200 Subject: [PATCH 34/90] Normalise the setting was created event --- Modules/Setting/Events/SettingWasCreated.php | 25 +++++-------------- .../Eloquent/EloquentSettingRepository.php | 10 +++++--- .../Tests/EloquentSettingRepositoryTest.php | 22 ++++++++++++++++ 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Modules/Setting/Events/SettingWasCreated.php b/Modules/Setting/Events/SettingWasCreated.php index 70d48b6a2..b10d6b99b 100644 --- a/Modules/Setting/Events/SettingWasCreated.php +++ b/Modules/Setting/Events/SettingWasCreated.php @@ -2,30 +2,17 @@ namespace Modules\Setting\Events; +use Modules\Setting\Entities\Setting; + class SettingWasCreated { /** - * @var bool - */ - public $isTranslatable; - /** - * @var string Setting name + * @var Setting */ - public $name; - /** - * @var string|array - */ - public $values; + public $setting; - /** - * @param $name - * @param $isTranslatable - * @param $values - */ - public function __construct($name, $isTranslatable, $values) + public function __construct(Setting $setting) { - $this->isTranslatable = $isTranslatable; - $this->name = $name; - $this->values = $values; + $this->setting = $setting; } } diff --git a/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php b/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php index 623b9cc7a..e8de00a2e 100644 --- a/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php +++ b/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Config; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; +use Modules\Setting\Entities\Setting; use Modules\Setting\Events\SettingWasCreated; use Modules\Setting\Events\SettingWasUpdated; use Modules\Setting\Repositories\SettingRepository; @@ -77,6 +78,7 @@ public function findByName($settingName) * Create a setting with the given name * @param string $settingName * @param $settingValues + * @return Setting */ private function createForName($settingName, $settingValues) { @@ -86,14 +88,16 @@ private function createForName($settingName, $settingValues) if ($this->isTranslatableSetting($settingName)) { $setting->isTranslatable = true; $this->setTranslatedAttributes($settingValues, $setting); - event(new SettingWasCreated($settingName, true, $settingValues)); } else { $setting->isTranslatable = false; $setting->plainValue = $this->getSettingPlainValue($settingValues); - event(new SettingWasCreated($settingName, false, $settingValues)); } - return $setting->save(); + $setting->save(); + + event(new SettingWasCreated($setting)); + + return $setting; } /** diff --git a/Modules/Setting/Tests/EloquentSettingRepositoryTest.php b/Modules/Setting/Tests/EloquentSettingRepositoryTest.php index ca1da43b8..9236829a2 100644 --- a/Modules/Setting/Tests/EloquentSettingRepositoryTest.php +++ b/Modules/Setting/Tests/EloquentSettingRepositoryTest.php @@ -2,6 +2,9 @@ namespace Modules\Setting\Tests; +use Illuminate\Support\Facades\Event; +use Modules\Setting\Events\SettingWasCreated; + class EloquentSettingRepositoryTest extends BaseSettingTest { public function setUp() @@ -111,4 +114,23 @@ public function it_encodes_array_of_non_translatable_data() $this->assertEquals('core::locales', $setting->name); $this->assertEquals('["su","bi","bs"]', $setting->plainValue); } + + /** @test */ + public function it_triggers_event_when_setting_was_created() + { + Event::fake(); + + $data = [ + 'core::template' => 'asgard', + 'core::site-name' => [ + 'en' => 'AsgardCMS_en', + 'fr' => 'AsgardCMS_fr', + ], + ]; + $this->settingRepository->createOrUpdate($data); + + Event::assertDispatched(SettingWasCreated::class, function ($e) { + return $e->setting->name === 'core::template'; + }); + } } From b0c4cdd3792fa7d4e6ba18fca2cd6df49a96b585 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 14:53:56 +0200 Subject: [PATCH 35/90] Normalise the setting was updated event --- Modules/Setting/Events/SettingWasUpdated.php | 25 +++++-------------- .../Eloquent/EloquentSettingRepository.php | 8 +++--- .../Tests/EloquentSettingRepositoryTest.php | 21 ++++++++++++++++ 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Modules/Setting/Events/SettingWasUpdated.php b/Modules/Setting/Events/SettingWasUpdated.php index 41a4de265..7a0da6a55 100644 --- a/Modules/Setting/Events/SettingWasUpdated.php +++ b/Modules/Setting/Events/SettingWasUpdated.php @@ -2,30 +2,17 @@ namespace Modules\Setting\Events; +use Modules\Setting\Entities\Setting; + class SettingWasUpdated { /** - * @var string The setting name - */ - public $name; - /** - * @var string|array - */ - public $values; - /** - * @var string|array Containing the old values - */ - public $oldValues; - /** - * @var bool + * @var Setting */ - public $isTranslatable; + public $setting; - public function __construct($name, $isTranslatable, $values, $oldValues = null) + public function __construct(Setting $setting) { - $this->name = $name; - $this->isTranslatable = $isTranslatable; - $this->values = $values; - $this->oldValues = $oldValues; + $this->setting = $setting; } } diff --git a/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php b/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php index e8de00a2e..0ad1dade0 100644 --- a/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php +++ b/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php @@ -111,14 +111,14 @@ private function updateSetting($setting, $settingValues) if ($this->isTranslatableSetting($name)) { $this->setTranslatedAttributes($settingValues, $setting); - event(new SettingWasUpdated($name, true, $settingValues)); } else { - $oldValues = $setting->plainValue; $setting->plainValue = $this->getSettingPlainValue($settingValues); - event(new SettingWasUpdated($name, false, $settingValues, $oldValues)); } + $setting->save(); + + event(new SettingWasUpdated($setting)); - return $setting->save(); + return $setting; } /** diff --git a/Modules/Setting/Tests/EloquentSettingRepositoryTest.php b/Modules/Setting/Tests/EloquentSettingRepositoryTest.php index 9236829a2..77d6150ce 100644 --- a/Modules/Setting/Tests/EloquentSettingRepositoryTest.php +++ b/Modules/Setting/Tests/EloquentSettingRepositoryTest.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Event; use Modules\Setting\Events\SettingWasCreated; +use Modules\Setting\Events\SettingWasUpdated; class EloquentSettingRepositoryTest extends BaseSettingTest { @@ -133,4 +134,24 @@ public function it_triggers_event_when_setting_was_created() return $e->setting->name === 'core::template'; }); } + + /** @test */ + public function it_triggers_event_when_setting_was_update() + { + Event::fake(); + + $data = [ + 'core::template' => 'asgard', + 'core::site-name' => [ + 'en' => 'AsgardCMS_en', + 'fr' => 'AsgardCMS_fr', + ], + ]; + $this->settingRepository->createOrUpdate($data); + $this->settingRepository->createOrUpdate(['core::template' => 'flatly']); + + Event::assertDispatched(SettingWasUpdated::class, function ($e) { + return $e->setting->name === 'core::template'; + }); + } } From dff456ead6fddce5d88186afd95168980e463c09 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 15:21:56 +0200 Subject: [PATCH 36/90] Triggering and using setting is creating/updating hooks --- Modules/Setting/Events/SettingIsCreating.php | 49 ++++++++ Modules/Setting/Events/SettingIsUpdating.php | 64 +++++++++++ .../Eloquent/EloquentSettingRepository.php | 13 ++- .../Tests/EloquentSettingRepositoryTest.php | 108 +++++++++++++++++- Modules/Setting/changelog.yml | 6 + 5 files changed, 235 insertions(+), 5 deletions(-) create mode 100644 Modules/Setting/Events/SettingIsCreating.php create mode 100644 Modules/Setting/Events/SettingIsUpdating.php diff --git a/Modules/Setting/Events/SettingIsCreating.php b/Modules/Setting/Events/SettingIsCreating.php new file mode 100644 index 000000000..d5ae59f22 --- /dev/null +++ b/Modules/Setting/Events/SettingIsCreating.php @@ -0,0 +1,49 @@ +settingName = $settingName; + $this->settingValues = $settingValues; + $this->original = $settingValues; + } + + /** + * @return mixed + */ + public function getSettingName() + { + return $this->settingName; + } + + /** + * @return mixed + */ + public function getSettingValues() + { + return $this->settingValues; + } + + /** + * @param mixed $settingValues + */ + public function setSettingValues($settingValues) + { + $this->settingValues = $settingValues; + } + + /** + * @return mixed + */ + public function getOriginal() + { + return $this->original; + } +} diff --git a/Modules/Setting/Events/SettingIsUpdating.php b/Modules/Setting/Events/SettingIsUpdating.php new file mode 100644 index 000000000..30aa4f56e --- /dev/null +++ b/Modules/Setting/Events/SettingIsUpdating.php @@ -0,0 +1,64 @@ +settingName = $settingName; + $this->settingValues = $settingValues; + $this->original = $settingValues; + $this->setting = $setting; + } + + /** + * @return mixed + */ + public function getSettingName() + { + return $this->settingName; + } + + /** + * @return mixed + */ + public function getSettingValues() + { + return $this->settingValues; + } + + /** + * @param mixed $settingValues + */ + public function setSettingValues($settingValues) + { + $this->settingValues = $settingValues; + } + + /** + * @return mixed + */ + public function getOriginal() + { + return $this->original; + } + + /** + * @return Setting + */ + public function getSetting() + { + return $this->setting; + } +} diff --git a/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php b/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php index 0ad1dade0..27e46d7bb 100644 --- a/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php +++ b/Modules/Setting/Repositories/Eloquent/EloquentSettingRepository.php @@ -5,6 +5,8 @@ use Illuminate\Support\Facades\Config; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; use Modules\Setting\Entities\Setting; +use Modules\Setting\Events\SettingIsCreating; +use Modules\Setting\Events\SettingIsUpdating; use Modules\Setting\Events\SettingWasCreated; use Modules\Setting\Events\SettingWasUpdated; use Modules\Setting\Repositories\SettingRepository; @@ -82,15 +84,17 @@ public function findByName($settingName) */ private function createForName($settingName, $settingValues) { + event($event = new SettingIsCreating($settingName, $settingValues)); + $setting = new $this->model(); $setting->name = $settingName; if ($this->isTranslatableSetting($settingName)) { $setting->isTranslatable = true; - $this->setTranslatedAttributes($settingValues, $setting); + $this->setTranslatedAttributes($event->getSettingValues(), $setting); } else { $setting->isTranslatable = false; - $setting->plainValue = $this->getSettingPlainValue($settingValues); + $setting->plainValue = $this->getSettingPlainValue($event->getSettingValues()); } $setting->save(); @@ -108,11 +112,12 @@ private function createForName($settingName, $settingValues) private function updateSetting($setting, $settingValues) { $name = $setting->name; + event($event = new SettingIsUpdating($setting, $name, $settingValues)); if ($this->isTranslatableSetting($name)) { - $this->setTranslatedAttributes($settingValues, $setting); + $this->setTranslatedAttributes($event->getSettingValues(), $setting); } else { - $setting->plainValue = $this->getSettingPlainValue($settingValues); + $setting->plainValue = $this->getSettingPlainValue($event->getSettingValues()); } $setting->save(); diff --git a/Modules/Setting/Tests/EloquentSettingRepositoryTest.php b/Modules/Setting/Tests/EloquentSettingRepositoryTest.php index 77d6150ce..021d49bff 100644 --- a/Modules/Setting/Tests/EloquentSettingRepositoryTest.php +++ b/Modules/Setting/Tests/EloquentSettingRepositoryTest.php @@ -3,6 +3,8 @@ namespace Modules\Setting\Tests; use Illuminate\Support\Facades\Event; +use Modules\Setting\Events\SettingIsCreating; +use Modules\Setting\Events\SettingIsUpdating; use Modules\Setting\Events\SettingWasCreated; use Modules\Setting\Events\SettingWasUpdated; @@ -136,7 +138,55 @@ public function it_triggers_event_when_setting_was_created() } /** @test */ - public function it_triggers_event_when_setting_was_update() + public function it_triggers_event_when_setting_is_creating() + { + Event::fake(); + + $data = [ + 'core::template' => 'asgard', + 'core::site-name' => [ + 'en' => 'AsgardCMS_en', + 'fr' => 'AsgardCMS_fr', + ], + ]; + $this->settingRepository->createOrUpdate($data); + + Event::assertDispatched(SettingIsCreating::class, function (SettingIsCreating $e) { + return $e->getSettingName() === 'core::template' && $e->getSettingValues() === 'asgard'; + }); + } + + /** @test */ + public function it_can_change_data_when_it_is_creating_event() + { + Event::listen(SettingIsCreating::class, function (SettingIsCreating $event) { + if ($event->getSettingName() === 'core::template') { + $event->setSettingValues('my-template'); + } + if ($event->getSettingName() === 'core::site-name') { + $event->setSettingValues([ + 'en' => 'English AsgardCMS' + ]); + } + }); + + $data = [ + 'core::template' => 'asgard', + 'blog::posts' => 10, + 'core::site-name' => [ + 'en' => 'AsgardCMS_en', + 'fr' => 'AsgardCMS_fr', + ], + ]; + $this->settingRepository->createOrUpdate($data); + + $this->assertEquals('my-template', $this->settingRepository->findByName('core::template')->plainValue); + $this->assertEquals(10, $this->settingRepository->findByName('blog::posts')->plainValue); + $this->assertEquals('English AsgardCMS', $this->settingRepository->findByName('core::site-name')->translate('en')->value); + } + + /** @test */ + public function it_triggers_event_when_setting_was_updated() { Event::fake(); @@ -154,4 +204,60 @@ public function it_triggers_event_when_setting_was_update() return $e->setting->name === 'core::template'; }); } + + /** @test */ + public function it_triggers_event_when_setting_is_updating() + { + Event::fake(); + + $data = [ + 'core::template' => 'asgard', + 'core::site-name' => [ + 'en' => 'AsgardCMS_en', + 'fr' => 'AsgardCMS_fr', + ], + ]; + $this->settingRepository->createOrUpdate($data); + $this->settingRepository->createOrUpdate(['core::template' => 'flatly']); + + Event::assertDispatched(SettingIsUpdating::class, function ($e) { + return $e->getSetting()->name === 'core::template'; + }); + } + + /** @test */ + public function it_can_change_date_when_updating_setting() + { + Event::listen(SettingIsUpdating::class, function (SettingIsUpdating $event) { + if ($event->getSettingName() === 'core::template') { + $event->setSettingValues('my-template'); + } + if ($event->getSettingName() === 'core::site-name') { + $event->setSettingValues([ + 'en' => 'English AsgardCMS' + ]); + } + }); + + $data = [ + 'core::template' => 'asgard', + 'blog::posts' => 10, + 'core::site-name' => [ + 'en' => 'AsgardCMS_en', + 'fr' => 'AsgardCMS_fr', + ], + ]; + $this->settingRepository->createOrUpdate($data); + $this->settingRepository->createOrUpdate([ + 'core::template' => 'flatly', + 'core::site-name' => [ + 'en' => 'The AsgardCMS_en', + 'fr' => 'The AsgardCMS_fr', + ], + ]); + + $this->assertEquals('my-template', $this->settingRepository->findByName('core::template')->plainValue); + $this->assertEquals(10, $this->settingRepository->findByName('blog::posts')->plainValue); + $this->assertEquals('English AsgardCMS', $this->settingRepository->findByName('core::site-name')->translate('en')->value); + } } diff --git a/Modules/Setting/changelog.yml b/Modules/Setting/changelog.yml index 6cef67b54..b00935576 100644 --- a/Modules/Setting/changelog.yml +++ b/Modules/Setting/changelog.yml @@ -1,5 +1,11 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + changed: + - Normalise the setting was created event + - Normalise the setting was updated event + - Trigger SettingIsCreating hook + - Trigger SettingIsUpdating hook "2.0.0": added: - Laravel 5.2 compatibility From 3438a7d5494d372b2a919c38be6f1c480bec78c9 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 15:41:59 +0200 Subject: [PATCH 37/90] Adding extra changelog items --- Modules/Menu/changelog.yml | 6 ++++++ Modules/User/changelog.yml | 2 ++ 2 files changed, 8 insertions(+) diff --git a/Modules/Menu/changelog.yml b/Modules/Menu/changelog.yml index 5f940596b..d243dafd9 100644 --- a/Modules/Menu/changelog.yml +++ b/Modules/Menu/changelog.yml @@ -1,5 +1,11 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + added: + - Trigger event before a menu is created (MenuIsCreating) allow data to be changed + - Trigger event before a menu is updated (MenuIsUpdating) allow data to be changed + - Trigger event before a menu item is created (MenuItemIsCreating) allow data to be changed + - Trigger event before a menu item is updated (MenuItemIsUpdating) allow data to be changed "2.2.0": changed: - Only registering the menus for the frontend part. diff --git a/Modules/User/changelog.yml b/Modules/User/changelog.yml index aab4dffb9..e12c009dd 100644 --- a/Modules/User/changelog.yml +++ b/Modules/User/changelog.yml @@ -3,6 +3,8 @@ versions: "2.5.0@unreleased": added: - Trigger an event (UserIsUpdating) before a user is updated + - Trigger an event (RoleIsCreating) before a role is created + - Trigger an event (RoleIsUpdating) before a role is updated "2.4.0": added: - Trigger an event (UserIsCreating) before a user is created, allowing customising its data via listeners From ebefec7248220cb80b3f0bdaafacb77295e72985 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 15:42:44 +0200 Subject: [PATCH 38/90] Renaming test class name to match the tested class --- .../{TagRepositoryTest.php => EloquentTagRepositoryTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Modules/Tag/Tests/Integration/{TagRepositoryTest.php => EloquentTagRepositoryTest.php} (95%) diff --git a/Modules/Tag/Tests/Integration/TagRepositoryTest.php b/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php similarity index 95% rename from Modules/Tag/Tests/Integration/TagRepositoryTest.php rename to Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php index d1af8b52c..4d50e6686 100644 --- a/Modules/Tag/Tests/Integration/TagRepositoryTest.php +++ b/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php @@ -5,7 +5,7 @@ use Modules\Tag\Repositories\TagRepository; use Modules\Tag\Tests\BaseTestCase; -class TagRepositoryTest extends BaseTestCase +class EloquentTagRepositoryTest extends BaseTestCase { /** * @var TagRepository From ef6948a0e1e4f1325211838d008c3b95105f8a27 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 15:47:25 +0200 Subject: [PATCH 39/90] Create and trigger events when tags are created and updated --- Modules/Tag/Events/TagWasCreated.php | 18 +++++++++ Modules/Tag/Events/TagWasUpdated.php | 18 +++++++++ .../Eloquent/EloquentTagRepository.php | 21 ++++++++++ .../Integration/EloquentTagRepositoryTest.php | 40 +++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 Modules/Tag/Events/TagWasCreated.php create mode 100644 Modules/Tag/Events/TagWasUpdated.php diff --git a/Modules/Tag/Events/TagWasCreated.php b/Modules/Tag/Events/TagWasCreated.php new file mode 100644 index 000000000..99ac7d1df --- /dev/null +++ b/Modules/Tag/Events/TagWasCreated.php @@ -0,0 +1,18 @@ +tag = $tag; + } +} diff --git a/Modules/Tag/Events/TagWasUpdated.php b/Modules/Tag/Events/TagWasUpdated.php new file mode 100644 index 000000000..6184fb8fa --- /dev/null +++ b/Modules/Tag/Events/TagWasUpdated.php @@ -0,0 +1,18 @@ +tag = $tag; + } +} diff --git a/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php b/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php index 6fcb96d84..64c181068 100644 --- a/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php +++ b/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php @@ -3,6 +3,8 @@ namespace Modules\Tag\Repositories\Eloquent; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; +use Modules\Tag\Events\TagWasCreated; +use Modules\Tag\Events\TagWasUpdated; use Modules\Tag\Repositories\TagRepository; class EloquentTagRepository extends EloquentBaseRepository implements TagRepository @@ -16,4 +18,23 @@ public function allForNamespace($namespace) { return $this->model->with('translations')->where('namespace', $namespace)->get(); } + + public function create($data) + { + $tag = $this->model->create($data); + + event(new TagWasCreated($tag)); + + return $tag; + } + + public function update($tag, $data) + { + $tag->update($data); + + event(new TagWasUpdated($tag)); + + return $tag; + } + } diff --git a/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php b/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php index 4d50e6686..e50f26c20 100644 --- a/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php +++ b/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php @@ -2,6 +2,9 @@ namespace Modules\Tag\Tests\Integration; +use Illuminate\Support\Facades\Event; +use Modules\Tag\Events\TagWasCreated; +use Modules\Tag\Events\TagWasUpdated; use Modules\Tag\Repositories\TagRepository; use Modules\Tag\Tests\BaseTestCase; @@ -46,4 +49,41 @@ public function it_gets_all_tags_for_a_namespace() $this->assertCount(1, $this->tag->allForNamespace('asgardcms/blog')); } + + /** @test */ + public function it_triggers_event_when_tag_was_created() + { + Event::fake(); + + $tag = $this->tag->create([ + 'namespace' => 'asgardcms/media', + 'en' => [ + 'slug' => 'media-tag', + 'name' => 'media tag', + ], + ]); + + Event::assertDispatched(TagWasCreated::class, function ($e) use ($tag) { + return $e->tag->id === $tag->id; + }); + } + + /** @test */ + public function it_triggers_event_when_tag_was_updated() + { + Event::fake(); + + $tag = $this->tag->create([ + 'namespace' => 'asgardcms/media', + 'en' => [ + 'slug' => 'media-tag', + 'name' => 'media tag', + ], + ]); + $this->tag->update($tag, []); + + Event::assertDispatched(TagWasUpdated::class, function ($e) use ($tag) { + return $e->tag->id === $tag->id; + }); + } } From 3997dc5fd692d711a416fbdf043748675a84e384 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 15:54:26 +0200 Subject: [PATCH 40/90] Creating and triggering event hooks when tags are creating and updating --- Modules/Tag/Events/TagIsCreating.php | 10 ++++ Modules/Tag/Events/TagIsUpdating.php | 29 ++++++++++ .../Eloquent/EloquentTagRepository.php | 8 ++- .../Integration/EloquentTagRepositoryTest.php | 57 +++++++++++++++++++ Modules/Tag/changelog.yml | 5 ++ 5 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 Modules/Tag/Events/TagIsCreating.php create mode 100644 Modules/Tag/Events/TagIsUpdating.php diff --git a/Modules/Tag/Events/TagIsCreating.php b/Modules/Tag/Events/TagIsCreating.php new file mode 100644 index 000000000..de0a12a96 --- /dev/null +++ b/Modules/Tag/Events/TagIsCreating.php @@ -0,0 +1,10 @@ +tag = $tag; + parent::__construct($attributes); + } + + /** + * @return Tag + */ + public function getTag() + { + return $this->tag; + } +} diff --git a/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php b/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php index 64c181068..ce1a8c872 100644 --- a/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php +++ b/Modules/Tag/Repositories/Eloquent/EloquentTagRepository.php @@ -3,6 +3,8 @@ namespace Modules\Tag\Repositories\Eloquent; use Modules\Core\Repositories\Eloquent\EloquentBaseRepository; +use Modules\Tag\Events\TagIsCreating; +use Modules\Tag\Events\TagIsUpdating; use Modules\Tag\Events\TagWasCreated; use Modules\Tag\Events\TagWasUpdated; use Modules\Tag\Repositories\TagRepository; @@ -21,7 +23,8 @@ public function allForNamespace($namespace) public function create($data) { - $tag = $this->model->create($data); + event($event = new TagIsCreating($data)); + $tag = $this->model->create($event->getAttributes()); event(new TagWasCreated($tag)); @@ -30,7 +33,8 @@ public function create($data) public function update($tag, $data) { - $tag->update($data); + event($event = new TagIsUpdating($tag, $data)); + $tag->update($event->getAttributes()); event(new TagWasUpdated($tag)); diff --git a/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php b/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php index e50f26c20..052930d6f 100644 --- a/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php +++ b/Modules/Tag/Tests/Integration/EloquentTagRepositoryTest.php @@ -3,6 +3,8 @@ namespace Modules\Tag\Tests\Integration; use Illuminate\Support\Facades\Event; +use Modules\Tag\Events\TagIsCreating; +use Modules\Tag\Events\TagIsUpdating; use Modules\Tag\Events\TagWasCreated; use Modules\Tag\Events\TagWasUpdated; use Modules\Tag\Repositories\TagRepository; @@ -68,6 +70,42 @@ public function it_triggers_event_when_tag_was_created() }); } + /** @test */ + public function it_triggers_event_when_tag_is_creating() + { + Event::fake(); + + $tag = $this->tag->create([ + 'namespace' => 'asgardcms/media', + 'en' => [ + 'slug' => 'media-tag', + 'name' => 'media tag', + ], + ]); + + Event::assertDispatched(TagIsCreating::class, function ($e) use ($tag) { + return $e->getAttribute('namespace') === $tag->namespace; + }); + } + + /** @test */ + public function it_can_change_data_when_it_is_creating_event() + { + Event::listen(TagIsCreating::class, function (TagIsCreating $event) { + $event->setAttributes(['en' => ['name' => 'MEDIA TAG']]); + }); + + $tag = $this->tag->create([ + 'namespace' => 'asgardcms/media', + 'en' => [ + 'slug' => 'media-tag', + 'name' => 'media tag', + ], + ]); + + $this->assertEquals('MEDIA TAG', $tag->translate('en')->name); + } + /** @test */ public function it_triggers_event_when_tag_was_updated() { @@ -86,4 +124,23 @@ public function it_triggers_event_when_tag_was_updated() return $e->tag->id === $tag->id; }); } + + /** @test */ + public function it_can_change_data_when_it_is_updating_event() + { + Event::listen(TagIsUpdating::class, function (TagIsUpdating $event) { + $event->setAttributes(['en' => ['name' => 'MEDIA TAG']]); + }); + + $tag = $this->tag->create([ + 'namespace' => 'asgardcms/media', + 'en' => [ + 'slug' => 'media-tag', + 'name' => 'media tag', + ], + ]); + $this->tag->update($tag, []); + + $this->assertEquals('MEDIA TAG', $tag->translate('en')->name); + } } diff --git a/Modules/Tag/changelog.yml b/Modules/Tag/changelog.yml index 2c854f36a..40cc6b0b0 100644 --- a/Modules/Tag/changelog.yml +++ b/Modules/Tag/changelog.yml @@ -1,5 +1,10 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0": + added: + - Create and trigger events when tags are created and updated + - Trigger event before a tag is created (TagIsCreating) allow data to be changed + - Trigger event before a tag is updated (TagIsUpdating) allow data to be changed "2.1.0": changed: - Fixed tags not being removed probably on update & delete From d50c9e153c99c2341ac8e300d824aeda201377f2 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 18:05:00 +0200 Subject: [PATCH 41/90] Setting up translation module to be tested --- Modules/Translation/Tests/.gitkeep | 0 .../Translation/Tests/BaseTranslationTest.php | 64 +++++++++++++++++++ .../EloquentTranslationRepositoryTest.php | 25 ++++++++ 3 files changed, 89 insertions(+) delete mode 100644 Modules/Translation/Tests/.gitkeep create mode 100644 Modules/Translation/Tests/BaseTranslationTest.php create mode 100644 Modules/Translation/Tests/EloquentTranslationRepositoryTest.php diff --git a/Modules/Translation/Tests/.gitkeep b/Modules/Translation/Tests/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/Modules/Translation/Tests/BaseTranslationTest.php b/Modules/Translation/Tests/BaseTranslationTest.php new file mode 100644 index 000000000..9bf46c977 --- /dev/null +++ b/Modules/Translation/Tests/BaseTranslationTest.php @@ -0,0 +1,64 @@ +resetDatabase(); + } + + protected function getPackageProviders($app) + { + return [ + LaravelModulesServiceProvider::class, + CoreServiceProvider::class, + TranslationServiceProvider::class, + LaravelLocalizationServiceProvider::class, + SidebarServiceProvider::class, + ]; + } + + protected function getPackageAliases($app) + { + return []; + } + + protected function getEnvironmentSetUp($app) + { + $app['path.base'] = __DIR__ . '/..'; + $app['config']->set('database.default', 'sqlite'); + $app['config']->set('database.connections.sqlite', array( + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + )); + $app['config']->set('translatable.locales', ['en', 'fr']); + } + + private function resetDatabase() + { + // Makes sure the migrations table is created + $this->artisan('migrate', [ + '--database' => 'sqlite', + ]); + // We empty all tables + $this->artisan('migrate:reset', [ + '--database' => 'sqlite', + ]); + // Migrate + $this->artisan('migrate', [ + '--database' => 'sqlite', + ]); + } +} diff --git a/Modules/Translation/Tests/EloquentTranslationRepositoryTest.php b/Modules/Translation/Tests/EloquentTranslationRepositoryTest.php new file mode 100644 index 000000000..f8348ce76 --- /dev/null +++ b/Modules/Translation/Tests/EloquentTranslationRepositoryTest.php @@ -0,0 +1,25 @@ +translation = app(TranslationRepository::class); + } + + /** @test */ + public function it_is_true() + { + $this->assertTrue(true); + } +} From 07fd5ab2201c7a84decc925bd33881ecd139c674 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 20:19:22 +0200 Subject: [PATCH 42/90] Adding stacks to the main template --- Themes/Adminlte/changelog.yml | 3 +++ Themes/Adminlte/views/layouts/master.blade.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Themes/Adminlte/changelog.yml b/Themes/Adminlte/changelog.yml index aaba5a846..d89c4bf70 100644 --- a/Themes/Adminlte/changelog.yml +++ b/Themes/Adminlte/changelog.yml @@ -1,5 +1,8 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0": + added: + - js-stack and css-stack stacks "2.4.0": changed: - Moved to using laravel.mix diff --git a/Themes/Adminlte/views/layouts/master.blade.php b/Themes/Adminlte/views/layouts/master.blade.php index 713a1ee41..1d68b3263 100644 --- a/Themes/Adminlte/views/layouts/master.blade.php +++ b/Themes/Adminlte/views/layouts/master.blade.php @@ -17,6 +17,7 @@ @include('partials.asgard-globals') @section('styles') @show + @stack('css-stack') @stop + +@if ($editor->getEditorJsPartial() !== null) + @include($editor->getEditorJsPartial()) +@endif diff --git a/Modules/Page/Resources/views/admin/edit.blade.php b/Modules/Page/Resources/views/admin/edit.blade.php index d43df1722..82647ddb0 100644 --- a/Modules/Page/Resources/views/admin/edit.blade.php +++ b/Modules/Page/Resources/views/admin/edit.blade.php @@ -109,3 +109,7 @@ class="flat-blue" }); @stop + +@if ($editor->getEditorJsPartial() !== null) + @include($editor->getEditorJsPartial()) +@endif diff --git a/Modules/Page/Resources/views/admin/partials/create-fields.blade.php b/Modules/Page/Resources/views/admin/partials/create-fields.blade.php index f23b6a2ad..dc728f513 100644 --- a/Modules/Page/Resources/views/admin/partials/create-fields.blade.php +++ b/Modules/Page/Resources/views/admin/partials/create-fields.blade.php @@ -12,7 +12,7 @@
{!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} - + {!! $errors->first("{$lang}.body", ':message') !!}
diff --git a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php index 176a19aba..6464fc32f 100644 --- a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php +++ b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php @@ -15,9 +15,7 @@
{!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} hasTranslation($lang) ? $page->translate($lang)->body : '' ?> - + {!! $errors->first("{$lang}.body", ':message') !!}
From 576d6ee746b61e42ffa290a858860feec61747d2 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:47:27 +0200 Subject: [PATCH 50/90] Create event handlers to load ckeditor or simplemde --- Modules/Core/Events/Handlers/LoadCkEditor.php | 16 ++++++++++++++++ Modules/Core/Events/Handlers/LoadSimpleMde.php | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Modules/Core/Events/Handlers/LoadCkEditor.php create mode 100644 Modules/Core/Events/Handlers/LoadSimpleMde.php diff --git a/Modules/Core/Events/Handlers/LoadCkEditor.php b/Modules/Core/Events/Handlers/LoadCkEditor.php new file mode 100644 index 000000000..ae7bcac04 --- /dev/null +++ b/Modules/Core/Events/Handlers/LoadCkEditor.php @@ -0,0 +1,16 @@ +addJs('ckeditor.js'); + $editor->setEditorClass('ckeditor'); + + return false; + } +} diff --git a/Modules/Core/Events/Handlers/LoadSimpleMde.php b/Modules/Core/Events/Handlers/LoadSimpleMde.php new file mode 100644 index 000000000..01d71c4ad --- /dev/null +++ b/Modules/Core/Events/Handlers/LoadSimpleMde.php @@ -0,0 +1,17 @@ +addJs('simplemde.js')->addCss('simplemde.css'); + $editor->setEditorClass('simplemde'); + $editor->setEditorJsPartial('core::partials.simplemde'); + + return false; + } +} From 241fb79de874fb2f4edcf05b49c4179ba8549de1 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:47:44 +0200 Subject: [PATCH 51/90] Create a ready to use handler to render markdown --- .../Core/Events/Handlers/RenderMarkdown.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Modules/Core/Events/Handlers/RenderMarkdown.php diff --git a/Modules/Core/Events/Handlers/RenderMarkdown.php b/Modules/Core/Events/Handlers/RenderMarkdown.php new file mode 100644 index 000000000..81a9b141e --- /dev/null +++ b/Modules/Core/Events/Handlers/RenderMarkdown.php @@ -0,0 +1,18 @@ +convertToHtml($event->getOriginal()); + + $event->setBody($html); + } +} From b687f874e212b2579ff7b05b57fced8333277e95 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:47:59 +0200 Subject: [PATCH 52/90] Create an EditorIsRendering Hook --- Modules/Core/Events/EditorIsRendering.php | 66 +++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Modules/Core/Events/EditorIsRendering.php diff --git a/Modules/Core/Events/EditorIsRendering.php b/Modules/Core/Events/EditorIsRendering.php new file mode 100644 index 000000000..af4eb34a6 --- /dev/null +++ b/Modules/Core/Events/EditorIsRendering.php @@ -0,0 +1,66 @@ +assetPipeline = $assetPipeline; + } + + public function addJs($asset) + { + $this->assetPipeline->requireJs($asset); + + return $this; + } + + public function addCss($asset) + { + $this->assetPipeline->requireCss($asset); + + return $this; + } + + /** + * @return mixed + */ + public function getEditorClass() + { + return $this->editorClass; + } + + /** + * @param mixed $editorClass + */ + public function setEditorClass($editorClass) + { + $this->editorClass = $editorClass; + } + + /** + * @return mixed + */ + public function getEditorJsPartial() + { + return $this->editorJsPartial; + } + + /** + * @param mixed $editorJsPartial + */ + public function setEditorJsPartial($editorJsPartial) + { + $this->editorJsPartial = $editorJsPartial; + } +} From 75ce82c9a1c6106ca723c89d61f3676648c01f2b Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:48:25 +0200 Subject: [PATCH 53/90] Configure the default editor to ckeditor --- Modules/Core/Config/core.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Modules/Core/Config/core.php b/Modules/Core/Config/core.php index d4b45263d..bd33c47f9 100644 --- a/Modules/Core/Config/core.php +++ b/Modules/Core/Config/core.php @@ -32,6 +32,18 @@ */ 'skin' => 'skin-blue', + /* + |-------------------------------------------------------------------------- + | WYSIWYG Backend Editor + |-------------------------------------------------------------------------- + | Define which editor you would like to use for the backend wysiwygs. + | These classes are event handlers, listening to EditorIsRendering + | you can define your own handlers and use them here + | Options: + | - \Modules\Core\Events\Handlers\LoadCkEditor::class + | - \Modules\Core\Events\Handlers\LoadSimpleMde::class + */ + 'wysiwyg-handler' => \Modules\Core\Events\Handlers\LoadCkEditor::class, /* |-------------------------------------------------------------------------- | Custom CKeditor configuration file From 6a28f2ff5b4b969617eb2b4f55dc940832ad8193 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:48:53 +0200 Subject: [PATCH 54/90] Bind the configured handler to the EditorIsRendering hook --- Modules/Core/Providers/CoreServiceProvider.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Core/Providers/CoreServiceProvider.php b/Modules/Core/Providers/CoreServiceProvider.php index 11e82dcbb..e2b2244da 100644 --- a/Modules/Core/Providers/CoreServiceProvider.php +++ b/Modules/Core/Providers/CoreServiceProvider.php @@ -12,6 +12,7 @@ use Modules\Core\Console\InstallCommand; use Modules\Core\Console\PublishModuleAssetsCommand; use Modules\Core\Console\PublishThemeAssetsCommand; +use Modules\Core\Events\EditorIsRendering; use Modules\Core\Foundation\Theme\ThemeManager; use Modules\Core\Traits\CanPublishConfiguration; use Nwidart\Modules\Module; @@ -53,6 +54,7 @@ public function boot() $this->registerModuleResourceNamespaces(); $this->bladeDirectives(); + $this->app['events']->listen(EditorIsRendering::class, config('asgard.core.core.wysiwyg-handler')); } /** From 826867f2a757a9551cca21b25a8ab813105c3c99 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:49:08 +0200 Subject: [PATCH 55/90] Create a partial to instantiate simplemde --- .../Resources/views/partials/simplemde.blade.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Modules/Core/Resources/views/partials/simplemde.blade.php diff --git a/Modules/Core/Resources/views/partials/simplemde.blade.php b/Modules/Core/Resources/views/partials/simplemde.blade.php new file mode 100644 index 000000000..e760fe2de --- /dev/null +++ b/Modules/Core/Resources/views/partials/simplemde.blade.php @@ -0,0 +1,12 @@ +@push('js-stack') + +@endpush From f568aaeff2fdbbd9b58f358882a5eed5b64ec9b3 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:50:00 +0200 Subject: [PATCH 56/90] Adding items to changelog --- Modules/Core/changelog.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/Core/changelog.yml b/Modules/Core/changelog.yml index 920750eca..141508093 100644 --- a/Modules/Core/changelog.yml +++ b/Modules/Core/changelog.yml @@ -4,6 +4,9 @@ versions: added: - Adding a EntityIsChanging interface to use on events which are triggered before a create / update action - Create an AbstractEntityHook containing base logic for entity hooks + - Trigger the EditorIsRendering event on assets view composer and send editor variable to view + - New configuration value wysiwyg-handler in config/asgard/core/core.php to change the editor in backend + - New handler RenderMarkdown if you want to render markdown on a ContentIsRendering event changed: - Adding more core modules (tag, translation and page). Preventing them to be disabled. "2.3.0": From 2d8c700f371e5eaa86cac4606621674f7c91244a Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:50:42 +0200 Subject: [PATCH 57/90] Adding items to changelog --- Modules/Page/changelog.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/Page/changelog.yml b/Modules/Page/changelog.yml index c3c178a08..934b2204e 100644 --- a/Modules/Page/changelog.yml +++ b/Modules/Page/changelog.yml @@ -4,6 +4,9 @@ versions: added: - Trigger event before a page is created (PageIsCreating) allow data to be changed - Trigger event before a page is updated (PageIsUpdating) allow data to be changed + changed: + - Requiring the editor assets via hook + - Making editor textarea dynamic "2.2.0": added: - Testing event trigger on page deletion From b8ec0c67bc3d802b007aca3e4f78f9d14b471085 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 21:52:08 +0200 Subject: [PATCH 58/90] Making BaseTranslation test abstract --- Modules/Translation/Tests/BaseTranslationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Translation/Tests/BaseTranslationTest.php b/Modules/Translation/Tests/BaseTranslationTest.php index 9bf46c977..4503c8050 100644 --- a/Modules/Translation/Tests/BaseTranslationTest.php +++ b/Modules/Translation/Tests/BaseTranslationTest.php @@ -9,7 +9,7 @@ use Nwidart\Modules\LaravelModulesServiceProvider; use Orchestra\Testbench\TestCase; -class BaseTranslationTest extends TestCase +abstract class BaseTranslationTest extends TestCase { public function setUp() { From 1e4117ce317cd29c76a1429f69b5e09bc62967c7 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 22:07:22 +0200 Subject: [PATCH 59/90] Publish the core module configuration --- config/asgard/core/core.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/config/asgard/core/core.php b/config/asgard/core/core.php index 18b0f1b4c..bd33c47f9 100644 --- a/config/asgard/core/core.php +++ b/config/asgard/core/core.php @@ -32,6 +32,18 @@ */ 'skin' => 'skin-blue', + /* + |-------------------------------------------------------------------------- + | WYSIWYG Backend Editor + |-------------------------------------------------------------------------- + | Define which editor you would like to use for the backend wysiwygs. + | These classes are event handlers, listening to EditorIsRendering + | you can define your own handlers and use them here + | Options: + | - \Modules\Core\Events\Handlers\LoadCkEditor::class + | - \Modules\Core\Events\Handlers\LoadSimpleMde::class + */ + 'wysiwyg-handler' => \Modules\Core\Events\Handlers\LoadCkEditor::class, /* |-------------------------------------------------------------------------- | Custom CKeditor configuration file @@ -84,7 +96,6 @@ 'selectize-default.css' => ['module' => 'core:vendor/selectize/dist/css/selectize.default.css'], 'animate.css' => ['theme' => 'vendor/animate.css/animate.min.css'], 'pace.css' => ['theme' => 'vendor/admin-lte/plugins/pace/pace.min.css'], - 'simplemde.css' => ['theme' => 'vendor/simplemde/dist/simplemde.min.css'], // Javascript 'bootstrap.js' => ['theme' => 'vendor/bootstrap/dist/js/bootstrap.min.js'], 'mousetrap.js' => ['theme' => 'js/vendor/mousetrap.min.js'], @@ -96,7 +107,6 @@ 'app.js' => ['theme' => 'vendor/admin-lte/dist/js/app.js'], 'keypressAction.js' => ['module' => 'core:js/keypressAction.js'], 'ckeditor.js' => ['theme' => 'js/vendor/ckeditor/ckeditor.js'], - 'simplemde.js' => ['theme' => 'vendor/simplemde/dist/simplemde.min.js'], 'lodash.js' => ['module' => 'dashboard:vendor/lodash/lodash.min.js'], 'jquery-ui-core.js' => ['module' => 'dashboard:vendor/jquery-ui/ui/minified/core.min.js'], 'jquery-ui-widget.js' => ['module' => 'dashboard:vendor/jquery-ui/ui/minified/widget.min.js'], From bd8ebbd8f88f9b23e30d2b8624f9c15493ee21de Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Wed, 12 Jul 2017 22:17:48 +0200 Subject: [PATCH 60/90] Adding ability to set a css partial view --- Modules/Core/Events/EditorIsRendering.php | 17 +++++++++++++++++ .../Page/Resources/views/admin/create.blade.php | 4 ++++ .../Page/Resources/views/admin/edit.blade.php | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/Modules/Core/Events/EditorIsRendering.php b/Modules/Core/Events/EditorIsRendering.php index af4eb34a6..9d5efacad 100644 --- a/Modules/Core/Events/EditorIsRendering.php +++ b/Modules/Core/Events/EditorIsRendering.php @@ -12,6 +12,7 @@ class EditorIsRendering private $assetPipeline; private $editorClass; private $editorJsPartial; + private $editorCssPartial; public function __construct(AssetPipeline $assetPipeline) { @@ -63,4 +64,20 @@ public function setEditorJsPartial($editorJsPartial) { $this->editorJsPartial = $editorJsPartial; } + + /** + * @return mixed + */ + public function getEditorCssPartial() + { + return $this->editorCssPartial; + } + + /** + * @param mixed $editorCssPartial + */ + public function setEditorCssPartial($editorCssPartial) + { + $this->editorCssPartial = $editorCssPartial; + } } diff --git a/Modules/Page/Resources/views/admin/create.blade.php b/Modules/Page/Resources/views/admin/create.blade.php index 9f69e4459..39a620c32 100644 --- a/Modules/Page/Resources/views/admin/create.blade.php +++ b/Modules/Page/Resources/views/admin/create.blade.php @@ -19,6 +19,10 @@ @stop +@if ($editor->getEditorCssPartial() !== null) + @include($editor->getEditorCssPartial()) +@endif + @section('content') {!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!}
diff --git a/Modules/Page/Resources/views/admin/edit.blade.php b/Modules/Page/Resources/views/admin/edit.blade.php index 82647ddb0..dab7522ac 100644 --- a/Modules/Page/Resources/views/admin/edit.blade.php +++ b/Modules/Page/Resources/views/admin/edit.blade.php @@ -19,6 +19,10 @@ @stop +@if ($editor->getEditorCssPartial() !== null) + @include($editor->getEditorCssPartial()) +@endif + @section('content') {!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!}
From f74230bfca98970ef0d69752de5c24cb8f97966a Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 10:39:20 +0200 Subject: [PATCH 61/90] Adding simplemde assets back to configuration --- Modules/Core/Config/core.php | 2 ++ config/asgard/core/core.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Modules/Core/Config/core.php b/Modules/Core/Config/core.php index bd33c47f9..67ec2a105 100644 --- a/Modules/Core/Config/core.php +++ b/Modules/Core/Config/core.php @@ -96,6 +96,7 @@ 'selectize-default.css' => ['module' => 'core:vendor/selectize/dist/css/selectize.default.css'], 'animate.css' => ['theme' => 'vendor/animate.css/animate.min.css'], 'pace.css' => ['theme' => 'vendor/admin-lte/plugins/pace/pace.min.css'], + 'simplemde.css' => ['theme' => 'vendor/simplemde/dist/simplemde.min.css'], // Javascript 'bootstrap.js' => ['theme' => 'vendor/bootstrap/dist/js/bootstrap.min.js'], 'mousetrap.js' => ['theme' => 'js/vendor/mousetrap.min.js'], @@ -122,6 +123,7 @@ 'pace.js' => ['theme' => 'vendor/admin-lte/plugins/pace/pace.min.js'], 'moment.js' => ['theme' => 'vendor/admin-lte/plugins/daterangepicker/moment.min.js'], 'clipboard.js' => ['theme' => 'vendor/clipboard/dist/clipboard.min.js'], + 'simplemde.js' => ['theme' => 'vendor/simplemde/dist/simplemde.min.js'], ], /* diff --git a/config/asgard/core/core.php b/config/asgard/core/core.php index bd33c47f9..67ec2a105 100644 --- a/config/asgard/core/core.php +++ b/config/asgard/core/core.php @@ -96,6 +96,7 @@ 'selectize-default.css' => ['module' => 'core:vendor/selectize/dist/css/selectize.default.css'], 'animate.css' => ['theme' => 'vendor/animate.css/animate.min.css'], 'pace.css' => ['theme' => 'vendor/admin-lte/plugins/pace/pace.min.css'], + 'simplemde.css' => ['theme' => 'vendor/simplemde/dist/simplemde.min.css'], // Javascript 'bootstrap.js' => ['theme' => 'vendor/bootstrap/dist/js/bootstrap.min.js'], 'mousetrap.js' => ['theme' => 'js/vendor/mousetrap.min.js'], @@ -122,6 +123,7 @@ 'pace.js' => ['theme' => 'vendor/admin-lte/plugins/pace/pace.min.js'], 'moment.js' => ['theme' => 'vendor/admin-lte/plugins/daterangepicker/moment.min.js'], 'clipboard.js' => ['theme' => 'vendor/clipboard/dist/clipboard.min.js'], + 'simplemde.js' => ['theme' => 'vendor/simplemde/dist/simplemde.min.js'], ], /* From 717065480747dcf5c938aced114dab1bf8d144a1 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 17:12:34 +0200 Subject: [PATCH 62/90] Moving the AbstractEntityHook to the Events namespace --- Modules/Core/{Abstracts => Events}/AbstractEntityHook.php | 2 +- Modules/Media/Events/FileIsCreating.php | 2 +- Modules/Media/Events/FileIsUpdating.php | 2 +- Modules/Menu/Events/MenuIsCreating.php | 2 +- Modules/Menu/Events/MenuIsUpdating.php | 2 +- Modules/Menu/Events/MenuItemIsCreating.php | 2 +- Modules/Menu/Events/MenuItemIsUpdating.php | 2 +- Modules/Page/Events/PageIsCreating.php | 2 +- Modules/Page/Events/PageIsUpdating.php | 2 +- Modules/Tag/Events/TagIsCreating.php | 2 +- Modules/Tag/Events/TagIsUpdating.php | 2 +- Modules/User/Events/RoleIsCreating.php | 2 +- Modules/User/Events/RoleIsUpdating.php | 2 +- Modules/User/Events/UserIsCreating.php | 2 +- Modules/User/Events/UserIsUpdating.php | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) rename Modules/Core/{Abstracts => Events}/AbstractEntityHook.php (97%) diff --git a/Modules/Core/Abstracts/AbstractEntityHook.php b/Modules/Core/Events/AbstractEntityHook.php similarity index 97% rename from Modules/Core/Abstracts/AbstractEntityHook.php rename to Modules/Core/Events/AbstractEntityHook.php index 82aeb52b8..6e10abd42 100644 --- a/Modules/Core/Abstracts/AbstractEntityHook.php +++ b/Modules/Core/Events/AbstractEntityHook.php @@ -1,6 +1,6 @@ Date: Fri, 14 Jul 2017 17:19:00 +0200 Subject: [PATCH 63/90] Removing old filters folder --- Modules/Page/Http/Filters/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Modules/Page/Http/Filters/.gitkeep diff --git a/Modules/Page/Http/Filters/.gitkeep b/Modules/Page/Http/Filters/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 85c13f9a338deeeb34db8c01e6cac47e2e32e476 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 17:31:25 +0200 Subject: [PATCH 64/90] removing gitkeep --- Modules/Page/Http/Controllers/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Modules/Page/Http/Controllers/.gitkeep diff --git a/Modules/Page/Http/Controllers/.gitkeep b/Modules/Page/Http/Controllers/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 4147cdac61e866671f995e71faa33c1eacdc1c65 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 17:32:01 +0200 Subject: [PATCH 65/90] Removing empty folders --- Modules/Page/Assets/.gitkeep | 0 Modules/Page/Console/.gitkeep | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Modules/Page/Assets/.gitkeep delete mode 100644 Modules/Page/Console/.gitkeep diff --git a/Modules/Page/Assets/.gitkeep b/Modules/Page/Assets/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/Modules/Page/Console/.gitkeep b/Modules/Page/Console/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 5f9684d48203bf97d1f3eed29ca2ce69298671fb Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 17:38:56 +0200 Subject: [PATCH 66/90] Removing obsolete asset call --- Modules/Page/Http/Controllers/Admin/PageController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/Page/Http/Controllers/Admin/PageController.php b/Modules/Page/Http/Controllers/Admin/PageController.php index 307483169..dd5330581 100644 --- a/Modules/Page/Http/Controllers/Admin/PageController.php +++ b/Modules/Page/Http/Controllers/Admin/PageController.php @@ -20,7 +20,6 @@ public function __construct(PageRepository $page) parent::__construct(); $this->page = $page; - $this->assetPipeline->requireCss('icheck.blue.css'); } public function index() From 363ed1945d66ba0cada124f5ac4660162325be7d Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 18:32:53 +0200 Subject: [PATCH 67/90] Create a CollectingAssets hook. Page module hooking into CollectingAssets to add iCheck --- Modules/Core/Composers/AssetsViewComposer.php | 2 + Modules/Core/Events/CollectingAssets.php | 65 +++++++++++++++++++ .../Page/Providers/PageServiceProvider.php | 16 +++++ 3 files changed, 83 insertions(+) create mode 100644 Modules/Core/Events/CollectingAssets.php diff --git a/Modules/Core/Composers/AssetsViewComposer.php b/Modules/Core/Composers/AssetsViewComposer.php index 30f84bee1..68ba9496f 100644 --- a/Modules/Core/Composers/AssetsViewComposer.php +++ b/Modules/Core/Composers/AssetsViewComposer.php @@ -4,6 +4,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Http\Request; +use Modules\Core\Events\CollectingAssets; use Modules\Core\Events\EditorIsRendering; use Modules\Core\Foundation\Asset\Manager\AssetManager; use Modules\Core\Foundation\Asset\Pipeline\AssetPipeline; @@ -50,6 +51,7 @@ public function compose(View $view) $this->assetPipeline->requireJs(config('asgard.core.core.admin-required-assets.js')); event($editor = new EditorIsRendering($this->assetPipeline)); + event(new CollectingAssets($this->assetPipeline)); $view->with('cssFiles', $this->assetPipeline->allCss()); $view->with('jsFiles', $this->assetPipeline->allJs()); diff --git a/Modules/Core/Events/CollectingAssets.php b/Modules/Core/Events/CollectingAssets.php new file mode 100644 index 000000000..c31827755 --- /dev/null +++ b/Modules/Core/Events/CollectingAssets.php @@ -0,0 +1,65 @@ +assetPipeline = $assetPipeline; + } + + /** + * @param string $asset + * @return AssetPipeline + */ + public function requireJs($asset) + { + return $this->assetPipeline->requireJs($asset); + } + + /** + * @param string $asset + * @return AssetPipeline + */ + public function requireCss($asset) + { + return $this->assetPipeline->requireCss($asset); + } + + /** + * Match a single route + * @param string|array $route + * @return bool + */ + public function onRoute($route) + { + $request = request(); + + return str_is($route, $request->route()->getName()); + } + + /** + * Match multiple routes + * @param array $routes + * @return bool + */ + public function onRoutes(array $routes) + { + $request = request(); + + foreach ($routes as $route) { + if (str_is($route, $request->route()->getName()) === true) { + return true; + } + } + return false; + } +} diff --git a/Modules/Page/Providers/PageServiceProvider.php b/Modules/Page/Providers/PageServiceProvider.php index 47721435a..1c3102acc 100644 --- a/Modules/Page/Providers/PageServiceProvider.php +++ b/Modules/Page/Providers/PageServiceProvider.php @@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Config; use Illuminate\Support\ServiceProvider; +use Modules\Core\Events\CollectingAssets; use Modules\Core\Traits\CanPublishConfiguration; use Modules\Page\Entities\Page; use Modules\Page\Repositories\Cache\CachePageDecorator; @@ -38,6 +39,8 @@ public function boot() $this->app[TagManager::class]->registerNamespace(new Page()); $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + $this->handleAssets(); } /** @@ -69,4 +72,17 @@ function () { } ); } + + /** + * Require iCheck on edit and create pages + */ + private function handleAssets() + { + $this->app['events']->listen(CollectingAssets::class, function (CollectingAssets $event) { + if ($event->onRoutes(['*page*create', '*page*edit'])) { + $event->requireCss('icheck.blue.css'); + $event->requireJs('icheck.js'); + } + }); + } } From 8dddeb0fdc349b1a2b01779fa977a2ede5e62c70 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 23:12:16 +0200 Subject: [PATCH 68/90] Create an use a textarea component to extract all complex logic out of the view(s) Ability to use a custom component if needed --- Modules/Core/Events/EditorIsRendering.php | 24 +++++++++++++++++++ .../views/components/i18n/textarea.blade.php | 14 +++++++++++ .../Resources/views/admin/create.blade.php | 8 ------- .../Page/Resources/views/admin/edit.blade.php | 8 ------- .../admin/partials/create-fields.blade.php | 9 ++++--- .../admin/partials/edit-fields.blade.php | 10 ++++---- 6 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 Modules/Core/Resources/views/components/i18n/textarea.blade.php diff --git a/Modules/Core/Events/EditorIsRendering.php b/Modules/Core/Events/EditorIsRendering.php index 9d5efacad..3c23e4536 100644 --- a/Modules/Core/Events/EditorIsRendering.php +++ b/Modules/Core/Events/EditorIsRendering.php @@ -13,6 +13,10 @@ class EditorIsRendering private $editorClass; private $editorJsPartial; private $editorCssPartial; + private $editorComponents = [ + 'i18n' => 'core::components.i18n.textarea', + 'normal' => 'core::components.textarea', + ]; public function __construct(AssetPipeline $assetPipeline) { @@ -80,4 +84,24 @@ public function setEditorCssPartial($editorCssPartial) { $this->editorCssPartial = $editorCssPartial; } + + public function getI18nComponentName() + { + return $this->editorComponents['i18n']; + } + + public function setI18nComponentName($componentName) + { + $this->editorComponents['i18n'] = $componentName; + } + + public function getNormalComponentName() + { + return $this->editorComponents['normal']; + } + + public function setNormalComponentName($componentName) + { + $this->editorComponents['normal'] = $componentName; + } } diff --git a/Modules/Core/Resources/views/components/i18n/textarea.blade.php b/Modules/Core/Resources/views/components/i18n/textarea.blade.php new file mode 100644 index 000000000..1c55df395 --- /dev/null +++ b/Modules/Core/Resources/views/components/i18n/textarea.blade.php @@ -0,0 +1,14 @@ +@if ($editor->getEditorCssPartial() !== null) + @include($editor->getEditorCssPartial()) +@endif + +
+ {!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} + + {!! $errors->first("{$lang}.body", ':message') !!} +
+ +@if ($editor->getEditorJsPartial() !== null) + @include($editor->getEditorJsPartial()) +@endif + diff --git a/Modules/Page/Resources/views/admin/create.blade.php b/Modules/Page/Resources/views/admin/create.blade.php index 39a620c32..cab086fc7 100644 --- a/Modules/Page/Resources/views/admin/create.blade.php +++ b/Modules/Page/Resources/views/admin/create.blade.php @@ -19,10 +19,6 @@ @stop -@if ($editor->getEditorCssPartial() !== null) - @include($editor->getEditorCssPartial()) -@endif - @section('content') {!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!}
@@ -106,7 +102,3 @@ class="flat-blue" }); @stop - -@if ($editor->getEditorJsPartial() !== null) - @include($editor->getEditorJsPartial()) -@endif diff --git a/Modules/Page/Resources/views/admin/edit.blade.php b/Modules/Page/Resources/views/admin/edit.blade.php index dab7522ac..d43df1722 100644 --- a/Modules/Page/Resources/views/admin/edit.blade.php +++ b/Modules/Page/Resources/views/admin/edit.blade.php @@ -19,10 +19,6 @@ @stop -@if ($editor->getEditorCssPartial() !== null) - @include($editor->getEditorCssPartial()) -@endif - @section('content') {!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!}
@@ -113,7 +109,3 @@ class="flat-blue" }); @stop - -@if ($editor->getEditorJsPartial() !== null) - @include($editor->getEditorJsPartial()) -@endif diff --git a/Modules/Page/Resources/views/admin/partials/create-fields.blade.php b/Modules/Page/Resources/views/admin/partials/create-fields.blade.php index dc728f513..2c76ad8e3 100644 --- a/Modules/Page/Resources/views/admin/partials/create-fields.blade.php +++ b/Modules/Page/Resources/views/admin/partials/create-fields.blade.php @@ -10,11 +10,10 @@ {!! Form::text("{$lang}[slug]", old("{$lang}.slug"), ['class' => 'form-control slug', 'data-slug' => 'target', 'placeholder' => trans('page::pages.form.slug')]) !!} {!! $errors->first("{$lang}.slug", ':message') !!}
-
- {!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} - - {!! $errors->first("{$lang}.body", ':message') !!} -
+ @component($editor->getI18nComponentName(), compact('lang')) + {{ old("{$lang}.body") }} + @endcomponent + @include($partial) diff --git a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php index 6464fc32f..eebf15e1a 100644 --- a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php +++ b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php @@ -12,12 +12,12 @@ {!! Form::text("{$lang}[slug]", old("{$lang}.slug", $old), ['class' => 'form-control slug', 'data-slug' => 'target', 'placeholder' => trans('page::pages.form.slug')]) !!} {!! $errors->first("{$lang}.slug", ':message') !!}
-
- {!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} + + @component($editor->getI18nComponentName(), compact('lang')) hasTranslation($lang) ? $page->translate($lang)->body : '' ?> - - {!! $errors->first("{$lang}.body", ':message') !!} -
+ {!! old("$lang.body", $old) !!} + @endcomponent + @include($partial) From 5c4e2cc148dd630e031875818516a49872be15fb Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Fri, 14 Jul 2017 23:16:15 +0200 Subject: [PATCH 69/90] simply the method names for non translatable inputs --- Modules/Core/Events/EditorIsRendering.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Core/Events/EditorIsRendering.php b/Modules/Core/Events/EditorIsRendering.php index 3c23e4536..27bc9c0f7 100644 --- a/Modules/Core/Events/EditorIsRendering.php +++ b/Modules/Core/Events/EditorIsRendering.php @@ -95,12 +95,12 @@ public function setI18nComponentName($componentName) $this->editorComponents['i18n'] = $componentName; } - public function getNormalComponentName() + public function getComponentName() { return $this->editorComponents['normal']; } - public function setNormalComponentName($componentName) + public function setComponentName($componentName) { $this->editorComponents['normal'] = $componentName; } From 1dfdda96ec0a4ecd4b60c94a111df1fefdfbe619 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sat, 15 Jul 2017 00:24:22 +0200 Subject: [PATCH 70/90] Create a helper function for easier access --- .../views/components/i18n/textarea-wrapper.blade.php | 3 +++ Modules/Core/helpers.php | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 Modules/Core/Resources/views/components/i18n/textarea-wrapper.blade.php diff --git a/Modules/Core/Resources/views/components/i18n/textarea-wrapper.blade.php b/Modules/Core/Resources/views/components/i18n/textarea-wrapper.blade.php new file mode 100644 index 000000000..c04f432b6 --- /dev/null +++ b/Modules/Core/Resources/views/components/i18n/textarea-wrapper.blade.php @@ -0,0 +1,3 @@ +@component($editor->getI18nComponentName(), compact('lang', 'fieldName', 'labelName')) + {!! $content !!} +@endcomponent diff --git a/Modules/Core/helpers.php b/Modules/Core/helpers.php index 251f4f821..c00af099a 100644 --- a/Modules/Core/helpers.php +++ b/Modules/Core/helpers.php @@ -33,3 +33,10 @@ function is_core_module($module) return in_array(strtolower($module), app('asgard.ModulesList')); } } + +if (! function_exists('asgard_i18n_editor')) { + function asgard_i18n_editor($fieldName, $labelName, $content, $lang) + { + return view('core::components.i18n.textarea-wrapper', compact('fieldName','labelName', 'content', 'lang')); + } +} From 6aebb0fa53f397dfe0f747157fc07bb0d334afc6 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sat, 15 Jul 2017 00:24:41 +0200 Subject: [PATCH 71/90] Create a blade directive to use @editor --- Modules/Core/Blade/AsgardEditorDirective.php | 32 +++++++++++++++++++ .../Blade/Facades/AsgardEditorDirective.php | 13 ++++++++ .../Core/Providers/CoreServiceProvider.php | 13 ++++++++ Modules/Core/module.json | 3 +- 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 Modules/Core/Blade/AsgardEditorDirective.php create mode 100644 Modules/Core/Blade/Facades/AsgardEditorDirective.php diff --git a/Modules/Core/Blade/AsgardEditorDirective.php b/Modules/Core/Blade/AsgardEditorDirective.php new file mode 100644 index 000000000..2b46d6d1a --- /dev/null +++ b/Modules/Core/Blade/AsgardEditorDirective.php @@ -0,0 +1,32 @@ +extractArguments($arguments); + + if ($this->lang !== null) { + return asgard_i18n_editor($this->fieldName, $this->labelName, $this->content, $this->lang); + } + } + + /** + * Extract the possible arguments as class properties + * @param array $arguments + */ + private function extractArguments(array $arguments) + { + $this->fieldName = array_get($arguments, 0); + $this->labelName = array_get($arguments, 1); + $this->content = array_get($arguments, 2); + $this->lang = array_get($arguments, 3); + } +} diff --git a/Modules/Core/Blade/Facades/AsgardEditorDirective.php b/Modules/Core/Blade/Facades/AsgardEditorDirective.php new file mode 100644 index 000000000..ad8db2a67 --- /dev/null +++ b/Modules/Core/Blade/Facades/AsgardEditorDirective.php @@ -0,0 +1,13 @@ +registerCommands(); $this->registerServices(); $this->setLocalesConfigurations(); + + $this->app->bind('core.asgard.editor', function () { + return new AsgardEditorDirective(); + }); } /** @@ -307,6 +312,10 @@ private function getCentralisedTranslationPath(Module $module) */ public function bladeDirectives() { + if (app()->environment() === 'testing') { + return; + } + /** * Set variable. * Usage: @set($variable, value) @@ -316,6 +325,10 @@ public function bladeDirectives() return ""; }); + + $this->app['blade.compiler']->directive('editor', function ($value) { + return ""; + }); } /** diff --git a/Modules/Core/module.json b/Modules/Core/module.json index c6a4d3685..f86d221a2 100644 --- a/Modules/Core/module.json +++ b/Modules/Core/module.json @@ -20,7 +20,8 @@ "aliases": { "Form": "Collective\\Html\\FormFacade", "Flash": "Laracasts\\Flash\\Flash", - "LaravelLocalization": "Mcamara\\LaravelLocalization\\Facades\\LaravelLocalization" + "LaravelLocalization": "Mcamara\\LaravelLocalization\\Facades\\LaravelLocalization", + "AsgardEditorDirective": "Modules\\Core\\Blade\\Facades\\AsgardEditorDirective" }, "files": [ "start.php", From 51ee8acb89802ef3e48a61357427e5bbabf921a9 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sat, 15 Jul 2017 00:25:09 +0200 Subject: [PATCH 72/90] Moving css and js stacks outside the component. Making field and label name dynamic --- .../views/components/i18n/textarea.blade.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Modules/Core/Resources/views/components/i18n/textarea.blade.php b/Modules/Core/Resources/views/components/i18n/textarea.blade.php index 1c55df395..48fe87ec2 100644 --- a/Modules/Core/Resources/views/components/i18n/textarea.blade.php +++ b/Modules/Core/Resources/views/components/i18n/textarea.blade.php @@ -1,14 +1,6 @@ -@if ($editor->getEditorCssPartial() !== null) - @include($editor->getEditorCssPartial()) -@endif - -
- {!! Form::label("{$lang}[body]", trans('page::pages.form.body')) !!} - - {!! $errors->first("{$lang}.body", ':message') !!} +
+ {!! Form::label("{$lang}[{$fieldName}]", $labelName) !!} + + {!! $errors->first("{$lang}.{$fieldName}", ':message') !!}
-@if ($editor->getEditorJsPartial() !== null) - @include($editor->getEditorJsPartial()) -@endif - From f296c292989be476dac85dde7b02a3b6164aaab7 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sat, 15 Jul 2017 00:25:37 +0200 Subject: [PATCH 73/90] Bringing back the js and css stacks on main views --- Modules/Page/Resources/views/admin/create.blade.php | 8 ++++++++ Modules/Page/Resources/views/admin/edit.blade.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Modules/Page/Resources/views/admin/create.blade.php b/Modules/Page/Resources/views/admin/create.blade.php index cab086fc7..39a620c32 100644 --- a/Modules/Page/Resources/views/admin/create.blade.php +++ b/Modules/Page/Resources/views/admin/create.blade.php @@ -19,6 +19,10 @@ @stop +@if ($editor->getEditorCssPartial() !== null) + @include($editor->getEditorCssPartial()) +@endif + @section('content') {!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!}
@@ -102,3 +106,7 @@ class="flat-blue" }); @stop + +@if ($editor->getEditorJsPartial() !== null) + @include($editor->getEditorJsPartial()) +@endif diff --git a/Modules/Page/Resources/views/admin/edit.blade.php b/Modules/Page/Resources/views/admin/edit.blade.php index d43df1722..dab7522ac 100644 --- a/Modules/Page/Resources/views/admin/edit.blade.php +++ b/Modules/Page/Resources/views/admin/edit.blade.php @@ -19,6 +19,10 @@ @stop +@if ($editor->getEditorCssPartial() !== null) + @include($editor->getEditorCssPartial()) +@endif + @section('content') {!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!}
@@ -109,3 +113,7 @@ class="flat-blue" }); @stop + +@if ($editor->getEditorJsPartial() !== null) + @include($editor->getEditorJsPartial()) +@endif From 99df22568aa5b9f22a1d97c114dece97e01dec72 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sat, 15 Jul 2017 00:26:00 +0200 Subject: [PATCH 74/90] Using new blade directives --- .../Resources/views/admin/partials/create-fields.blade.php | 5 ++--- .../Resources/views/admin/partials/edit-fields.blade.php | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Modules/Page/Resources/views/admin/partials/create-fields.blade.php b/Modules/Page/Resources/views/admin/partials/create-fields.blade.php index 2c76ad8e3..31699930d 100644 --- a/Modules/Page/Resources/views/admin/partials/create-fields.blade.php +++ b/Modules/Page/Resources/views/admin/partials/create-fields.blade.php @@ -10,9 +10,8 @@ {!! Form::text("{$lang}[slug]", old("{$lang}.slug"), ['class' => 'form-control slug', 'data-slug' => 'target', 'placeholder' => trans('page::pages.form.slug')]) !!} {!! $errors->first("{$lang}.slug", ':message') !!}
- @component($editor->getI18nComponentName(), compact('lang')) - {{ old("{$lang}.body") }} - @endcomponent + + @editor('body', trans('page::pages.form.body'), old("{$lang}.body"), $lang) diff --git a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php index eebf15e1a..abf34c45b 100644 --- a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php +++ b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php @@ -13,10 +13,7 @@ {!! $errors->first("{$lang}.slug", ':message') !!}
- @component($editor->getI18nComponentName(), compact('lang')) - hasTranslation($lang) ? $page->translate($lang)->body : '' ?> - {!! old("$lang.body", $old) !!} - @endcomponent + @editor('body', trans('page::pages.form.body'), old("$lang.body", $old), $lang) From 9acdc2b4c443335a85796aa98f19aa15416b3b34 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 14:13:22 +0200 Subject: [PATCH 75/90] Moving assets inclusion to component --- .../views/components/i18n/textarea.blade.php | 13 +++++++++++++ Modules/Page/Resources/views/admin/create.blade.php | 8 -------- Modules/Page/Resources/views/admin/edit.blade.php | 8 -------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Modules/Core/Resources/views/components/i18n/textarea.blade.php b/Modules/Core/Resources/views/components/i18n/textarea.blade.php index 48fe87ec2..1909b321c 100644 --- a/Modules/Core/Resources/views/components/i18n/textarea.blade.php +++ b/Modules/Core/Resources/views/components/i18n/textarea.blade.php @@ -1,6 +1,19 @@ +@if ($editor->getEditorCssPartial() !== null) + @if (Cache::store('array')->add('textareaCssLoaded', true, 100)) + @include($editor->getEditorCssPartial()) + @endif +@endif +
{!! Form::label("{$lang}[{$fieldName}]", $labelName) !!} {!! $errors->first("{$lang}.{$fieldName}", ':message') !!}
+@if ($editor->getEditorJsPartial() !== null) + @if (Cache::store('array')->add('textareaJsLoaded', true, 100)) + @include($editor->getEditorJsPartial()) + @endif +@endif + + diff --git a/Modules/Page/Resources/views/admin/create.blade.php b/Modules/Page/Resources/views/admin/create.blade.php index 39a620c32..cab086fc7 100644 --- a/Modules/Page/Resources/views/admin/create.blade.php +++ b/Modules/Page/Resources/views/admin/create.blade.php @@ -19,10 +19,6 @@ @stop -@if ($editor->getEditorCssPartial() !== null) - @include($editor->getEditorCssPartial()) -@endif - @section('content') {!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!}
@@ -106,7 +102,3 @@ class="flat-blue" }); @stop - -@if ($editor->getEditorJsPartial() !== null) - @include($editor->getEditorJsPartial()) -@endif diff --git a/Modules/Page/Resources/views/admin/edit.blade.php b/Modules/Page/Resources/views/admin/edit.blade.php index dab7522ac..d43df1722 100644 --- a/Modules/Page/Resources/views/admin/edit.blade.php +++ b/Modules/Page/Resources/views/admin/edit.blade.php @@ -19,10 +19,6 @@ @stop -@if ($editor->getEditorCssPartial() !== null) - @include($editor->getEditorCssPartial()) -@endif - @section('content') {!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!}
@@ -113,7 +109,3 @@ class="flat-blue" }); @stop - -@if ($editor->getEditorJsPartial() !== null) - @include($editor->getEditorJsPartial()) -@endif From 4f552936bd968cec85a265000ec1a39d74703462 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 14:20:14 +0200 Subject: [PATCH 76/90] Fixing field name variable echo --- Modules/Core/Resources/views/components/i18n/textarea.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Core/Resources/views/components/i18n/textarea.blade.php b/Modules/Core/Resources/views/components/i18n/textarea.blade.php index 1909b321c..bcc1a475a 100644 --- a/Modules/Core/Resources/views/components/i18n/textarea.blade.php +++ b/Modules/Core/Resources/views/components/i18n/textarea.blade.php @@ -6,7 +6,7 @@
{!! Form::label("{$lang}[{$fieldName}]", $labelName) !!} - + {!! $errors->first("{$lang}.{$fieldName}", ':message') !!}
From 10e9defa673d0b333b91a9ba03a6f301649dcb92 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 14:22:39 +0200 Subject: [PATCH 77/90] Creating a non translatable textarea component and make it usable with same @editor directive --- Modules/Core/Blade/AsgardEditorDirective.php | 1 + .../components/textarea-wrapper.blade.php | 3 +++ .../views/components/textarea.blade.php | 19 +++++++++++++++++++ Modules/Core/helpers.php | 8 ++++++++ 4 files changed, 31 insertions(+) create mode 100644 Modules/Core/Resources/views/components/textarea-wrapper.blade.php create mode 100644 Modules/Core/Resources/views/components/textarea.blade.php diff --git a/Modules/Core/Blade/AsgardEditorDirective.php b/Modules/Core/Blade/AsgardEditorDirective.php index 2b46d6d1a..128ac17a7 100644 --- a/Modules/Core/Blade/AsgardEditorDirective.php +++ b/Modules/Core/Blade/AsgardEditorDirective.php @@ -16,6 +16,7 @@ public function show($arguments) if ($this->lang !== null) { return asgard_i18n_editor($this->fieldName, $this->labelName, $this->content, $this->lang); } + return asgard_editor($this->fieldName, $this->labelName, $this->content); } /** diff --git a/Modules/Core/Resources/views/components/textarea-wrapper.blade.php b/Modules/Core/Resources/views/components/textarea-wrapper.blade.php new file mode 100644 index 000000000..d37506195 --- /dev/null +++ b/Modules/Core/Resources/views/components/textarea-wrapper.blade.php @@ -0,0 +1,3 @@ +@component($editor->getComponentName(), compact('fieldName', 'labelName')) + {!! $content !!} +@endcomponent diff --git a/Modules/Core/Resources/views/components/textarea.blade.php b/Modules/Core/Resources/views/components/textarea.blade.php new file mode 100644 index 000000000..c7413cef7 --- /dev/null +++ b/Modules/Core/Resources/views/components/textarea.blade.php @@ -0,0 +1,19 @@ +@if ($editor->getEditorCssPartial() !== null) + @if (Cache::store('array')->add('textareaCssLoaded', true, 100)) + @include($editor->getEditorCssPartial()) + @endif +@endif + +
+ {!! Form::label($fieldName, $labelName) !!} + + {!! $errors->first($fieldName, ':message') !!} +
+ +@if ($editor->getEditorJsPartial() !== null) + @if (Cache::store('array')->add('textareaJsLoaded', true, 100)) + @include($editor->getEditorJsPartial()) + @endif +@endif + + diff --git a/Modules/Core/helpers.php b/Modules/Core/helpers.php index c00af099a..bb44b7913 100644 --- a/Modules/Core/helpers.php +++ b/Modules/Core/helpers.php @@ -40,3 +40,11 @@ function asgard_i18n_editor($fieldName, $labelName, $content, $lang) return view('core::components.i18n.textarea-wrapper', compact('fieldName','labelName', 'content', 'lang')); } } + + +if (! function_exists('asgard_editor')) { + function asgard_editor($fieldName, $labelName, $content) + { + return view('core::components.textarea-wrapper', compact('fieldName','labelName', 'content')); + } +} From 3d82c7eb2fd0bab1fd38963722111d5e05b5ce35 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 14:24:40 +0200 Subject: [PATCH 78/90] Adding changelog item for core module --- Modules/Core/changelog.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Core/changelog.yml b/Modules/Core/changelog.yml index 141508093..07fce4721 100644 --- a/Modules/Core/changelog.yml +++ b/Modules/Core/changelog.yml @@ -7,6 +7,7 @@ versions: - Trigger the EditorIsRendering event on assets view composer and send editor variable to view - New configuration value wysiwyg-handler in config/asgard/core/core.php to change the editor in backend - New handler RenderMarkdown if you want to render markdown on a ContentIsRendering event + - New @editor('fieldname', 'fieldlabel, 'content', 'locale') blade directive to include a textarea. The last locale parameter is optional and can be omitted for non translatable textarea. changed: - Adding more core modules (tag, translation and page). Preventing them to be disabled. "2.3.0": From 50385c76ca90963b01f4ea8b1f3600fea3cec287 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 14:29:20 +0200 Subject: [PATCH 79/90] Adding back the correct old input for the body field --- .../Page/Resources/views/admin/partials/edit-fields.blade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php index abf34c45b..09871ce56 100644 --- a/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php +++ b/Modules/Page/Resources/views/admin/partials/edit-fields.blade.php @@ -13,6 +13,7 @@ {!! $errors->first("{$lang}.slug", ':message') !!}
+ hasTranslation($lang) ? $page->translate($lang)->body : '' ?> @editor('body', trans('page::pages.form.body'), old("$lang.body", $old), $lang) From 14ebd0c29d7d5b94643b32950a759687328b8cf9 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:29:04 +0200 Subject: [PATCH 80/90] Adding changelog item --- Modules/Page/changelog.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Page/changelog.yml b/Modules/Page/changelog.yml index 934b2204e..95d23e441 100644 --- a/Modules/Page/changelog.yml +++ b/Modules/Page/changelog.yml @@ -7,6 +7,7 @@ versions: changed: - Requiring the editor assets via hook - Making editor textarea dynamic + - Using the new @editor blade directive for the body textarea field "2.2.0": added: - Testing event trigger on page deletion From 1bb48928991638592685c064cb5c9cf959f065e1 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:33:28 +0200 Subject: [PATCH 81/90] Remove the ckeditor inclusion on create/edit view stubs --- Modules/Workshop/Scaffold/Module/stubs/create-view.stub | 4 ---- Modules/Workshop/Scaffold/Module/stubs/edit-view.stub | 4 ---- 2 files changed, 8 deletions(-) diff --git a/Modules/Workshop/Scaffold/Module/stubs/create-view.stub b/Modules/Workshop/Scaffold/Module/stubs/create-view.stub index 2cfd4c3ad..0a7ab02c6 100644 --- a/Modules/Workshop/Scaffold/Module/stubs/create-view.stub +++ b/Modules/Workshop/Scaffold/Module/stubs/create-view.stub @@ -11,10 +11,6 @@ @stop -@section('styles') - {!! Theme::script('js/vendor/ckeditor/ckeditor.js') !!} -@stop - @section('content') {!! Form::open(['route' => ['admin.$LOWERCASE_MODULE_NAME$.$LOWERCASE_CLASS_NAME$.store'], 'method' => 'post']) !!}
diff --git a/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub b/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub index fdab1230e..da5a50a8b 100644 --- a/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub +++ b/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub @@ -11,10 +11,6 @@ @stop -@section('styles') - {!! Theme::script('js/vendor/ckeditor/ckeditor.js') !!} -@stop - @section('content') {!! Form::open(['route' => ['admin.$LOWERCASE_MODULE_NAME$.$LOWERCASE_CLASS_NAME$.update', $$LOWERCASE_CLASS_NAME$->id], 'method' => 'put']) !!}
From 3ce5cc67a1a062667aa6537a1ba9cbf257f8d48d Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:33:40 +0200 Subject: [PATCH 82/90] New changelog item --- Modules/Page/changelog.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Modules/Page/changelog.yml b/Modules/Page/changelog.yml index 95d23e441..b21ece16c 100644 --- a/Modules/Page/changelog.yml +++ b/Modules/Page/changelog.yml @@ -8,6 +8,7 @@ versions: - Requiring the editor assets via hook - Making editor textarea dynamic - Using the new @editor blade directive for the body textarea field + - Remove the ckeditor inclusion on create/edit view stubs "2.2.0": added: - Testing event trigger on page deletion From 4c8a01e4058129e68bfc395fb9fbae8866bf20ad Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:42:59 +0200 Subject: [PATCH 83/90] Using the @push css stacks over the styles section --- Modules/Dashboard/Resources/views/admin/dashboard.blade.php | 4 ++-- Modules/Media/Resources/views/admin/index.blade.php | 4 ++-- Modules/Menu/Resources/views/admin/menuitems/create.blade.php | 3 --- Modules/Menu/Resources/views/admin/menuitems/edit.blade.php | 3 --- Modules/Menu/Resources/views/admin/menus/create.blade.php | 3 --- Modules/Menu/Resources/views/admin/menus/edit.blade.php | 4 ++-- Modules/Page/Resources/views/admin/create.blade.php | 4 ++-- Modules/Page/Resources/views/admin/edit.blade.php | 4 ++-- Modules/Tag/Resources/views/admin/tags/create.blade.php | 3 --- Modules/Tag/Resources/views/admin/tags/edit.blade.php | 4 ---- .../Workshop/Resources/views/admin/modules/index.blade.php | 4 ++-- Modules/Workshop/Resources/views/admin/modules/show.blade.php | 2 +- Modules/Workshop/Resources/views/admin/themes/index.blade.php | 4 ++-- Modules/Workshop/Resources/views/admin/themes/show.blade.php | 4 ++-- 14 files changed, 17 insertions(+), 33 deletions(-) diff --git a/Modules/Dashboard/Resources/views/admin/dashboard.blade.php b/Modules/Dashboard/Resources/views/admin/dashboard.blade.php index aea76b944..df23a0834 100644 --- a/Modules/Dashboard/Resources/views/admin/dashboard.blade.php +++ b/Modules/Dashboard/Resources/views/admin/dashboard.blade.php @@ -12,13 +12,13 @@
@stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content') diff --git a/Modules/Media/Resources/views/admin/index.blade.php b/Modules/Media/Resources/views/admin/index.blade.php index 34b8c8b14..bcc5cebbe 100644 --- a/Modules/Media/Resources/views/admin/index.blade.php +++ b/Modules/Media/Resources/views/admin/index.blade.php @@ -10,7 +10,7 @@ @stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content')
diff --git a/Modules/Menu/Resources/views/admin/menuitems/create.blade.php b/Modules/Menu/Resources/views/admin/menuitems/create.blade.php index ed56aaa37..9d8736335 100644 --- a/Modules/Menu/Resources/views/admin/menuitems/create.blade.php +++ b/Modules/Menu/Resources/views/admin/menuitems/create.blade.php @@ -11,9 +11,6 @@ @stop -@section('styles') -@stop - @section('content') {!! Form::open(['route' => ['dashboard.menuitem.store', $menu->id], 'method' => 'post']) !!}
diff --git a/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php b/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php index bf786f96b..c032182a6 100644 --- a/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php +++ b/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php @@ -11,9 +11,6 @@ @stop -@section('styles') -@stop - @section('content') {!! Form::open(['route' => ['dashboard.menuitem.update', $menu->id, $menuItem->id], 'method' => 'put']) !!}
diff --git a/Modules/Menu/Resources/views/admin/menus/create.blade.php b/Modules/Menu/Resources/views/admin/menus/create.blade.php index 1b650fd50..4e1fdaf80 100644 --- a/Modules/Menu/Resources/views/admin/menus/create.blade.php +++ b/Modules/Menu/Resources/views/admin/menus/create.blade.php @@ -11,9 +11,6 @@ @stop -@section('styles') -@stop - @section('content') {!! Form::open(['route' => ['admin.menu.menu.store'], 'method' => 'post']) !!}
diff --git a/Modules/Menu/Resources/views/admin/menus/edit.blade.php b/Modules/Menu/Resources/views/admin/menus/edit.blade.php index 8d6a736bc..284a41b3d 100644 --- a/Modules/Menu/Resources/views/admin/menus/edit.blade.php +++ b/Modules/Menu/Resources/views/admin/menus/edit.blade.php @@ -11,9 +11,9 @@ @stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content') {!! Form::open(['route' => ['admin.menu.menu.update', $menu->id], 'method' => 'put']) !!} diff --git a/Modules/Page/Resources/views/admin/create.blade.php b/Modules/Page/Resources/views/admin/create.blade.php index cab086fc7..1d606c5df 100644 --- a/Modules/Page/Resources/views/admin/create.blade.php +++ b/Modules/Page/Resources/views/admin/create.blade.php @@ -11,13 +11,13 @@ @stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content') {!! Form::open(['route' => ['admin.page.page.store'], 'method' => 'post']) !!} diff --git a/Modules/Page/Resources/views/admin/edit.blade.php b/Modules/Page/Resources/views/admin/edit.blade.php index d43df1722..95eb8df5f 100644 --- a/Modules/Page/Resources/views/admin/edit.blade.php +++ b/Modules/Page/Resources/views/admin/edit.blade.php @@ -11,13 +11,13 @@ @stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content') {!! Form::open(['route' => ['admin.page.page.update', $page->id], 'method' => 'put']) !!} diff --git a/Modules/Tag/Resources/views/admin/tags/create.blade.php b/Modules/Tag/Resources/views/admin/tags/create.blade.php index 46aa65c05..7c1f51332 100644 --- a/Modules/Tag/Resources/views/admin/tags/create.blade.php +++ b/Modules/Tag/Resources/views/admin/tags/create.blade.php @@ -11,9 +11,6 @@ @stop -@section('styles') -@stop - @section('content') {!! Form::open(['route' => ['admin.tag.tag.store'], 'method' => 'post']) !!}
diff --git a/Modules/Tag/Resources/views/admin/tags/edit.blade.php b/Modules/Tag/Resources/views/admin/tags/edit.blade.php index 3d8deb6dd..348111754 100644 --- a/Modules/Tag/Resources/views/admin/tags/edit.blade.php +++ b/Modules/Tag/Resources/views/admin/tags/edit.blade.php @@ -11,10 +11,6 @@ @stop -@section('styles') - {!! Theme::script('js/vendor/ckeditor/ckeditor.js') !!} -@stop - @section('content') {!! Form::open(['route' => ['admin.tag.tag.update', $tag->id], 'method' => 'put']) !!}
diff --git a/Modules/Workshop/Resources/views/admin/modules/index.blade.php b/Modules/Workshop/Resources/views/admin/modules/index.blade.php index 0777b7b85..8e7c0ffee 100644 --- a/Modules/Workshop/Resources/views/admin/modules/index.blade.php +++ b/Modules/Workshop/Resources/views/admin/modules/index.blade.php @@ -10,13 +10,13 @@ @stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content')
diff --git a/Modules/Workshop/Resources/views/admin/modules/show.blade.php b/Modules/Workshop/Resources/views/admin/modules/show.blade.php index 99a4351b1..c81d3214a 100644 --- a/Modules/Workshop/Resources/views/admin/modules/show.blade.php +++ b/Modules/Workshop/Resources/views/admin/modules/show.blade.php @@ -17,7 +17,7 @@ @stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content')
diff --git a/Modules/Workshop/Resources/views/admin/themes/show.blade.php b/Modules/Workshop/Resources/views/admin/themes/show.blade.php index 24d2cc12d..176199c27 100644 --- a/Modules/Workshop/Resources/views/admin/themes/show.blade.php +++ b/Modules/Workshop/Resources/views/admin/themes/show.blade.php @@ -17,7 +17,7 @@ @stop -@section('styles') +@push('css-stack') -@stop +@endpush @section('content')
From da64d7c8f6ce60dea33359e046cd26e5ed61aed6 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:48:39 +0200 Subject: [PATCH 84/90] Using the @push js stacks over the scripts section --- Modules/Dashboard/Resources/views/admin/dashboard.blade.php | 4 ++-- Modules/Media/Resources/views/admin/edit.blade.php | 4 ++-- Modules/Media/Resources/views/admin/index.blade.php | 4 ++-- .../Menu/Resources/views/admin/menuitems/create.blade.php | 4 ++-- Modules/Menu/Resources/views/admin/menuitems/edit.blade.php | 4 ++-- Modules/Menu/Resources/views/admin/menus/create.blade.php | 4 ++-- Modules/Menu/Resources/views/admin/menus/edit.blade.php | 4 ++-- Modules/Menu/Resources/views/admin/menus/index.blade.php | 4 ++-- Modules/Page/Resources/views/admin/create.blade.php | 4 ++-- Modules/Page/Resources/views/admin/edit.blade.php | 4 ++-- Modules/Page/Resources/views/admin/index.blade.php | 4 ++-- .../Setting/Resources/views/admin/module-settings.blade.php | 4 ++-- Modules/Tag/Resources/views/admin/tags/create.blade.php | 4 ++-- Modules/Tag/Resources/views/admin/tags/edit.blade.php | 4 ++-- Modules/Tag/Resources/views/admin/tags/index.blade.php | 4 ++-- .../Resources/views/admin/translations/index.blade.php | 4 ++-- .../Resources/views/admin/account/api-keys/index.blade.php | 4 ++-- .../Resources/views/admin/account/profile/edit.blade.php | 5 +++-- Modules/User/Resources/views/admin/roles/create.blade.php | 5 +++-- Modules/User/Resources/views/admin/roles/edit.blade.php | 5 +++-- Modules/User/Resources/views/admin/roles/index.blade.php | 4 ++-- Modules/User/Resources/views/admin/users/create.blade.php | 5 +++-- Modules/User/Resources/views/admin/users/edit.blade.php | 5 +++-- Modules/User/Resources/views/admin/users/index.blade.php | 4 ++-- .../Workshop/Resources/views/admin/modules/index.blade.php | 4 ++-- .../Workshop/Resources/views/admin/modules/show.blade.php | 4 ++-- .../Workshop/Resources/views/admin/themes/index.blade.php | 4 ++-- Modules/Workshop/Resources/views/admin/themes/show.blade.php | 4 ++-- .../Workshop/Resources/views/admin/workbench/index.blade.php | 4 ++-- Modules/Workshop/Scaffold/Module/stubs/create-view.stub | 4 ++-- Modules/Workshop/Scaffold/Module/stubs/edit-view.stub | 4 ++-- Modules/Workshop/Scaffold/Module/stubs/index-view.stub | 4 ++-- 32 files changed, 69 insertions(+), 64 deletions(-) diff --git a/Modules/Dashboard/Resources/views/admin/dashboard.blade.php b/Modules/Dashboard/Resources/views/admin/dashboard.blade.php index df23a0834..b4485bb82 100644 --- a/Modules/Dashboard/Resources/views/admin/dashboard.blade.php +++ b/Modules/Dashboard/Resources/views/admin/dashboard.blade.php @@ -46,7 +46,7 @@
@stop -@section('scripts') +@push('js-stack') @parent -@stop +@endpush diff --git a/Modules/Media/Resources/views/admin/edit.blade.php b/Modules/Media/Resources/views/admin/edit.blade.php index 91b07e7f1..d601d0206 100644 --- a/Modules/Media/Resources/views/admin/edit.blade.php +++ b/Modules/Media/Resources/views/admin/edit.blade.php @@ -75,7 +75,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Media/Resources/views/admin/index.blade.php b/Modules/Media/Resources/views/admin/index.blade.php index bcc5cebbe..073a633dd 100644 --- a/Modules/Media/Resources/views/admin/index.blade.php +++ b/Modules/Media/Resources/views/admin/index.blade.php @@ -91,7 +91,7 @@ @include('core::partials.delete-modal') @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Menu/Resources/views/admin/menuitems/create.blade.php b/Modules/Menu/Resources/views/admin/menuitems/create.blade.php index 9d8736335..aa396a207 100644 --- a/Modules/Menu/Resources/views/admin/menuitems/create.blade.php +++ b/Modules/Menu/Resources/views/admin/menuitems/create.blade.php @@ -87,7 +87,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php b/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php index c032182a6..a80ba9c19 100644 --- a/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php +++ b/Modules/Menu/Resources/views/admin/menuitems/edit.blade.php @@ -93,7 +93,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Menu/Resources/views/admin/menus/create.blade.php b/Modules/Menu/Resources/views/admin/menus/create.blade.php index 4e1fdaf80..9741eee5d 100644 --- a/Modules/Menu/Resources/views/admin/menus/create.blade.php +++ b/Modules/Menu/Resources/views/admin/menus/create.blade.php @@ -69,7 +69,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Menu/Resources/views/admin/menus/edit.blade.php b/Modules/Menu/Resources/views/admin/menus/edit.blade.php index 284a41b3d..36b6ce90c 100644 --- a/Modules/Menu/Resources/views/admin/menus/edit.blade.php +++ b/Modules/Menu/Resources/views/admin/menus/edit.blade.php @@ -89,7 +89,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Menu/Resources/views/admin/menus/index.blade.php b/Modules/Menu/Resources/views/admin/menus/index.blade.php index ba44d3d75..cfa52b1c1 100644 --- a/Modules/Menu/Resources/views/admin/menus/index.blade.php +++ b/Modules/Menu/Resources/views/admin/menus/index.blade.php @@ -107,7 +107,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Page/Resources/views/admin/create.blade.php b/Modules/Page/Resources/views/admin/create.blade.php index 1d606c5df..db5c10b37 100644 --- a/Modules/Page/Resources/views/admin/create.blade.php +++ b/Modules/Page/Resources/views/admin/create.blade.php @@ -87,7 +87,7 @@ class="flat-blue" @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Page/Resources/views/admin/edit.blade.php b/Modules/Page/Resources/views/admin/edit.blade.php index 95eb8df5f..27f53d800 100644 --- a/Modules/Page/Resources/views/admin/edit.blade.php +++ b/Modules/Page/Resources/views/admin/edit.blade.php @@ -94,7 +94,7 @@ class="flat-blue" @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Page/Resources/views/admin/index.blade.php b/Modules/Page/Resources/views/admin/index.blade.php index 58b8d6967..aaef45527 100644 --- a/Modules/Page/Resources/views/admin/index.blade.php +++ b/Modules/Page/Resources/views/admin/index.blade.php @@ -98,7 +98,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Setting/Resources/views/admin/module-settings.blade.php b/Modules/Setting/Resources/views/admin/module-settings.blade.php index 8e1640d5c..58d8b72ee 100644 --- a/Modules/Setting/Resources/views/admin/module-settings.blade.php +++ b/Modules/Setting/Resources/views/admin/module-settings.blade.php @@ -79,7 +79,7 @@ class="{{ $module == $currentModule->getLowerName() ? 'active' : '' }}"> {!! Form::close() !!} @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Tag/Resources/views/admin/tags/create.blade.php b/Modules/Tag/Resources/views/admin/tags/create.blade.php index 7c1f51332..d04130866 100644 --- a/Modules/Tag/Resources/views/admin/tags/create.blade.php +++ b/Modules/Tag/Resources/views/admin/tags/create.blade.php @@ -58,7 +58,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Tag/Resources/views/admin/tags/edit.blade.php b/Modules/Tag/Resources/views/admin/tags/edit.blade.php index 348111754..9e24c027c 100644 --- a/Modules/Tag/Resources/views/admin/tags/edit.blade.php +++ b/Modules/Tag/Resources/views/admin/tags/edit.blade.php @@ -58,7 +58,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Tag/Resources/views/admin/tags/index.blade.php b/Modules/Tag/Resources/views/admin/tags/index.blade.php index 876bba18f..41bc6669f 100644 --- a/Modules/Tag/Resources/views/admin/tags/index.blade.php +++ b/Modules/Tag/Resources/views/admin/tags/index.blade.php @@ -83,7 +83,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Translation/Resources/views/admin/translations/index.blade.php b/Modules/Translation/Resources/views/admin/translations/index.blade.php index 7eac135c4..701c2c6fc 100644 --- a/Modules/Translation/Resources/views/admin/translations/index.blade.php +++ b/Modules/Translation/Resources/views/admin/translations/index.blade.php @@ -121,7 +121,7 @@ @stop -@section('scripts') +@push('js-stack') has('file')): ?> -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/account/api-keys/index.blade.php b/Modules/User/Resources/views/admin/account/api-keys/index.blade.php index 7f5ee08cd..94d6a2bfb 100644 --- a/Modules/User/Resources/views/admin/account/api-keys/index.blade.php +++ b/Modules/User/Resources/views/admin/account/api-keys/index.blade.php @@ -62,7 +62,7 @@ @include('core::partials.delete-modal') @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/account/profile/edit.blade.php b/Modules/User/Resources/views/admin/account/profile/edit.blade.php index 450475714..d88ee216e 100644 --- a/Modules/User/Resources/views/admin/account/profile/edit.blade.php +++ b/Modules/User/Resources/views/admin/account/profile/edit.blade.php @@ -62,7 +62,8 @@ @stop @section('shortcuts') @stop -@section('scripts') + +@push('js-stack') -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/roles/create.blade.php b/Modules/User/Resources/views/admin/roles/create.blade.php index 20b2323e5..c8415bedf 100644 --- a/Modules/User/Resources/views/admin/roles/create.blade.php +++ b/Modules/User/Resources/views/admin/roles/create.blade.php @@ -61,7 +61,8 @@
{{ trans('user::roles.navigation.back to index') }}
@stop -@section('scripts') + +@push('js-stack') -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/roles/edit.blade.php b/Modules/User/Resources/views/admin/roles/edit.blade.php index 0ce269891..4e601f428 100644 --- a/Modules/User/Resources/views/admin/roles/edit.blade.php +++ b/Modules/User/Resources/views/admin/roles/edit.blade.php @@ -80,7 +80,8 @@
{{ trans('user::roles.navigation.back to index') }}
@stop -@section('scripts') + +@push('js-stack') -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/roles/index.blade.php b/Modules/User/Resources/views/admin/roles/index.blade.php index 8a3ea5aff..2bd03b028 100644 --- a/Modules/User/Resources/views/admin/roles/index.blade.php +++ b/Modules/User/Resources/views/admin/roles/index.blade.php @@ -82,7 +82,7 @@ @include('core::partials.delete-modal') @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/users/create.blade.php b/Modules/User/Resources/views/admin/users/create.blade.php index a21454678..b791f3a3b 100644 --- a/Modules/User/Resources/views/admin/users/create.blade.php +++ b/Modules/User/Resources/views/admin/users/create.blade.php @@ -113,7 +113,8 @@
{{ trans('user::users.navigation.back to index') }}
@stop -@section('scripts') + +@push('js-stack') -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/users/edit.blade.php b/Modules/User/Resources/views/admin/users/edit.blade.php index f976cde2c..750922ef6 100644 --- a/Modules/User/Resources/views/admin/users/edit.blade.php +++ b/Modules/User/Resources/views/admin/users/edit.blade.php @@ -135,7 +135,8 @@ class="flat-blue"
{{ trans('user::users.navigation.back to index') }}
@stop -@section('scripts') + +@push('js-stack') -@stop +@endpush diff --git a/Modules/User/Resources/views/admin/users/index.blade.php b/Modules/User/Resources/views/admin/users/index.blade.php index c3980cced..dfc23e312 100644 --- a/Modules/User/Resources/views/admin/users/index.blade.php +++ b/Modules/User/Resources/views/admin/users/index.blade.php @@ -99,7 +99,7 @@ @include('core::partials.delete-modal') @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Resources/views/admin/modules/index.blade.php b/Modules/Workshop/Resources/views/admin/modules/index.blade.php index 8e7c0ffee..385e91f0b 100644 --- a/Modules/Workshop/Resources/views/admin/modules/index.blade.php +++ b/Modules/Workshop/Resources/views/admin/modules/index.blade.php @@ -75,7 +75,7 @@
@stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Resources/views/admin/modules/show.blade.php b/Modules/Workshop/Resources/views/admin/modules/show.blade.php index c81d3214a..0e266375b 100644 --- a/Modules/Workshop/Resources/views/admin/modules/show.blade.php +++ b/Modules/Workshop/Resources/views/admin/modules/show.blade.php @@ -90,7 +90,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Resources/views/admin/themes/index.blade.php b/Modules/Workshop/Resources/views/admin/themes/index.blade.php index 17dac0d0f..6dcd9239c 100644 --- a/Modules/Workshop/Resources/views/admin/themes/index.blade.php +++ b/Modules/Workshop/Resources/views/admin/themes/index.blade.php @@ -82,7 +82,7 @@
@stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Resources/views/admin/themes/show.blade.php b/Modules/Workshop/Resources/views/admin/themes/show.blade.php index 176199c27..670b674c4 100644 --- a/Modules/Workshop/Resources/views/admin/themes/show.blade.php +++ b/Modules/Workshop/Resources/views/admin/themes/show.blade.php @@ -95,7 +95,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Resources/views/admin/workbench/index.blade.php b/Modules/Workshop/Resources/views/admin/workbench/index.blade.php index 9571c5b63..45f27dda4 100644 --- a/Modules/Workshop/Resources/views/admin/workbench/index.blade.php +++ b/Modules/Workshop/Resources/views/admin/workbench/index.blade.php @@ -35,7 +35,7 @@
@stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Scaffold/Module/stubs/create-view.stub b/Modules/Workshop/Scaffold/Module/stubs/create-view.stub index 0a7ab02c6..3fca93b9b 100644 --- a/Modules/Workshop/Scaffold/Module/stubs/create-view.stub +++ b/Modules/Workshop/Scaffold/Module/stubs/create-view.stub @@ -47,7 +47,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub b/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub index da5a50a8b..d2c196887 100644 --- a/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub +++ b/Modules/Workshop/Scaffold/Module/stubs/edit-view.stub @@ -47,7 +47,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush diff --git a/Modules/Workshop/Scaffold/Module/stubs/index-view.stub b/Modules/Workshop/Scaffold/Module/stubs/index-view.stub index ba59c00cb..0c4712669 100644 --- a/Modules/Workshop/Scaffold/Module/stubs/index-view.stub +++ b/Modules/Workshop/Scaffold/Module/stubs/index-view.stub @@ -79,7 +79,7 @@ @stop -@section('scripts') +@push('js-stack') -@stop +@endpush From 87947ed14402794a638186137752f711e7f7c187 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:52:30 +0200 Subject: [PATCH 85/90] CLosing css stack --- Modules/Workshop/Resources/views/admin/modules/show.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/Workshop/Resources/views/admin/modules/show.blade.php b/Modules/Workshop/Resources/views/admin/modules/show.blade.php index 0e266375b..89e793ff3 100644 --- a/Modules/Workshop/Resources/views/admin/modules/show.blade.php +++ b/Modules/Workshop/Resources/views/admin/modules/show.blade.php @@ -32,7 +32,7 @@ display: inline; } -@stop +@endpush @section('content')
From 5e4d35885534a0f918398044095909c8e9edeb4e Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:53:50 +0200 Subject: [PATCH 86/90] Preparing 2.5.0 changelogs --- Modules/Dashboard/changelog.yml | 4 ++++ Modules/Media/changelog.yml | 3 +++ Modules/Menu/changelog.yml | 3 +++ Modules/Page/changelog.yml | 2 ++ Modules/Setting/changelog.yml | 3 +++ Modules/Tag/changelog.yml | 5 ++++- Modules/Translation/changelog.yml | 4 ++++ Modules/User/changelog.yml | 3 +++ Modules/Workshop/changelog.yml | 6 ++++++ 9 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Modules/Dashboard/changelog.yml b/Modules/Dashboard/changelog.yml index bb89aae5a..da22cc725 100644 --- a/Modules/Dashboard/changelog.yml +++ b/Modules/Dashboard/changelog.yml @@ -1,5 +1,9 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.0.0": added: - Laravel 5.4 compatibility diff --git a/Modules/Media/changelog.yml b/Modules/Media/changelog.yml index d5659e913..f4b378ac2 100644 --- a/Modules/Media/changelog.yml +++ b/Modules/Media/changelog.yml @@ -6,6 +6,9 @@ versions: - FileWasUpdated event - FileIsCreating hookable event - FileIsUpdating hookable event + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.4.0": added: - new blade directive for thumbnails @thumbnail('path', 'thumbnailName') diff --git a/Modules/Menu/changelog.yml b/Modules/Menu/changelog.yml index d243dafd9..3a7eece10 100644 --- a/Modules/Menu/changelog.yml +++ b/Modules/Menu/changelog.yml @@ -6,6 +6,9 @@ versions: - Trigger event before a menu is updated (MenuIsUpdating) allow data to be changed - Trigger event before a menu item is created (MenuItemIsCreating) allow data to be changed - Trigger event before a menu item is updated (MenuItemIsUpdating) allow data to be changed + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.2.0": changed: - Only registering the menus for the frontend part. diff --git a/Modules/Page/changelog.yml b/Modules/Page/changelog.yml index b21ece16c..f6e372b10 100644 --- a/Modules/Page/changelog.yml +++ b/Modules/Page/changelog.yml @@ -9,6 +9,8 @@ versions: - Making editor textarea dynamic - Using the new @editor blade directive for the body textarea field - Remove the ckeditor inclusion on create/edit view stubs + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.2.0": added: - Testing event trigger on page deletion diff --git a/Modules/Setting/changelog.yml b/Modules/Setting/changelog.yml index b00935576..44fbcca32 100644 --- a/Modules/Setting/changelog.yml +++ b/Modules/Setting/changelog.yml @@ -6,6 +6,9 @@ versions: - Normalise the setting was updated event - Trigger SettingIsCreating hook - Trigger SettingIsUpdating hook + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.0.0": added: - Laravel 5.2 compatibility diff --git a/Modules/Tag/changelog.yml b/Modules/Tag/changelog.yml index 40cc6b0b0..84097342a 100644 --- a/Modules/Tag/changelog.yml +++ b/Modules/Tag/changelog.yml @@ -1,10 +1,13 @@ url: https://github.com/AsgardCms/Platform versions: - "2.5.0": + "2.5.0@unreleased": added: - Create and trigger events when tags are created and updated - Trigger event before a tag is created (TagIsCreating) allow data to be changed - Trigger event before a tag is updated (TagIsUpdating) allow data to be changed + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.1.0": changed: - Fixed tags not being removed probably on update & delete diff --git a/Modules/Translation/changelog.yml b/Modules/Translation/changelog.yml index 495183eda..45fa23011 100644 --- a/Modules/Translation/changelog.yml +++ b/Modules/Translation/changelog.yml @@ -1,5 +1,9 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.2.0": changed: - Optimising the checking and loading of module translations (~20% speed increase) diff --git a/Modules/User/changelog.yml b/Modules/User/changelog.yml index e12c009dd..1db70eeda 100644 --- a/Modules/User/changelog.yml +++ b/Modules/User/changelog.yml @@ -5,6 +5,9 @@ versions: - Trigger an event (UserIsUpdating) before a user is updated - Trigger an event (RoleIsCreating) before a role is created - Trigger an event (RoleIsUpdating) before a role is updated + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section "2.4.0": added: - Trigger an event (UserIsCreating) before a user is created, allowing customising its data via listeners diff --git a/Modules/Workshop/changelog.yml b/Modules/Workshop/changelog.yml index e2d642add..022ebebe9 100644 --- a/Modules/Workshop/changelog.yml +++ b/Modules/Workshop/changelog.yml @@ -1,5 +1,11 @@ url: https://github.com/AsgardCms/Platform versions: + "2.5.0@unreleased": + changed: + - Using the @push js stacks over the scripts section + - Using the @push css stacks over the styles section + removed: + - Removing ckeditor from the default scaffolded views, now included via EditorIsRendering hook "2.4.0": added: - Add the ability to set custom stubs folder used by generated modules From 7d519c1bbf83089ca732b80497d932989ce82103 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 17:56:21 +0200 Subject: [PATCH 87/90] Preparing 2.5.0 versions --- Modules/Core/module.json | 2 +- Modules/Dashboard/module.json | 2 +- Modules/Media/module.json | 2 +- Modules/Menu/module.json | 2 +- Modules/Page/module.json | 2 +- Modules/Setting/module.json | 2 +- Modules/Tag/module.json | 1 + Modules/Translation/module.json | 2 +- Modules/User/module.json | 2 +- Modules/Workshop/module.json | 2 +- Themes/Adminlte/theme.json | 2 +- Themes/Flatly/theme.json | 2 +- 12 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Modules/Core/module.json b/Modules/Core/module.json index f86d221a2..9784cf347 100644 --- a/Modules/Core/module.json +++ b/Modules/Core/module.json @@ -4,7 +4,7 @@ "description": "The core module with all base classes and logic.", "keywords": [], "require": {}, - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 0, "providers": [ diff --git a/Modules/Dashboard/module.json b/Modules/Dashboard/module.json index bb72ac2be..c74160cff 100644 --- a/Modules/Dashboard/module.json +++ b/Modules/Dashboard/module.json @@ -3,7 +3,7 @@ "alias": "dashboard", "description": "The module responsible for the admin dashboard page.", "keywords": [], - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 1, "providers": [ diff --git a/Modules/Media/module.json b/Modules/Media/module.json index 5c8539064..49390b507 100644 --- a/Modules/Media/module.json +++ b/Modules/Media/module.json @@ -3,7 +3,7 @@ "alias": "media", "description": "A media library, used throughout the CMS.", "keywords": [], - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 1, "providers": [ diff --git a/Modules/Menu/module.json b/Modules/Menu/module.json index c08ec8727..778f51266 100644 --- a/Modules/Menu/module.json +++ b/Modules/Menu/module.json @@ -4,7 +4,7 @@ "description": "Managing menus.", "keywords": [ ], - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 1, "providers": [ diff --git a/Modules/Page/module.json b/Modules/Page/module.json index d02a59da5..01baafdcb 100644 --- a/Modules/Page/module.json +++ b/Modules/Page/module.json @@ -3,7 +3,7 @@ "alias": "page", "description": "Managing pages.", "keywords": [], - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 9999, "providers": [ diff --git a/Modules/Setting/module.json b/Modules/Setting/module.json index ee3085053..f89af1c65 100644 --- a/Modules/Setting/module.json +++ b/Modules/Setting/module.json @@ -6,7 +6,7 @@ "asgardcms", "settings" ], - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 1, "providers": [ diff --git a/Modules/Tag/module.json b/Modules/Tag/module.json index 922c3a8a2..15d1644c2 100644 --- a/Modules/Tag/module.json +++ b/Modules/Tag/module.json @@ -7,6 +7,7 @@ "AsgardCMS", "taggable" ], + "version": "2.5.0", "active": 1, "order": 1, "providers": [ diff --git a/Modules/Translation/module.json b/Modules/Translation/module.json index 0eba3c06a..b404548c1 100644 --- a/Modules/Translation/module.json +++ b/Modules/Translation/module.json @@ -2,7 +2,7 @@ "name": "Translation", "alias": "translation", "description": "Module containing all AsgardCms translations", - "version": "2.0.0", + "version": "2.5.0", "keywords": [], "active": 1, "order": 2, diff --git a/Modules/User/module.json b/Modules/User/module.json index 90e857065..e494a98fc 100644 --- a/Modules/User/module.json +++ b/Modules/User/module.json @@ -3,7 +3,7 @@ "alias": "user", "description": "The user module is responsible for managing users and permissions.", "keywords": [], - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 1, "providers": [ diff --git a/Modules/Workshop/module.json b/Modules/Workshop/module.json index 8e7dabe34..6b686ba70 100644 --- a/Modules/Workshop/module.json +++ b/Modules/Workshop/module.json @@ -4,7 +4,7 @@ "description": "Module used to handle the create of new modules.", "keywords": [ ], - "version": "2.0.0", + "version": "2.5.0", "active": 1, "order": 1, "providers": [ diff --git a/Themes/Adminlte/theme.json b/Themes/Adminlte/theme.json index e38e4e67f..47e1d65eb 100644 --- a/Themes/Adminlte/theme.json +++ b/Themes/Adminlte/theme.json @@ -2,5 +2,5 @@ "name": "AdminLTE", "description": "This is an administration theme", "type": "backend", - "version": "2.0.0" + "version": "2.5.0" } diff --git a/Themes/Flatly/theme.json b/Themes/Flatly/theme.json index 26d9e9c1c..8d54d09f8 100644 --- a/Themes/Flatly/theme.json +++ b/Themes/Flatly/theme.json @@ -2,5 +2,5 @@ "name": "Flatly", "description": "This is the Flatly theme", "type": "frontend", - "version": "2.0.0" + "version": "2.5.0" } From 1a865b3559947217f363bceb9981af60c29d18dd Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 18:05:30 +0200 Subject: [PATCH 88/90] Using ::class notation --- Modules/Page/Providers/PageServiceProvider.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Modules/Page/Providers/PageServiceProvider.php b/Modules/Page/Providers/PageServiceProvider.php index 1c3102acc..3e5df72f0 100644 --- a/Modules/Page/Providers/PageServiceProvider.php +++ b/Modules/Page/Providers/PageServiceProvider.php @@ -9,6 +9,7 @@ use Modules\Page\Entities\Page; use Modules\Page\Repositories\Cache\CachePageDecorator; use Modules\Page\Repositories\Eloquent\EloquentPageRepository; +use Modules\Page\Repositories\PageRepository; use Modules\Page\Services\FinderService; use Modules\Tag\Repositories\TagManager; @@ -59,18 +60,15 @@ private function registerBindings() return new FinderService(); }); - $this->app->bind( - 'Modules\Page\Repositories\PageRepository', - function () { - $repository = new EloquentPageRepository(new Page()); + $this->app->bind(PageRepository::class, function () { + $repository = new EloquentPageRepository(new Page()); - if (! Config::get('app.cache')) { - return $repository; - } - - return new CachePageDecorator($repository); + if (! Config::get('app.cache')) { + return $repository; } - ); + + return new CachePageDecorator($repository); + }); } /** From 061047beac1b92827c9f6825a9979860931bc241 Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 18:07:52 +0200 Subject: [PATCH 89/90] Using ::class notation --- .../Menu/Providers/MenuServiceProvider.php | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/Modules/Menu/Providers/MenuServiceProvider.php b/Modules/Menu/Providers/MenuServiceProvider.php index 87ca8fd63..67851d2ae 100644 --- a/Modules/Menu/Providers/MenuServiceProvider.php +++ b/Modules/Menu/Providers/MenuServiceProvider.php @@ -68,31 +68,25 @@ public function provides() */ private function registerBindings() { - $this->app->bind( - 'Modules\Menu\Repositories\MenuRepository', - function () { - $repository = new EloquentMenuRepository(new Menu()); + $this->app->bind(MenuRepository::class, function () { + $repository = new EloquentMenuRepository(new Menu()); - if (! config('app.cache')) { - return $repository; - } - - return new CacheMenuDecorator($repository); + if (! config('app.cache')) { + return $repository; } - ); - $this->app->bind( - 'Modules\Menu\Repositories\MenuItemRepository', - function () { - $repository = new EloquentMenuItemRepository(new Menuitem()); + return new CacheMenuDecorator($repository); + }); - if (! config('app.cache')) { - return $repository; - } + $this->app->bind(MenuItemRepository::class, function () { + $repository = new EloquentMenuItemRepository(new Menuitem()); - return new CacheMenuItemDecorator($repository); + if (! config('app.cache')) { + return $repository; } - ); + + return new CacheMenuItemDecorator($repository); + }); } /** From 35c1d5bafe7af1781830edf8d26afe82eb55ea6c Mon Sep 17 00:00:00 2001 From: Nicolas Widart Date: Sun, 16 Jul 2017 20:43:02 +0200 Subject: [PATCH 90/90] Removing old stylist command --- Modules/Core/stylistPublishMix.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Modules/Core/stylistPublishMix.js diff --git a/Modules/Core/stylistPublishMix.js b/Modules/Core/stylistPublishMix.js deleted file mode 100644 index 541768f63..000000000 --- a/Modules/Core/stylistPublishMix.js +++ /dev/null @@ -1,12 +0,0 @@ -var gulp = require("gulp"); -var shell = require('gulp-shell'); -var elixir = require('laravel-elixir'); -var themeInfo = require('./theme.json'); - -var Task = elixir.Task; - -elixir.extend('stylistPublish', function() { - new Task('stylistPublish', function() { - return gulp.src("").pipe(shell("php ../../artisan stylist:publish " + themeInfo.name)); - }); -});