Skip to content

Commit

Permalink
v2.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ctf0 committed Dec 17, 2017
1 parent 82595e7 commit b902911
Show file tree
Hide file tree
Showing 18 changed files with 262 additions and 183 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ new Vue({
- toggle between `random names` & `original names` for uploaded files
- download selected ["including bulk selection"](https://github.com/ctf0/Laravel-Media-Manager/wiki/Download-Files-as-a-ZipFile)
- directly copy selected file link
- use manager [from modal with ease](https://github.com/ctf0/Laravel-Media-Manager/wiki/Use-The-Manager-From-A-Modal)
- use the manager
+ [from modal with ease](https://github.com/ctf0/Laravel-Media-Manager/wiki/Use-The-Manager-From-A-Modal)
+ [with any wysiwyg editor](https://github.com/ctf0/Laravel-Media-Manager/wiki/Use-The-Manager-With-Any-WYSIWYG-Editor)
- auto scroll to selected item when using (left/up, right/down, home, end)
- [lock/unlock selected files/folders](https://github.com/ctf0/Laravel-Media-Manager/wiki/Lock-Files-&-Folder) "***sqlite needs to be installed"***
- search
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"require": {
"php" : "~7.0",
"illuminate/support": "5.4 || 5.5",
"maennchen/zipstream-php": "^0.5.0",
"ctf0/package-changelog": "^1.0"
},
"autoload": {
Expand Down
10 changes: 0 additions & 10 deletions logs/v2.3.5.txt

This file was deleted.

25 changes: 25 additions & 0 deletions logs/v2.3.6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Fix

- show correct total size in delete modal
- add some sense to css classes
- move dropzone file input inside its own form so you don’t have a bazillion inputs at the end of the DOM on each toggle of the modal
- some cleanup to the media-controller

# New

- add support for WYSIWYG Editors
https://github.com/ctf0/Laravel-Media-Manager/wiki/Use-The-Manager-With-Any-WYSIWYG-Editor
- sidebar no selection icon is now a btn to reset “bulk select & search”

# Zip

- you can now download folders as a zip as well
- the zipping is now done on server & downloaded as a stream, so no worries about memory issues nor you need to install any extra js packages
- sadly no more progress for zipping as the form submit is not being handled by js, so any ideas/PRs are welcome


# Update

- update readme
- update assets
- update wiki
61 changes: 58 additions & 3 deletions src/Controllers/MediaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ctf0\MediaManager\Controllers;

use Exception;
use ZipStream\ZipStream;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

Expand Down Expand Up @@ -107,9 +108,9 @@ public function upload(Request $request)
$file_type = $one->getMimeType();

$original = $one->getClientOriginalName();
$file_ext = $one->getClientOriginalExtension();
$get_name = str_replace(".$file_ext", '', $original);
$file_name = $random_name ? uniqid() . ".$file_ext" : $this->cleanName($get_name, null, $file_ext) . ".$file_ext";
$get_name = pathinfo($original, PATHINFO_FILENAME);
$file_ext = pathinfo($original, PATHINFO_EXTENSION);
$file_name = $random_name ? uniqid() . ".$file_ext" : $this->cleanName($get_name, null) . ".$file_ext";
$destination = "$upload_path/$file_name";

try {
Expand Down Expand Up @@ -355,4 +356,58 @@ public function lock_file(Request $request)

return response()->json(['message'=>"'$path' " . ucfirst($state)]);
}

/**
* zip folder.
*
* @param Request $request [description]
*
* @return [type] [description]
*/
public function folder_download(Request $request)
{
$name = $request->name;
$dir = "{$request->folders}/$name";

return response()->stream(function () use ($name, $dir) {
$zip = new ZipStream("$name.zip", [
'content_type' => 'application/octet-stream',
]);

foreach ($this->storageDisk->allFiles($dir) as $file) {
$name = pathinfo($file, PATHINFO_BASENAME);
$stream = $this->storageDisk->readStream($file);

$zip->addFileFromStream($name, $stream);
}

$zip->finish();
});
}

/**
* zip files.
*
* @param Request $request [description]
*
* @return [type] [description]
*/
public function files_download(Request $request)
{
$name = $request->name;
$list = json_decode($request->list, true);

return response()->stream(function () use ($name, $list) {
$zip = new ZipStream("$name.zip", [
'content_type' => 'application/octet-stream',
]);

foreach ($list as $file) {
$stream = fopen($file['path'], 'r');
$zip->addFileFromStream($file['name'], $stream);
}

$zip->finish();
});
}
}
6 changes: 3 additions & 3 deletions src/Controllers/OpsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function getData($dir)
if (!preg_grep($pattern, [$folder])) {
$time = $this->storageDisk->lastModified($folder);
$files[] = [
'name' => strpos($folder, '/') > 1 ? str_replace('/', '', strrchr($folder, '/')) : $folder,
'name' => pathinfo($folder, PATHINFO_BASENAME),
'type' => 'folder',
'path' => $this->storageDisk->url($folder),
'size' => $this->folderSize($folder),
Expand All @@ -40,7 +40,7 @@ protected function getData($dir)
if (!preg_grep($pattern, [$file])) {
$time = $this->storageDisk->lastModified($file);
$files[] = [
'name' => strpos($file, '/') > 1 ? str_replace('/', '', strrchr($file, '/')) : $file,
'name' => pathinfo($file, PATHINFO_BASENAME),
'type' => $this->storageDisk->mimeType($file),
'path' => $this->storageDisk->url($file),
'size' => $this->storageDisk->size($file),
Expand Down Expand Up @@ -109,7 +109,7 @@ protected function folderFiles($folder)
}

/**
* get file path from storange.
* get file path from storage.
*
* @param [type] $disk [description]
* @param [type] $name [description]
Expand Down
3 changes: 3 additions & 0 deletions src/MediaRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public static function routes()
Route::post('move_file', ['uses' => '\ctf0\MediaManager\Controllers\MediaController@move_file', 'as' => 'move_file']);
Route::post('rename_file', ['uses' => '\ctf0\MediaManager\Controllers\MediaController@rename_file', 'as' => 'rename_file']);
Route::post('lock_file', ['uses' => '\ctf0\MediaManager\Controllers\MediaController@lock_file', 'as' => 'lock_file']);

Route::post('folder_download', ['uses' => '\ctf0\MediaManager\Controllers\MediaController@folder_download', 'as' => 'folder_download']);
Route::post('files_download', ['uses' => '\ctf0\MediaManager\Controllers\MediaController@files_download', 'as' => 'files_download']);
});
}
}
16 changes: 16 additions & 0 deletions src/resources/assets/js/components/editor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script>
export default {
name: 'editor-media-manager',
data() {
return {
showModal: false
}
},
methods: {
toggleModal() {
this.showModal = !this.showModal
}
},
render() {}
}
</script>
11 changes: 7 additions & 4 deletions src/resources/assets/js/components/media.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import SelectedFile from './mixins/selected'
import Restriction from './mixins/restriction'
import Watchers from './mixins/watch'
import Computed from './mixins/computed'
import Download from './mixins/download'
import Bounty from 'vue-bounty'
Expand All @@ -23,7 +22,6 @@ export default {
LockFile,
SelectedFile,
Restriction,
Download,
Computed,
Watchers
],
Expand Down Expand Up @@ -80,8 +78,12 @@ export default {
navDirection: null,
gradients: [
'linear-gradient(45deg,#6FE594,#27A47C)',
'linear-gradient(45deg,#F1467A,#FB949E)'
'linear-gradient(141deg, #009e6c 0%, #00d1b2 71%, #00e7eb 100%)',
'linear-gradient(141deg, #04a6d7 0%, #209cee 71%, #3287f5 100%)',
'linear-gradient(141deg, #12af2f 0%, #23d160 71%, #2ce28a 100%)',
'linear-gradient(141deg, #ffaf24 0%, #ffdd57 71%, #fffa70 100%)',
'linear-gradient(141deg, #ff0561 0%, #ff3860 71%, #ff5257 100%)',
'linear-gradient(141deg, #1f191a 0%, #363636 71%, #46403f 100%)'
]
}
},
Expand Down Expand Up @@ -134,6 +136,7 @@ export default {
new Dropzone('#new-upload', {
createImageThumbnails: false,
parallelUploads: 10,
hiddenInputContainer: '#new-upload',
uploadMultiple: true,
forceFallback: false,
ignoreHiddenFiles: true,
Expand Down
92 changes: 0 additions & 92 deletions src/resources/assets/js/components/mixins/download.js

This file was deleted.

21 changes: 21 additions & 0 deletions src/resources/assets/js/components/mixins/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('./../../vendor/download.min')

export default {
methods: {
isLastItem(item, list) {
Expand Down Expand Up @@ -58,6 +60,12 @@ export default {
!this.allItemsCount ||
this.isBulkSelecting() && !this.bulkItemsCount
},
reset() {
this.bulkSelect = false
this.bulkSelectAll = false
this.resetInput('bulkList', [])
this.resetInput(['selectedFile', 'currentFileIndex', 'searchFor'])
},

/* Resolve */
getFileName(name) {
Expand Down Expand Up @@ -165,6 +173,19 @@ export default {
this.linkCopied = true
this.$copyText(path)
},
// download
saveFile(item) {
if (this.isBulkSelecting()) {
this.bulkList.forEach((e) => {
downloadFile(e.path)
})

return this.showNotif('All Done')
}

downloadFile(item.path)
return this.showNotif(`"${item.name}" ${this.trans('downloaded')}`)
},

// ls
updateLs(obj) {
Expand Down
3 changes: 1 addition & 2 deletions src/resources/assets/js/events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// M O D A L //
// M O D A L
EventHub.listen('modal-show', () => {})
EventHub.listen('modal-hide', () => {})

Expand Down Expand Up @@ -40,7 +40,6 @@ EventHub.listen('ajax-error-show', () => {

/**
* body movin animation
* you can remove it / replace it, do what you want
*/
function bm(el, name) {
bodymovin.loadAnimation({
Expand Down
3 changes: 2 additions & 1 deletion src/resources/assets/js/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import 'vue-awesome/icons/angle-double-left'
import 'vue-awesome/icons/bars'
import 'vue-awesome/icons/clone'
import 'vue-awesome/icons/file-pdf-o'
import 'vue-awesome/icons/mouse-pointer'
import 'vue-awesome/icons/power-off'
import 'vue-awesome/icons/file-text-o'
import 'vue-awesome/icons/download'
import 'vue-awesome/icons/warning'
Expand All @@ -78,6 +78,7 @@ Vue.component('icon', require('vue-awesome/components/Icon'))

/* Components */
Vue.component('MediaManager', require('./components/media.vue'))
Vue.component('EditorMediaManager', require('./components/editor.vue'))
Vue.component('MyNotification', require('vue-notif'))

/* Events */
Expand Down
Loading

0 comments on commit b902911

Please sign in to comment.