Skip to content
Browse files

Add ckeditor assets to precompile list

  • Loading branch information...
1 parent 391a31a commit b336d27ee741a696b060a9ef1debedab6b6abfe6 @galetahub galetahub committed Jan 23, 2012
Showing with 20 additions and 1 deletion.
  1. +15 −0 lib/ckeditor.rb
  2. +4 −0 lib/ckeditor/engine.rb
  3. +1 −1 lib/ckeditor/utils.rb
View
15 lib/ckeditor.rb
@@ -1,4 +1,5 @@
require 'orm_adapter'
+require 'pathname'
module Ckeditor
IMAGE_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/jpg', 'image/pjpeg', 'image/tiff', 'image/x-png']
@@ -42,6 +43,20 @@ def self.setup
yield self
end
+ def self.root_path
+ @root_path ||= Pathname.new( File.dirname(File.expand_path('../', __FILE__)) )
+ end
+
+ def self.assets
+ Dir[root_path.join('vendor/assets/javascripts/ckeditor/**', '*.{js,css}')].inject([]) do |list, path|
+ unless path.include?("/ckeditor/filebrowser/")
+ list << Pathname.new(path).relative_path_from(root_path.join('vendor/assets/javascripts'))
+ end
+
+ list
+ end
+ end
+
def self.picture_model
Ckeditor::Picture.to_adapter
end
View
4 lib/ckeditor/engine.rb
@@ -7,6 +7,10 @@ class Engine < ::Rails::Engine
config.action_view.javascript_expansions[:ckeditor] = "ckeditor/ckeditor"
+ initializer "ckeditor.assets_precompile" do |app|
+ app.config.assets.precompile += Ckeditor.assets
+ end
+
initializer "ckeditor.helpers" do
ActiveSupport.on_load(:action_controller) do
ActionController::Base.send :include, Ckeditor::Helpers::Controllers
View
2 lib/ckeditor/utils.rb
@@ -70,7 +70,7 @@ def applay_options(options)
def filethumb(filename)
extname = filename.blank? ? "unknown" : File.extname(filename).gsub(/^\./, '')
image = "#{extname}.gif"
- source = File.expand_path("../../../vendor/assets/javascripts/ckeditor/filebrowser/images/thumbs", __FILE__)
+ source = Ckeditor.root_path.join("vendor/assets/javascripts/ckeditor/filebrowser/images/thumbs")
unless File.exists?(File.join(source, image))
image = "unknown.gif"

0 comments on commit b336d27

Please sign in to comment.
Something went wrong with that request. Please try again.