TinyMCE wrapper for Rails that allows managing media files (ie. uploding images, creating new directories, etc).
Ruby
Switch branches/tags
Nothing to show
Pull request Compare This branch is 15 commits behind galdomedia:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
config
generators
lib
rails
test
MIT-LICENSE
README.rdoc
Rakefile
init.rb
install.rb
uninstall.rb

README.rdoc

TinymceFilemanager (v0.2)

TinyMCE wrapper, that takes care of managing media files (images, videos) and links within your application.

Installation

This plugin require “RMagic” to work. RMagick is used to create thumbnails of images.

If you want, you can also manage multimedia files (ie. videos), but then you will need to have ffmpeg installed on your machine (thumb generation).

  1. Install plugin using console:

rails plugin install git://github.com/galdomedia/tinymce_filemanager.git

  1. Run generators:

rails generate tinymce_filemanager:installation rails generate tinymce_filemanager:icons_installation

  1. Add include line in controller that will manage images ( controller Pages for example )

include TinymceFilemanager

  1. In layout (best in page <head> section) add:

<%= tinymce_managed_javascript_tag “pages” %>

where "pages" is name of controller from last step
  1. Add tag in form:

<%= tinymce_managed_tag “some_field_name”, “some field content” %>

or use builder method:

tinymce_managed :some_field_name

Basic Usage

controller “pages”:

class PagesController < ApplicationController

		include TinymceFilemanager

		def index
		...

end

application layout:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=“www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”>

		<head>
  			<meta http-equiv="content-type" content="text/html;charset=UTF-8" />

			...

			<%= tinymce_managed_javascript_tag "pages" %>

			...

		</head>

<body>

		...

		</body>

</html>

pages new view:

<h1>New page</h1> <% form_for(@page) do |f| %> <%= f.error_messages %> … <p> <%= f.label :body %><br /> <%= f.tinymce_managed :body %> </p> … <p> <%= f.submit “Create” %> </p> <% end %>

<%= link_to 'Back', pages_path %>

Sample Configuration

for “pages” controller

class PagesController < ApplicationController include TinymceFilemanager

# accept only jpeg and gif for images image_accept_mime_types ['image/jpeg', 'image/gif'] # limit image file size to 2MB image_file_size_limit 2.megabytes # accept only mpeg and flash files(swf) for media media_accept_mime_types ['video/mpeg', 'application/x-shockwave-flash']

# limit media file size to 15MB media_file_size_limit 15.megabytes #thumbs created into 'small' subdir thumbs_subdir 'small' #images save to RAILS_ROOT/public/manager/images thumbs in RAILS_ROOT/public/manager/images/small image_save_into_public_subdir 'manager/images' #images save to RAILS_ROOT/public/manager/images thumbs in RAILS_ROOT/public/manager/images/small media_save_into_public_subdir 'manager/media' #classes of objects, that can be browsed through LinkBrowser link_classes_accepted [Page] … end

TODO

  • convert into gem

  • link browser should accept chained queries (ie. Page.where('visible=?',true).order('updated_at DESC') )

Copyright © 2011 Galdomedia, Leszek Smentek, released under the MIT license