Change ckeditor gem and kaminari in gemfile

This commit is contained in:
chris 2013-07-22 17:26:32 +08:00
parent 92faeccdb6
commit 6cf249ccfb
12 changed files with 141 additions and 9 deletions

View File

@ -14,7 +14,7 @@ gem 'execjs'
gem 'jquery-rails', '2.1.4' gem 'jquery-rails', '2.1.4'
gem 'jquery-ui-rails' gem 'jquery-ui-rails'
gem "select2-rails", '3.3.1' gem "select2-rails", '3.3.1'
gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' gem 'kaminari'
# gem "memcached", "~> 1.4.3" # gem "memcached", "~> 1.4.3"
# gem "memcache-client" # gem "memcache-client"
@ -46,7 +46,7 @@ gem 'sinatra'
gem 'sprockets' gem 'sprockets'
gem 'social-share-button' gem 'social-share-button'
gem 'ckeditor_rails' gem 'ckeditor'
# gem 'tinymce-rails', "~> 3.5.8" # gem 'tinymce-rails', "~> 3.5.8"
gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
gem 'libv8', '~> 3.11.8' if RUBY_PLATFORM.downcase.include?("linux") gem 'libv8', '~> 3.11.8' if RUBY_PLATFORM.downcase.include?("linux")

View File

@ -8,4 +8,4 @@
//= require basic/jquery.nanoscroller.js //= require basic/jquery.nanoscroller.js
//= require basic/jquery.easing.1.3.js //= require basic/jquery.easing.1.3.js
//= require ckeditor-jquery //= require ckeditor/init

View File

@ -22,9 +22,13 @@ CKEDITOR.editorConfig = function( config ) {
]; ];
config.autoGrow_onStartup = true; config.autoGrow_onStartup = true;
config.forcePasteAsPlainText = false; config.forcePasteAsPlainText = false;
config.filebrowserBrowseUrl = '/browser/browse.php'; // config.filebrowserBrowseUrl = '/browser/browse.php';
// config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images'; // config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
config.filebrowserUploadUrl = '/uploader/upload.php'; // config.filebrowserUploadUrl = '/uploader/upload.php';
config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>"
config.filebrowserUploadUrl = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>"
config.contentsCss = '/orbit_4.0.1/assets/javascripts/lib/ckeditor/plugins/stylesheetparser/samples/assets/sample.css'; config.contentsCss = '/orbit_4.0.1/assets/javascripts/lib/ckeditor/plugins/stylesheetparser/samples/assets/sample.css';
// Load from a list of definitions. // Load from a list of definitions.

View File

@ -0,0 +1,7 @@
class Ckeditor::Asset
include Ckeditor::Orm::Mongoid::AssetBase
delegate :url, :current_path, :size, :content_type, :filename, :to => :data
validates_presence_of :data
end

View File

@ -0,0 +1,7 @@
class Ckeditor::AttachmentFile < Ckeditor::Asset
mount_uploader :data, CkeditorAttachmentFileUploader, :mount_on => :data_file_name
def url_thumb
@url_thumb ||= Ckeditor::Utils.filethumb(filename)
end
end

View File

@ -0,0 +1,7 @@
class Ckeditor::Picture < Ckeditor::Asset
mount_uploader :data, CkeditorPictureUploader, :mount_on => :data_file_name
def url_content
url(:content)
end
end

View File

@ -0,0 +1,36 @@
# encoding: utf-8
class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/ckeditor/attachments/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
Ckeditor.attachment_file_types
end
end

View File

@ -0,0 +1,47 @@
# encoding: utf-8
class CkeditorPictureUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/ckeditor/pictures/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
process :read_dimensions
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [118, 100]
end
version :content do
process :resize_to_limit => [800, 800]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
Ckeditor.image_file_types
end
end

View File

@ -27,13 +27,14 @@ module Orbit
# Custom directories with classes and modules you want to be autoloadable. # Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras) # config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += %W(#{config.root}/lib) config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
config.autoload_paths += %W(#{config.root}/lib/parsers)
config.autoload_paths += %W(#{config.root}/app/models/design) config.autoload_paths += %W(#{config.root}/app/models/design)
config.autoload_paths += %W(#{config.root}/app/models/desktop)
config.autoload_paths += %W(#{config.root}/app/models/meta) config.autoload_paths += %W(#{config.root}/app/models/meta)
config.autoload_paths += %W(#{config.root}/app/models/purchase) config.autoload_paths += %W(#{config.root}/app/models/purchase)
config.autoload_paths += %W(#{config.root}/app/models/user) config.autoload_paths += %W(#{config.root}/app/models/user)
config.autoload_paths += %W(#{config.root}/app/models/desktop) config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W(#{config.root}/lib/parsers)
# Include all helpers # Include all helpers
# 'helper :all' must be removed in ApplicationController # 'helper :all' must be removed in ApplicationController

View File

@ -0,0 +1,21 @@
# Use this hook to configure ckeditor
if Object.const_defined?("Ckeditor")
Ckeditor.setup do |config|
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require "ckeditor/orm/mongoid"
# Allowed image file types for upload.
# Set to nil or [] (empty array) for all file types
# config.image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]
# Allowed attachment file types for upload.
# Set to nil or [] (empty array) for all file types
# config.attachment_file_types = ["doc", "docx", "xls", "odt", "ods", "pdf", "rar", "zip", "tar", "swf"]
# Setup authorization to be run as a before filter
# config.authorize_with :cancan
end
end

View File

@ -1,4 +1,6 @@
Orbit::Application.routes.draw do Orbit::Application.routes.draw do
mount Ckeditor::Engine => '/ckeditor'
# get "robots.txt" => 'robots#index' # get "robots.txt" => 'robots#index'

View File

@ -194,7 +194,7 @@
<div class="controls"> <div class="controls">
<div class="textarea"> <div class="textarea">
<%= f.fields_for :text_translations do |f| %> <%= f.fields_for :text_translations do |f| %>
<%= f.text_area locale, rows: 5, class: "ckeditor input-block-level", id: "content_#{locale}", name: "content_#{locale}", :value => (@bulletin.text_translations[locale] rescue nil) %> <%= f.cktext_area locale, rows: 5, class: "input-block-level", id: "content_#{locale}", name: "content_#{locale}", :value => (@bulletin.text_translations[locale] rescue nil) %>
<% end %> <% end %>
</div> </div>
</div> </div>