Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moves to Rails::Engine pattern

  • Loading branch information...
commit 50cc70a7a655fcc63b0d647cae8b46331f4b20c9 1 parent bb4fec3
Ryan Ahearn rahearn authored committed
8 Rakefile
View
@@ -1,6 +1,6 @@
-unless defined? TinyMCE::VERSION
+unless defined? TinyMCE::Rails::VERSION
$:.unshift File.expand_path("../lib", __FILE__)
- require "tinymce/version"
+ require "tinymce/rails/version"
end
def step(name)
@@ -19,8 +19,8 @@ desc "Update TinyMCE to version specified in lib/tinymce/version.rb"
task :update => [ :fetch, :extract, :process ]
task :fetch do
- download("https://github.com/downloads/tinymce/tinymce/tinymce_#{TinyMCE::VERSION}.zip", "tinymce.zip")
- download("https://github.com/downloads/tinymce/tinymce/tinymce_#{TinyMCE::VERSION}_jquery.zip", "tinymce.jquery.zip")
+ download("https://github.com/downloads/tinymce/tinymce/tinymce_#{TinyMCE::Rails::VERSION}.zip", "tinymce.zip")
+ download("https://github.com/downloads/tinymce/tinymce/tinymce_#{TinyMCE::Rails::VERSION}_jquery.zip", "tinymce.jquery.zip")
end
task :extract do
4 assets/integration/tinymce/preinit.js.erb
View
@@ -1,5 +1,5 @@
window.tinyMCEPreInit = window.tinyMCEPreInit || {
- base: '<%= TinyMCE.base %>',
- query: '<%= TinyMCE::VERSION %>',
+ base: '<%= TinyMCE::Rails.base %>',
+ query: '<%= TinyMCE::Rails::VERSION %>',
suffix: ''
};
3  lib/tinymce-rails.rb
View
@@ -1,2 +1 @@
-require "tinymce/version"
-require "tinymce/railtie"
+require "tinymce/rails"
65 lib/tinymce/rails-3.1.0.rake
View
@@ -1,65 +0,0 @@
-Rake::Task['assets:precompile'].clear
-
-namespace :assets do
- task :precompile do
- # We need to do this dance because RAILS_GROUPS is used
- # too early in the boot process and changing here is already too late.
- if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
- ENV["RAILS_GROUPS"] ||= "assets"
- ENV["RAILS_ENV"] ||= "production"
- Kernel.exec $0, *ARGV
- else
- Rake::Task["environment"].invoke
-
- # Ensure that action view is loaded and the appropriate sprockets hooks get executed
- ActionView::Base
-
- # Always perform caching so that asset_path appends the timestamps to file references.
- Rails.application.config.action_controller.perform_caching = true
-
- # Always compile assets
- Rails.application.config.assets.compile = true
-
- config = Rails.application.config
- env = Rails.application.assets
- target = Pathname.new(File.join(Rails.public_path, config.assets.prefix))
- manifest = {}
- manifest_path = config.assets.manifest || target
-
- if env.respond_to?(:each_logical_path)
- config.assets.precompile.each do |path|
- env.each_logical_path do |logical_path|
- if path.is_a?(Regexp)
- next unless path.match(logical_path)
- else
- next unless File.fnmatch(path.to_s, logical_path)
- end
-
- if asset = env.find_asset(logical_path)
- manifest[logical_path] = asset.digest_path
- filename = target.join(asset.digest_path)
- mkdir_p filename.dirname
-
- asset.write_to(filename)
- asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
-
- # Write undigested version of file
- filename = target.join(logical_path)
- asset.write_to(filename)
- asset.write_to("#{filename}.gz") if filename.to_s =~ /\.(css|js)$/
- end
- end
- end
- else
- # TODO: Remove this once we're depending on sprockets beta 15
- assets = config.assets.precompile.dup
- assets << {:to => target}
- env.precompile(*assets)
- end
-
- File.open("#{manifest_path}/manifest.yml", 'w') do |f|
- YAML.dump(manifest, f)
- end
- end
- end
-end
13 lib/tinymce/rails.rb
View
@@ -0,0 +1,13 @@
+module TinyMCE
+ module Rails
+ require 'tinymce/rails/engine'
+ require 'tinymce/rails/version'
+
+ def self.base
+ Engine.config.tinymce.base ||
+ [::Rails.application.config.action_controller.asset_host,
+ ActionController::Base.config.relative_url_root,
+ ::Rails.application.config.assets.prefix, '/tinymce'].compact.join
+ end
+ end
+end
4 lib/tinymce/assets.rake → lib/tinymce/rails/assets.rake
View
@@ -6,9 +6,9 @@ else
end
Rake::Task[task].enhance do
- assets = File.expand_path(File.dirname(__FILE__) + "/../../assets/precompiled/tinymce")
+ assets = File.expand_path(File.dirname(__FILE__) + "/../../../vendor/assets/javascripts/tinymce")
target = File.join(Rails.public_path, Rails.application.config.assets.prefix)
-
+
mkdir_p target
cp_r assets, target
end
11 lib/tinymce/rails/engine.rb
View
@@ -0,0 +1,11 @@
+module TinyMCE
+ module Rails
+ class Engine < ::Rails::Engine
+ config.tinymce = ActiveSupport::OrderedOptions.new
+
+ rake_tasks do
+ load File.join(File.dirname(__FILE__), 'assets.rake')
+ end
+ end
+ end
+end
5 lib/tinymce/rails/version.rb
View
@@ -0,0 +1,5 @@
+module TinyMCE
+ module Rails
+ VERSION = "3.4.8"
+ end
+end
36 lib/tinymce/railtie.rb
View
@@ -1,36 +0,0 @@
-module TinyMCE
- def self.base
- Railtie.config.tinymce.base ||
- [Rails.application.config.action_controller.asset_host,
- ActionController::Base.config.relative_url_root,
- Rails.application.config.assets.prefix, "/tinymce"].compact.join
- end
-
- class Railtie < Rails::Railtie
- config.tinymce = ActiveSupport::OrderedOptions.new
-
- def asset_root
- File.join(File.dirname(__FILE__), "../../assets")
- end
-
- rake_tasks do
- # Replacement for assets:precompile task in Rails 3.1.0
- load "tinymce/rails-3.1.0.rake" if Rails.version <= "3.1.0"
-
- # Copy TinyMCE assets when assets:precompile task is called
- load "tinymce/assets.rake"
- end
-
- initializer "configure assets", :group => :all do |app|
- app.config.assets.paths.unshift File.join(asset_root, 'integration')
- app.config.assets.paths.unshift File.join(asset_root, 'vendor')
- app.config.assets.precompile << "tinymce/*"
- end
-
- initializer "static assets", :group => :all do |app|
- if app.config.serve_static_assets
- app.config.assets.paths.unshift File.join(asset_root, 'precompiled')
- end
- end
- end
-end
3  lib/tinymce/version.rb
View
@@ -1,3 +0,0 @@
-module TinyMCE
- VERSION = "3.4.8"
-end
22 spec/lib/tinymce_rails_spec.rb
View
@@ -0,0 +1,22 @@
+require 'spec_helper'
+
+describe TinyMCE::Rails do
+ before(:each) do
+ ::Rails.application.config.action_controller.asset_host = nil
+ ActionController::Base.config.relative_url_root = nil
+ end
+
+ it "has a base path" do
+ TinyMCE::Rails.base.should eq("/assets/tinymce")
+ end
+
+ it "uses the asset host in the base path when set" do
+ ::Rails.application.config.action_controller.asset_host = "http://assets.example.com"
+ TinyMCE::Rails.base.should eq("http://assets.example.com/assets/tinymce")
+ end
+
+ it "uses the relative url root in the base path when set" do
+ ActionController::Base.config.relative_url_root = "/subfolder"
+ TinyMCE::Rails.base.should eq("/subfolder/assets/tinymce")
+ end
+end
22 spec/lib/tinymce_spec.rb
View
@@ -1,22 +0,0 @@
-require 'spec_helper'
-
-describe TinyMCE do
- before(:each) do
- Rails.application.config.action_controller.asset_host = nil
- ActionController::Base.config.relative_url_root = nil
- end
-
- it "has a base path" do
- TinyMCE.base.should eq("/assets/tinymce")
- end
-
- it "uses the asset host in the base path when set" do
- Rails.application.config.action_controller.asset_host = "http://assets.example.com"
- TinyMCE.base.should eq("http://assets.example.com/assets/tinymce")
- end
-
- it "uses the relative url root in the base path when set" do
- ActionController::Base.config.relative_url_root = "/subfolder"
- TinyMCE.base.should eq("/subfolder/assets/tinymce")
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.