Skip to content

Commit

Permalink
remove cmnd and auto add instead
Browse files Browse the repository at this point in the history
add changelog

fucken file

keep cache forever
  • Loading branch information
ctf0 committed Sep 15, 2017
1 parent e897208 commit eef304c
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 100 deletions.
28 changes: 8 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
# Laravel Media Manager

![Demo](./demo.jpg)
<p align="center">
<img src="demo.jpg">
</p>

## 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)

Expand All @@ -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' => [
Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -30,7 +31,8 @@
"providers": [
"ctf0\\MediaManager\\MediaManagerServiceProvider"
]
}
},
"changeLog": "logs"
},
"config": {
"sort-packages": true
Expand Down
3 changes: 3 additions & 0 deletions logs/v1.2.2.txt
Original file line number Diff line number Diff line change
@@ -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
69 changes: 0 additions & 69 deletions src/Commands/MMAppend.php

This file was deleted.

82 changes: 76 additions & 6 deletions src/MediaManagerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
}
}
4 changes: 1 addition & 3 deletions src/resources/views/bulma/media.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
{{-- FW --}}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
{{-- bulma --}}
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bulma/0.5.1/css/bulma.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bulma/0.5.2/css/bulma.min.css">
{{-- Main styles --}}
<link rel="stylesheet" href="{{ mix('assets/vendor/MediaManager/style.css') }}"/>

{{-- js --}}
<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="//cdn.jsdelivr.net/jquery.scrollto/2.1.2/jquery.scrollTo.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bodymovin/4.10.2/bodymovin.min.js"></script>
{{-- Vue --}}
<script src="https://unpkg.com/vue"></script>
{{-- ziggy --}}
@routes
</head>
Expand Down

0 comments on commit eef304c

Please sign in to comment.