use_tinymce 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +51 -8
- data/Rakefile +5 -24
- data/lib/tasks/use_tinymce.rake +45 -18
- data/lib/use_tinymce/use_tinymce.rb +1 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
UseTinyMCE - 0.0.
|
1
|
+
UseTinyMCE - 0.0.11
|
2
2
|
==========
|
3
3
|
|
4
4
|
**UseTinyMCE** is yet another (as if we needed another) hack for including
|
5
5
|
TinyMCE in a Rails 3.0 or 3.1 app.
|
6
6
|
|
7
|
-
**NOTE:** Rails 3.1.0 broke version 0.0.8. The current version
|
7
|
+
**NOTE:** Rails 3.1.0 broke version 0.0.8. The current version has been tested
|
8
|
+
on both Rails 3.1.0 & 3.0.10. All installations work properly.
|
8
9
|
|
9
10
|
It differs from the others that I looked at on rubygems in that:
|
10
11
|
|
@@ -15,13 +16,21 @@ TinyMCE. You just use the config stuff which comes with TinyMCE - in javascript.
|
|
15
16
|
|
16
17
|
## Rails 3.0 & 3.1 Integration
|
17
18
|
|
18
|
-
It's the same in both cases. See [Step By Step](#step_by_step) below
|
19
|
+
It's almost the same in both cases. See [Step By Step](#step_by_step) below.
|
20
|
+
|
21
|
+
**Rails 3.0 Note:** Rails 3.0 defaults to `prototype` for javascript, so `use_tinymce`
|
22
|
+
supports both *raw* TinyMCE (which works well with Prototype) and the *jquery* version,
|
23
|
+
which works with 'jquery'. It also supports both *simple* and *advanced* editor
|
24
|
+
installations for the *raw* type.
|
19
25
|
|
20
26
|
**Rails 3.1 Note:** TinyMCE doesn't play well with the asset pipeline, so it is installed
|
21
27
|
in public. This has to do with the way TinyMCE is architected: it is plugin based
|
22
28
|
and scatters javascript, css, and html all through it's plugin directory. It manages it's
|
23
29
|
own loading.
|
24
30
|
|
31
|
+
Also, **Rails 3.1** defaults to jQuery for javascript, so `use_tinymce` does not support
|
32
|
+
installing the *raw* version of TinyMCE.
|
33
|
+
|
25
34
|
## Selectively adding TinyMCE to selected text areas
|
26
35
|
|
27
36
|
TinyMCE supports selectively using TinyMCE in or not in different textareas within
|
@@ -37,6 +46,9 @@ Or read the TinyMCE code.
|
|
37
46
|
|
38
47
|
1. You will need to install *TinyMCE* in your /public/javascript directory.
|
39
48
|
Do that by running one of these rake tasks:
|
49
|
+
|
50
|
+
Rails 3.0:
|
51
|
+
|
40
52
|
* `rake use_tinymce:install_jquery` - if you are using jQuery (Rails 3.1 default)
|
41
53
|
* `rake use_tinymce:install_simple` - if you are using Prototype (Rails 3.0 default)
|
42
54
|
* `rake use_tinymce:install_advanced` - if you are using Prototype (Rails 3.0 default)
|
@@ -44,10 +56,21 @@ Do that by running one of these rake tasks:
|
|
44
56
|
If you don't need much and aren't familiar with *TinyMCE*, then `rake use_tinymce:install_simple`
|
45
57
|
should be fine. The *advanced* version configures *TinyMCE* with many more features. Go to
|
46
58
|
the ["TinyMCE website for details"](http://tinymce.moxiecode.com/)
|
59
|
+
|
60
|
+
Rails 3.1
|
61
|
+
|
62
|
+
* rake use_tinymce:install - installs the jQuery version of TinyMCE
|
63
|
+
|
64
|
+
This creates an `advanced` editor. See the *TinyMCE* website for configuration information:
|
65
|
+
["TinyMCE website for details"](http://tinymce.moxiecode.com/)
|
66
|
+
|
47
67
|
2. Add `use_tinymce args` to all the controllers for views containing **textarea** fields
|
48
68
|
in which you want to run *TinyMCE*. `args` should be:
|
49
69
|
* `:all` - to enable *TinyMCE* for all actions
|
50
70
|
* `:foo, :bar` - to enable *TinyMCE* only for views rendered by `foo` and `bar` actions
|
71
|
+
[usually this is something like `use_tinymce :new, :edit`].
|
72
|
+
|
73
|
+
**Note:** you should *not* have to 'require use_tinymce` anyplace. If you do, please let me know.
|
51
74
|
3. Add `<%= use_tinymce_link %>` to the `HEAD` section of you application layout - for *at least*
|
52
75
|
all pages which should use *TinyMCE*
|
53
76
|
4. (Optional) Edit `/public/javascript/use_tinymce_init.js` to customize your *TinyMCE* feature
|
@@ -85,7 +108,7 @@ by a previous call to `use_tinymce` [or if you included `use_tinymce :all` in yo
|
|
85
108
|
`action` will usually come from `params[:action]`, so it's easier to use
|
86
109
|
`use_tinymce_link` which already does that.
|
87
110
|
|
88
|
-
##
|
111
|
+
## Rake Tasks:
|
89
112
|
|
90
113
|
**NOTE** `assets` here refers to the `assets` directory in the `use_tinymce`
|
91
114
|
gem - **not** the Rails 3.1 asset pipeline directory.
|
@@ -94,6 +117,8 @@ This initialization scripts were copied literally from the TinyMCE website
|
|
94
117
|
["For Dummies" page](http://tinymce.moxiecode.com/wiki.php/%22For_Dummies%22)
|
95
118
|
- that is: *http://tinymce.moxiecode.com/wiki.php/%22For_Dummies%22*
|
96
119
|
|
120
|
+
### Rails 3.0
|
121
|
+
|
97
122
|
Prototype Versions:
|
98
123
|
|
99
124
|
* `rake use_tinymce:install_advanced` copies `use_tinymce/assets/use_tinymce_init_advanced.js`
|
@@ -116,8 +141,27 @@ Maintenance: if you want to get rid of `use_tinymce`, then:
|
|
116
141
|
* `rake use_tinymce:uninstall` removes use_tinymce_init.js and the TinyMCE
|
117
142
|
directory from your applications `public/javascripts`
|
118
143
|
|
119
|
-
|
120
|
-
|
144
|
+
**Note:** `rake use_tinymce::uninstall` is called automatically when running any
|
145
|
+
`rake use_tinymce::install_*` to insure you get a clean installation. This will also
|
146
|
+
*clean* out any customization you have done.
|
147
|
+
|
148
|
+
### Rails 3.1
|
149
|
+
|
150
|
+
`use_tinymce` only supports installing the jQuery version of TinyMCE on Rails 3.1.
|
151
|
+
|
152
|
+
There are two Rake tasks:
|
153
|
+
|
154
|
+
* rake use_tinymce:install - copies `assets/use_tinymce_init_jquery.js`
|
155
|
+
and the contents of `use_tinymce/tinymce_jquery` -
|
156
|
+
which attaches an 'advanced' TinyMCE configuration to textareas.
|
157
|
+
* `rake use_tinymce:uninstall` removes use_tinymce_init.js and the TinyMCE
|
158
|
+
directory from your applications `public/javascripts`
|
159
|
+
|
160
|
+
**Note:** `rake use_tinymce::uninstall` is called automatically when running
|
161
|
+
`rake use_tinymce::install` to insure you get a clean installation. This will also
|
162
|
+
*clean* out any customization you have done.
|
163
|
+
|
164
|
+
## Relocating *TinyMCE* or Something Else
|
121
165
|
|
122
166
|
This gem is pretty simple, so if you want to change the location and/or names of some files,
|
123
167
|
go ahead and hack it.
|
@@ -127,8 +171,7 @@ turned out to be more trouble than it was worth.
|
|
127
171
|
|
128
172
|
So, if you want to do it, have a blast - but please don't send me the patches.
|
129
173
|
|
130
|
-
Upgrading *TinyMCE*
|
131
|
-
==================
|
174
|
+
## Upgrading *TinyMCE*
|
132
175
|
|
133
176
|
`use_tinymce` ships with version 3.4.2 of *TinyMCE* - which I downloaded from the Moxiecode
|
134
177
|
website. You *should* be able to upgrade your *TinyMCE* if you want by doing the exact
|
data/Rakefile
CHANGED
@@ -13,35 +13,16 @@ task :default => :test
|
|
13
13
|
|
14
14
|
desc "Run use_tinymce unit tests"
|
15
15
|
task :test do
|
16
|
-
require "./test
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "run rdoc to create doc"
|
20
|
-
task :doc do
|
21
|
-
system 'rdoc'
|
16
|
+
require "./test/test_#{gem_name}_base"
|
22
17
|
end
|
23
18
|
|
24
19
|
desc "build gem"
|
25
20
|
task :gem do
|
26
21
|
system "gem build #{gem_name}.gemspec"
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
system 'git add .'
|
32
|
-
system "git commit -m \"checkin version #{gem_version}: ${MSG}\""
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "commit changes and tag as #{gem_version} - add Env Var MSG to add tag message"
|
36
|
-
task :tag => :commit do
|
37
|
-
tag_message = "version #{gem_version}"
|
38
|
-
tag_message += ENV['MSG'] if ENV.keys.include? 'MSG'
|
39
|
-
system "git tag #{gem_version} -m '#{tag_message}'"
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "push to github"
|
43
|
-
task :git_push do
|
44
|
-
system 'git push'
|
22
|
+
if 'mike.local' == IO.popen('hostname').read.chomp
|
23
|
+
system "cp #{gem_name}-#{gem_version}.gem ~/Rails/GemCache/gems/"
|
24
|
+
system "(cd ~/Rails/GemCache ; gem generate_index -d . )"
|
25
|
+
end
|
45
26
|
end
|
46
27
|
|
47
28
|
desc "push to rubygems"
|
data/lib/tasks/use_tinymce.rake
CHANGED
@@ -35,18 +35,27 @@ module UseTinyMCE
|
|
35
35
|
# This MODE_STRING will configure to NOT USE TinyMCE in textareas unless the 'editor_selector'
|
36
36
|
# class is present.
|
37
37
|
# MODE_STRING = [ 'mode: "specific_textareas"', ' editor_selector: "tinymce"' ].join(",\n")
|
38
|
-
JQUERY_SELECTOR = '"textarea.tinymce"'
|
38
|
+
# JQUERY_SELECTOR = '"textarea.tinymce"'
|
39
|
+
JQUERY_SELECTOR = '"textarea"'
|
39
40
|
|
40
41
|
def self.copy_init_script(source)
|
41
42
|
source_path = File.join(ASSETS_ROOT, source)
|
42
43
|
source_text = File.new(source_path).read.sub(/{mode_string}/, MODE_STRING).sub(/{jquery_selector}/, JQUERY_SELECTOR)
|
43
44
|
|
44
45
|
dest_path = File.join(JAVASCRIPT_ROOT, 'use_tinymce_init.js')
|
46
|
+
mkdir_tree(JAVASCRIPT_ROOT)
|
45
47
|
dest_file = File.new(dest_path, "w")
|
46
48
|
dest_file.write(source_text)
|
47
49
|
dest_file.close
|
48
50
|
end
|
49
51
|
|
52
|
+
# returns true if all directories from 'base' on up exist or can be created; else false
|
53
|
+
def self.mkdir_tree(base)
|
54
|
+
return File.directory?(base) if File.exists? base
|
55
|
+
Dir.mkdir(base) if mkdir_tree File.dirname(base)
|
56
|
+
return File.directory? base
|
57
|
+
end
|
58
|
+
|
50
59
|
def self.rmdir_tree(root)
|
51
60
|
Dir.entries(root).each do |fname|
|
52
61
|
if fname[0] == '.'
|
@@ -74,25 +83,43 @@ namespace :use_tinymce do
|
|
74
83
|
tinymce_root_path = File.join(UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT, 'tinymce')
|
75
84
|
UseTinyMCE::RakeSupport::rmdir_tree(tinymce_root_path) if File.exists? tinymce_root_path
|
76
85
|
end
|
77
|
-
task :install_tinymce_advanced => :uninstall do
|
78
|
-
FileUtils.cp_r File.join(UseTinyMCE::RakeSupport::ASSETS_ROOT, 'tinymce_no_jquery', 'tinymce'), UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
79
|
-
end
|
80
|
-
task :install_tinymce_jquery => :uninstall do
|
81
|
-
FileUtils.cp_r File.join(UseTinyMCE::RakeSupport::ASSETS_ROOT, 'tinymce_jquery', 'tinymce'), UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
82
|
-
end
|
83
86
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
87
|
+
case Rails.version
|
88
|
+
when /^3.0/
|
89
|
+
# common task - this undescribed task installs the non-jquery version of TinyMCE, but not the initialization script
|
90
|
+
task :install_tinymce_advanced => :uninstall do
|
91
|
+
raise Exception.new("Cannot install: #{UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT} does not exist") unless UseTinyMCE::RakeSupport.mkdir_tree UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
92
|
+
FileUtils.cp_r File.join(UseTinyMCE::RakeSupport::ASSETS_ROOT, 'tinymce_no_jquery', 'tinymce'), UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
93
|
+
end
|
94
|
+
# common task - this undescribed task installs the jquery version of TinyMCE, but not the initialization script
|
95
|
+
task :install_tinymce_jquery => :uninstall do
|
96
|
+
raise Exception.new("Cannot install: #{UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT} does not exist") unless UseTinyMCE::RakeSupport.mkdir_tree UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
97
|
+
FileUtils.cp_r File.join(UseTinyMCE::RakeSupport::ASSETS_ROOT, 'tinymce_jquery', 'tinymce'), UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
98
|
+
end
|
88
99
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
100
|
+
desc "Install tinymce with 'simple' initialization"
|
101
|
+
task :install_simple => :install_tinymce_advanced do
|
102
|
+
UseTinyMCE::RakeSupport::copy_init_script('use_tinymce_init_simple.js')
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "Install tinymce with 'advanced' initialization"
|
106
|
+
task :install_advanced => :install_tinymce_advanced do
|
107
|
+
UseTinyMCE::RakeSupport::copy_init_script('use_tinymce_init_advanced.js')
|
108
|
+
end
|
93
109
|
|
94
|
-
|
95
|
-
|
96
|
-
|
110
|
+
desc "Install tinymce jquery plugin with 'advanced' initialization"
|
111
|
+
task :install_jquery => :install_tinymce_jquery do
|
112
|
+
UseTinyMCE::RakeSupport::copy_init_script('use_tinymce_init_jquery.js')
|
113
|
+
end
|
114
|
+
when /^3.1/
|
115
|
+
desc "Install tinymce jquery plugin with 'advanced' initialization"
|
116
|
+
task :install => :uninstall do
|
117
|
+
raise Exception.new("Cannot install: #{UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT} does not exist") unless UseTinyMCE::RakeSupport.mkdir_tree UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
118
|
+
FileUtils.cp_r File.join(UseTinyMCE::RakeSupport::ASSETS_ROOT, 'tinymce_jquery', 'tinymce'), UseTinyMCE::RakeSupport::JAVASCRIPT_ROOT
|
119
|
+
UseTinyMCE::RakeSupport::copy_init_script('use_tinymce_init_jquery.js')
|
120
|
+
end
|
121
|
+
else
|
122
|
+
puts "Don't know how to install in Rails #{Rails.version}"
|
123
|
+
exit 1
|
97
124
|
end
|
98
125
|
end
|
@@ -30,7 +30,7 @@ module UseTinymce
|
|
30
30
|
if defined?(params) && use_tinymce?(params[:action])
|
31
31
|
jq_path = File.join(Rails.root, 'public', 'javascripts', 'tinymce', 'jscripts', 'tiny_mce', 'jquery.tinymce.js')
|
32
32
|
if File.exists? jq_path
|
33
|
-
javascript_include_tag( '/javascripts/tinymce/jscripts/tiny_mce/jquery.tinymce', '/javascripts/use_tinymce_init' )
|
33
|
+
javascript_include_tag( '/javascripts/tinymce/jscripts/tiny_mce/jquery.tinymce.js', '/javascripts/use_tinymce_init' )
|
34
34
|
else
|
35
35
|
javascript_include_tag( '/javascripts/tinymce/jscripts/tiny_mce/tiny_mce', '/javascripts/use_tinymce_init' )
|
36
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: use_tinymce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
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: 2011-09-
|
12
|
+
date: 2011-09-13 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'UseTinymce - Yet Another tinyMCE integrations gem for Rails 3
|
15
15
|
|