Skip to content

Commit

Permalink
add mm:append cmnd
Browse files Browse the repository at this point in the history
  • Loading branch information
ctf0 committed Aug 4, 2017
1 parent c1f98af commit 31b63ec
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 23 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 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)
- 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/)
Expand Down Expand Up @@ -117,12 +117,14 @@ return [

## Usage

- package automatically appends routes to `routes/web.php`
- package automatically appends assets compiling to `webpack.mix.js`
- add `MIX_MM_FRAMEWORK=bulma` to `.env`
- 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`

#### - Simple
- visit `http://127.0.0.1:8000/media`
- open `views/vendor/MediaManager/bulma/media.blade.php` and make any changes you may need ex.**"use bootstrap instead of bulma"**

#### - Advanced
- install javascript dependencies
Expand All @@ -146,7 +148,10 @@ npm install vue dropzone keycode vue-tippy vue2-filters vue-lightbox vuemit
>
> after you are done, maybe you can send me a PR so everyone else can benefit from it :trophy:
## ToDo "ANY HELP IS DEEPLY APPRECIATED"
## Notes
- if you are using multilocale and you are having issues when switching to different locale other than `en`, [MultiLocale](https://github.com/ctf0/Laravel-Media-Manager/wiki/MultiLocale).

## ToDo "ANY HELP IS APPRECIATED"

* [ ] Add Support To Other Css Frameworks.
* [ ] Add Support For Editors "tinymce / Ckeditor/ etc".
Expand Down
69 changes: 69 additions & 0 deletions src/Commands/MMAppend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace ctf0\MediaManager\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;

class MMAppend extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'mm:append';

/**
* The console command description.
*
* @var string
*/
protected $description = "Append routes to 'routes/web.php', Append assets compiling to 'webpack.mix.js'";

/**
* Create a new command instance.
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// routes
$route_file = base_path('routes/web.php');
$search = 'MediaManager';
if (File::exists($route_file) && !str_contains(File::get($route_file), $search)) {
$data = "\n// Media-Manager\nnew \ctf0\MediaManager\MediaRoutes();";

File::append($route_file, $data);
$this->comment("['new \ctf0\MediaManager\MediaRoutes()'] 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\nmix.js('resources/assets/vendor/MediaManager/js/media.js', 'public/assets/vendor/MediaManager/script.js')\n\t.sass('resources/assets/vendor/MediaManager/sass/' + process.env.MIX_MM_FRAMEWORK + '/media.scss', 'public/assets/vendor/MediaManager/style.css')\n\t.version();";

File::append($mix_file, $data);
$this->comment("['mix.js(..).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]");
}
}
}
22 changes: 4 additions & 18 deletions src/MediaManagerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace ctf0\MediaManager;

use Illuminate\Support\Facades\File;
use Illuminate\Support\ServiceProvider;

class MediaManagerServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -39,22 +38,9 @@ public function boot()
__DIR__.'/resources/views' => resource_path('views/vendor/MediaManager'),
], 'view');

// routes
$route_file = base_path('routes/web.php');
$search = 'MediaManager';
if (File::exists($route_file) && !str_contains(File::get($route_file), $search)) {
$data = "\n// MediaManager\nnew \ctf0\MediaManager\MediaRoutes();";

File::append($route_file, $data);
}

// mix
$mix_file = base_path('webpack.mix.js');
$search = 'MediaManager';
if (File::exists($mix_file) && !str_contains(File::get($mix_file), $search)) {
$data = "\n// MediaManager\nmix.js('resources/assets/vendor/MediaManager/js/media.js', 'public/assets/vendor/MediaManager/script.js')\n\t.sass('resources/assets/vendor/MediaManager/sass/' + process.env.MIX_MM_FRAMEWORK + '/media.scss', 'public/assets/vendor/MediaManager/style.css')\n\t.version();";

File::append($mix_file, $data);
}
// cmnds
$this->commands([
Commands\MMAppend::class,
]);
}
}

0 comments on commit 31b63ec

Please sign in to comment.