Giter Site home page Giter Site logo

kristiandaugaard / silverstripe-kickassets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unclecheese/silverstripe-kickassets

0.0 1.0 0.0 9.49 MB

KickAssets module for asset management in SilverStripe 3

License: GNU General Public License v2.0

PHP 0.94% CSS 7.29% JavaScript 91.76% Scheme 0.02%

silverstripe-kickassets's Introduction

KickAssets 3 for SilverStripe

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.

See it. In 49 Seconds of Superfluous Flair.

Demo

Try it out.

(User: kickassets / Pass: kickassets)

Installation

composer require unclecheese/silverstripe-kickassets

Dependencies

Screenshots

JavaScript API

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

$('.select-files').entwine({
	onclick: function(e) {	
		e.preventDefault();
		var $t = this;
		KickAssets.requestFile(function(file) {
			$t.next('ul').append('<li><img src="'+file.iconURL+'"> '+file.filename+'</li>');
		});
	}
});

Also available is KickAssets.requestFiles, which returns an array of file objects.

Optionally, you can pass list of permissions as a first parameter to requestFile or requestFiles.

$('.select-files').entwine({
	onclick: function(e) {	
		e.preventDefault();
		var $t = this;
		var permissions = {
			folderID: 123, 
			canUpload: false		
		};
		KickAssets.requestFile(permissions, function(file) {
			$t.next('ul').append('<li><img src="'+file.iconURL+'"> '+file.filename+'</li>');
		});
	}
});

A full list of permissions:

Name Description Default value
maxSelection The maximum number of files that can be selected and returned. 0 for unlimited. 0
folderID The ID of the folder to start in 0
canUpload Whether the user should be able to upload in the window true
canDelete Whether the user should be able to delete files or folders in the window true
canEdit Whether the user should be able to edit files in the window true
canCreateFolder Whether the user should be able to add folders in the window true
allowedTypes A comma-separated list of file types that can be selected 'file,image,folder'

Usage with UploadField and Dropzone

By default, the unclecheese/silverstripe-dropzone module will detect KickAssets and use it on FileAttachmentField for selecting existing files.

To get the same behaviour on UploadField, ensure the use_on_uploadfield setting is set to true. (It is by default).

KickAssets:
  use_on_uploadfield: true

Most settings, such as max files, allowed extensions, and and upload folder will transfer over to the KickAssets window.

Usage with HTMLEditorField

In addition to the "Insert Media" button that comes with the default configuration of the CMS, KickAssets adds a "Browse files..." buttton that opens the KickAssets window, allowing you to upload, move, edit, and delete files and insert them into the editor at the position of the cursor.

If you select one or many images, they will be appended to the the editor in the order in which they were selected. If you select a file, it will link any text that is selected in the editor to the URL of that file. If no text is selected and you choose a file, it will insert a link to the file using the title of the file as the clickable text.

Browser support

Everyone can come to the party except IE9. Sorry.

(I'm not really sorry.)

Contributing

KickAssets is written in React JS, and requires transpiling from ES6 and JSX. This is done using Webpack and Babel. You will need to install Webpack on your system.

npm install -g webpack

Then, run npm install in your kickassets module directory to install all of the dependencies.

To start writing code, run: webpack --watch

When finished, create a production bundle by setting an environment file and turning on minification.

PROD=1 webpack -p.

If you would prefer not to install webpack globally, there are these handy npm scripts:

  • npm run build - Does a one time webpack build
  • npm run build:watch - Equivalent to webpack --watch
  • npm run build:prod - Equivalent to PROD=1 webpack -p

Troubleshooting

Ring Uncle Cheese.

silverstripe-kickassets's People

Contributors

jonom avatar alex-dna avatar grzegorzbialy avatar cjsewell avatar davidmorrisonnz avatar rsmclaren avatar shrikefin avatar

Watchers

Kristian Daugaard avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.