Skip to content

Commit

Permalink
v3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ctf0 committed Sep 21, 2019
1 parent cc3e535 commit 1535538
Show file tree
Hide file tree
Showing 26 changed files with 1,047 additions and 635 deletions.
118 changes: 65 additions & 53 deletions README.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"MediaManager"
],
"authors": [
{
"name": "Muah",
"email": "[email protected]"
}
],
{
"name": "Muah",
"email": "[email protected]"
}
],
"require": {
"php" : "~7.0",
"illuminate/support": "5.4 - 5.8",
"php": "~7.0",
"illuminate/support": "5.4 - 6.0",
"maennchen/zipstream-php": "~1.0",
"ctf0/package-changelog": "*"
},
Expand Down
8 changes: 0 additions & 8 deletions logs/v3.2.7.txt

This file was deleted.

8 changes: 8 additions & 0 deletions logs/v3.4.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- move db file from logs to database
- remove db connection auto register for Lock Files & Folder, check: https://github.com/ctf0/Laravel-Media-Manager/wiki/Lock-Files-&-Folder
- add support for laravel 6.0
- some cleanup to the js code
- add support to preview files before uploading (along with total uploads & size)
- remove deprecated laravel helper methods
- fix incorrect upload panel img paths
- update date-fns imports
3 changes: 2 additions & 1 deletion src/Commands/PackageSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace ctf0\MediaManager\Commands;

use Illuminate\Support\Str;
use Illuminate\Console\Command;

class PackageSetup extends Command
Expand Down Expand Up @@ -66,6 +67,6 @@ public function handle()
*/
protected function checkExist($file, $search)
{
return $this->file->exists($file) && !str_contains($this->file->get($file), $search);
return $this->file->exists($file) && !Str::contains($this->file->get($file), $search);
}
}
19 changes: 10 additions & 9 deletions src/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ class MediaController extends Controller

