Tagged: fckeditro

[HOWTO] WYSIWYG with Grails + CKEditor + Spring Security

Add last version of Grails CKEditor plugin to BuildConfig.groovy

grails.project.dependency.resolution = {
    plugins {
        compile ":ckeditor:"

Plugin version corresponding to bundled CKEditor version, and may be outdated.
To update it, and you use assets pipeline plugin, download CKEditor and unpack to grails-app/assets/ckeditor.
Then you should add dependency to application.js like this

//= require jquery-1.11.1.min
//= require jquery-ui.min
//= require_tree plugins
//= require_tree globalize
//= require bootstrap
//= require ../ckeditor/ckeditor
//= require_self

If CKEditor version is good enough for you, just put ckeditor:resources tag into head of view:


Then you can insert CKEditor in form with tag ckeditor:editor. For example editor of article content:

<ckeditor:editor name="content" height="400px" width="80%" userSpace="${currentUser.id}">${article.content}</ckeditor:editor>

Here used attribute userSpace with value of current user's id. It makes all user images upload to server separated to their own folders.

But you should also restrict access to users spaces. If you use Spring Security (S2) plugin you can create custom filter with command grails create-filters OfmSecurity:

class OfmSecurityFilters {
 def springSecurityService
 def filters = {
 all(uri: '/ck/ofm/**') {
 before = {
 if (springSecurityService.currentUser?.id != params.space?.toLong()) {
 redirect(controller: "user", action: "login")
 return false

 after = { Map model ->

 afterView = { Exception e ->