How to make text edit function by Rails - ruby-on-rails

Same as title the following, thx~

It is called RTE, or Rich Text Editor. There're many RTEs, and one of them for rails is wysiwyg-rails, it provides the Froala WYSIWYG HTML Editor javascript and stylesheets as a Rails engine for use with the asset pipeline.
You can follow this tutorial to install it: https://github.com/froala/wysiwyg-rails

Related

Does liquid work with wysiwyg editors? - rails

I have just found liquid and watched the Railscasts on it. The video was pretty old but from watching it, it i can see liquid is what im looking for. Problem is I'm not sure if it will work with popular wysiwyg editor gems. I don't really want my users to be using plain input fields to make the templates.
I don't know if the wysiwyg editor has to be special to work with liquid or if liquid can basically work with any wysiwyg editor gem.
Are there recommended wysiwyg editor gems that work well with liquid or if that isn't a thing are there just normal editor gems that work with liquid?
Yes. Please read this blog. You can also use newsly gem to manage your liquid template with wysiwyg editor. I used ckeditor in one of my application. It's quite easy to install.
Basically you will need to parse the content and add your own data. The editor will not automatically figure out the variables and their values. The editor will save the content with tags and later you can parse it with Liquid
Here is an example form Liquid
#template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
#template.render('name' => 'tobi') # => "hi topi"
https://github.com/Shopify/liquid#how-to-use-liquid
And here is a blog post on how someone is using a wysiwyg with Liquid
https://customer.io/blog/Email-wysiwyg-editor-inspired-by-jekyll.html
Hope that helps

Gem for surveys with images on RoR

I am a newbie on RoR and I am looking for a GEM that would create surveys and support images. I have tried Surveyor and it seems great for text only surveys (I will definitely use it again for surveys). Ideas?
Easiest way would be to generate the HTML with that gem, then use the generated HTML and put it in the html.erb and update it with the images.
You can look at the generated HTML with developer tools on your browser.
Otherwise, you will have to write it yourself or add new methods to that gem.

bgStretcher (jQuery) in Ruby on Rails

I came across the following code online:
http://www.ajaxblender.com/bgstretcher-2-jquery-stretch-background-plugin-updated.html
It works like a charm on HTML & Javascript & CSS.
Now the question is how do I implement this kind of code in Ruby on Rails Environment.
I have split off this question in multiple questions:
where do I place the CSS & jQuery
how do I implement the javascript into the erb file
how do I link to my css & jQuery files (like in HTML)
Kind regards,
Vincent
Your best bet is to go through asset pipleline which will clear up a lot of things
http://guides.rubyonrails.org/asset_pipeline.html
http://railscasts.com/episodes/279-understanding-the-asset-pipeline

Show Redcloth source in ckeditor : rails3

I just installed ckeditor into my rails app. Now i am trying to do is, configure redcloth and ckeditor in a way that, instead of the html source i would like the ckeditor to show the redcloth source ?
Any hints on how would i achieve that ?
If you are using CKEditor just for its toolbar, I mean just just the possibility to be able to use buttons to apply formatting, I think you should not use CKEditor, which is (from what I know) absolutely not made to work with markdown. What you are looking is a markdown editor.
I recently looked for a good markdown editor, and guess what, the best solution I have found is Stackoverflow markdown editor. It is called pagedown
Note that this editor is a lot lighter than something like ckeditor since the actual element in which you are editing your content is just a textarea. You just hook pagedown to it by using javascript. In Ckeditor, you are actually writing your content into an iframe with a contentEditable="true" parameter, and CKEditor is recopying what you are writing into a hidden textarea.

Help with rails and tinyMce

I have been using tinyMce_hammer plugin to use tinymce in my rails app... but right now I also want a way for my users to upload photos and insert them into their wysiwyg editor.... is there a simple way to get this done??.. is there any other wysiwyg editor that works with rails and comes with this feature built in??... what do you reccomend?
These two plugins claim to offer it - Rails 2.3 - https://github.com/andreferraro/rails_tiny_mce
Rails 3 - https://github.com/sandipransing/rails_tiny_mce
I don't think there's an easy way to do this in any of the common rich text editors. I usually have a separate section where users can upload photos and then choose from a variety of layout options.
TinyMCE has a couple of commercial image and file management plugins, but they are based on PHP and .Net. However, I haven't seen a Rails version. It's not particularly hard to build your own image manager using a plugin like paperclip and hook into TinyMCE.

Resources