资源说明:TinyMCE FileManager
= TinymceFm gem (v0.0.2) (previously - TinymceFilemanager plugin) TinyMCE wrapper, that takes care of managing media files (images, videos) and links within your application. It will be published as official gem after some tests, etc. == Installation This plugin requires mini_magick gem to work (so also - imagemagick binaries installed on server). 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. Add gem to you Gemfile: gem 'tinymce_fm' 2. Add Engine to routes.rb file: Freshmag::Application.routes.draw do # TinymceFm Engine mount TinymceFm::Engine => "/tinymce_fm" # ... root :to=>"welcome#index" end 3. Add include line in controller that will manage images ( controller Pages for example ) include TinymceFm::Filemanager 4. In layout (best in page section) add: <%= tinymce_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_javascript_tag "pages", "simple" %> 5. Add tag in form: <%= tinymce_tag "some_field_name", "some field content" %> or use builder method: <%= f.tinymce :some_field_name %> == Basic Usage controller "pages": class PagesController < ApplicationController include TinymceFm::Filemanager def index ... end application layout: ... <%= tinymce_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_javascript_tag "pages", "simple" %> pages new view:New page
<% form_for(@page) do |f| %> <%= f.error_messages %> ...<%= f.label :body %>
...
<%= f.tinymce :body %><%= f.submit "Create" %>
<% end %> <%= link_to 'Back', pages_path %> == Sample Configuration for "pages" controller class PagesController < ApplicationController include TinymceFm::Filemanager # 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 - link browser should accept chained queries (ie. Page.where('visible=?',true).order('updated_at DESC') ) - tests! == Special Thanks - {Leszek Smentek}[https://github.com/lechu] for initial work - {Maciej Litwiniuk}[https://github.com/mlitwiniuk] for all contribution - {Piotr Boniecki}[https://github.com/bonias] for making this Rails 3 compatible - {Matenia Rossides}[https://github.com/matenia] for some cleanup work Copyright (c) 2011 Galdomedia, Leszek Smentek and Maciej Litwiniuk, released under the MIT license
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。