Code Monkey home page Code Monkey logo

redactor-rails's Introduction

This repo is deprecated

Please check out official gem for Redactor 2. https://github.com/Redactor2/redactor2_rails

Rails 3.2 Integration for Redactor (Devise Edition)

The redactor-rails gem integrates the Redactor editor with the Rails 3.2 asset pipeline.

This gem bundles Redactor version 10.0.4 which is the most recent version as of January 9, 2015. Check Redactor's changelog for further updates.

Installation

Add this line to your application's Gemfile:

gem 'redactor-rails'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install redactor-rails

Now generate models for store uploading files

ActiveRecord + carrierwave

gem "carrierwave"
gem "mini_magick"

$ rails generate redactor:install

or

$ rails generate redactor:install --devise

# --devise option generate user_id attribute for asset(Picture, Document) models. For more details show Devise gem.
# Now, Pictures and Documents uploading available only for signed in users
# All uploaded files will stored with current user_id
# User will choose only own uploaded Pictures and Documents

$ rake db:migrate

Mongoid + carrierwave

gem "carrierwave"
gem "carrierwave-mongoid", :require => "carrierwave/mongoid"
gem "mini_magick"

$ rails generate redactor:install

Include the Redactor assets

Add to your application.js:

  //= require redactor-rails

Add to your application.css:

  *= require redactor-rails

Initialize Redactor

For each textarea that you want to use with Redactor, add the "redactor" class and ensure it has a unique ID:

<%= text_area_tag :editor, "", :class => "redactor", :rows => 40, :cols => 120 %>

Custom Your redactor

If you need change some config in redactor, you can

$ rails generate redactor:config

Then generate app\assets\redactor-rails\config.js.

See the Redactor Documentation for a full list of configuration options.

If You Want To setup a new language in Redactor you should do two things:

In you file app\assets\redactor-rails\config.js set option

"lang":'zh_tw'

and

if redactor-rails gem version <= 0.3.7

Add to your layout

<%= redactor_lang('zh_tw') %>

elsif redactor-rails gem version >= 0.4

Add to your application.js:

//= require redactor-rails/langs/zh_tw

Setting a max image size with carrierwave

If you want to set a maximum image size used when a user uploads an image via carrierwave, open the uploader file and add add the following:

# app/uploaders/redactor_rails_picture_uploader.rb:33

process :resize_to_limit => [500, -1]

The above example will set the image to have a maximum width of 500px.

Using plugins

This gem comes bundled with several Redactor plugins:

  • Fullscreen
  • Clips
  • FontColor
  • FontSize
  • FontFamily
  • Text direction

Full details of these can be found at Redactor Plugins

To include all the plugins just add to your application.js:

    //= require redactor-rails/plugins

and add to your application.css:

    *= redactor-rails/plugins

If you would prefer to pick and choose which plugins to include you can add for example:

  //= require redactor-rails/plugins/fontsize
  //= require redactor-rails/plugins/fontfamily

After including the desired plugins they can be configured in the redactor config file as normal.

To add it into the editor just add 'plugins' attributes to config.js file and specify which ones do you want to use:

  $('.redactor').redactor(
    { "plugins": ['fontsize',
                'fontcolor',
                'fontfamily',
                'fullscreen',
                'textdirection',
                'clips']
    });

Defining a Devise User Model

By default redactor-rails uses the User model.

You may use a different model by:

  1. Run a migration to update the user_id column in the

  2. Overriding the user class in an initializer.

  3. Overriding the authentication helpers in your controller.

    Create a new Migration: rails g rename_user_id_to_new_user_id

    # db/migrate/...rename_user_id_to_new_user_id.rb
    
    class RenameUserIdToNewUserId < ActiveRecord::Migration
      def up
        rename_column :redactor_assets, :user_id, :admin_user_id
      end
    
      def down
        rename_column :redactor_assets, :admin_user_id, :user_id
      end
    end
    
    # config/initializers/redactor.rb
    # Overrides the user class
    
    module RedactorRails
      def self.devise_user
        %s(admin_user) # name of your user class
      end
    
      # You may override this to support legacy schema.
      # def self.devise_user_key
      #   "#{self.devise_user.to_s}_id".to_sym
      # end
    end
    
    # app/controllers/application_controller.rb
    
    class ApplicationController < ActionController::Base
      ...
    
      def redactor_authenticate_user!
        authenticate_admin_user! # devise before_filter
      end
    
      def redactor_current_user
        current_admin_user # devise user helper
      end
    end
    

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Contributors

