tinymce-rails 3.5.8 → 3.5.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -0
- data/app/assets/javascripts/tinymce/preinit.js.erb +1 -1
- data/lib/tasks/tinymce-assets.rake +9 -5
- data/lib/tinymce/rails.rb +4 -0
- data/lib/tinymce/rails/asset_installer.rb +66 -0
- data/lib/tinymce/rails/asset_manifest.rb +122 -0
- data/lib/tinymce/rails/engine.rb +8 -0
- data/lib/tinymce/rails/helper.rb +3 -0
- data/lib/tinymce/rails/version.rb +1 -1
- metadata +4 -3
data/Rakefile
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
Rake::Task
|
2
|
-
assets = File.expand_path(File.dirname(__FILE__) + "/../../vendor/assets/javascripts/tinymce")
|
3
|
-
target = File.join(Rails.public_path, Rails.application.config.assets.prefix)
|
1
|
+
assets_task = Rake::Task.task_defined?('assets:precompile:primary') ? 'assets:precompile:primary' : 'assets:precompile'
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
Rake::Task[assets_task].enhance do
|
4
|
+
require "tinymce/rails/asset_installer"
|
5
|
+
|
6
|
+
config = Rails.application.config
|
7
|
+
target = File.join(Rails.public_path, config.assets.prefix)
|
8
|
+
manifest = config.assets.manifest
|
9
|
+
|
10
|
+
TinyMCE::Rails::AssetInstaller.new(target, manifest).install
|
7
11
|
end
|
data/lib/tinymce/rails.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
require "tinymce/rails/asset_manifest"
|
2
|
+
|
3
|
+
module TinyMCE
|
4
|
+
module Rails
|
5
|
+
class AssetInstaller
|
6
|
+
ASSETS = Pathname.new(File.expand_path(File.dirname(__FILE__) + "/../../../vendor/assets/javascripts/tinymce"))
|
7
|
+
|
8
|
+
def initialize(target, manifest_path)
|
9
|
+
@target = target
|
10
|
+
@manifest_path = manifest_path || target
|
11
|
+
end
|
12
|
+
|
13
|
+
def install
|
14
|
+
cleanup_assets
|
15
|
+
copy_assets
|
16
|
+
append_to_manifest
|
17
|
+
|
18
|
+
manifest.write
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def manifest
|
23
|
+
@manifest ||= AssetManifest.load(@manifest_path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def cleanup_assets
|
27
|
+
manifest.each(/^tinymce\//) do |asset|
|
28
|
+
manifest.remove(asset) if index_asset?(asset)
|
29
|
+
|
30
|
+
manifest.remove_digest(asset) do |src, dest|
|
31
|
+
move_asset(src, dest)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def copy_assets
|
37
|
+
FileUtils.cp_r(ASSETS, @target, :preserve => true)
|
38
|
+
end
|
39
|
+
|
40
|
+
def append_to_manifest
|
41
|
+
asset_files.each do |file|
|
42
|
+
manifest.append(logical_path(file), file)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def asset_files
|
47
|
+
Pathname.glob("#{ASSETS}/**/*").select(&:file?)
|
48
|
+
end
|
49
|
+
|
50
|
+
def logical_path(file)
|
51
|
+
file.relative_path_from(ASSETS.parent).to_s
|
52
|
+
end
|
53
|
+
|
54
|
+
def move_asset(src, dest)
|
55
|
+
src = File.join(@target, src)
|
56
|
+
dest = File.join(@target, dest)
|
57
|
+
|
58
|
+
FileUtils.mv(src, dest, :force => true) if src != dest && File.exists?(src)
|
59
|
+
end
|
60
|
+
|
61
|
+
def index_asset?(asset)
|
62
|
+
asset =~ /\/index\.js$/
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require "multi_json"
|
2
|
+
|
3
|
+
module TinyMCE
|
4
|
+
module Rails
|
5
|
+
class AssetManifest
|
6
|
+
def self.load(manifest_path)
|
7
|
+
YamlManifest.try(manifest_path) ||
|
8
|
+
JsonManifest.try(manifest_path) ||
|
9
|
+
NullManifest.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class YamlManifest
|
15
|
+
def self.try(manifest_path)
|
16
|
+
yaml_file = File.join(manifest_path, "manifest.yml")
|
17
|
+
new(yaml_file) if File.exists?(yaml_file)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(file)
|
21
|
+
@file = file
|
22
|
+
@manifest = YAML.load_file(file)
|
23
|
+
end
|
24
|
+
|
25
|
+
def append(logical_path, file)
|
26
|
+
@manifest[logical_path] = logical_path
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove(logical_path)
|
30
|
+
@manifest.delete(logical_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def remove_digest(logical_path)
|
34
|
+
if digested = @manifest[logical_path]
|
35
|
+
@manifest[logical_path] = logical_path
|
36
|
+
yield digested, logical_path if block_given?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def each(pattern)
|
41
|
+
@manifest.each_key do |asset|
|
42
|
+
yield asset if asset =~ pattern
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_s
|
47
|
+
dump
|
48
|
+
end
|
49
|
+
|
50
|
+
def dump(io=nil)
|
51
|
+
YAML.dump(@manifest, io)
|
52
|
+
end
|
53
|
+
|
54
|
+
def write
|
55
|
+
File.open(@file, "wb") { |f| dump(f) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class JsonManifest
|
60
|
+
def self.try(manifest_path)
|
61
|
+
paths = Dir[File.join(manifest_path, "manifest*.json")]
|
62
|
+
new(paths.first) if paths.any?
|
63
|
+
end
|
64
|
+
|
65
|
+
def initialize(file)
|
66
|
+
@file = file
|
67
|
+
@manifest = MultiJson.load(File.read(file))
|
68
|
+
end
|
69
|
+
|
70
|
+
def append(logical_path, file)
|
71
|
+
stat = File.stat(file)
|
72
|
+
|
73
|
+
@manifest["assets"][logical_path] = logical_path
|
74
|
+
@manifest["files"][logical_path] = {
|
75
|
+
"logical_path" => logical_path,
|
76
|
+
"mtime" => stat.mtime.iso8601,
|
77
|
+
"size" => stat.size,
|
78
|
+
"digest" => nil
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
def remove(logical_path)
|
83
|
+
if digested = @manifest["assets"].delete(logical_path)
|
84
|
+
@manifest["files"].delete(digested)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def remove_digest(logical_path)
|
89
|
+
if digested = @manifest["assets"][logical_path]
|
90
|
+
@manifest["assets"][logical_path] = logical_path
|
91
|
+
@manifest["files"][logical_path] = @manifest["files"].delete(digested).tap { |f| f["digest"] = nil }
|
92
|
+
yield digested, logical_path if block_given?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def each(pattern)
|
97
|
+
@manifest["assets"].each_key do |asset|
|
98
|
+
yield asset if asset =~ pattern
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def to_s
|
103
|
+
dump
|
104
|
+
end
|
105
|
+
|
106
|
+
def dump
|
107
|
+
MultiJson.dump(@manifest)
|
108
|
+
end
|
109
|
+
|
110
|
+
def write
|
111
|
+
File.open(@file, "wb") { |f| f.write(dump) }
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class NullManifest
|
116
|
+
def append(*); end
|
117
|
+
def remove(*); end
|
118
|
+
def remove_digest(*); end
|
119
|
+
def each(*); end
|
120
|
+
def write; end
|
121
|
+
end
|
122
|
+
end
|
data/lib/tinymce/rails/engine.rb
CHANGED
@@ -14,5 +14,13 @@ module TinyMCE::Rails
|
|
14
14
|
include Helper
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
def self.base
|
19
|
+
config.tinymce.base || default_base
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.default_base
|
23
|
+
File.join(Rails.application.config.relative_url_root || "", Rails.application.config.assets.prefix || "/", "tinymce")
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
data/lib/tinymce/rails/helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/core_ext/hash/keys'
|
2
|
+
|
1
3
|
module TinyMCE::Rails
|
2
4
|
module Helper
|
3
5
|
# Initializes TinyMCE on the current page based on the global configuration.
|
@@ -20,6 +22,7 @@ module TinyMCE::Rails
|
|
20
22
|
# Returns the JavaScript code required to initialize TinyMCE.
|
21
23
|
def tinymce_javascript(config=:default, options={})
|
22
24
|
options, config = config, :default if config.is_a?(Hash)
|
25
|
+
options.stringify_keys!
|
23
26
|
|
24
27
|
base_configuration = TinyMCE::Rails.configuration
|
25
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinymce-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.8
|
4
|
+
version: 3.5.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -41,6 +41,8 @@ files:
|
|
41
41
|
- app/assets/javascripts/tinymce-jquery.js
|
42
42
|
- app/assets/javascripts/tinymce.js
|
43
43
|
- lib/tasks/tinymce-assets.rake
|
44
|
+
- lib/tinymce/rails/asset_installer.rb
|
45
|
+
- lib/tinymce/rails/asset_manifest.rb
|
44
46
|
- lib/tinymce/rails/configuration.rb
|
45
47
|
- lib/tinymce/rails/engine.rb
|
46
48
|
- lib/tinymce/rails/helper.rb
|
@@ -331,4 +333,3 @@ signing_key:
|
|
331
333
|
specification_version: 3
|
332
334
|
summary: Rails asset pipeline integration for TinyMCE.
|
333
335
|
test_files: []
|
334
|
-
has_rdoc:
|