1
votes

I'm new to rails and could use some help choosing the right rich text editor. I would like visitors to be able to add content (text, images, and video) to the site using one  rich text editor form. Once submitted by the visitor I need to be able to sanitize content, save images/video to public folder, and save text and the path to those images/videos to the database for future retrieval. Is there a gem or combination of gems that can help me accomplish this. 

I've already looked into tinymce, ckeditor, and mercury but none seems to meet my needs. Tinymce and ckeditor and their plugins require the URL of the image which means that users would first have to upload the image and then know the path to it. That's a little to complicated for my audience. Mercury is based in html5 and is currently unstable depending on the browser. Are there any other options out there?

2
All those requirements you want (sanitizing content, saving images, etc) are not appropriate for the View Layer, but the Model. For instance, you want your data to be scrubbed where no user can alter it (otherwise, what's the point?). The view is not the place to do this, because the user can alter the heck out of the view.BryanH
I'm trying to track down the same type of a plugin for Rails. I've seen it about a month ago, I know it exists, I just don't know where I save a bookmark for it!Victor S

2 Answers

0
votes

http://www.queness.com/post/212/10-jquery-and-non-jquery-javascript-rich-text-editors

I didn't look to deeply, but I'm assuming one of these jquery/javascript plugins is a WYSIWYG HTML editor.

Once you've got a good client side HTML editor running, the next part is parsing the HTML when sent to the rails app.

http://www.rubyinside.com/nokogiri-ruby-html-parser-and-xml-parser-1288.html

I've never used Nokogiri, but it's name is very familiar, It seems to be used a lot.

Sanitization is baked into Rails. The default sanitize will strip out ANY HTML, but you can call sanitize telling it which HTML elements NOT to block. Assuming you parse out the HTML you allow to pass through sanitize, using Nokogiri (or whatever HTNL parser you find), you'd be manually santitizing those elements as you extract values from them.

The tricky part would be eliminating the 'file select' operation on the client side as the user needs to select a local image to place in the HTML document. I don't think you can eliminate it, but hopefully HTML editor makes it as simple as possible. There not really much you can do about it, if the user will add one of HIS images to an HTML document he'll upload, he'll HAVE to select it at some point.

0
votes

This is the closest I've come to something that you describe, I'm also looking for something similar so I'll keep you posted :)

http://youhack.me/2011/07/07/create-a-facebook-post-to-wall-system-using-php-and-jquery-part-2/