Sebastian Wilgosz

Special Thanks

wildjcrt (Jerry Lee)

Statement

redactor-rails part of reference galetahub/ckeditor project.

redactor-rails uses MIT-LICENSE. Rock!!!!!

License

the redactor-rails project is MIT-LICENSE.

You may use Redactor for non-commercial websites for free, however, we do not guarantee any technical support.

Redactor has 3 different licenses for commercial use. For details please see License Agreement.

redactor-rails's People

Contributors

agis avatar bubai-babi avatar coolagin avatar dave4u90 avatar davimedrade avatar efexen avatar feipinghunag avatar itsnikolay avatar jhanggi avatar joemsak avatar kryachkov avatar mattgibson avatar meal avatar mihserf avatar mikerogers0 avatar nathanpsouza avatar phuwanart avatar redvulps avatar rubinsh avatar rvrm avatar sammylin avatar sen avatar snooc avatar spilin avatar wilgoszpl avatar zmillman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redactor-rails's Issues

Assets not found when redactor render the iframe

I've following error on my development log when use redactor-rails
ActionController::RoutingError (No route matches [GET] "/observation_tiles/false/css/style.css")
when I remove

<%= f.text_area :content, :rows => '3', :cols => '65', :style => "height: 300px;" %>

or add a new id to text_area ,then error gone.
I check a little on the source code and not sure if redactor.js does load some css that conflict with sth.
Thanks.

Redactor breaks my html formatting

Is there anyway to disable redactor automatically inserting p tags and removing other tags when using the html edit mode

example
if i write this

<div class="span12>Exampletext</div>

next time i try to edit the text, the formatting is this

<p>Exampletext</p>

Cropping and Uploading to S3

I need to be able to store an image to S3 without writing it to a temporary file.
My application will be deployed to heroku which has a read only file system. Is there a way to save the image directly to S3 from memory?

thank's

CSS include issue with Active Admin

I'm trying to include redactor with active admin - I added the gem, and my config file looks like this:

autoresize: true
lang: en
path: /assets/redactor-rails/
css: style.css

I also added the following line to my application.rb:

config.assets.precompile += ["redactor-rails/css/*"]

In my active admin form I have this line to create the textarea:

f.input :contents, input_html: { id: "redactor_content" }

My active admin js looks like this:

//= require active_admin/base
//= require redactor-rails

$(function() {
  $('#redactor_content').redactor();
});

And I include the CSS in the active admin CSS file too:

// Active Admin CSS Styles
@import "active_admin/mixins";
@import "active_admin/base";
@import "redactor-rails";

