Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.
/ yui_editor Public archive
forked from larsklevan/yui_editor

Integrate the YUI Rich Text Editor into a Rails application and with file uploading support with paperclip

License

Notifications You must be signed in to change notification settings

mooktakim/yui_editor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YuiEditor
=========

Integrate the Yahoo Rich Text Editor (http://developer.yahoo.com/yui/editor/) into a Rails application.
Integration of file uploads through the text editor. It can be used with whatever upload plugin for rails. But, i will describe how to make it work with Paparclip below.

Example
=======

# Basic usage

blog_controller.rb:

class BlogController < ApplicationController
  uses_yui_editor
end

new.html.erb:

<% form_for(@blog) do |f| %>
  <%= f.text_area :post, :class => 'rich_text_editor' %>
<% end %>

blogs.html.erb:

<head>
  <%= include_yui_editor_if_used %>
</head>

Simple method for upload controller:

Add this method to your paperclip upload image controller

  def yui_upload
    @uploaded_image = UploadedImage.new(params[:uploaded_image])

    respond_to do |format|
      if @uploaded_image.save
        format.html do
          render :text => "{status:'UPLOADED',image_url:'#{@uploaded_image.file.url}',large_image_url:'#{@uploaded_image.file.url(:large)}'}", :layout => false
        end
      else
        format.html do
          render :text => "{status:'Upload was unsuccessful.'}", :layout => false
        end
      end
    end
  end

decide on the image sizes you would like to return. In this case, i'm return the default image size for display "image_url", and :large size for url link "large_image_url"


# Customizing the configuration

default settings are in RAILS_ROOT/config/yui_editor.yml.

Edit the following line for the correct url for image uploads:
yuiImgUploader(editor, textArea.id, '/uploaded_images/yui_upload','uploaded_image[file]');
In the above example i have a controller called UploadedImages and a method yui_upload.
Also, its important to have the correct field name: uploaded_image[file]

you can override the editor defaults in each controller:

class BlogController < ApplicationController
  uses_yui_editor(:only => [:new, :create, :edit, :update], :selector => 'blog_post')
end

Instructions for configuring the plugin:
http://wiki.github.com/larsklevan/yui_editor

Instructions for configuring the editor:
http://developer.yahoo.com/yui/docs/YAHOO.widget.Editor.html#configattributes

Instructions for configuring the toolbar:
http://developer.yahoo.com/yui/examples/editor/toolbar_editor.html

Installation
============

script/plugin install git://github.com/larsklevan/yui_editor.git

Feedback
========

Send feedback and questions to:
tastybyte at gmail.com

Copyright (c) 2009 Lars Klevan, released under the MIT license

About

Integrate the YUI Rich Text Editor into a Rails application and with file uploading support with paperclip

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%