|
1 |
| -silverstripe-kickassets |
2 |
| -======================= |
| 1 | +# KickAssets 3 for SilverStripe |
3 | 2 |
|
4 |
| -KickAssets module for asset management in SilverStripe 3. Replaces AssetAdmin. Offers desktop-like file management with multi-selection, drag and drop, etc. |
| 3 | +KickAssets is a replacement for the *Files & Images* section (AssetAdmin) in SilverStripe CMS. It adds drag-and-drop uploading, mouse and keyboard selection, and a variety of other desktop-like file UI features. |
| 4 | + |
| 5 | +## See it. In 49 Seconds of Superfluous Flair. |
| 6 | +<a href="https://vimeo.com/145456487" target="_blank"><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/0.png" width="600"></a> |
| 7 | + |
| 8 | +## Installation |
| 9 | + |
| 10 | +`composer require unclecheese/silverstripe-kickassets` |
| 11 | + |
| 12 | +## Screenshots |
| 13 | + |
| 14 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/1.png" width="600"></p> |
| 15 | + |
| 16 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/2.png" width="600"></p> |
| 17 | + |
| 18 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/3.png" width="600"></p> |
| 19 | + |
| 20 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/4.png" width="600"></p> |
| 21 | + |
| 22 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/5.png" width="600"></p> |
| 23 | + |
| 24 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/6.png" width="600"></p> |
| 25 | + |
| 26 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/7.png" width="600"></p> |
| 27 | + |
| 28 | +<p><img src="https://raw.githubusercontent.com/unclecheese/silverstripe-kickassets/master/images/screenshots/8.png" width="600"></p> |
| 29 | + |
| 30 | +## JavaScript API |
| 31 | + |
| 32 | +An API is exposed to the entire CMS that allows you to prompt the user to select a file in the KickAssets UI. The following |
| 33 | +```js |
| 34 | +$('.select-files').entwine({ |
| 35 | + onclick: function(e) { |
| 36 | + e.preventDefault(); |
| 37 | + var $t = this; |
| 38 | + KickAssets.requestFile(function(file) { |
| 39 | + $t.next('ul').append('<li><img src="'+file.iconURL+'"> '+file.filename+'</li>'); |
| 40 | + }); |
| 41 | + } |
| 42 | +}); |
| 43 | +``` |
| 44 | + |
| 45 | +Also available is `KickAssets.requestFiles`, which returns an array of `file` objects. |
| 46 | + |
| 47 | +Optionally, you can pass list of permissions as a first parameter to `requestFile` or `requestFiles`. |
| 48 | + |
| 49 | +```js |
| 50 | +$('.select-files').entwine({ |
| 51 | + onclick: function(e) { |
| 52 | + e.preventDefault(); |
| 53 | + var $t = this; |
| 54 | + var permissions = { |
| 55 | + folderID: 123, |
| 56 | + canUpload: false |
| 57 | + }; |
| 58 | + KickAssets.requestFile(permissions, function(file) { |
| 59 | + $t.next('ul').append('<li><img src="'+file.iconURL+'"> '+file.filename+'</li>'); |
| 60 | + }); |
| 61 | + } |
| 62 | +}); |
| 63 | +``` |
| 64 | + |
| 65 | +A full list of permissions: |
| 66 | + |
| 67 | +| Name | Description | Default value | |
| 68 | +|---|---|---| |
| 69 | +| maxSelection | The maximum number of files that can be selected and returned. 0 for unlimited. | 0 | |
| 70 | +| folderID | The ID of the folder to start in | 0 | |
| 71 | +| canUpload | Whether the user should be able to upload in the window | true | |
| 72 | +| canDelete | Whether the user should be able to delete files or folders in the window | true | |
| 73 | +| canEdit | Whether the user should be able to edit files in the window | true | |
| 74 | +| canCreateFolder | Whether the user should be able to add folders in the window | true | |
| 75 | +| allowedTypes | A comma-separated list of file types that can be selected | 'file,image,folder' | |
| 76 | + |
| 77 | + |
| 78 | +## Browser support |
| 79 | + |
| 80 | +Everyone can come to the party except IE9. Sorry. |
| 81 | + |
| 82 | +(Not really.) |
| 83 | + |
| 84 | +## Contributing |
| 85 | + |
| 86 | +KickAssets is written in <a target="_blank" href="http://facebook.github.io/react">React JS</a>, and requires transpiling from ES6 and JSX. This is done using <a target="_blank" href="http://webpack.github.io">Webpack</a> and <a href="http://babeljs.io" target="_blank">Babel</a>. You will need to install Webpack on your system. |
| 87 | + |
| 88 | +`npm install -g webpack` |
| 89 | + |
| 90 | +Then, run `npm install` in your `kickassets` module directory to install all of the dependencies. |
| 91 | + |
| 92 | +To start writing code, run: |
| 93 | +`webpack -watch` |
| 94 | + |
| 95 | +When finished, create a production bundle by setting an environment file and turning on minification. |
| 96 | + |
| 97 | +`PROD=1 webpack -p`. |
| 98 | + |
| 99 | +## Troubleshooting |
| 100 | + |
| 101 | +Ring Uncle Cheese. |
0 commit comments