• Stars
    star
    154
  • Rank 241,303 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 15 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Tiny MCE Rich text Editor for rails using jquery, paperclip with image and media upload support

RailsTinyMCE - A Rich Text Editor for rails

TinyMCE is a javascript rich text editor. It is easy to integrate with blogs, cms, messages and mailers.

Plugin uses jrails(jQuery) and Paperclip plugin for image & media upload support

Features

  • Provides Rich Text Editor
  • Customisable TinyMCE plugins
  • Easy to integrate
  • Supports Image upload & insert
  • Supports Media upload & Youtube embed
  • TODO: Document upload plugin

Installation

Add this line to your application's Gemfile:

gem 'rails_tinymce'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_tinymce

Migrations

rails g tiny_migration
rake db:migrate

Dependency Gems

  • paperclip git://github.com/thoughtbot/paperclip.git
  • respond_to_parent git://github.com/itkin/respond_to_parent.git
  • will_paginate git://github.com/mislav/will_paginate.git

Usage

  • In your layout add following lines
<%= javascript_include_tag :defaults %>
<%= javascript_include_tiny_mce_if_used %>
<%= tiny_mce if using_tiny_mce? %>
  • Inside controller class on top add following lines
uses_tiny_mce(options: AppConfig.default_mce_options, only: [:new, :edit])

This AppConfig.default_mce_options is in config/initializers/tiny_mce_plus_config.rb, you could change the setting there

  • In your view add class mceEditor to text_area Then append the following to the text area you want to transform into a TinyMCE editor.
:class => :mceEditor
  • Install file lists
rake rails_tiny_mce:install

This will create following files:

    app
      |-- controller
        |-- attachments_controller.rb
      |-- helpers
        |-- remote_link_renderer.rb
      |-- models
        |-- print.rb
        |-- video.rb
      |-- views
        |-- attachments
           |-- _show_attachment_list.html.erb
    config
      |-- initializers
        |-- tiny_mce_plus_config.rb
    public
      |-- images
        |-- tiny_mce
      |-- javascripts
        |-- tiny_mce

You may custom the config in tiny_mce_plus_config.rb.

Attention Note:

  • Do not put \<p> \</p> around the textarea.
  • If you are using old will_paginate plugin, change the url_for to url_option in remote_link_renderer.rb
  • If you are using gem "will_paginate", "~> 3.0.pre2" you need changes in app/helpers/remote_link_renderer.rb class RemoteLinkRenderer < WillPaginate::LinkRenderer to class RemoteLinkRenderer < WillPaginate::ViewHelpers::LinkRenderer

Example use:

  • Create CRUD for post

    rails g scaffold post title:string text:description

  • Run Migrations

    rake db:migrate

  • Add following line to posts_controller.rb

    uses_tiny_mce(:options => AppConfig.default_mce_options, :only => [:new, :edit])

  • Open /views/posts/_form.html.erb

  • Modifiy following line

    <%= f.text_area :description %> to <%= f.text_area :description, :class => :mceEditor %>

FAQ

  • How to get image from post body
#Add imagepath method in post model
def imagepath
  match = body.match(/img src="(.+)" border/)
  $1 if match
end

And use post.imagepath to get url of image embeded in post content

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_tinymce. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

More Repositories

1

rails_tooltip

Allows to add hover help text i.e. tooltip to html nodes i.e. form fields, table columns in rails views
Ruby
9
star
2

library_management_system

Ruby
6
star
3

prawn-example

Example PDF using prawn library
4
star
4

rails_api

Ruby On Rails API to download & clone.
3
star
5

twinkle_tel

firefox click to call script for twinkle using tel protocol (clicktocall using asterisk)
2
star
6

radiant-session_management-extension

Tracts visitor information (i.e. ip, session, page_url, site)
2
star
7

rails_polymorphic_comments

'Plymorphic' name itself implies that can be plugged with any type of resource. using this plugin one can observe how easy are using comments in rails. You can use polymorphic comments to any type of resource. resources types can be blog post, review, ideas, etc.
Ruby
2
star
8

number_to_indian_currency

number_to_indian_currency helper converts given number to the indian currency format (also displays Rupees symbol)
Ruby
2
star
9

buildyourcv

Build your cv
Ruby
1
star
10

rails_ari

Active record inheritance basics (Prepared for josh night)
Ruby
1
star
11

ubuntu_settings

1
star
12

rails_blank

Boost to get started with rails 3.1.1, haml, sass, jquery, devise, twitter-bootstrap, railroady, heroku specific setup, etc...
Ruby
1
star
13

sample

rails 3.1 getting started
Ruby
1
star
14

ganesha

Ruby
1
star
15

funonrails

Manage funonrails blog related stuffs like icons, images, etc.
1
star
16

rails_vim

Vim editor for ruby on rails development using rails.vim
Vim Script
1
star
17

rails_activecalendar

compatible with rails 2.3 with firefox, IE and chrome support
JavaScript
1
star
18

blogapp

Ruby
1
star
19

decoder

Country and State code lookups
Ruby
1
star
20

rails-activecalendar

compatible with rails 2.3 with firefox, IE and chrome support
1
star
21

voip

Ruby
1
star
22

simpleFormatJS

Returns text transformed into HTML using simple formatting rules. Two or more consecutive newlines(\n\n) are considered as a paragraph and wrapped in <p> tags. One newline (\n) is considered as a linebreak and a <br /> tag is appended.
JavaScript
1
star