public function __construct()
{
$config = app('config')->get('mediaManager');
$this->fileSystem = array_get($config, 'storage_disk');
$this->ignoreFiles = array_get($config, 'ignore_files');
$this->fileChars = array_get($config, 'allowed_fileNames_chars');
$this->folderChars = array_get($config, 'allowed_folderNames_chars');
$this->sanitizedText = array_get($config, 'sanitized_text');
$this->unallowedMimes = array_get($config, 'unallowed_mimes');
$this->LMF = array_get($config, 'last_modified_format');
$this->GFI = array_get($config, 'get_folder_info', true);
$config = app('config')->get('mediaManager');

$this->fileSystem = $config['storage_disk'];
$this->ignoreFiles = $config['ignore_files'];
$this->fileChars = $config['allowed_fileNames_chars'];
$this->folderChars = $config['allowed_folderNames_chars'];
$this->sanitizedText = $config['sanitized_text'];
$this->unallowedMimes = $config['unallowed_mimes'];
$this->LMF = $config['last_modified_format'];
$this->GFI = $config['get_folder_info'] ?? true;

$this->storageDisk = app('filesystem')->disk($this->fileSystem);
$this->storageDiskInfo = app('config')->get("filesystems.disks.{$this->fileSystem}");
Expand Down
8 changes: 4 additions & 4 deletions src/Controllers/Modules/Move.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function moveItem(Request $request)
if (app('files')->copyDirectory($old, $new)) {
$result[] = array_merge($defaults, ['success' => true]);
} else {
$exc = array_get($this->storageDiskInfo, 'root')
? trans('MediaManager::messages.error.moving')
: trans('MediaManager::messages.error.moving_cloud');
$exc = isset($this->storageDiskInfo['root'])
? trans('MediaManager::messages.error.moving')
: trans('MediaManager::messages.error.moving_cloud');

throw new Exception($exc);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ public function moveItem(Request $request)
} else {
$exc = trans('MediaManager::messages.error.moving');

if ($file_type == 'folder' && !array_get($this->storageDiskInfo, 'root')) {
if ($file_type == 'folder' && !isset($this->storageDiskInfo['root'])) {
$exc = trans('MediaManager::messages.error.moving_cloud');
}

Expand Down
25 changes: 13 additions & 12 deletions src/Controllers/Modules/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ctf0\MediaManager\Controllers\Moduels;

use Exception;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use ctf0\MediaManager\Events\MediaFileOpsNotifications;
use Symfony\Component\HttpFoundation\File\UploadedFile;
Expand Down Expand Up @@ -39,7 +40,7 @@ public function upload(Request $request)

try {
// check for mime type
if (str_contains($file_type, $this->unallowedMimes)) {
if (Str::contains($file_type, $this->unallowedMimes)) {
throw new Exception(
trans('MediaManager::messages.not_allowed_file_ext', ['attr' => $file_type])
);
Expand Down Expand Up @@ -103,10 +104,10 @@ public function upload(Request $request)
public function uploadEditedImage(Request $request)
{
if ($this->allowUpload()) {
$type = $request->mime_type;
$path = $request->path;
$original = $request->name;
$data = explode(',', $request->data)[1];
$type = $request->mime_type;
$path = $request->path;
$original = $request->name;
$data = explode(',', $request->data)[1];

$name_only = pathinfo($original, PATHINFO_FILENAME) . '_' . $this->getRandomString();
$ext_only = pathinfo($original, PATHINFO_EXTENSION);
Expand All @@ -126,14 +127,14 @@ public function uploadEditedImage(Request $request)

// fire event
event('MMFileSaved', [
'file_path' => $this->getItemPath($destination),
'mime_type' => $type,
'file_path' => $this->getItemPath($destination),
'mime_type' => $type,
]);

// broadcast
broadcast(new MediaFileOpsNotifications([
'op' => 'upload',
'path' => $path,
'op' => 'upload',
'path' => $path,
]))->toOthers();

$result = [
Expand Down Expand Up @@ -182,7 +183,7 @@ public function uploadLink(Request $request)

try {
// check for mime type
if (str_contains($file_type, $this->unallowedMimes)) {
if (Str::contains($file_type, $this->unallowedMimes)) {
throw new Exception(
trans('MediaManager::messages.not_allowed_file_ext', ['attr' => $file_type])
);
Expand All @@ -200,8 +201,8 @@ public function uploadLink(Request $request)

// fire event
event('MMFileSaved', [
'file_path' => $this->getItemPath($destination),
'mime_type' => $file_type,
'file_path' => $this->getItemPath($destination),
'mime_type' => $file_type,
]);

// broadcast
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/Modules/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ protected function getItemPath($path)
{
$info = $this->storageDiskInfo;
$url = $this->resolveUrl($path); // get the file url
$root = array_get($info, 'root');
$root = $info['root'] ?? null;

// for other disks without root ex."cloud"
if (!$root) {
return preg_replace('/(.*\/\/.*?)\//', '', $url); // get the full path
}

$dir = str_replace(array_get($info, 'url'), '', $url); // remove the uri
$dir = str_replace($info['url'], '', $url); // remove the uri

return $root . $dir; // get the full path
}
Expand Down
26 changes: 7 additions & 19 deletions src/MediaManagerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function boot()
$this->file = $this->app['files'];

$this->packagePublish();
$this->extraConfigs();
$this->socketRoute();
$this->viewComp();
$this->command();
Expand All @@ -36,7 +35,7 @@ protected function packagePublish()

// database
$this->publishes([
__DIR__ . '/database' => storage_path('logs'),
__DIR__ . '/database/MediaManager.sqlite' => database_path('MediaManager.sqlite'),
], 'db');

$this->publishes([
Expand All @@ -61,19 +60,6 @@ protected function packagePublish()
], 'view');
}

protected function extraConfigs()
{
// database
$db = storage_path('logs/MediaManager.sqlite');

if ($this->file->exists($db)) {
$this->app['config']->set('database.connections.mediamanager', [
'driver' => 'sqlite',
'database' => $db,
]);
}
}

protected function socketRoute()
{
Broadcast::channel('User.{id}.media', function ($user, $id) {
Expand All @@ -93,8 +79,8 @@ protected function viewComp()
// base url
$config = $this->app['config']->get('mediaManager');
$url = $this->app['filesystem']
->disk(array_get($config, 'storage_disk'))
->url('/');
->disk($config['storage_disk'])
->url('/');

$data['base_url'] = preg_replace('/\/+$/', '/', $url);

Expand All @@ -105,7 +91,9 @@ protected function viewComp()
$patterns = collect(
$this->file->allFiles($pattern_path)
)->map(function ($item) {
return preg_replace('/.*\/patterns/', '/assets/vendor/MediaManager/patterns', $item->getPathName());
$name = str_replace('\\', '/', $item->getPathName());

return preg_replace('/.*\/patterns/', '/assets/vendor/MediaManager/patterns', $name);
});

$data['patterns'] = json_encode($patterns);
Expand Down Expand Up @@ -138,4 +126,4 @@ public function register()
{
$this->app->register(PackageChangeLogServiceProvider::class);
}
}
}
7 changes: 6 additions & 1 deletion src/config/mediaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
/*
* when file names gets cleand up
*
* put here any global function that
* put here any global function that
* doesnt take arguments
*/
'sanitized_text' => 'uniqid',
Expand Down Expand Up @@ -119,4 +119,9 @@
* above the manager
*/
'show_ratio_bar' => true,

/*
* preview and remove files b4 uploading
*/
'preview_files_before_upload' => true,
];
Binary file added src/resources/assets/dist/noPreview.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 11 additions & 8 deletions src/resources/assets/js/components/imageEditor/main.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<div ref="editor" class="card __editor">

<!-- btns -->
<div class="top">
<div class="__top-toolbar">
Expand All @@ -13,8 +12,8 @@
:caman-filters="camanFilters"
class="__left-index"/>

<!-- glitch -->
<!-- <glitch v-if="showGlitch"
<!-- glitch -->
<!-- <glitch v-if="showGlitch"
:cropper="imageCropper"
:show-glitch="showGlitch"
:get-cropper-data="getCropperData"
Expand All @@ -32,8 +31,8 @@
</button> -->

<!-- diff toggle -->
<button v-tippy="{arrow: true, theme: 'mm'}"
v-if="showDiffBtn()"
<button v-if="showDiffBtn()"
v-tippy="{arrow: true, theme: 'mm'}"
:disabled="processing && !imageDiffIsReady || showGlitch"
:class="{'is-active': showDiff}"
:title="trans('diff')"
Expand Down Expand Up @@ -149,6 +148,7 @@ export default {
},
props: [
'file',
'noScroll',
'translations',
'route',
'url'
Expand Down Expand Up @@ -205,9 +205,12 @@ export default {
'pointer-events': 'none'
}
}
return {}
}
},
created() {
this.noScroll('add')
window.addEventListener('dblclick', this.onDblClick)
},
mounted() {
Expand All @@ -217,6 +220,7 @@ export default {
beforeDestroy() {
window.removeEventListener('dblclick', this.onDblClick)
this.imageCropper.destroy()
this.noScroll('remove')
},
methods: {
// init
Expand Down Expand Up @@ -322,14 +326,13 @@ export default {
let cropper = this.imageCropper
let getData = cropper.getData()
this.hasChanged =
this.hasChanged = (
getData.rotate != 0 ||
getData.scaleX != 1 ||
getData.scaleY != 1 ||
cropper.cropped ||
this.haveFilters()
? true
: false
) ? true : false
},
resetAll() {
this.$nextTick(() => {
Expand Down
Loading

0 comments on commit 1535538

Please sign in to comment.