Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit eef304c

Browse files
committed
remove cmnd and auto add instead
add changelog fucken file keep cache forever
1 parent e897208 commit eef304c

File tree

6 files changed

+92
-100
lines changed

6 files changed

+92
-100
lines changed

README.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
1-
# Laravel Media Manager
2-
3-
![Demo](./demo.jpg)
1+
<p align="center">
2+
<img src="demo.jpg">
3+
</p>
44

55
## Intro
66

77
- Inspired by [Voyager](https://github.com/the-control-group/voyager), [October](https://github.com/octobercms/october), [WordPress](https://codex.wordpress.org/Media_Library_Screen)
8-
- Built using
9-
+ [Vue](https://vuejs.org/)
10-
+ [jQuery](https://jquery.com/)
11-
+ [dropzone](http://www.dropzonejs.com/)
12-
+ [keycode](https://github.com/timoxley/keycode)
13-
+ [jquery.scrollTo](https://github.com/flesler/jquery.scrollTo)
14-
+ [vue-tippy](https://github.com/KABBOUCHI/vue-tippy)
15-
+ [vue2-filters](https://github.com/freearhey/vue2-filters)
16-
+ [vue-lightbox](https://github.com/phecko/vue-lightbox)
17-
+ [bootstrap modal](http://getbootstrap.com/javascript/#modals)
18-
+ [notification-component](https://github.com/ctf0/Notification-Component)
19-
+ [Ziggy](https://github.com/tightenco/ziggy)
208

219
- 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)
2210

@@ -26,7 +14,7 @@
2614

2715
- `composer require ctf0/media-manager`
2816

29-
- add the service provider to `config/app.php`
17+
- (Laravel < 5.5) add the service provider to `config/app.php`
3018

3119
```php
3220
'providers' => [
@@ -38,10 +26,10 @@
3826

3927
`php artisan vendor:publish --provider="ctf0\MediaManager\MediaManagerServiceProvider"`
4028

41-
- run `php artisan mm:append` to
42-
+ add package routes to `routes/web.php`
43-
+ add package assets compiling to `webpack.mix.js`
44-
+ add `MIX_MM_FRAMEWORK=bulma` to `.env`
29+
- after installation, package will auto-add
30+
+ package routes to `routes/web.php`
31+
+ package assets compiling to `webpack.mix.js`
32+
+ `MIX_MM_FRAMEWORK=bulma` to `.env`
4533

4634
## Features
4735

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"require": {
1919
"php" : "~7.0",
2020
"illuminate/support": "^5.4",
21-
"tightenco/ziggy": "^0.3"
21+
"tightenco/ziggy": "^0.3",
22+
"ctf0/package-changelog": "^1.0"
2223
},
2324
"autoload": {
2425
"psr-4": {
@@ -30,7 +31,8 @@
3031
"providers": [
3132
"ctf0\\MediaManager\\MediaManagerServiceProvider"
3233
]
33-
}
34+
},
35+
"changeLog": "logs"
3436
},
3537
"config": {
3638
"sort-packages": true

logs/v1.2.2.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- add changelog feature so now you can know what was changed/updated/added on each update
2+
- remove cmnd as we auto-add extra data on package installation
3+
- update view

src/Commands/MMAppend.php

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/MediaManagerServiceProvider.php

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
namespace ctf0\MediaManager;
44

5+
use Illuminate\Support\Facades\File;
56
use Illuminate\Support\ServiceProvider;
67

78
class MediaManagerServiceProvider extends ServiceProvider
89
{
10+
public function boot()
11+
{
12+
$this->packagePublish();
13+
14+
// append extra data
15+
if (!app('cache')->store('file')->has('ct-mm')) {
16+
$this->autoReg();
17+
}
18+
}
19+
920
/**
10-
* Perform post-registration booting of services.
21+
* [packagePublish description].
22+
*
23+
* @return [type] [description]
1124
*/
12-
public function boot()
25+
protected function packagePublish()
1326
{
1427
// config
1528
$this->mergeConfigFrom(
@@ -40,15 +53,72 @@ public function boot()
4053
$this->publishes([
4154
__DIR__ . '/resources/views' => resource_path('views/vendor/MediaManager'),
4255
], 'view');
56+
}
57+
58+
/**
59+
* [autoReg description].
60+
*
61+
* @return [type] [description]
62+
*/
63+
protected function autoReg()
64+
{
65+
// routes
66+
$route_file = base_path('routes/web.php');
67+
$search = 'MediaManager';
68+
69+
if ($this->checkExist($route_file, $search)) {
70+
$data = "\n// Media-Manager\nctf0\MediaManager\MediaRoutes::routes();";
71+
72+
File::append($route_file, $data);
73+
}
4374

44-
// cmnds
45-
$this->commands([
46-
Commands\MMAppend::class,
47-
]);
75+
// mix
76+
$mix_file = base_path('webpack.mix.js');
77+
$search = 'MediaManager';
78+
79+
if ($this->checkExist($mix_file, $search)) {
80+
$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();";
81+
82+
File::append($mix_file, $data);
83+
}
84+
85+
// fw
86+
$env_file = base_path('.env');
87+
$search = 'MIX_MM_FRAMEWORK';
88+
89+
if ($this->checkExist($env_file, $search)) {
90+
$data = "\nMIX_MM_FRAMEWORK=bulma";
91+
92+
File::append($env_file, $data);
93+
}
94+
95+
// run check once
96+
app('cache')->store('file')->rememberForever('ct-mm', function () {
97+
return 'added';
98+
});
4899
}
49100

101+
/**
102+
* [checkExist description].
103+
*
104+
* @param [type] $file [description]
105+
* @param [type] $search [description]
106+
*
107+
* @return [type] [description]
108+
*/
109+
protected function checkExist($file, $search)
110+
{
111+
return File::exists($file) && !str_contains(File::get($file), $search);
112+
}
113+
114+
/**
115+
* [register description].
116+
*
117+
* @return [type] [description]
118+
*/
50119
public function register()
51120
{
52121
$this->app->register(\Tightenco\Ziggy\ZiggyServiceProvider::class);
122+
$this->app->register(\ctf0\PackageChangeLog\PackageChangeLogServiceProvider::class);
53123
}
54124
}

src/resources/views/bulma/media.blade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55
{{-- FW --}}
66
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
77
{{-- bulma --}}
8-
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bulma/0.5.1/css/bulma.min.css">
8+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bulma/0.5.2/css/bulma.min.css">
99
{{-- Main styles --}}
1010
<link rel="stylesheet" href="{{ mix('assets/vendor/MediaManager/style.css') }}"/>
1111

1212
{{-- js --}}
1313
<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>
1414
<script src="//cdn.jsdelivr.net/jquery.scrollto/2.1.2/jquery.scrollTo.min.js"></script>
1515
<script src="//cdnjs.cloudflare.com/ajax/libs/bodymovin/4.10.2/bodymovin.min.js"></script>
16-
{{-- Vue --}}
17-
<script src="https://unpkg.com/vue"></script>
1816
{{-- ziggy --}}
1917
@routes
2018
</head>

0 commit comments

Comments
 (0)