In my edit form inside active admin (which is at http://localhost:3000/admin/snippets/1/edit), redactor does appear, but is strangely formatted, and for some reason, is trying to load this file: http://localhost:3000/admin/snippets/1/false/css/style.css - which of course 404s.

My redactor looks like this:

redactor screenshot

Do you know why it might be trying to load the file at that path? I assume that's what's causing it to look odd.

Redactor controller redirecting from SSL

I have an app that uses SSL for all of the backend editing and I have redactor-rails running and handling image and document uploads and it works great on non-SSL connections. However, when I am on a secure page, the browser throws an error stating that redactor_rails is displaying non-secure content.
When I hit the URL for redactor_rails/pictures directly, it clearly redirects the request to a non SSL connection. Is there some way to stop redactor-rails from redirecting the request?

CSRF Errors

I am getting CSRF errors with the photo upload.

Adding csrf-param option to the imageUpload url will be good.

Example code:

$('.redactor').redactor({"imageUpload":"/redactor_rails/pictures" + "?" + $('meta[name=csrf-param]').attr('content') + "=" + encodeURIComponent($('meta[name=csrf-token]').attr('content')),"imageGetJson":"/redactor_rails/pictures","lang":"tr","autoresize":true});

Asset only installation possibility?

I would like to have a possibility to only use this gem to have up-to-date Redactor assets (JS + CSS).

My application is not using Devise and I don't need models for documents and images, etc.

What do you think?

Regards!
Jakub Cerny

Status of Upgrading to Redactor v8.2.5?

What is the status of upgrading to Redactor v8.2.5, given that it is bundled with jQuery 1.9.1, which is more likely to cause compatibility issues than some previous jQuery upgrades?

Thanks!

TypeError: $(...).redactor is not a function

Redactor-style text area is not loading, text-area is just a plain text area.

My gemfile has these gems, bundle installed:
gem 'jquery-ui-rails'
gem 'redactor-rails'
gem "carrierwave"
gem "mini_magick"

My application.js file has these:
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require autocomplete-rails
//= require redactor-rails
//= require_tree .

The html.erb file calling the text area has this:
<%= f.text_area :content_1, :class => "redactor", :size => "60x4", :maxlength=> 300, :placeholder => "Featured text for this entry..."%>

What could be causing this?

Dealing with signed URLs

I'm using a private S3 bucket to store uploads, so Fog generates signed URLs for all assets. The problem is that those URLs are saved into the HTML body so I get a 403 against all embedded images when the request expires. I'm wondering what the best way to deal with this would be.

Thanks

uninitialized constant RedactorRails::Asset::User

My devise model name is admin not user and it's giving me some problems with redactor,
when trying to upload an image I get the errors below;

I have followed the instructions in the 'defining a devise user model' section,
but still get the error

Started POST "/redactor_rails/pictures?authenticity_token=931GXG0D%2BgtwV38IVrDTsMPX8jWh1qSOUk0bVBpWTr4%3D" for 127.0.0.1 at 2013-06-12 13:52:42 +0100
Processing by RedactorRails::PicturesController#create as HTML
Parameters: {"file"=>#<ActionDispatch::Http::UploadedFile:0x007f8b0c90eab8 @content_type="image/jpeg", @tempfile=#File:/var/folders/r3/1gzzfk2964b4tvvndtnr527m0000gn/T/RackMultipart20130612-25128-uvje7, @original_filename="14.jpg", @headers="Content-Disposition: form-data; name="file"; filename="14.jpg"\r\nContent-Type: image/jpeg\r\n">, "authenticity_token"=>"931GXG0D+gtwV38IVrDTsMPX8jWh1qSOUk0bVBpWTr4="}
Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = 1 LIMIT 1
Completed 500 Internal Server Error in 879ms

NameError - uninitialized constant RedactorRails::Asset::User:

ActiveRecord::StatementInvalid at /pictures

SQLite3::SQLException: no such column: redactor_assets.user_id: SELECT "redactor_assets".* FROM "redactor_assets" WHERE "redactor_assets"."type" IN ('RedactorRails::Picture') AND "redactor_assets"."user_id" = 1

(gem) sqlite3-1.3.7/lib/sqlite3/database.rb, line 91

NameError at /pictures

uninitialized constant RedactorRails::Asset::User

(gem) activerecord-3.2.13/lib/active_record/inheritance.rb, line 111

  106                 # We don't want to swallow NoMethodError < NameError errors
  107                 raise e unless e.instance_of?(NameError)
  108               end
  109             end
  110   
> 111             raise NameError, "uninitialized constant #{candidates.first}"
  112           end
  113         end
  114   
  115         private
  116   

App backtrace

Full backtrace

  • (gem) activerecord-3.2.13/lib/active_record/inheritance.rb:111:in `compute_type'
  • (gem) activerecord-3.2.13/lib/active_record/reflection.rb:172:in `klass'
  • (gem) activerecord-3.2.13/lib/active_record/associations/association.rb:202:in `raise_on_type_mismatch'
  • (gem) activerecord-3.2.13/lib/active_record/associations/belongs_to_association.rb:6:in `replace'
  • (gem) activerecord-3.2.13/lib/active_record/associations/singular_association.rb:17:in `writer'
  • (gem) activerecord-3.2.13/lib/active_record/associations/builder/association.rb:51:in `block in define_writers'
  • (gem) redactor-rails-0.3.5/app/controller/redactor_rails/pictures_controller.rb:16:in `create'
  • (gem) actionpack-3.2.13/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  • (gem) actionpack-3.2.13/lib/abstract_controller/base.rb:167:in `process_action'
  • (gem) actionpack-3.2.13/lib/action_controller/metal/rendering.rb:10:in `process_action'
  • (gem) actionpack-3.2.13/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:425:in `_run__553481357801718632__process_action__101932776178536029__callbacks'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
  • (gem) actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in `process_action'
  • (gem) actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in `process_action'
  • (gem) actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
  • (gem) activesupport-3.2.13/lib/active_support/notifications.rb:123:in `block in instrument'
  • (gem) activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  • (gem) activesupport-3.2.13/lib/active_support/notifications.rb:123:in `instrument'
  • (gem) actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
  • (gem) actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
  • (gem) activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  • (gem) actionpack-3.2.13/lib/abstract_controller/base.rb:121:in `process'
  • (gem) actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in `process'
  • (gem) actionpack-3.2.13/lib/action_controller/metal.rb:203:in `dispatch'
  • (gem) actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
  • (gem) actionpack-3.2.13/lib/action_controller/metal.rb:246:in `block in action'
  • (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
  • (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in `call'
  • (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
  • (gem) journey-1.0.4/lib/journey/router.rb:56:in `each'
  • (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
  • (gem) railties-3.2.13/lib/rails/engine.rb:479:in `call'
  • (gem) railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
  • (gem) journey-1.0.4/lib/journey/router.rb:68:in `block in call'
  • (gem) journey-1.0.4/lib/journey/router.rb:56:in `each'
  • (gem) journey-1.0.4/lib/journey/router.rb:56:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in `call'
  • (gem) warden-1.2.1/lib/warden/manager.rb:35:in `block in call'
  • (gem) warden-1.2.1/lib/warden/manager.rb:34:in `catch'
  • (gem) warden-1.2.1/lib/warden/manager.rb:34:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  • (gem) rack-1.4.5/lib/rack/etag.rb:23:in `call'
  • (gem) rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/head.rb:14:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/flash.rb:242:in `call'
  • (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
  • (gem) rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/cookies.rb:341:in `call'
  • (gem) activerecord-3.2.13/lib/active_record/query_cache.rb:64:in `call'
  • (gem) activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `_run__1702292936982773496__call__4197470933517314153__callbacks'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  • (gem) activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/reloader.rb:65:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  • (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:84:in `protected_app_call'
  • (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:79:in `better_errors_call'
  • (gem) better_errors-0.8.0/lib/better_errors/middleware.rb:56:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  • (gem) railties-3.2.13/lib/rails/rack/logger.rb:32:in `call_app'
  • (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `block in call'
  • (gem) activesupport-3.2.13/lib/active_support/tagged_logging.rb:22:in `tagged'
  • (gem) railties-3.2.13/lib/rails/rack/logger.rb:16:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/request_id.rb:22:in `call'
  • (gem) rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
  • (gem) rack-1.4.5/lib/rack/runtime.rb:17:in `call'
  • (gem) activesupport-3.2.13/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  • (gem) rack-1.4.5/lib/rack/lock.rb:15:in `call'
  • (gem) actionpack-3.2.13/lib/action_dispatch/middleware/static.rb:63:in `call'
  • (gem) railties-3.2.13/lib/rails/engine.rb:479:in `call'
  • (gem) railties-3.2.13/lib/rails/application.rb:223:in `call'
  • (gem) rack-1.4.5/lib/rack/content_length.rb:14:in `call'
  • (gem) railties-3.2.13/lib/rails/rack/log_tailer.rb:17:in `call'
  • (gem) thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
  • (gem) thin-1.5.1/lib/thin/connection.rb:79:in `catch'
  • (gem) thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
  • (gem) thin-1.5.1/lib/thin/connection.rb:54:in `process'
  • (gem) thin-1.5.1/lib/thin/connection.rb:39:in `receive_data'
  • (gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
  • (gem) eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
  • (gem) thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
  • (gem) thin-1.5.1/lib/thin/server.rb:159:in `start'
  • (gem) rack-1.4.5/lib/rack/handler/thin.rb:13:in `run'
  • (gem) rack-1.4.5/lib/rack/server.rb:268:in `start'
  • (gem) railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
  • (gem) railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
  • (gem) railties-3.2.13/lib/rails/commands.rb:50:in `tap'
  • (gem) railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
  • script/rails:6:in `require'
  • script/rails:6:in `'

Redactor 9.0.2

Redactor 9 is out for a while. Will this gem be updated soon?

image upload dont work

I have a controller admin:post
redactor show in my new/edit views
but image upload cant work :-/

ps. sorry my poor english.
ps. great plugin !

UTF8 - Image Path Error

When editing some content, already submited to the database, redactor doesn't display image if it is in a folder for example as:

  • Multimédia/image.jpg

It gives a javascript error saying:

Failed to load resource: the server responded with a status of 404 : Multime?dia/image.jpg

It converts Mutimédia to Multime?dia

Anyone knows how to fix this?

Error when running redactor:install (on Mongoid)

$ rails generate redactor:install
       route  mount RedactorRails::Engine => '/redactor_rails'
Could not find "mongoid/carrierwave/redactor/asset.rb" in any of your source paths. Your current source paths are: 
/Users/josh/Documents/Work/Sientia/iq/lib/templates/redactor/install
/Users/josh/.rvm/gems/ruby-1.9.3-p0/gems/redactor-rails-0.3.2/lib/generators/redactor/templates

Any idea? Thanks.

uninitialized constant RedactorRails::Document (NameError) on Heroku

Hi, here's the error I'm seeing after pushing my app to Heroku:

2013-02-12T19:29:50+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/redactor-rails-0.3.3/lib/redactor-rails.rb:30:in `document_model': uninitialized constant RedactorRails::Document (NameError)
2013-02-12T19:29:50+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/redactor-rails-0.3.3/app/controller/redactor_rails/documents_controller.rb:2:in `<class:DocumentsController>'
2013-02-12T19:29:50+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/redactor-rails-0.3.3/app/controller/redactor_rails/documents_controller.rb:1:in `<top (required)>'
2013-02-12T19:29:50+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
2013-02-12T19:29:50+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `each'

I don't see this issue locally. I have tried to force Heroku to use ruby 1.9.3, but it still spits out the error from the bundle in the ruby/1.9.1 directory.

Devise fails when using untraditional Devise User class

The filters and helpers are hard coded to use the User model. If you are using a model class anything else, the filters will fail.

Example:

# User.rb
authenticate_user!
current_user

# AdminUser.rb 
authenticate_admin_user!
current_admin_user

I have updated my own fork to allow this to be configurable:

https://github.com/snooc/redactor-rails/tree/configurable_devise

Instructions are at the bottom of the README.

Due to the lack of configuration classes in this gem, is opted to just use monkey patching in a initializer to define the class.

I'd love to submit a pull request. 😄

My textarea stays a plain old textarea

I'm using Carrierwave/Mongoid and run exactly all the steps to install Redactor. Sadly, when wanting to use it on one of my textarea, simply nothing happens.

<%= text_area_tag :editor, "", :class => "redactor", :rows => 40, :cols => 120 %>

The textarea stays a plain old textarea. How can I try to track this down to the problem? Thank you.

css file for iframe not loading correctly

Hi, this might not be a bug, since i'm the first to report it.

I have the gem installed, and it appears to be working correctly except that the stylesheet that gets loaded to style the iframe that holds the contents of the text area isn't loading.

my app is looking for localhost:3000/assets/css/style.css and it's not being found.

I followed the instructions in the readme, but it makes no mention of this. I was having a similar, but different issue with installing redactor manually so i figured i'd try the gem to see if that fixed it.

i either need to configure the redactor.yml file to look for different css or i need to install a css file somewhere. Neither is mentioned in the readme so i figured i'd ask.

If this is a simple thing, which is entirely possible because i'm fairly new at this, then please let me know what mistake i made.

thanks in advance!

Doesn't seem to like re-selecting with fog (AWS) storage

When I use the :fog storage mechanism, it seems to say "undefined" for the image src (when choosing an already-uploaded image). I haven't tested it without fog, but I assume it works. Is there some way to switch this gem into debug mode so that I can propose a solution or debug it better?

Uncaught TypeError: Cannot read property 'msie' of undefined

I followed the instructions to the point, but I keep getting this error:
Uncaught TypeError: Cannot read property 'msie' of undefined

The full error is as such:
Uncaught TypeError: Cannot read property 'msie' of undefined
a.buildColorPicker
(anonymous function)
proxy jquery.js:802
jQuery.extend.each jquery.js:632
a.buildToolbar
a.init
a
(anonymous function)
jQuery.extend.each jquery.js:632
jQuery.fn.jQuery.each jquery.js:254
jQuery.fn.redactor
(anonymous function) config.js:9
fire jquery.js:1018
self.fireWith jquery.js:1128
jQuery.extend.ready jquery.js:417
DOMContentLoaded jquery.js:93

If I take redactor complete away, the error disappears. Am I doing something wrong or is it an actual error?

Not support Devise

I have generated with this command:

$ rails generate redactor:install --devise

First it not add :user_id in migration, OK it not a problem I add by manual but I upload picture all upload file is not store :user_id.

I found a problem is

RedactorRails.picture_model.respond_to?(:user_id) 

is false

I try in console every Model is return false in respond_to? method.

I missed something, please suggest me.

can't insert image into text_field

I've installed Redactor with instructions(--devise) and when I try to insert image, I have error:

MiniMagick::Error (Command ("identify -quiet -ping -format %wn /home/igor/rubycode/badm.by/public/uploads/tmp/1374091702-9075-8190/637.jpg") failed: {:status_code=>127, :output=>"sh: 1: identify: not found\n"}):
mini_magick (3.6.0) lib/mini_magick.rb:409:in run' mini_magick (3.6.0) lib/mini_magick.rb:391:inrun_command'
mini_magick (3.6.0) lib/mini_magick.rb:230:in `[]'
Redactor works good, but only this issue

How do you set external link option

Currently I am able to set the default link without external link option. How do you make sure that link button take an external link option? Thanks.

editor broke after update

I just updated redactor-rails to the latest version because uploading an image resulted in CSRF-errors. After the update, i had to remove the <% redactor %> and add "redactor" as the class of my text_area. I did that, but it doesn't work. The text_area does not transform in a redactor editor.

I read the documentation and did all what's in there. Any ideas?

Adding Keyboard Shortcuts

Is there a way to add keyboard shortcuts to redactor-rails?
(shortcuts: http://imperavi.com/redactor/docs/shortcuts/)

I would like a keyboard shortcut for "text-deleted" format, but it seems to not exist in the current version.

Download the redactor.js file from the vendor directory from github, and look for "shortcuts" function inside. Add a shortcut key accordingly in the file, and load this from the application.js.

How to use different uploaders

I want to store uploaded images in different locations, depending on the view.

This could be done if there's a way to use different model & uploader for each editor instance. Is there a way to do this?

For example, in my app I may have posts & products. These are 2 different type of resources, so each one has their own controller/views/forms etc. I want the images uploaded for a product to be stored in assets/products and those for a post in assets/posts.

Any ideas?

Text outside of paragraph tags

When a user begins typing into a redactor box, the first bit of text before the first return is not wrapped in p tags, just a div. All subsequent paragraphs are however. Has anyone else seen this issue?

Unicorn Rails + Redactor Rails 0.3.3 = uninitialized constant RedactorRails::Document (NameError)

Hey.
Recently gem was updated and if you try to start Unicorn server it fails, because can't find document model.

This is the stacktrace:
I, [2013-02-07T16:02:16.989869 #27768]  INFO -- : Refreshing Gem list
/home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/redactor-rails-0.3.3/lib/redactor-rails.rb:30:in `document_model': uninitialized constant RedactorRails::Document (NameError)
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/redactor-rails-0.3.3/app/controller/redactor_rails/documents_controller.rb:2:in `<class:DocumentsController>'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/redactor-rails-0.3.3/app/controller/redactor_rails/documents_controller.rb:1:in `<top (required)>'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in `each'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in `block in eager_load!'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in `each'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in `eager_load!'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/railties.rb:8:in `each'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/railties.rb:8:in `all'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:434:in `eager_load!'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /home/isamashii/web/app/releases/20130207140018/config/environment.rb:5:in `<top (required)>'
    from config.ru:4:in `require'
from config.ru:4:in `block in <main>'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:51:in `instance_eval'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:51:in `initialize'
from config.ru:1:in `new'
    from config.ru:1:in `<main>'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn.rb:44:in `eval'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn.rb:44:in `block in builder'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/bin/unicorn_rails:139:in `call'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/bin/unicorn_rails:139:in `block in rails_builder'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:700:in `call'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:700:in `build_app!'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/lib/unicorn/http_server.rb:139:in `start'
from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/gems/unicorn-4.4.0/bin/unicorn_rails:209:in `<top (required)>'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/bin/unicorn_rails:23:in `load'
    from /home/isamashii/web/app/shared/bundle/ruby/1.9.1/bin/unicorn_rails:23:in `<main>'

Unable to customise buttons

I'm trying to customise the buttons, but I just end up with a load of dividers and no actual buttons. If I don't try to customise the buttons, they display correctly.

When I was including redactor manually (and failing to get the stylesheets to work with the asset pipeline!) I had this:

  $('.redactor').redactor({
    buttons: ['formatting', '|', 'bold', 'italic', 'deleted', '|',
      'unorderedlist', 'orderedlist', 'outdent', 'indent', '|',
      'table', '|',
      'image', 'file', 'link', '|',
      'alignleft', 'aligncenter', 'alignright', 'justify', '|',
      'html', '|'],

I've tried this in redactor.yml, but it doesn't work:

buttons: [formatting, '|', bold, italic, deleted, '|',
    unorderedlist, orderedlist, outdent, indent, '|',
    table, '|',
    image, file, link, '|',
    alignleft, aligncenter, alignright, justify, '|',
    html, '|']

This also doesn't work, even though the YAML docs imply it should:

buttons:
  - formatting
  - '|'
  - bold
  - italic
  - deleted
  - '|'
  - unorderedList
  - orderedList
  - outdent
  - indent
  - '|'
  - table
  - '|'
  - image
  - file
  - link
  - '|'
  - alignLeft
  - alignCenter
  - alignRight
  - justify
  - '|'
  - html
  - '|'

What is the correct syntax to use?

(Incidentally, it would make life so much easier if redactor-rails could spot redactor.yml had been updated without having to restart the server — when including manually, the config is just part of your page's JavaScript :)

Redactor Toolbar Not Working

when I click any link on the toolbar it does not working.

on console browser

jQuery.fn.redactor
(anonymous function) config.js:9

config.js

$(document).ready(
  function(){
  var csrf_token = $('meta[name=csrf-token]').attr('content');
  var csrf_param = $('meta[name=csrf-param]').attr('content');
  var params;
  if (csrf_param !== undefined && csrf_token !== undefined) {
    params = csrf_param + "=" + encodeURIComponent(csrf_token);
  }
  $('.redactor').redactor(
    { "imageUpload":"/redactor_rails/pictures?" + params,
      "imageGetJson":"/redactor_rails/pictures",
      "path":"/assets/redactor-rails",
      "css":"style.css",
      "lang":'id'
      }
  );
});

and all link on toolbar not working

<li><a href="javascript:void(null);" title="HTML" class="redactor_btn_html"></a></li>

Dragonfly Integration

Carrierwave is indeed awesome, but for images Dragonfly blows it out of the water. You can dynamically resize your images on the fly. This is expecially useful when you are building a whitelabel service with multiple users/domains and each of them has different layouts and needs for image formatting.

Some people might complain that it's too slow without caching, but this is a moot point now given that you can cache your own images using the **to_file() method.

Of course this is just a minor thing, overall I am very happy with how well this gem works.

Cheers!

Redactor AJAX call

Redactor works normally on most of my site. However, it doesn't appear at all when I call it via AJAX. For instance, I have an edit button that replaces the relevant text with a text area. Edit.js.erb looks like this:

$("#lightbox-impression").html("<%= escape_javascript(render 'impression_form') %>")

And _impression_form.html.erb looks like this:

<%= form_for @impression, :remote => true do |f| %>
    <%= f.text_area :content, :class => "redactor" %>
    <%= f.submit 'Submit' %>
<% end %>

Any idea why Redactor doesn't show up here?

Asset pipeline issue

rails generate redactor:config generates the file app/assets/redactor-rails/config.js. This will not work in the asset pipeline correctly as the rake assets:precompile task will still take config.js from the gem instead of the app (note that it'll work fine in development though). See http://stackoverflow.com/questions/7829726/overriding-backend-assets-in-production-environment

The solution is to create your own config.js (or any file name) and put it anywhere in your app's assets. Then when requiring redactor, instead of //= require redactor-rails, use:

//= require redactor-rails/redactor.min
//= require path/to/custom/config

Alternatively you could keep the initial require statement the same, but instead of overriding redactor-rails/config.js, you need to override redactor-rails/index.js instead and use the following lines in it:

//= require ./redactor.min
//= require path/to/custom/config

Release 0.3.3

Lasted version of this gem on rubygems is 0.3.2 released in September. That has an old version of Redactor and is missing Mongoid support. I'm currently depending on my forked master, but I'll like to use the release from rubygems in my gemfiles.

Thanks!

File button on the toolbar

Hi. How can I add the file button on the toolbar?
I tried insert into my redactor-rails/config.js the line:

'buttons': ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image', 'video', 'file', 'table', 'link', '|', 'fontcolor', 'backcolor', '|', 'alignment', '|', 'horizontalrule']

Everything works correctly but the file button does not work.
Can you help-me?

Add a Document RedactorAsset?

Hey!

We actually forked your project in the hopes of starting the work on this ourselves, but I've run into an issue trying to get a test environment setup around a new Document class that subclasses from Asset.

There are just too many dependencies to get it running.

# My latest attempt that is awful
require 'minitest/autorun'
require './lib/generators/redactor/templates/base/carrierwave/uploaders/redactor_rails_document_uploader'
module RedactorRails; class Orm; end; end
class ActiveRecord; class Base; end; class AssetBase; end; end
require './lib/generators/redactor/templates/active_record/carrierwave/redactor/asset'
require './lib/generators/redactor/templates/active_record/carrierwave/redactor/document'

require './test/helpers/redactor_assets/test_implements_redactor_asset_interface'

module RedactorRails
  class DocumentTest < MiniTest::Unit::TestCase
    include ImplementsRedactorAssetInterface

    def setup
      @document = @object = Document.new
    end
  end
end

So I'm wondering you have any tips for how we might go about beginning this work? We'd like for our clients to be able to upload Document-type files, like PDF, DOC, etc... just as fantastically easily as they do with Images!

Let me know what I can do to pitch in, we'd really like to contribute! Thanks

Uploading an image to the dialog kills the session when using Devise

Hi,

I installed the gem and I'm trying to integrate the redactor editor into an exisiting model.
The problem is, that If I try to upload an image, the image uploads, but when trying to submit the form, I loose my session and have to login back again.

I'm using Devise for authentication and tried to debug this problem pretty heavily.
I don't know what is causing this - I even tried to switch from carrierwave to paperclip - but it didn't help.

The problem is definetly caused by the upload.

Please help.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.