Skip to content

galdomedia/tinymce_filemanager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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 <head> 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">
<html xmlns="http://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>

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:

<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', '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

  • 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

About

TinyMCE wrapper for Rails that allows managing media files (ie. uploding images, creating new directories, etc).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages