Warning: Division by zero in /.2/vhosts/www.friendlinkup.com/html/nonsense.php on line 340

Warning: Division by zero in /.2/vhosts/www.friendlinkup.com/html/nonsense.php on line 342
Gerenciador de imagens em Rails para TinyMCE e FCKEditor
raulsimoninib's Blog
O Yang do Ying, não o contrário.. RSS Feed - Newest 10 Posts Add To Favourites

Gerenciador de imagens em Rails para TinyMCE e FCKEditor
Posted on 2008-12-03 by raulsimoninib

Problema: Estou usando TyneMCE ou FCKEditor em minha aplicação Rails, quero um gerenciador de imagens pra ontem!

Problem: I´m using TyneMCE or FCKEditor in my Rails app as well as the File Mananger does not work ! I require this due yesterday!!

First Step: Use a plugin to insert this Rich-Text editors in Rails may prove to be a great time saver !
TinyMCE: http://github.com/kete/tiny_mce/tree/master
FCKEditor: http://rubyforge.org/projects/fckeditorp/

Optional: This article: http://wiki.rubyonrails.org/rails/pages/howtousetinymce raise some thoughts about security IMHO at all times a useful wast of brain cells..

Still if the plugin don´t do the image job endeavour my fast solution -would be this: a iFrame below the text area!

iframe with files


-Because the plugin support drag-and-drop you can drag the thumbs or the full pictures as well as drop where you want.. great?!

Uploading:

Way simple..

Showing:

Ok.. basic Portuguese lesson:
lista = list
adicionar = add
Imagens de Notícias = News Pictures
Caminho: = path
Dimensões: = (like ~) width height
Tamanho: = size
Enviar = Send
Well you figure out the rest.. =)

How to do: You shall require the following plugins:

  1. attachment_fu
  2. mislav-will_paginate

Now manufacture a scaffold (just on behalf of laziness) with this params: mananger filename:string

Cause I don´t like migrations.. in your database create something like:

CREATE TABLE `mydatabase`.`manangers` (
`id` int(10) unsigned NOT NULL auto_increment,
`filename` varchar(80) default NULL,
`content_type` varchar(40) default NULL,
`size` int(10) unsigned default NULL,
`height` int(10) unsigned default NULL,
`width` int(10) unsigned default NULL,
PRIMARY KEY (`id`)
)

On CONTROLLER: manangers_controller.rb:
class ManangersController params[:page], :order =>”id DESC” # we desire the new first
end

def show
@mananger = Mananger.find(params[:id])
end

def new
@mananger = Mananger.new
end

def create
@mananger = Mananger.new(params[:mananger])

respond_to do |format|
if @mananger.save
flash[:notice] = ‘Upload com sucesso.’
format.html { redirect_to(@mananger) }
format.xml { render :xml => @mananger, :status => :created, :location => @mananger }
else
flash[:notice] = ‘Falha no upload’
format.html { render :action => “new” }
format.xml { render :xml => @mananger.errors, :status => :unprocessable_entity }
end
end
end

def destroy
@mananger = Mananger.find(params[:id])
@mananger.destroy

respond_to do |format|
format.html { redirect_to(manangers_url) }
format.xml { head :ok }
end
end
end

On MODEL mananger.rb:
class Mananger " already exist !"

has_attachment :content_type => :image,
:path_prefix => ‘public/files’,
:storage => :file_system,
:size => 1..1048576, # 2MB
:partition => false
validates_as_attachment
end

On VIEWS we are going to utilize 3:
index.html.erb:

Imagens de Notícias

<!–

–>
<!–

–>

80) %>
px x px
|

new.html.erb:

UPLOAD

{ :multipart => true }) do |f| %>

show.html.erb

Caminho:

Dimensões: px x px

Tamanho:

DONE !

Now.. you desire to position this in a iframe over or under one Rich-Text WYSWIG insert something like this:

      
feed | tags: desenvolvimento, rails, rails, tinymce, fckeditor, richtext


del.icio.us digg Fark YahooMyWeb Reddit Furl NewsVine Spurl BlinkList blogmarks

<<< Back