diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 197e83d..fc5640e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -2,7 +2,7 @@ name: Bug report about: Create a report to help us improve title: "[BUG]" -labels: '' +labels: bug assignees: '' --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bcdf762..90b08d9 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Feature request about: Suggest an enhancement title: "[Feature]" -labels: '' +labels: enhancement assignees: '' --- diff --git a/.github/ISSUE_TEMPLATE/have-a-question.md b/.github/ISSUE_TEMPLATE/have-a-question.md new file mode 100644 index 0000000..0e1fb4a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/have-a-question.md @@ -0,0 +1,10 @@ +--- +name: Have A Question +about: Ask A Question +title: "[Question]" +labels: question +assignees: '' + +--- + + diff --git a/README.md b/README.md index 7e8ba68..68e0698 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,16 @@

main - diff card filter diff

-- to optimize uploaded files on the fly try [spatie](https://github.com/spatie/laravel-image-optimizer) +- [Installation](##Installation) +- [Config](##Config) +- [Features](##Features) +- [Events](##Events) +- [Usage](##Usage)
@@ -41,13 +44,14 @@ - [install dependencies](https://github.com/ctf0/Laravel-Media-Manager/wiki/Packages-In-Use) ```bash - yarn add vue vue-ls vue-async-computed vue-list-rendered vue-image-compare2 vue-tippy@v1 vue2-filters vue-input-autowidth vue-notif vue-clipboard2 vue-awesome@v2 vue-touch@next idb-keyval axios dropzone cropperjs keycode date-fns lottie-web plyr fuse.js + yarn add vue vue-ls vue-async-computed vue-list-rendered vue-image-compare2 vue-tippy@v1 vue2-filters vue-input-autowidth vue-notif vue-clipboard2 vue-awesome@v2 vue-touch@next vue-focuspoint-component idb-keyval axios dropzone cropperjs keycode date-fns lottie-web plyr fuse.js # or - npm install vue vue-ls vue-async-computed vue-list-rendered vue-image-compare2 vue-tippy@v1 vue2-filters vue-input-autowidth vue-notif vue-clipboard2 vue-awesome@v2 vue-touch@next idb-keyval axios dropzone cropperjs keycode date-fns lottie-web plyr fuse.js --save + npm install vue vue-ls vue-async-computed vue-list-rendered vue-image-compare2 vue-tippy@v1 vue2-filters vue-input-autowidth vue-notif vue-clipboard2 vue-awesome@v2 vue-touch@next vue-focuspoint-component idb-keyval axios dropzone cropperjs keycode date-fns lottie-web plyr fuse.js --save ``` - add this one liner to your main js file and run `npm run watch` to compile your `js/css` files. + if you are having issues [Check](https://ctf0.wordpress.com/2017/09/12/laravel-mix-es6/). + ```js // app.js @@ -55,13 +59,129 @@ // pre Laravel v5.7 require('../vendor/MediaManager/js/manager') - // Laravel v5.7 + // Laravel v5.7+ // require('../assets/vendor/MediaManager/js/manager') new Vue({ el: '#app' }) ``` + +
+ +## Config + +- **config/mediaManager.php** + + ```php + return [ + /* + * ignore files pattern + */ + 'ignore_files' => '/^\..*/', + + /* + * filesystem disk + */ + 'storage_disk' => 'public', + + /* + * manager controller + */ + 'controller' => '\ctf0\MediaManager\Controllers\MediaController', + + /* + * remove any file special chars except + */ + 'allowed_fileNames_chars' => '.\_\-\'\s\(\)\,', + + /* + * remove any folder special chars except (_ -) + */ + 'allowed_folderNames_chars' => '\_\-', + + /* + * disallow uploading files with the following mimetypes + * https://www.iana.org/assignments/media-types/media-types.xhtml + */ + 'unallowed_mimes' => ['php', 'java'], + + /* + * extra mime-types + */ + 'extended_mimes' => [ + 'image' => [ + 'binary/octet-stream', + ], + 'archive' => [ + 'application/x-tar', + 'application/zip', + ], + ], + + /* + * when file names gets cleand up + */ + 'sanitized_text' => 'uniqid', + + /* + * display file last modification time as + * http://carbon.nesbot.com/docs/#api-formatting + */ + 'last_modified_format' => 'toDateString', + + /** + * hide file extension in files list + */ + 'hide_files_ext' => true, + + /* + * load image preview only when item is clicked ? + */ + 'lazy_load_image_on_click' => false, + + /* + * automatically invalidate cache after "in Minutes" + */ + 'cache_expires_after' => 60, + + /* + * in-order to get the folder items count & size + * we need to recursively get all the files inside the folders + * which could make the request take longer + */ + 'get_folder_info' => true, + + /** + * do you want to enable broadcasting the changes + * made by one user to others ? + * + * "laravel-echo" must be installed + */ + 'enable_broadcasting' => false, + + /** + * show "an itunes like" content ratio bar + */ + 'show_ratio_bar' => true, + + /* + * preview and remove files b4 uploading + */ + 'preview_files_before_upload' => true, + + /* + * Database connection + */ + 'database_connection' => env('DB_CONNECTION'), + + /* + * Locked items table name (defaults to "locked") + */ + 'table_locked' => 'locked' + ]; + ``` +
## Features @@ -75,7 +195,7 @@ + using the upload panel + drag & drop anywhere + click & hold on an empty area **"items container"** -- preview files before uploading "you can also add more or remove selected" +- [preview files before uploading](https://github.com/ctf0/Laravel-Media-Manager/wiki/Preview-Files-Before-Uploading) - toggle between `random/original` names for uploaded files - upload an image from a url - [load image on demand](https://github.com/ctf0/Laravel-Media-Manager/wiki/Caching-Strategies#cache-api-image-offline-caching) @@ -177,20 +297,20 @@ ## Events -| type | event-name | description | -|-----------------|----------------------------------------------------|-------------------------------------------------------------| -| [JS][js] | | | -| | modal-show | when modal is showen | -| | modal-hide | when modal is hidden | -| | file_selected *([when inside modal][modal])* | get selected file url | -| | multi_file_selected *([when inside modal][modal])* | get bulk selected files urls | -| | folder_selected *([when inside modal][modal])* | get selected folder path | -| [Laravel][lara] | | | -| | MMFileUploaded($file_path, $mime_type) | get uploaded file full [path][path] & mime type | -| | [MMFileSaved][event]($file_path, $mime_type) | get saved (edited/link) image full [path][path] & mime type | -| | MMFileDeleted($file_path, $is_folder) | get deleted file/folder full [path][path] | -| | MMFileRenamed($old_path, $new_path) | get renamed file/folder "old & new" [path][path] | -| | MMFileMoved($old_path, $new_path) | get moved file/folder "old & new" [path][path] | +| type | event-name | description | +|-----------------|----------------------------------------------------|---------------------------------------------------------------------------------| +| [JS][js] | | | +| | modal-show | when modal is showen | +| | modal-hide | when modal is hidden | +| | file_selected *([when inside modal][modal])* | get selected file url | +| | multi_file_selected *([when inside modal][modal])* | get bulk selected files urls | +| | folder_selected *([when inside modal][modal])* | get selected folder path | +| [Laravel][lara] | | | +| | MMFileUploaded($file_path, $mime_type) | get uploaded file full [path][path], mime type, [custom options][customOptions] | +| | [MMFileSaved][event]($file_path, $mime_type) | get saved (edited/link) image full [path][path] & mime type | +| | MMFileDeleted($file_path, $is_folder) | get deleted file/folder full [path][path] | +| | MMFileRenamed($old_path, $new_path) | get renamed file/folder "old & new" [path][path] | +| | MMFileMoved($old_path, $new_path) | get moved file/folder "old & new" [path][path] | [js]: https://github.com/gocanto/vuemit [lara]: https://laravel.com/docs/master/events#manually-registering-events @@ -198,137 +318,7 @@ [path]: https://gist.github.com/ctf0/9fa6013954654384052d2e2e809b9bf6 [modal]: https://github.com/ctf0/Laravel-Media-Manager/wiki/Use-The-Manager-From-A-Modal [showPreview]: https://github.com/ctf0/Laravel-Media-Manager/blob/master/src/config/mediaManager.php#L126 - -
- -## Config -- **config/mediaManager.php** - - ```php - return [ - /* - * ignore files pattern - */ - 'ignore_files' => '/^\..*/', - - /* - * filesystem disk - */ - 'storage_disk' => 'public', - - /* - * manager controller - */ - 'controller' => '\ctf0\MediaManager\Controllers\MediaController', - - /* - * remove any file special chars except - */ - 'allowed_fileNames_chars' => '.\_\-\'\s\(\)\,', - - /* - * remove any folder special chars except (_ -) - */ - 'allowed_folderNames_chars' => '\_\-', - - /* - * disallow uploading files with the following mimetypes - * https://www.iana.org/assignments/media-types/media-types.xhtml - */ - 'unallowed_mimes' => ['php', 'java'], - - /* - * extra mime-types - */ - 'extended_mimes' => [ - 'image' => [ - 'binary/octet-stream', - ], - 'archive' => [ - 'application/x-tar', - 'application/zip', - ], - ], - - /* - * when file names gets cleand up - */ - 'sanitized_text' => 'uniqid', - - /* - * display file last modification time as - * http://carbon.nesbot.com/docs/#api-formatting - */ - 'last_modified_format' => 'toDateString', - - /** - * hide file extension in files list - */ - 'hide_files_ext' => true, - - /* - * load image preview only when item is clicked ? - */ - 'lazy_load_image_on_click' => false, - - /* - * automatically invalidate cache after "in Minutes" - */ - 'cache_expires_after' => 60, - - /* - * in-order to get the folder items count & size - * we need to recursively get all the files inside the folders - * which could make the request take longer - */ - 'get_folder_info' => true, - - /** - * do you want to enable broadcasting the changes - * made by one user to others ? - * - * "laravel-echo" must be installed - */ - 'enable_broadcasting' => false, - - /** - * show "an itunes like" content ratio bar - */ - 'show_ratio_bar' => true, - - /* - * preview and remove files b4 uploading - */ - 'preview_files_before_upload' => true, - - /* - * Database connection (defaults to "mediamanager") - */ - 'database_connection' => 'mediamanager', - - /* - * Locked items table name (defaults to "locked") - */ - 'table_locked' => 'locked' - ]; - ``` - -- **config/database.php** - - ```php - 'connections' => [ - // ... - - 'mediamanager' => [ - 'driver' => 'mysql', // or whatever you want - 'database' => env('DB_DATABASE'), // or database_path('MediaManager.sqlite') - 'host' => env('DB_HOST'), - 'port' => env('DB_PORT'), - 'username' => env('DB_USERNAME'), - 'password' => env('DB_PASSWORD'), - ] - ] - ``` +[customOptions]: https://github.com/ctf0/Laravel-Media-Manager/wiki/Preview-Files-Before-Uploading#send-custom-options-with-uploaded-files
diff --git a/logs/v3.4.1.txt b/logs/v3.4.1.txt deleted file mode 100644 index c2ac156..0000000 --- a/logs/v3.4.1.txt +++ /dev/null @@ -1,8 +0,0 @@ -- some cleanup -- fix scroll by row after upload -- fix autoscroll to item not firing when the manager panel height changes -- fix mysql-db id issue -- fix missing vue prop for search panel -- check if name of the file being uploaded already exists & ignore it, this way we dont need to wait for the upload to finish just to get an error -- update uploadpreview for small screens -- fix img size in uploadpreview \ No newline at end of file diff --git a/logs/v3.4.3.txt b/logs/v3.4.3.txt new file mode 100644 index 0000000..3f3b788 --- /dev/null +++ b/logs/v3.4.3.txt @@ -0,0 +1,2 @@ +- some cleanup +- more options for upload preview, check https://github.com/ctf0/Laravel-Media-Manager/wiki/Preview-Files-Before-Uploading \ No newline at end of file diff --git a/src/Controllers/Modules/Upload.php b/src/Controllers/Modules/Upload.php index d13f09b..e750d5c 100644 --- a/src/Controllers/Modules/Upload.php +++ b/src/Controllers/Modules/Upload.php @@ -23,20 +23,21 @@ public function upload(Request $request) $random_name = filter_var($request->random_names, FILTER_VALIDATE_BOOLEAN); $result = []; $broadcast = false; + $custom_attr = collect(json_decode($request->custom_attrs)); foreach ($request->file as $one) { if ($this->allowUpload($one)) { - $one = $this->optimizeUpload($one); - - $original = $one->getClientOriginalName(); - $name_only = pathinfo($original, PATHINFO_FILENAME); - $ext_only = pathinfo($original, PATHINFO_EXTENSION); - $file_name = $random_name + $one = $this->optimizeUpload($one); + $orig_name = $one->getClientOriginalName(); + $name_only = pathinfo($orig_name, PATHINFO_FILENAME); + $ext_only = pathinfo($orig_name, PATHINFO_EXTENSION); + $final_name = $random_name ? $this->getRandomString() . ".$ext_only" : $this->cleanName($name_only) . ".$ext_only"; - $file_type = $one->getMimeType(); - $destination = !$upload_path ? $file_name : $this->clearDblSlash("$upload_path/$file_name"); + $file_options = optional($custom_attr->firstWhere('name', $orig_name))->options; + $file_type = $one->getMimeType(); + $destination = !$upload_path ? $final_name : $this->clearDblSlash("$upload_path/$final_name"); try { // check for mime type @@ -54,12 +55,13 @@ public function upload(Request $request) } // save file - $saved_name = $this->storeFile($one, $upload_path, $file_name); + $full_path = $this->storeFile($one, $upload_path, $final_name); // fire event event('MMFileUploaded', [ - 'file_path' => $this->getItemPath($saved_name), + 'file_path' => $this->getItemPath($full_path), 'mime_type' => $file_type, + 'options' => $file_options, 'cache_path' => $upload_path, ]); @@ -67,12 +69,12 @@ public function upload(Request $request) $result[] = [ 'success' => true, - 'file_name' => $file_name, + 'file_name' => $final_name, ]; } catch (Exception $e) { $result[] = [ 'success' => false, - 'message' => "\"$file_name\" " . $e->getMessage(), + 'message' => "\"$final_name\" " . $e->getMessage(), ]; } } else { diff --git a/src/config/mediaManager.php b/src/config/mediaManager.php index 757336c..3109cb7 100644 --- a/src/config/mediaManager.php +++ b/src/config/mediaManager.php @@ -72,10 +72,9 @@ /* * display file last modification time as + * check "/vendor/nesbot/carbon/src/Carbon/Carbon.php" * * "clear browser cache on change" - * - * check "/vendor/nesbot/carbon/src/Carbon/Carbon.php" */ 'last_modified_format' => 'toDateString', @@ -126,12 +125,12 @@ 'preview_files_before_upload' => true, /* - * Database connection (defaults to "mediamanager") + * Database connection */ - 'database_connection' => 'mediamanager', + 'database_connection' => env('DB_CONNECTION'), /* * Locked items table name (defaults to "locked") */ - 'table_locked' => 'locked' + 'table_locked' => 'locked', ]; diff --git a/src/resources/assets/js/components/globalSearch/lazyLoading.vue b/src/resources/assets/js/components/globalSearch/lazyLoading.vue index 8819858..e5bd2a7 100644 --- a/src/resources/assets/js/components/globalSearch/lazyLoading.vue +++ b/src/resources/assets/js/components/globalSearch/lazyLoading.vue @@ -1,6 +1,6 @@