May 5th, 2009

Integrating fckeditor with mephisto

After configuring mephisto blogging application by following steps from previous post (Integrate Mephisto with Rails), you will notice that text formating options available with mephisto are not so user friendly and you will have tough time while formatting text, including inline images in your blogs. And you will require a wysiwyg editor for formatting text of your blogs with images and well formated texts which is not available by default in mephisto.

Now in order to integrate fckeditor with your mephisto installation you need to follow certain steps which are mentioned below :

*steps are for rails version 2.2.2 or higher

1.) Install and Configure mephisto (Follow steps from Integrate Mephisto with Rails)

 

2.) Install fckeditor plugin

ruby script/plugin install svn://rubyforge.org//var/svn/fckeditorp/trunk/fckeditor

rake fckeditor:install

 

3.) If you are using rails version 2.2.2 or higher then

* in the file vendor/plugins/fckeditor/app/controllers/fckeditor_controller.rb look for

uploaded = request.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"

replace it with this

uploaded = ActionController::Base.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"

similarly in the file vendor/plugins/fckeditor/lib/fckeditor.rb replace

js_path = "#{request.relative_url_root}/javascripts"

with

js_path = "#{ActionController::Base.relative_url_root}/javascripts"

* patch fromhttp://github.com/salicio/fckeditor/commit/fcf8fbee8cfad3a3df0df50172e448727909ccb9

 

4.) Edit app/views/layouts/application.htm.erb file 

* Put this line in the file

<%= javascript_include_tag 'fckeditor/fckeditor' %>

 

5.) Edit your app/views/admin/articles/_form.html.erb for articles 

* Search for <%= form.text_area :body, :class => 'fat', :rows => 25 %> near line no 11

replace it with this 

 

<%= fckeditor_textarea( 'article', 'body',:toolbarSet => 'Simple', :width => '100%', :height => '200px') %>

 

other usage details are available in README file of fckeditor plugin (vendor/plugins/fckeditor)

or can be found on http://blog.caronsoftware.com/2006/08/07/fckeditor-plugin-for-rails

 

6.) There is a another small glitch, due to the interaction with safe_erb.

 

in the file vendor/plugins/fckeditor/lib/fckeditor.rb at line no 15 replace
value = value.nil? ? "" : value

with

value = value.nil? ? "" : value.untaint()

After carefully following above steps you will be able to use fckeditor in your mephisto application and will be able to insert inline images and rich text to your blogs.

 

Happy blogging.....!!!!!