tiny_mce_helper 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +6 -0
- data/README.rdoc +5 -5
- data/Rakefile +1 -1
- data/install.rb +2 -2
- data/lib/tiny_mce_helper.rb +233 -234
- data/tasks/tiny_mce_helper_tasks.rake +4 -4
- data/test/helpers/tiny_mce_helper_test.rb +187 -0
- data/test/test_helper.rb +10 -1
- data/test/unit/tiny_mce_helper_test.rb +124 -325
- data/uninstall.rb +1 -1
- metadata +12 -9
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
== master
|
2
2
|
|
3
|
+
== 0.2.0 / 2008-12-14
|
4
|
+
|
5
|
+
* Remove the PluginAWeek namespace
|
6
|
+
* Update tests to use mocha
|
7
|
+
* Update tests to use ActionView::TestCase
|
8
|
+
|
3
9
|
== 0.1.1 / 2008-10-19
|
4
10
|
|
5
11
|
* Fix TinyMCE temp file getting closed/deleted too soon after being downloaded [Brandon Goodin]
|
data/README.rdoc
CHANGED
@@ -149,13 +149,17 @@ will generate the following javascript:
|
|
149
149
|
'content_css' : '/stylesheets/tiny_mce_content.css'
|
150
150
|
});
|
151
151
|
|
152
|
-
To see additional initialization helpers, see the API for
|
152
|
+
To see additional initialization helpers, see the API for TinyMCEHelper
|
153
153
|
|
154
154
|
== Testing
|
155
155
|
|
156
156
|
Before you can run any tests, the following gem must be installed:
|
157
157
|
* plugin_test_helper[http://github.com/pluginaweek/plugin_test_helper]
|
158
158
|
|
159
|
+
To run against a specific version of Rails:
|
160
|
+
|
161
|
+
rake test RAILS_FRAMEWORK_ROOT=/path/to/rails
|
162
|
+
|
159
163
|
Since the rake tasks for installing TinyMCE and updating the configuration
|
160
164
|
options are part of the unit tests, already-downloaded files are included with
|
161
165
|
the plugin. If you want to perform a "live" test which actually downloads the
|
@@ -164,10 +168,6 @@ the LIVE environment variable to true. For example,
|
|
164
168
|
|
165
169
|
rake test LIVE=true
|
166
170
|
|
167
|
-
To run against a specific version of Rails:
|
168
|
-
|
169
|
-
rake test RAILS_FRAMEWORK_ROOT=/path/to/rails
|
170
|
-
|
171
171
|
== Dependencies
|
172
172
|
|
173
173
|
* Rails 2.0 or later
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/contrib/sshpublisher'
|
|
5
5
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = 'tiny_mce_helper'
|
8
|
-
s.version = '0.
|
8
|
+
s.version = '0.2.0'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.summary = 'Adds helper methods for creating the TinyMCE initialization script.'
|
11
11
|
|
data/install.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Install TinyMCE
|
2
2
|
puts 'Installing TinyMCE...'
|
3
|
-
|
3
|
+
TinyMCEHelper.install(:version => ENV['VERSION'], :target => ENV['TARGET'])
|
4
4
|
|
5
5
|
# Update the configuration options
|
6
6
|
puts 'Updating TinyMCE configuration options...'
|
7
|
-
|
7
|
+
TinyMCEHelper.update_options
|
data/lib/tiny_mce_helper.rb
CHANGED
@@ -1,264 +1,263 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
print "Invalid option. Overwrite #{target_path}? (y/n): "
|
70
|
-
end
|
71
|
-
return if option == 'n'
|
72
|
-
end
|
73
|
-
|
74
|
-
# Get the url of the TinyMCE version
|
75
|
-
require 'hpricot'
|
76
|
-
require 'open-uri'
|
77
|
-
|
78
|
-
puts "Finding url of TinyMCE-#{version || 'latest'} download..." if verbose
|
79
|
-
doc = Hpricot(open('http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430'))
|
80
|
-
if version
|
81
|
-
url_version = version.gsub('.', '_')
|
82
|
-
file_element = (doc/'tr[@id*="rel0_"] a').detect {|file| file.innerHTML =~ /#{url_version}.zip$/}
|
83
|
-
raise ArgumentError, "Could not find TinyMCE version #{version}" if !file_element
|
84
|
-
else
|
85
|
-
file_element = (doc/'tr[@id^="pkg0_1rel0_"] a').detect {|file| file.innerHTML.to_s =~ /tinymce_([\d_]+).zip$/}
|
86
|
-
raise ArgumentError, 'Could not find latest TinyMCE version' if !file_element
|
87
|
-
|
88
|
-
version = $1.gsub('_', '.')
|
1
|
+
# Adds helper methods for generating the TinyMCE initialization script
|
2
|
+
# within your views
|
3
|
+
module TinyMCEHelper
|
4
|
+
# The path to the file which contains all valid options that can be used
|
5
|
+
# to configure TinyMCE
|
6
|
+
OPTIONS_FILE_PATH = "#{Rails.root}/config/tiny_mce_options.yml"
|
7
|
+
|
8
|
+
# A regular expression matching options that are dynamic (i.e. they can
|
9
|
+
# vary on an integer or string basis)
|
10
|
+
DYNAMIC_OPTIONS = /theme_advanced_buttons|theme_advanced_container/
|
11
|
+
|
12
|
+
# Whether or not to use verbose output
|
13
|
+
mattr_accessor :verbose
|
14
|
+
@@verbose = true
|
15
|
+
|
16
|
+
# A list of all valid options that can be used to configure TinyMCE
|
17
|
+
mattr_accessor :valid_options
|
18
|
+
@@valid_options = File.exists?(OPTIONS_FILE_PATH) ? File.open(OPTIONS_FILE_PATH) {|f| YAML.load(f.read)} : []
|
19
|
+
|
20
|
+
class << self
|
21
|
+
# Installs TinyMCE by downloading it and adding it to your application's
|
22
|
+
# javascripts folder.
|
23
|
+
#
|
24
|
+
# Configuration options:
|
25
|
+
# * +version+ - The version of TinyMCE to install. Default is the latest version.
|
26
|
+
# * +target+ - The path to install TinyMCE to, relative to the project root. Default is "public/javascripts/tiny_mce"
|
27
|
+
# * +force+ - Whether to install TinyMCE, regardless of whether it already exists on the filesystem.
|
28
|
+
#
|
29
|
+
# == Versions
|
30
|
+
#
|
31
|
+
# By default, this will install the latest version of TinyMCE. You can
|
32
|
+
# install a specific version of TinyMCE (if you are using an old API) by
|
33
|
+
# passing in the version number.
|
34
|
+
#
|
35
|
+
# For example,
|
36
|
+
# TinyMCEHelper.install # Installs the latest version
|
37
|
+
# TinyMCEHelper.install(:version => '2.0.8') # Installs version 2.0.8
|
38
|
+
#
|
39
|
+
# An exception will be raised if the specified version cannot be found.
|
40
|
+
#
|
41
|
+
# == Target path
|
42
|
+
#
|
43
|
+
# By default, this will install TinyMCE into Rails.root/public/javascripts/tiny_mce.
|
44
|
+
# If you want to install it to a different directory, you can pass in a
|
45
|
+
# parameter with the relative path from Rails.root.
|
46
|
+
#
|
47
|
+
# For example,
|
48
|
+
# TinyMCEHelper.install(:target => 'public/javascripts/richtext')
|
49
|
+
#
|
50
|
+
# == Conflicting paths
|
51
|
+
#
|
52
|
+
# If TinyMCE is found to already be installed on the filesystem, a prompt
|
53
|
+
# will be displayed for whether to overwrite the existing directory. This
|
54
|
+
# prompt can be automatically skipped by passing in the :force option.
|
55
|
+
def install(options = {})
|
56
|
+
options.assert_valid_keys(:version, :target, :force)
|
57
|
+
options.reverse_merge!(:force => false)
|
58
|
+
|
59
|
+
version = options[:version]
|
60
|
+
base_target = options[:target] || 'public/javascripts/tiny_mce'
|
61
|
+
source_path = 'tinymce'
|
62
|
+
target_path = File.expand_path(File.join(Rails.root, base_target))
|
63
|
+
|
64
|
+
# If TinyMCE is already installed, make sure the user wants to continue
|
65
|
+
if !options[:force] && File.exists?(target_path)
|
66
|
+
print "TinyMCE already installed in #{target_path}. Overwrite? (y/n): "
|
67
|
+
while !%w(y n).include?(option = STDIN.gets.chop)
|
68
|
+
print "Invalid option. Overwrite #{target_path}? (y/n): "
|
89
69
|
end
|
90
70
|
|
91
|
-
|
92
|
-
file_url = file_element['href']
|
93
|
-
|
94
|
-
# Download the file
|
95
|
-
puts "Downloading TinyMCE-#{version} source from #{file_url}..." if verbose
|
96
|
-
open(file_url) do |file|
|
97
|
-
file_path = file.path
|
98
|
-
|
99
|
-
# Extract and install
|
100
|
-
puts "Extracting source from #{file_path}..." if verbose
|
101
|
-
|
102
|
-
require 'zip/zip'
|
103
|
-
require 'zip/zipfilesystem'
|
104
|
-
|
105
|
-
Zip::ZipFile.open(file_path) do |zipfile|
|
106
|
-
zipfile.entries.each do |entry|
|
107
|
-
if match = /tinymce\/jscripts\/tiny_mce\/(.*)/.match(entry.name)
|
108
|
-
FileUtils.mkdir_p("#{target_path}/#{File.dirname(match[1])}")
|
109
|
-
entry.extract("#{target_path}/#{match[1]}") { true }
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
puts 'Done!' if verbose
|
115
|
-
end
|
71
|
+
return if option == 'n'
|
116
72
|
end
|
117
73
|
|
118
|
-
#
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
74
|
+
# Get the url of the TinyMCE version
|
75
|
+
require 'hpricot'
|
76
|
+
require 'open-uri'
|
77
|
+
|
78
|
+
puts "Finding url of TinyMCE-#{version || 'latest'} download..." if verbose
|
79
|
+
doc = Hpricot(open('http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430'))
|
80
|
+
if version
|
81
|
+
url_version = version.gsub('.', '_')
|
82
|
+
file_element = (doc/'tr[@id*="rel0_"] a').detect {|file| file.innerHTML =~ /#{url_version}.zip$/}
|
83
|
+
raise ArgumentError, "Could not find TinyMCE version #{version}" if !file_element
|
84
|
+
else
|
85
|
+
file_element = (doc/'tr[@id^="pkg0_1rel0_"] a').detect {|file| file.innerHTML.to_s =~ /tinymce_([\d_]+).zip$/}
|
86
|
+
raise ArgumentError, 'Could not find latest TinyMCE version' if !file_element
|
125
87
|
|
126
|
-
|
127
|
-
FileUtils.rm_rf(options[:target] || "#{Rails.root}/public/javascripts/tiny_mce")
|
88
|
+
version = $1.gsub('_', '.')
|
128
89
|
end
|
129
90
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
#
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
91
|
+
filename = file_element.innerHTML
|
92
|
+
file_url = file_element['href']
|
93
|
+
|
94
|
+
# Download the file
|
95
|
+
puts "Downloading TinyMCE-#{version} source from #{file_url}..." if verbose
|
96
|
+
open(file_url) do |file|
|
97
|
+
file_path = file.path
|
98
|
+
|
99
|
+
# Extract and install
|
100
|
+
puts "Extracting source from #{file_path}..." if verbose
|
139
101
|
|
140
|
-
|
141
|
-
|
142
|
-
options = (doc/'a[@title*="Configuration/"]/').collect {|option| option.to_s}.sort
|
143
|
-
options.reject! {|option| option =~ DYNAMIC_OPTIONS}
|
102
|
+
require 'zip/zip'
|
103
|
+
require 'zip/zipfilesystem'
|
144
104
|
|
145
|
-
|
146
|
-
|
105
|
+
Zip::ZipFile.open(file_path) do |zipfile|
|
106
|
+
zipfile.entries.each do |entry|
|
107
|
+
if match = /tinymce\/jscripts\/tiny_mce\/(.*)/.match(entry.name)
|
108
|
+
FileUtils.mkdir_p("#{target_path}/#{File.dirname(match[1])}")
|
109
|
+
entry.extract("#{target_path}/#{match[1]}") { true }
|
110
|
+
end
|
111
|
+
end
|
147
112
|
end
|
113
|
+
|
148
114
|
puts 'Done!' if verbose
|
149
115
|
end
|
150
116
|
end
|
151
117
|
|
152
|
-
#
|
153
|
-
def using_tiny_mce?
|
154
|
-
@uses_tiny_mce
|
155
|
-
end
|
156
|
-
|
157
|
-
# Create the TinyMCE initialization scripts. The default configuration
|
158
|
-
# is for a simple theme that replaces all textareas on the page. For
|
159
|
-
# example, the default initialization script will generate the following:
|
160
|
-
#
|
161
|
-
# tinyMCE.init({
|
162
|
-
# 'mode' : 'textareas',
|
163
|
-
# 'theme' : 'simple'
|
164
|
-
# });
|
165
|
-
#
|
166
|
-
# == Customizing initialization options
|
167
|
-
#
|
168
|
-
# To customize the options to be included in the initialization script,
|
169
|
-
# you can pass in a hash to +tiny_mce_init_script+. For example,
|
170
|
-
#
|
171
|
-
# tiny_mce_init_script(
|
172
|
-
# :theme => 'advanced',
|
173
|
-
# :editor_selector => 'rich_text',
|
174
|
-
# :content_css => '/stylesheets/tiny_mce_content.css',
|
175
|
-
# :editor_css => '/stylesheets/tiny_mce_editor.css',
|
176
|
-
# :auto_reset_designmode => true
|
177
|
-
# )
|
178
|
-
#
|
179
|
-
# will generate:
|
118
|
+
# Uninstalls the TinyMCE installation and optional configuration file
|
180
119
|
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
# });
|
187
|
-
#
|
188
|
-
# == Validating options
|
189
|
-
#
|
190
|
-
# If additional options are passed in to initialize TinyMCE, they will be
|
191
|
-
# validated against the list of valid options in PluginAWeek::TinyMCEHelper#valid_options.
|
192
|
-
# These options are configured in the file config/tiny_mce_options.yml.
|
193
|
-
# You can generate this file by invoke the rake task tiny_mce:update_options.
|
194
|
-
def tiny_mce_init_script(options = @tiny_mce_options)
|
195
|
-
options ||= {}
|
196
|
-
options.stringify_keys!.reverse_merge!(
|
197
|
-
'mode' => 'textareas',
|
198
|
-
'theme' => 'simple'
|
199
|
-
)
|
120
|
+
# Configuration options:
|
121
|
+
# * +target+ - The path that TinyMCE was installed to. Default is "public/javascripts/tiny_mce"
|
122
|
+
def uninstall(options = {})
|
123
|
+
# Remove the TinyMCE configuration file
|
124
|
+
File.delete(OPTIONS_FILE_PATH)
|
200
125
|
|
201
|
-
#
|
202
|
-
|
203
|
-
|
204
|
-
|
126
|
+
# Remove the TinyMCE installation
|
127
|
+
FileUtils.rm_rf(options[:target] || "#{Rails.root}/public/javascripts/tiny_mce")
|
128
|
+
end
|
129
|
+
|
130
|
+
# Updates the list of possible configuration options that can be used
|
131
|
+
# when initializing the TinyMCE script. These are always installed to
|
132
|
+
# the application folder, config/tiny_mce_options.yml. If this file
|
133
|
+
# does not exist, then the TinyMCE helper will not be able to verify
|
134
|
+
# that all of the initialization options are valid.
|
135
|
+
def update_options
|
136
|
+
require 'hpricot'
|
137
|
+
require 'open-uri'
|
138
|
+
require 'yaml'
|
205
139
|
|
206
|
-
|
140
|
+
puts 'Downloading configuration options from TinyMCE Wiki...' if verbose
|
141
|
+
doc = Hpricot(open('http://wiki.moxiecode.com/index.php/TinyMCE:Configuration'))
|
142
|
+
options = (doc/'a[@title*="Configuration/"]/').collect {|option| option.to_s}.sort
|
143
|
+
options.reject! {|option| option =~ DYNAMIC_OPTIONS}
|
207
144
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
case value
|
212
|
-
when String, Symbol, Fixnum
|
213
|
-
init_script << "'#{value}'"
|
214
|
-
when Array
|
215
|
-
init_script << "'#{value.join(',')}'"
|
216
|
-
when TrueClass
|
217
|
-
init_script << 'true'
|
218
|
-
when FalseClass
|
219
|
-
init_script << 'false'
|
220
|
-
else
|
221
|
-
raise ArgumentError, "Cannot parse value of type #{value.class} passed for TinyMCE option #{key}"
|
222
|
-
end
|
223
|
-
|
224
|
-
init_script << ','
|
145
|
+
File.open(OPTIONS_FILE_PATH, 'w') do |out|
|
146
|
+
YAML.dump(options, out)
|
225
147
|
end
|
226
|
-
|
227
|
-
init_script.chop << "\n});"
|
148
|
+
puts 'Done!' if verbose
|
228
149
|
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Is TinyMCE being used?
|
153
|
+
def using_tiny_mce?
|
154
|
+
@uses_tiny_mce
|
155
|
+
end
|
156
|
+
|
157
|
+
# Create the TinyMCE initialization scripts. The default configuration
|
158
|
+
# is for a simple theme that replaces all textareas on the page. For
|
159
|
+
# example, the default initialization script will generate the following:
|
160
|
+
#
|
161
|
+
# tinyMCE.init({
|
162
|
+
# 'mode' : 'textareas',
|
163
|
+
# 'theme' : 'simple'
|
164
|
+
# });
|
165
|
+
#
|
166
|
+
# == Customizing initialization options
|
167
|
+
#
|
168
|
+
# To customize the options to be included in the initialization script,
|
169
|
+
# you can pass in a hash to +tiny_mce_init_script+. For example,
|
170
|
+
#
|
171
|
+
# tiny_mce_init_script(
|
172
|
+
# :theme => 'advanced',
|
173
|
+
# :editor_selector => 'rich_text',
|
174
|
+
# :content_css => '/stylesheets/tiny_mce_content.css',
|
175
|
+
# :editor_css => '/stylesheets/tiny_mce_editor.css',
|
176
|
+
# :auto_reset_designmode => true
|
177
|
+
# )
|
178
|
+
#
|
179
|
+
# will generate:
|
180
|
+
#
|
181
|
+
# tinyMCE.init({
|
182
|
+
# 'mode' : 'textareas',
|
183
|
+
# 'theme' : 'advanced',
|
184
|
+
# 'editor_selected' : 'rich_text',
|
185
|
+
# 'content_css' : '/stylesheets/tiny_mce_content.css'
|
186
|
+
# });
|
187
|
+
#
|
188
|
+
# == Validating options
|
189
|
+
#
|
190
|
+
# If additional options are passed in to initialize TinyMCE, they will be
|
191
|
+
# validated against the list of valid options in TinyMCEHelper#valid_options.
|
192
|
+
# These options are configured in the file config/tiny_mce_options.yml.
|
193
|
+
# You can generate this file by invoke the rake task tiny_mce:update_options.
|
194
|
+
def tiny_mce_init_script(options = @tiny_mce_options)
|
195
|
+
options ||= {}
|
196
|
+
options.stringify_keys!.reverse_merge!(
|
197
|
+
'mode' => 'textareas',
|
198
|
+
'theme' => 'simple'
|
199
|
+
)
|
229
200
|
|
230
|
-
#
|
231
|
-
|
232
|
-
|
233
|
-
|
201
|
+
# Check validity
|
202
|
+
plugins = options['plugins']
|
203
|
+
options_to_validate = options.reject {|option, value| plugins && plugins.include?(option.split('_')[0]) || option =~ DYNAMIC_OPTIONS}
|
204
|
+
options_to_validate.assert_valid_keys(@@valid_options) if @@valid_options && @@valid_options.any?
|
234
205
|
|
235
|
-
|
236
|
-
# will use the source (uncompressed) file in order to help with debugging
|
237
|
-
# issues that occur within TinyMCE. In production, the compressed version
|
238
|
-
# of TinyMCE will be used in order to increased download speed.
|
239
|
-
def tiny_mce_file_name
|
240
|
-
Rails.env == 'development' ? 'tiny_mce/tiny_mce_src' : 'tiny_mce/tiny_mce'
|
241
|
-
end
|
206
|
+
init_script = 'tinyMCE.init({'
|
242
207
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
208
|
+
options.sort.each do |key, value|
|
209
|
+
init_script += "\n#{key} : "
|
210
|
+
|
211
|
+
case value
|
212
|
+
when String, Symbol, Fixnum
|
213
|
+
init_script << "'#{value}'"
|
214
|
+
when Array
|
215
|
+
init_script << "'#{value.join(',')}'"
|
216
|
+
when TrueClass
|
217
|
+
init_script << 'true'
|
218
|
+
when FalseClass
|
219
|
+
init_script << 'false'
|
220
|
+
else
|
221
|
+
raise ArgumentError, "Cannot parse value of type #{value.class} passed for TinyMCE option #{key}"
|
222
|
+
end
|
223
|
+
|
224
|
+
init_script << ','
|
252
225
|
end
|
253
226
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
227
|
+
init_script.chop << "\n});"
|
228
|
+
end
|
229
|
+
|
230
|
+
# Generate the TinyMCE. Any arguments will be passed to tiny_mce_init_script.
|
231
|
+
def tiny_mce(*args)
|
232
|
+
javascript_tag tiny_mce_init_script(*args)
|
233
|
+
end
|
234
|
+
|
235
|
+
# The name of the TinyMCE javascript file to use. In development, this
|
236
|
+
# will use the source (uncompressed) file in order to help with debugging
|
237
|
+
# issues that occur within TinyMCE. In production, the compressed version
|
238
|
+
# of TinyMCE will be used in order to increased download speed.
|
239
|
+
def tiny_mce_file_name
|
240
|
+
Rails.env == 'development' ? 'tiny_mce/tiny_mce_src' : 'tiny_mce/tiny_mce'
|
241
|
+
end
|
242
|
+
|
243
|
+
# Generates the javascript include for TinyMCE. For example,
|
244
|
+
#
|
245
|
+
# javascript_include_tiny_mce
|
246
|
+
#
|
247
|
+
# will generate:
|
248
|
+
#
|
249
|
+
# <script type="text/javascript" src="/javascripts/tiny_mce/tiny_mce.js"></script>
|
250
|
+
def javascript_include_tiny_mce
|
251
|
+
javascript_include_tag tiny_mce_file_name
|
252
|
+
end
|
253
|
+
|
254
|
+
# Conditionally includes the TinyMCE javascript file if the variable
|
255
|
+
# @uses_tiny_mce has been set to true.
|
256
|
+
def javascript_include_tiny_mce_if_used
|
257
|
+
javascript_include_tiny_mce if using_tiny_mce?
|
259
258
|
end
|
260
259
|
end
|
261
260
|
|
262
261
|
ActionController::Base.class_eval do
|
263
|
-
helper
|
262
|
+
helper TinyMCEHelper
|
264
263
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
namespace :tiny_mce do
|
2
2
|
desc 'Downloads TinyMCE and installs it in the application. Target specific version with VERSION=x, specific target path with TARGET=y'
|
3
3
|
task :install => :environment do
|
4
|
-
|
4
|
+
TinyMCEHelper.install(:version => ENV['VERSION'], :target => ENV['TARGET'])
|
5
5
|
end
|
6
6
|
|
7
7
|
desc 'Downloads TinyMCE and installs it in the application. Target specific version with VERSION=x, specific target path with TARGET=y'
|
8
8
|
task :update => :environment do
|
9
|
-
|
9
|
+
TinyMCEHelper.install(:version => ENV['VERSION'], :target => ENV['TARGET'], :force => true)
|
10
10
|
end
|
11
11
|
|
12
12
|
desc 'Uninstalls TinyMCE and removes any associated configuration files.'
|
13
13
|
task :uninstall => :environment do
|
14
|
-
|
14
|
+
TinyMCEHelper.uninstall(:target => ENV['TARGET'])
|
15
15
|
end
|
16
16
|
|
17
17
|
desc 'Updates the list of TinyMCE options and stores them in config/tiny_mce_options.yml.'
|
18
18
|
task :update_options => :environment do
|
19
|
-
|
19
|
+
TinyMCEHelper.update_options
|
20
20
|
end
|
21
21
|
end
|