galdomedia / tinymce_filemanager

TinyMCE wrapper for Rails that allows managing media files (ie. uploding images, creating new directories, etc).
http://trackingrails.com/posts/managing-images-directly-from-tinymce-tinymcefilemanager
MIT License
28 stars 3 forks source link

= TinymceFilemanager (v0.2)

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

Gem (still unofficial) is available in different repo: {tinymce_fm}[https://github.com/galdomedia/tinymce_fm]

== Installation

This plugin require "MiniMagick" to work. MiniMagick 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

  2. Run generators:

    rails generate tinymce_filemanager:installation rails generate tinymce_filemanager:icons_installation

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

    include TinymceFilemanager

  4. In layout (best in page section) add:

    <%= tinymce_managed_javascript_tag "pages" %>

    where "pages" is name of controller from last step

    The theme defaults to tinymce_filemanager's "advanced" theme flavour however you can pass an additional parameter to the tinymce_managed_javascript_tag which will allow you to use a custom theme or the provided simple theme.

    <%= tinymce_managed_javascript_tag "pages", "simple" %>

  5. Add tag in form:

    <%= tinymce_managed_tag "some_field_name", "some field content" %>

    or use builder method:

    <%= f.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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

... <%= tinymce_managed_javascript_tag "pages" %> ... ...

optional theme:

The theme defaults to tinymce_filemanager's "advanced" theme flavour however you can pass an additional parameter to the tinymce_managed_javascript_tag which will allow you to use a custom theme or the provided simple theme.

<%= tinymce_managed_javascript_tag "pages", "simple" %>

pages new view:

New page

<% form_for(@page) do |f| %> <%= f.error_messages %> ...

<%= f.label :body %>
<%= f.tinymce_managed :body %>

...
<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', 'image/png']

# 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 (separate by comma for multiple classes)
link_classes_accepted [Page,Category] 

...

end

== TODO

Copyright (c) 2011 Galdomedia, Leszek Smentek, released under the MIT license