kreativgebiet / rich Goto Github PK
View Code? Open in Web Editor NEW:money_with_wings: An opinionated CKEditor editor for Rails with flexible image uploads
License: MIT License
:money_with_wings: An opinionated CKEditor editor for Rails with flexible image uploads
License: MIT License
Hi there and thanks for making Rich, I really like it!
Running into an issue with my project https://github.com/whitecl/devotion-cms
In development mode, all versions of IE load the rich editor with no problems. However in production mode, IE <= 9 does not work correctly. The textarea element is not converted into an editor, but no Javascript errors are thrown. Production mode works fine in all non-IE browsers.
Is there any additional troubleshooting data I can provide to help?
I'm trying to follow the steps to make rich available, however I receive this error:
Rendered /Users/nicholaspufal/.rvm/gems/ruby-1.9.2-p290/gems/activeadmin-0.3.3/app/views/active_admin/resource/new.html.arb (5.7ms)
Completed 500 Internal Server Error in 66ms
ActionView::Template::Error (undefined method `custom_namespace=' for Rich::FormBuilder:Module):
1: render renderer_for(:new)
I did migrate my database, and within my registered model, I did set the form correctly:
form do |f|
f.inputs "Basic info:" do
f.input :title
f.input :content, :as => :rich
end
f.buttons
end
Any ideas?
Thanks
I set on text area fields class 'rich_editor/edtior/rich' but CKEditor doesn't load. When i put custom id 'editor' on text area field and do this CKEDITOR.replace( 'editor' ) form firebug CKEditora is loaded. Can you write some example, how to use it without formtastic, please.
Hei everyone!
Sry for this question but how can I change the storage of uploaded files to default?
I once added some configuration for the S3 upload but I didn't need them anymore and deleted them. Now in production (after deploying) I don't have the "/system/rich/rich_files/..." directory anymore which means I can't upload any images from the backend.
Any ideas how to return to default options (upload path filesystem)?
I tried this css, it works well, but make stype picker strange.
.cke_skin_kama {
margin-left: 20%;
}
And I tried
float: left;
}
It seems a better way for active admin
I found some problems with File Browser. I can't fix them cause I haven't enough Rails knowledge, so far )
how to get the file's url or id?
When trying to run rake assets:precompile
on my production environment during deployment, the asset precompilation fails due to what it sees as invalid CSS in one of the CKEditor CSS files...
$ rake assets:precompile RAILS_ENV=production
Rich - Copying CKEditor to your assets folder
mkdir -p /my/root/dir/public/assets/ckeditor
cp -r /my/root/dir/vendor/bundle/ruby/1.8/gems/rich-1.0.3/vendor/assets/ckeditor/ckeditor/. /my/root/dir/public/assets/ckeditor
mkdir -p /my/root/dir/public/assets/ckeditor-contrib
cp -r /my/root/dir/vendor/bundle/ruby/1.8/gems/rich-1.0.3/vendor/assets/ckeditor/ckeditor-contrib/. /my/root/dir/public/assets/ckeditor-contrib
/usr/bin/ruby /usr/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
Invalid CSS after " +margin:": expected pseudoclass or pseudoelement, was " 2px 0; /* IE7 */"
(in /my/root/dir/vendor/bundle/ruby/1.8/gems/rich-1.0.3/vendor/assets/ckeditor/ckeditor/_source/skins/kama/dialog.css)
Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/usr/bin/ruby /usr/bin/rake assets:precomp...]
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
Any workarounds for this?
hi
= f.text_area :text, :as => :rich
just generate
<textarea as="rich" cols="40" id="item_text" name="item[text]" rows="20">
....
</textarea>
thx
Hi!
I am trying to imitate twitter bootstrap dom for style purposes.
I've put styles in my editor.css, but once i've created my <div class='row'>
and i try to insert a <div class='span4'>
it over-rides the <div class='row'>
element.
The dom I desire is as such:
<div class='row '>
<div class='span4'> Some text </div>
<div class='span8'> some other text </div>
</div>
If I go into the source tab and edit it there I can get it to work, but that's not ideal. Is there a good way around this? I'm not sure what approach to take, so any ideas are welcome!
Here are the relevant styles in my editor.css.less:
div.row {
.clearfix();
// extra 20 for padding
width: 960px;
}
.spanning {
float: left;
margin-right: 20px;
}
div.row div.span4 {
.spanning();
width: 300px;
}
div.row div.span8 {
.spanning();
width: 620px;
}
div.row div.span3 {
.spanning();
width: 220px;
}
div.row div.span12 {
.spanning();
width: 940px;
}
Hello. It seems that Rich and ActiveAdmin again aren't playing well together in Firefox 12.1. Updating and creating content works great in Chrome.
So I've installed the Gem and am mounting the engine, the WYSIWYG side works perfectly (with ActiveAdmin). However, when trying to upload from the file dialogue which all loads fine, I'm getting a routing error:
ActionController::RoutingError (No route matches [POST] "/rich/files/authenticity_token=bnRKfskN8ZdtOTNAWoc0reESW7wpeAEd9gBDTTAneYM=&simplified_type=image&scoped=false&scope_type=undefined&scope_id=undefined&qqfile=02.jpg")
Is anyone else experiencing this?
Hi,
I trying to add some buttons in my toolbar like this ( on the rich.rb file include in a initializers folder ) :
config.editor[:toolbar] = 'Easy';
config.editor[:toolbar_Easy] =
[
['Source','-','showblocks', 'ServerPreview', 'Preview'],
['Cut','Copy','Paste','PasteText','PasteFromWord'],
['Undo','Redo','-','SelectAll','RemoveFormat'],
['Templates'],
['Format', 'FontSize', 'TextColor', 'Font'], '/',
['Bold','Italic','Underline','Strike'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Link','Unlink','Anchor'],
['Table','HorizontalRule','Smiley','SpecialChar'],
['MediaEmbed', 'richfile'],
];
So now i try to add the "Browse and upload images" with 'richfile' as you can see at the end of the custom toolbar config.
But nothink appear and i can't find your default toolbar in your code.
Can you tell me where i could find your default toolbar config or the name of "Browse and upload images" plugins?
Thanks you.
Hi!
This is looking good I must say! It would be nice if the t method was used in views so we, from far far away, can translate your awesome gem :)
Ahh, saw that this was in "Planned features". Great :)
When I use:
<%= f.input :description, :as => :rich %>
I got the following error!
Expected /home/irfan/.rvm/gems/ruby-1.9.2-p320@xavy/gems/rich-1.3.1/app/inputs/rich_input.rb to define RichInput
Is there a way to readd the target/advanced tabs on the link dialog? I can see where they're being removed at in rich.rb but I can't figure out a way to get these back in there.
Hi!
We are working on moving to SSL, and currently everything is hard-coded to use the paperclip URL instead of a connection to the rich file itself.
Obviously, for inline connections we need to use the url (or have some sort of processor that calculates the url).
When I have a rich picker, I think I would rather have the association (or at least have the option) and then be able to generate the URL from that...so that I don't have to worry about migrating a bunch of data in my DB when I move to SSL.
I can dig through the code and look to see how to do this unless you know off-hand.
Thank you so much for being so responsive!
Hi, in firefox 15.0.1 textarea for rich editor is too large when using it with active_admin 0.5.0. What i mean is that textarea is larger than the page container, therefore it causes scroll to appear at the bottom of the page.
Also, any progress with loading in IE?
Thanks.
I am getting "No route matches {:controller=>"welcome"}" when selecting to upload an image from Active Admin. Form previously worked with a type of : file
Rails 3.2.8
Gemfile:
gem 'rails', '3.2.8'
gem 'mysql2'
gem 'json'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'compass-rails'
gem 'zurb-foundation'
gem 'uglifier', '>= 1.0.3'
end
gem 'will_paginate'
gem 'jquery-rails'
gem 'paperclip'
gem 'make_permalink'
gem 'money'
gem 'activeadmin'
gem 'rich'
gem "ckeditor", "3.7.3"
gem 'acts_as_list', '0.1.4'
gem 'activemerchant', '1.28.0'
Code from active admin:
f.inputs "Product Images" do
f.has_many :assets do |i|
i.input :attachment,
:as => :rich_picker, :config => {:style => 'width: 400px !important;', :hidden_input => true, :placeholder_image => image_path('placeholder.png'), :preview_size => '200px'},
:multipart => true,
:label => "Image"
end
end
Routes:
Loco::Application.routes.draw do
mount Rich::Engine => '/rich', :as => 'rich'
devise_for :users
ActiveAdmin.routes(self)
mount Ckeditor::Engine => "/ckeditor"
devise_for :admin_users, ActiveAdmin::Devise.config
match 'checkout' => 'checkout
match 'basket' => 'basket
match 'add_to_basket/:id' => 'basket
match 'remove_from_basket/:id' => 'basket
match 'offer_code/' => 'basket
match 'update_cart/:id' => 'basket
match 'check_basket' => 'basket
match "blog" => "blogs
match "post/:id" => "blogs
match "blog/category/:name" => 'blogs
resources :products do
collection do
get 'search'
end
end
resources :product_categories
root :to => 'welcome'
match ':controller(/:action(/:id))(.:format)'
end
How can I upload Images to an S3 host?
Hello everyone
I'm using the Rich Editor together with Rails Admin and configured a model "Document" in the Rails Admin initializer as following:
config.model Document do
edit do
fields :title, :category, :role
field :upload, :rich_picker do
config ({
:type => 'file',
:allowed_styles => [:original]
})
end
end
end
I also allowed document uploads and all document types in my rich initializer.
Now when I click on the "Select or upload" Button of the :upload field in the Rails Admin Backend, it doesn't open the rich file picker. Instead I am asked to download a file with the name "files" from my server.
Maybe I have to add, that when I want to upload a file within the rich text editor in the Backend, it opens the file picker but the files / pictures can't be uploaded.
It works without any problems in all browsers, except for the Internet Explorer 8 (I didn't test other versions because we actually use IE8 in my company).
I hope you guys could help me out with this problem.
Adding this style will make the picker look better for new versions of active admin (button and preview will align with inputs and not the label)
body.active_admin
li.rich_picker a.button {
margin-left: 20%;
margin-top: 10px;
}
li.rich_picker .rich-image-preview {
margin-left: 20%;
}
}
Looks like engine is not able to access this method.
I've tried to create a module to share this method between main app and Rich::FilesController, but it's not working.
I'm in rails 3.1 and activeadmin
Any ideas?
Before I could regenerate thumbnails using:
rake rich:refresh_assets
I get the following error:
uninitialized constant Rich::RichImage
Probably because RichImage was refactored to RichFile?
This makes heroku deploys not work correctly.
See here: https://devcenter.heroku.com/articles/rails3x-asset-pipeline-cedar#assetsprecompile_failures
I noticed that are you are requiring the environment in your asset compilation rake tasks and I think this is the problem. Let me know if you need help solving this!
The gem looks for the file "editor.css" in the asset pipeline, but the css file is named "rich_editor.css". This generates an error with the stylesheet not being found.
Changing the filename of the css file to "app/assets/stylesheets/rich/editor.css" solves issue.
does rich support deployment on Heroku?
I'm trying to deploy to Heroku and I get this error message:
Running: rake assets:precompile
mkdir -p /tmp/build_16synbmkjnz1z/public/assets/ckeditor
cp -r /tmp/build_16synbmkjnz1z/vendor/bundle/ruby/1.9.1/gems/rich-1.2.0/vendor/assets/ckeditor/ckeditor/. /tmp/build_16synbmkjnz1z/public/assets/ckeditor
mkdir -p /tmp/build_16synbmkjnz1z/public/assets/ckeditor-contrib
cp -r /tmp/build_16synbmkjnz1z/vendor/bundle/ruby/1.9.1/gems/rich-1.2.0/vendor/assets/ckeditor/ckeditor-contrib/. /tmp/build_16synbmkjnz1z/public/assets/ckeditor-contrib
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Tasks: TOP => environment
(See full trace by running task with --trace)
Rich - Copying CKEditor to your assets folder
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
using
gem 'rails_admin', "~> 0.1.2"
gem 'rich'
i add some option for image size (like thmb, medium, large etc)
In my controller i try get the medium image, but didnt success
if i add to the module
has_attached_image (like paperclip)
i got the error undefined method "image_file_name"
in short how can i get the image path to one of the size image
thanks!
I get this error every time I run my app on heroku, and I get it sometimes in development unless I restart. I think the issue is your base Rich controller does not inherit from ApplicationController, but from ActionController::Base.
I am defined authenticate_admin_user! in my ApplicationController, so it's not defined.
To be honest, I have no idea how it works 'sometimes' in development.
Here is an example where you can specify the base controller in the app config:
Implemented in controller: https://github.com/plataformatec/devise/blob/master/app/controllers/devise_controller.rb
Set in config: https://github.com/plataformatec/devise/blob/master/lib/devise.rb#L191
I know older versions of devise just inherited from ApplicationController, so you could probably do that until someone requires something else.
Here is my input:
f.input :tutorial, as: :rich_picker, config: { scoped: "tutorials", allowed_styles: [:original], type: 'file' }
I have updated the initializer-- everything is working, but the preview under the input is trying to load an image so I get a broken image tag.
I'm wondering if i can show in the filemanager only images that belong to current_user ? I think this is somehow tied to scoping, but i dont understand how to achieve a result.
I noted there are owner_id and owner_type fields in Rich::RichFile model. Should i somehow set the owner_id to the current_user id and than retrieve images which have that id in their owner_id filed?
Could you clarify this to me please?
I use Rich with active_admin and by its own in pure views.
Thank you.
When using the assets pipeline using an external asset host the editor doesn't work and keeps trying to load the assets from the local domain.
In config/environments/production.rb
config.action_controller.asset_host = "http://assets.domain.com"
The editor does not work in Firefox 9.1
Getting a missing rake task on install.
$ rails generate rich:install
create config/initializers/rich.rb
route mount Rich::Engine => '/rich', :as => 'rich'
create app/assets/stylesheets/rich/editor.css
create app/assets/javascripts/rich.js
rake rich:install:migrations
rake aborted!
Don't know how to build task 'rich:install:migrations'
And heres a little about the environment:
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.2]
$ gem list | grep 'rails\|rake\|rich'
coffee-rails (3.2.2)
jquery-rails (2.1.3)
rails (3.2.8)
rake (0.9.2.2)
rich (1.2.0)
It seems that my Rich editor isn't floating correctly when using Active Admin: http://cl.ly/IdKR Of course I could hack it but wondered what the problem was? This is using both latest git repo versions of Rich and ActiveAdmin
I applied rich_editor to an existing field in my rails_admin config.
field :description, :rich_editor
When I start the app and view that record the description field is empty. Is there something I need to add within the config to see existing data in the field?
Thanks
Hello!
I'm sorry to open this issue because maybe it is not an issue, but I can't seem to be able to change buttons on the editor.
I've tried overriding ckeditor's config.js and change "config.editor" on Rich's initializer. I'm stuck on this for about 4 days, and everything I've tried resulted in nothing.
Can I have some advice on this?
Thank you very much, looking forward for some help!
I was compiling assets on the fly in production and received a sass error:
It might have something to do with this issue:
ttps://github.com/galetahub/ckeditor/issues/89
I was able to resolve the issue by overriding vendor/assets/ckeditor/ckeditor-contrib/skins/BootstrapCK/editor.css and replacing the 4 cases of
filter:;
with
filter: none;
I'm not sure if this is correct but it fixed my issue.
Does rich work with
config.active_record.whitelist_attributes = true
I get the above error when running it as true. However if I
config.active_record.whitelist_attributes = false
It works fine
When I try to upload a file using the embedded uploader, the file doesn't get saved in the db and I get this error in the console:
Encoding::UndefinedConversionError ("\xFF" from ASCII-8BIT to UTF-8)
From what I can see it's something similar to the html5 upload bug, that was fixed here galetahub/ckeditor#8
I tried to temper with the gem and make the fix myself, but to no success.
I'm running rails3.1 on ruby 1.9.2-p290. ActiveAdmin 0.3.2 ( ebeigarts's fork) to make it work with formtastic 2 from here: https://github.com/mak-it/active_admin
Thanks a bunch!
Can't understand how to use file_picker only.
Besides from within the editor, the file manager can also be used on itβs own. See the rich_picker examples above. One important thing to note is that this requires a string field on the receiving object. A direct connection to the Rich::RichFile object is not supported at this time.
Please provide an example of using.
with many images, it can take minutes to show the image finder.
This looks really great! BUT It would be great if support for Mongoid existed.
Are there any alternatives?
Hello. Before anything, sorry for my english. I'm not so good as i wish.
I love the fact that you guys used Paperclip for this great implementation of ckeditor, but i have a problem. I need to use S3 for use in Heroku, so i looked for the RichFile model code and i found this:
has_attached_file :rich_file,
:styles => Proc.new {|a| a.instance.set_styles },
:convert_options => Proc.new { |a| Rich.convert_options[a] }
There is no hook for add s3 options through the has_attached_file method. So i have a question: Is there a way for add s3 credentials to the has_attached_file method without forking the entire project or monkey-patching the RichFile model using class_eval?
Thanks you.
Hello, I'm using the rich along with the Active Admin on a website and need to add a button to insert a "read more", insert the code a <!-- more ->
I looked at the code, but could not as I create this plugin for CKEditor and use the rich, as I do that?
From the Heroku Logs:
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.7/lib/active_record/dynamic_matchers.rb:50:in method_missing': undefined method
paginates_per' for Rich::RichFile(Table doesn't exist):Class (NoMethodError)
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.7/lib/active_record/dynamic_matchers.rb:50:in method_missing': undefined method
paginates_per' for Rich::RichFile(Table doesn't exist):Class (NoMethodError)
2012-09-16T23:50:35+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rich-1.2.0/app/models/rich/rich_file.rb:13:in <class:RichFile>' 2012-09-16T23:50:35+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rich-1.2.0/app/models/rich/rich_file.rb:6:in
module:Rich'
2012-09-16T23:50:35+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rich-1.2.0/app/models/rich/rich_file.rb:5:in `<top (required)>'
I am trying to use rich in my active_admin form, and get the Name Error undefined local variable or method `files_path' when I click on "Browse and Upload Images".
The error is here :
<div id="legacy-form"><%= form_for(@rich_asset, :url => files_path) do |f| %>
<p><%= f.file_field :rich_file%></p>
<%= f.submit("Upload") %>
<% end %>
I am using Rich here :
= semantic_form_for [:admin, @blog] do |f|
= f.inputs do
= f.input :name, :label => "Blog Title", :input_html => {:size => 120}
= f.input :body, :as => :rich, :config => { :width => "76%", :height => "400px" }
= f.buttons :commit
Hi, how to upgrade or downgrade ckeditor js files?
In the original galetahub/ckeditor gem you could specify Paperclip to use S3 by editing models/ckeditor/attachment_file.rb. Can this be done with Rich too?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.