Skip to content

Commit 63890c2

Browse files
committed
modify readme
1 parent 131f410 commit 63890c2

File tree

5 files changed

+260
-259
lines changed

5 files changed

+260
-259
lines changed

README.md

Lines changed: 7 additions & 259 deletions
Original file line numberDiff line numberDiff line change
@@ -11,269 +11,17 @@ PR is welcome!
1111
* Customizable views, routes and middlewares
1212
* Supported locales : en, fr, pt-BR, tr, zh-CN, zh-TW
1313

14-
15-
## Requirements
16-
17-
* php >= 5.5
18-
* Laravel 5
19-
* requires [intervention/image](https://github.com/Intervention/image) (to make thumbs, crop and resize images).
20-
21-
## Notes
22-
23-
* For `laravel 5.2`, please set `'middlewares' => ['web', 'auth'],` in config/lfm.php
24-
* With laravel-filemanager >= 1.3.0, the new configs `valid_image_mimetypes` and `valid_file_mimetypes` restrict the MIME types of the uploading files.
25-
26-
## Installation
27-
28-
1. Install package
29-
30-
```bash
31-
composer require unisharp/laravel-filemanager
32-
```
33-
34-
1. Edit `config/app.php` :
35-
36-
Add service providers
37-
38-
```php
39-
Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
40-
Intervention\Image\ImageServiceProvider::class,
41-
```
42-
43-
And add class aliases
44-
45-
```php
46-
'Image' => Intervention\Image\Facades\Image::class,
47-
```
48-
49-
1. Publish the package's config and assets :
50-
51-
```bash
52-
php artisan vendor:publish --tag=lfm_config
53-
php artisan vendor:publish --tag=lfm_public
54-
```
55-
56-
1. Ensure that the files & images directories (in `config/lfm.php`) are writable by your web server.
57-
58-
## WYSIWYG Editor Integration:
59-
### Option 1: CKEditor
60-
61-
1. Install [laravel-ckeditor](https://github.com/UniSharp/laravel-ckeditor) package
62-
63-
1. Modify the views
64-
65-
Sample 1 - Replace by ID:
66-
```html
67-
<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
68-
<textarea id="my-editor" name="content" class="form-control">{!! old('content', $content) !!}</textarea>
69-
<script>
70-
CKEDITOR.replace( 'my-editor', {
71-
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
72-
filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token={{csrf_token()}}',
73-
filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
74-
filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token={{csrf_token()}}'
75-
});
76-
</script>
77-
```
78-
79-
Sample 2 - With JQuery Selector:
80-
81-
```html
82-
<script src="/vendor/unisharp/laravel-ckeditor/ckeditor.js"></script>
83-
<script src="/vendor/unisharp/laravel-ckeditor/adapters/jquery.js"></script>
84-
<textarea name="content" class="form-control my-editor">{!! old('content', $content) !!}</textarea>
85-
<script>
86-
$('textarea.my-editor').ckeditor({
87-
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
88-
filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token={{csrf_token()}}',
89-
filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
90-
filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token={{csrf_token()}}'
91-
});
92-
</script>
93-
```
94-
95-
### Option 2: TinyMCE4
96-
97-
```html
98-
<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
99-
<textarea name="content" class="form-control my-editor">{!! old('content', $content) !!}</textarea>
100-
<script>
101-
var editor_config = {
102-
path_absolute : "/",
103-
selector: "textarea",
104-
plugins: [
105-
"advlist autolink lists link image charmap print preview hr anchor pagebreak",
106-
"searchreplace wordcount visualblocks visualchars code fullscreen",
107-
"insertdatetime media nonbreaking save table contextmenu directionality",
108-
"emoticons template paste textcolor colorpicker textpattern"
109-
],
110-
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media",
111-
relative_urls: false,
112-
file_browser_callback : function(field_name, url, type, win) {
113-
var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
114-
var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;
115-
116-
var cmsURL = editor_config.path_absolute + 'laravel-filemanager?field_name=' + field_name;
117-
if (type == 'image') {
118-
cmsURL = cmsURL + "&type=Images";
119-
} else {
120-
cmsURL = cmsURL + "&type=Files";
121-
}
122-
123-
tinyMCE.activeEditor.windowManager.open({
124-
file : cmsURL,
125-
title : 'Filemanager',
126-
width : x * 0.8,
127-
height : y * 0.8,
128-
resizable : "yes",
129-
close_previous : "no"
130-
});
131-
}
132-
};
133-
134-
tinymce.init(editor_config);
135-
</script>
136-
```
137-
138-
##Independent use
139-
140-
If you are going to use filemanager independently,meaning set the value of an input to selected photo/file url,follow this structure:
141-
142-
1. create a popup window or modal(whatever you like):
143-
144-
```html
145-
<a href="/laravel-filemanager" id="feature-img-container"><img src="no_photo.jpg"></a>
146-
<input name="thumbnail" type="hidden" id="thumbnail">
147-
```
148-
149-
```javascript
150-
$('#feature-img-container').on('click', function(e)
151-
{
152-
153-
window.open(this.href, 'Filemanager', 'width=900,height=600');
154-
155-
return false;
156-
});
157-
```
158-
159-
2. define a function named `SetUrl`:
160-
161-
```javascript
162-
function SetUrl(url){
163-
164-
//set the value of the desired input to image url,often this is a hidden input
165-
$('#thumbnail').val(url);
166-
167-
//set or change the feature image src,recall wordpress feature image
168-
$('#feature-img-container').find('img').attr('src',url);
169-
}
170-
```
171-
172-
173-
## Config
174-
175-
In `config/lfm.php` :
176-
177-
```php
178-
'rename_file' => true,
179-
// true : files will be renamed as uniqid
180-
// false : files will remain original names
181-
182-
'use_package_routes' => true,
183-
// set this to false to customize route for file manager
184-
185-
'middlewares' => ['auth'],
186-
// determine middlewares that apply to all file manager routes
187-
// NOTE: for laravel 5.2, please use ['web', 'auth']
188-
189-
'allow_multi_user' => true,
190-
// true : user can upload files to shared folder and their own folder
191-
// false : all files are put together in shared folder
192-
193-
'user_field' => 'id',
194-
// determine which column of users table will be used as user's folder name
195-
196-
'shared_folder_name' => 'shares',
197-
// the name of shared folder
198-
199-
'thumb_folder_name' => 'thumbs',
200-
// the name of thumb folder
201-
202-
'images_dir' => 'public/photos/',
203-
'images_url' => '/photos/',
204-
// path and url of images
205-
206-
'files_dir' => 'public/files/',
207-
'files_url' => '/files/',
208-
// path and url of files
209-
210-
211-
// valid image mimetypes
212-
'valid_image_mimetypes' => [
213-
'image/jpeg',
214-
'image/pjpeg',
215-
'image/png',
216-
'image/gif'
217-
],
218-
219-
220-
// valid file mimetypes (only when '/laravel-filemanager?type=Files')
221-
'valid_file_mimetypes' => [
222-
'image/jpeg',
223-
'image/pjpeg',
224-
'image/png',
225-
'image/gif',
226-
'application/pdf',
227-
'text/plain'
228-
],
229-
```
230-
231-
## Customization
232-
233-
1. If the route is changed, make sure urls below is correspond to your route :
234-
235-
CKEditor
236-
```javascript
237-
<script>
238-
CKEDITOR.replace( 'editor', {
239-
filebrowserImageBrowseUrl: '/your-custom-route?type=Images',
240-
filebrowserBrowseUrl: '/your-custom-route?type=Files',
241-
});
242-
</script>
243-
```
244-
245-
And be sure to include the `?type=Images` or `?type=Files` parameter.
246-
247-
TinyMCE
248-
```javascript
249-
...
250-
var cmsURL = editor_config.path_absolute + 'your-custom-route?field_name='+field_name+'&lang='+ tinymce.settings.language;
251-
if (type == 'image') {
252-
cmsURL = cmsURL + "&type=Images";
253-
} else {
254-
cmsURL = cmsURL + "&type=Files";
255-
}
256-
...
257-
```
258-
259-
1. To customize the views :
260-
261-
on Linux :
262-
263-
```bash
264-
cp -rf vendor/unisharp/laravel-filemanager/src/views/* resources/views/vendor/laravel-filemanager/
265-
```
266-
267-
on MAC :
268-
269-
```bash
270-
cp -rf vendor/unisharp/laravel-filemanager/src/views/ resources/views/vendor/laravel-filemanager/
271-
```
272-
27314
## Screenshots
27415
![FileManager screenshot 1](http://unisharp.com/img/filemanager1.png)
27516
![FileManager screenshot 2](http://unisharp.com/img/filemanager2.png)
27617

18+
## Documents
19+
20+
1. [Installation](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/installation.md)
21+
1. [Intergration](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/intergration.md)
22+
1. [Config](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/config.md)
23+
1. [Customization](https://github.com/UniSharp/laravel-filemanager/blob/master/doc/customization.md)
24+
27725
## Credits
27826
* All contibutors from GitHub. (issues / PR)
27927
* Special thanks to

doc/config.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Config
2+
3+
In `config/lfm.php` :
4+
5+
```php
6+
'rename_file' => true,
7+
// true : files will be renamed as uniqid
8+
// false : files will remain original names
9+
10+
'use_package_routes' => true,
11+
// set this to false to customize route for file manager
12+
13+
'middlewares' => ['auth'],
14+
// determine middlewares that apply to all file manager routes
15+
// NOTE: for laravel 5.2, please use ['web', 'auth']
16+
17+
'allow_multi_user' => true,
18+
// true : user can upload files to shared folder and their own folder
19+
// false : all files are put together in shared folder
20+
21+
'user_field' => 'id',
22+
// determine which column of users table will be used as user's folder name
23+
24+
'shared_folder_name' => 'shares',
25+
// the name of shared folder
26+
27+
'thumb_folder_name' => 'thumbs',
28+
// the name of thumb folder
29+
30+
'images_dir' => 'public/photos/',
31+
'images_url' => '/photos/',
32+
// path and url of images
33+
34+
'files_dir' => 'public/files/',
35+
'files_url' => '/files/',
36+
// path and url of files
37+
38+
39+
// valid image mimetypes
40+
'valid_image_mimetypes' => [
41+
'image/jpeg',
42+
'image/pjpeg',
43+
'image/png',
44+
'image/gif'
45+
],
46+
47+
48+
// valid file mimetypes (only when '/laravel-filemanager?type=Files')
49+
'valid_file_mimetypes' => [
50+
'image/jpeg',
51+
'image/pjpeg',
52+
'image/png',
53+
'image/gif',
54+
'application/pdf',
55+
'text/plain'
56+
],
57+
```

doc/customization.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Customization
2+
3+
1. If the route is changed, make sure urls below is correspond to your route :
4+
5+
CKEditor
6+
```javascript
7+
<script>
8+
CKEDITOR.replace( 'editor', {
9+
filebrowserImageBrowseUrl: '/your-custom-route?type=Images',
10+
filebrowserBrowseUrl: '/your-custom-route?type=Files',
11+
});
12+
</script>
13+
```
14+
15+
And be sure to include the `?type=Images` or `?type=Files` parameter.
16+
17+
TinyMCE
18+
```javascript
19+
...
20+
var cmsURL = editor_config.path_absolute + 'your-custom-route?field_name='+field_name+'&lang='+ tinymce.settings.language;
21+
if (type == 'image') {
22+
cmsURL = cmsURL + "&type=Images";
23+
} else {
24+
cmsURL = cmsURL + "&type=Files";
25+
}
26+
...
27+
```
28+
29+
1. To customize the views :
30+
31+
on Linux :
32+
33+
```bash
34+
cp -rf vendor/unisharp/laravel-filemanager/src/views/* resources/views/vendor/laravel-filemanager/
35+
```
36+
37+
on MAC :
38+
39+
```bash
40+
cp -rf vendor/unisharp/laravel-filemanager/src/views/ resources/views/vendor/laravel-filemanager/
41+
```

0 commit comments

Comments
 (0)