Integrate Dragonfly into CKeditor in Rails Admin with Rails 3 -


i have ckeditor working splendid in rails admin.

but want enable image upload users can insert own images. read possible paperclip , carrierwave i'm using dragonfly lot of things don't want change that.

this ckeditor config.js:

ckeditor.editorconfig = function( config ) {     config.toolbar_toolbar =     [         { name: 'basicstyles', items : [ 'bold','italic','strike','underline','-','removeformat'] },         { name: 'justify', items : [ 'justifyleft', 'justifycenter', 'justifyright', 'justifyblock' ] },         { name: 'styles', items : [ 'format' ] },                { name: 'insert', items : [ 'image','specialchar'] },         '/',         { name: 'clipboard', items : [ 'cut','copy','paste','pastetext','pastefromword','-','undo','redo' ] },                 { name: 'paragraph', items : [ 'numberedlist','bulletedlist','-','outdent','indent','-'] },         { name: 'links', items : [ 'link','unlink','anchor', 'source' ] }     ];     config.toolbar = 'toolbar';     config.allowedcontent = true; } 

when "image" don't see way of uploading file , can't clear answer on github page of ckeditor (https://github.com/galetahub/ckeditor).

important i'm using rails version 3.2.13

update 1:

i reading on page http://richonrails.com/articles/getting-started-with-ckeditor

and tried rails generate ckeditor:install --orm=active_record --backend=dragonfly still no difference.

i searching on stackoverflow , solution worked me :

ckeditor in rails 3

now config.js looks this:

ckeditor.editorconfig = function( config ) {     config.toolbar_toolbar =     [         { name: 'basicstyles', items : [ 'bold','italic','strike','underline','-','removeformat'] },         { name: 'justify', items : [ 'justifyleft', 'justifycenter', 'justifyright', 'justifyblock' ] },         { name: 'styles', items : [ 'format' ] },                { name: 'insert', items : [ 'image','specialchar','insert','tools'] },         '/',         { name: 'clipboard', items : [ 'cut','copy','paste','pastetext','pastefromword','-','undo','redo' ] },                 { name: 'paragraph', items : [ 'numberedlist','bulletedlist','-','outdent','indent','-'] },         { name: 'links', items : [ 'link','unlink','anchor', 'source' ] }     ];     config.toolbar = 'toolbar';     config.allowedcontent = true;        /* filebrowser routes */     // location of external file browser, should launched when "browse server" button pressed.     config.filebrowserbrowseurl = "/ckeditor/attachment_files";      // location of external file browser, should launched when "browse server" button pressed in flash dialog.     config.filebrowserflashbrowseurl = "/ckeditor/attachment_files";      // location of script handles file uploads in flash dialog.     config.filebrowserflashuploadurl = "/ckeditor/attachment_files";      // location of external file browser, should launched when "browse server" button pressed in link tab of image dialog.     config.filebrowserimagebrowselinkurl = "/ckeditor/pictures";      // location of external file browser, should launched when "browse server" button pressed in image dialog.     config.filebrowserimagebrowseurl = "/ckeditor/pictures";      // location of script handles file uploads in image dialog.     config.filebrowserimageuploadurl = "/ckeditor/pictures";      // location of script handles file uploads.     config.filebrowseruploadurl = "/ckeditor/attachment_files";      // rails csrf token     config.filebrowserparams = function(){         var csrf_token, csrf_param, meta,             metas = document.getelementsbytagname('meta'),             params = new object();          ( var = 0 ; < metas.length ; i++ ){             meta = metas[i];              switch(meta.name) {                 case "csrf-token":                     csrf_token = meta.content;                     break;                 case "csrf-param":                     csrf_param = meta.content;                     break;                 default:                     continue;             }         }          if (csrf_param !== undefined && csrf_token !== undefined) {             params[csrf_param] = csrf_token;         }          return params;     };      config.addquerystring = function( url, params ){         var querystring = [];          if ( !params ) {             return url;         } else {             ( var in params )                 querystring.push( + "=" + encodeuricomponent( params[ ] ) );         }          return url + ( ( url.indexof( "?" ) != -1 ) ? "&" : "?" ) + querystring.join( "&" );     };      // integrate rails csrf token file upload dialogs (link, image, attachment , flash)     ckeditor.on( 'dialogdefinition', function( ev ){         // take dialog name , definition event data.         var dialogname = ev.data.name;         var dialogdefinition = ev.data.definition;         var content, upload;          if (ckeditor.tools.indexof(['link', 'image', 'attachment', 'flash'], dialogname) > -1) {             content = (dialogdefinition.getcontents('upload') || dialogdefinition.getcontents('upload'));             upload = (content == null ? null : content.get('upload'));              if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) {                 upload.filebrowser['params'] = config.filebrowserparams();                 upload.action = config.addquerystring(upload.action, upload.filebrowser['params']);             }         }     }); } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -