From eef304c80607d2236221d8fe7f61f90a0619c273 Mon Sep 17 00:00:00 2001 From: Muah Date: Sat, 16 Sep 2017 00:30:19 +0200 Subject: [PATCH] remove cmnd and auto add instead add changelog fucken file keep cache forever --- README.md | 28 +++----- composer.json | 6 +- logs/v1.2.2.txt | 3 + src/Commands/MMAppend.php | 69 ------------------- src/MediaManagerServiceProvider.php | 82 +++++++++++++++++++++-- src/resources/views/bulma/media.blade.php | 4 +- 6 files changed, 92 insertions(+), 100 deletions(-) create mode 100644 logs/v1.2.2.txt delete mode 100644 src/Commands/MMAppend.php diff --git a/README.md b/README.md index 1aa3bed..5c4775b 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,10 @@ -# Laravel Media Manager - -![Demo](./demo.jpg) +

+ +

## Intro - Inspired by [Voyager](https://github.com/the-control-group/voyager), [October](https://github.com/octobercms/october), [WordPress](https://codex.wordpress.org/Media_Library_Screen) -- Built using - + [Vue](https://vuejs.org/) - + [jQuery](https://jquery.com/) - + [dropzone](http://www.dropzonejs.com/) - + [keycode](https://github.com/timoxley/keycode) - + [jquery.scrollTo](https://github.com/flesler/jquery.scrollTo) - + [vue-tippy](https://github.com/KABBOUCHI/vue-tippy) - + [vue2-filters](https://github.com/freearhey/vue2-filters) - + [vue-lightbox](https://github.com/phecko/vue-lightbox) - + [bootstrap modal](http://getbootstrap.com/javascript/#modals) - + [notification-component](https://github.com/ctf0/Notification-Component) - + [Ziggy](https://github.com/tightenco/ziggy) - to optimize uploaded files on the fly try [approached](https://github.com/approached/laravel-image-optimizer) or [spatie](https://github.com/spatie/laravel-image-optimizer) @@ -26,7 +14,7 @@ - `composer require ctf0/media-manager` -- add the service provider to `config/app.php` +- (Laravel < 5.5) add the service provider to `config/app.php` ```php 'providers' => [ @@ -38,10 +26,10 @@ `php artisan vendor:publish --provider="ctf0\MediaManager\MediaManagerServiceProvider"` -- run `php artisan mm:append` to - + add package routes to `routes/web.php` - + add package assets compiling to `webpack.mix.js` - + add `MIX_MM_FRAMEWORK=bulma` to `.env` +- after installation, package will auto-add + + package routes to `routes/web.php` + + package assets compiling to `webpack.mix.js` + + `MIX_MM_FRAMEWORK=bulma` to `.env` ## Features diff --git a/composer.json b/composer.json index 35d9f41..ab68a47 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "require": { "php" : "~7.0", "illuminate/support": "^5.4", - "tightenco/ziggy": "^0.3" + "tightenco/ziggy": "^0.3", + "ctf0/package-changelog": "^1.0" }, "autoload": { "psr-4": { @@ -30,7 +31,8 @@ "providers": [ "ctf0\\MediaManager\\MediaManagerServiceProvider" ] - } + }, + "changeLog": "logs" }, "config": { "sort-packages": true diff --git a/logs/v1.2.2.txt b/logs/v1.2.2.txt new file mode 100644 index 0000000..5ebf8a6 --- /dev/null +++ b/logs/v1.2.2.txt @@ -0,0 +1,3 @@ +- add changelog feature so now you can know what was changed/updated/added on each update +- remove cmnd as we auto-add extra data on package installation +- update view \ No newline at end of file diff --git a/src/Commands/MMAppend.php b/src/Commands/MMAppend.php deleted file mode 100644 index c181e09..0000000 --- a/src/Commands/MMAppend.php +++ /dev/null @@ -1,69 +0,0 @@ -comment("['ctf0\MediaManager\MediaRoutes::routes();'] added to [web.php]"); - } - - // mix - $mix_file = base_path('webpack.mix.js'); - $search = 'MediaManager'; - if (File::exists($mix_file) && !str_contains(File::get($mix_file), $search)) { - $data = "\n// Media-Manager\nrequire('dotenv').config()\nmix.sass('resources/assets/vendor/MediaManager/sass/' + process.env.MIX_MM_FRAMEWORK + '/media.scss', 'public/assets/vendor/MediaManager/style.css').version();"; - - File::append($mix_file, $data); - $this->comment("['mix.sass(..).version()'] added to [webpack.mix.js]"); - } - - // fw - $env_file = base_path('.env'); - $search = 'MIX_MM_FRAMEWORK'; - if (File::exists($env_file) && !str_contains(File::get($env_file), $search)) { - $data = "\nMIX_MM_FRAMEWORK=bulma"; - - File::append($env_file, $data); - $this->comment("['MIX_MM_FRAMEWORK=bulma'] added to [.env]"); - } - } -} diff --git a/src/MediaManagerServiceProvider.php b/src/MediaManagerServiceProvider.php index d08f9d6..a6ac115 100644 --- a/src/MediaManagerServiceProvider.php +++ b/src/MediaManagerServiceProvider.php @@ -2,14 +2,27 @@ namespace ctf0\MediaManager; +use Illuminate\Support\Facades\File; use Illuminate\Support\ServiceProvider; class MediaManagerServiceProvider extends ServiceProvider { + public function boot() + { + $this->packagePublish(); + + // append extra data + if (!app('cache')->store('file')->has('ct-mm')) { + $this->autoReg(); + } + } + /** - * Perform post-registration booting of services. + * [packagePublish description]. + * + * @return [type] [description] */ - public function boot() + protected function packagePublish() { // config $this->mergeConfigFrom( @@ -40,15 +53,72 @@ public function boot() $this->publishes([ __DIR__ . '/resources/views' => resource_path('views/vendor/MediaManager'), ], 'view'); + } + + /** + * [autoReg description]. + * + * @return [type] [description] + */ + protected function autoReg() + { + // routes + $route_file = base_path('routes/web.php'); + $search = 'MediaManager'; + + if ($this->checkExist($route_file, $search)) { + $data = "\n// Media-Manager\nctf0\MediaManager\MediaRoutes::routes();"; + + File::append($route_file, $data); + } - // cmnds - $this->commands([ - Commands\MMAppend::class, - ]); + // mix + $mix_file = base_path('webpack.mix.js'); + $search = 'MediaManager'; + + if ($this->checkExist($mix_file, $search)) { + $data = "\n// Media-Manager\nrequire('dotenv').config()\nmix.sass('resources/assets/vendor/MediaManager/sass/' + process.env.MIX_MM_FRAMEWORK + '/media.scss', 'public/assets/vendor/MediaManager/style.css').version();"; + + File::append($mix_file, $data); + } + + // fw + $env_file = base_path('.env'); + $search = 'MIX_MM_FRAMEWORK'; + + if ($this->checkExist($env_file, $search)) { + $data = "\nMIX_MM_FRAMEWORK=bulma"; + + File::append($env_file, $data); + } + + // run check once + app('cache')->store('file')->rememberForever('ct-mm', function () { + return 'added'; + }); } + /** + * [checkExist description]. + * + * @param [type] $file [description] + * @param [type] $search [description] + * + * @return [type] [description] + */ + protected function checkExist($file, $search) + { + return File::exists($file) && !str_contains(File::get($file), $search); + } + + /** + * [register description]. + * + * @return [type] [description] + */ public function register() { $this->app->register(\Tightenco\Ziggy\ZiggyServiceProvider::class); + $this->app->register(\ctf0\PackageChangeLog\PackageChangeLogServiceProvider::class); } } diff --git a/src/resources/views/bulma/media.blade.php b/src/resources/views/bulma/media.blade.php index da2ad17..7472401 100755 --- a/src/resources/views/bulma/media.blade.php +++ b/src/resources/views/bulma/media.blade.php @@ -5,7 +5,7 @@ {{-- FW --}} {{-- bulma --}} - + {{-- Main styles --}} @@ -13,8 +13,6 @@ - {{-- Vue --}} - {{-- ziggy --}} @routes