diff --git a/Gemfile b/Gemfile index f649f529..ea4ee913 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ gem 'execjs' gem 'jquery-rails', '2.1.4' gem 'jquery-ui-rails' gem "select2-rails", '3.3.1' -gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' +gem 'kaminari' # gem "memcached", "~> 1.4.3" # gem "memcache-client" @@ -46,7 +46,7 @@ gem 'sinatra' gem 'sprockets' gem 'social-share-button' -gem 'ckeditor_rails' +gem 'ckeditor' # gem 'tinymce-rails', "~> 3.5.8" gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") gem 'libv8', '~> 3.11.8' if RUBY_PLATFORM.downcase.include?("linux") diff --git a/app/assets/javascripts/basic.js b/app/assets/javascripts/basic.js index 9438f767..7f975c67 100644 --- a/app/assets/javascripts/basic.js +++ b/app/assets/javascripts/basic.js @@ -8,4 +8,4 @@ //= require basic/jquery.nanoscroller.js //= require basic/jquery.easing.1.3.js -//= require ckeditor-jquery \ No newline at end of file +//= require ckeditor/init \ No newline at end of file diff --git a/app/assets/javascripts/ckeditor/config.js b/app/assets/javascripts/ckeditor/config.js.erb similarity index 93% rename from app/assets/javascripts/ckeditor/config.js rename to app/assets/javascripts/ckeditor/config.js.erb index 61d2f521..064f9154 100644 --- a/app/assets/javascripts/ckeditor/config.js +++ b/app/assets/javascripts/ckeditor/config.js.erb @@ -22,9 +22,13 @@ CKEDITOR.editorConfig = function( config ) { ]; config.autoGrow_onStartup = true; config.forcePasteAsPlainText = false; - config.filebrowserBrowseUrl = '/browser/browse.php'; + // config.filebrowserBrowseUrl = '/browser/browse.php'; // 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'; // Load from a list of definitions. diff --git a/app/models/ckeditor/asset.rb b/app/models/ckeditor/asset.rb new file mode 100644 index 00000000..e2cbe077 --- /dev/null +++ b/app/models/ckeditor/asset.rb @@ -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 diff --git a/app/models/ckeditor/attachment_file.rb b/app/models/ckeditor/attachment_file.rb new file mode 100644 index 00000000..43a38728 --- /dev/null +++ b/app/models/ckeditor/attachment_file.rb @@ -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 diff --git a/app/models/ckeditor/picture.rb b/app/models/ckeditor/picture.rb new file mode 100644 index 00000000..74f6da4c --- /dev/null +++ b/app/models/ckeditor/picture.rb @@ -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 diff --git a/app/uploaders/ckeditor_attachment_file_uploader.rb b/app/uploaders/ckeditor_attachment_file_uploader.rb new file mode 100644 index 00000000..8d0e4773 --- /dev/null +++ b/app/uploaders/ckeditor_attachment_file_uploader.rb @@ -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 diff --git a/app/uploaders/ckeditor_picture_uploader.rb b/app/uploaders/ckeditor_picture_uploader.rb new file mode 100644 index 00000000..4a5a56a8 --- /dev/null +++ b/app/uploaders/ckeditor_picture_uploader.rb @@ -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 diff --git a/config/application.rb b/config/application.rb index f3a725c3..84e8d974 100644 --- a/config/application.rb +++ b/config/application.rb @@ -27,13 +27,14 @@ module Orbit # Custom directories with classes and modules you want to be autoloadable. # config.autoload_paths += %W(#{config.root}/extras) - config.autoload_paths += %W(#{config.root}/lib) - config.autoload_paths += %W(#{config.root}/lib/parsers) + config.autoload_paths += %W(#{config.root}/app/models/ckeditor) 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/purchase) 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 # 'helper :all' must be removed in ApplicationController diff --git a/config/initializers/ckeditor.rb b/config/initializers/ckeditor.rb new file mode 100644 index 00000000..e84ab73c --- /dev/null +++ b/config/initializers/ckeditor.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index a373f593..6f79f590 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Orbit::Application.routes.draw do + mount Ckeditor::Engine => '/ckeditor' + # get "robots.txt" => 'robots#index' diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index c7e45b0e..2086da51 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -194,7 +194,7 @@