Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Refining configuration options from YAML code, adding content to defa…

…ult config file, and adding changelog entry.
  • Loading branch information...
commit 944b21ba5f0d4e098857c3e211199dd50ca168de 1 parent 604556f
authored January 09, 2010
1  CHANGELOG_PLUGIN.rdoc
Source Rendered
@@ -4,6 +4,7 @@
4 4
 * Upgraded TinyMCE from 3.2.6 to 3.2.7 (see CHANGELOG_TINYMCE) (Sergio Cambra)
5 5
 * Further compatibility fixes for Rails versions prior to 2.3.x
6 6
 * Improving the installation instructions for plugin installs
  7
+* Ability to specify default TinyMCE options in config/tiny_mce.yml (Marty Zalega)
7 8
 
8 9
 == Version 0.1.0
9 10
 * tiny_mce is now available as a gem on github under kete-tiny_mce. See README.rdoc (Alexander Semyonov)
5  install.rb
@@ -16,8 +16,3 @@
16 16
 
17 17
 -------
18 18
 EOS
19  
-
20  
-filepath = File.join(RAILS_ROOT, 'config', 'tiny_mce.yml')
21  
-unless File.exists?(filepath)
22  
-  File.open(filepath, 'w') { |f| f.write '' }
23  
-end
15  lib/tiny_mce.rb
@@ -44,6 +44,21 @@ def self.install_or_update_tinymce
44 44
         end
45 45
       end
46 46
     end
  47
+
  48
+    tiny_mce_yaml_filepath = File.join(RAILS_ROOT, 'config', 'tiny_mce.yml')
  49
+    unless File.exists?(tiny_mce_yaml_filepath)
  50
+      File.open(tiny_mce_yaml_filepath, 'w') do |f|
  51
+        f.write <<-EOS
  52
+        # Here you can specify default options for TinyMCE across all controllers
  53
+        #
  54
+        # theme: advanced
  55
+        # plugins:
  56
+        #  - table
  57
+        #  - fullscreen
  58
+        EOS
  59
+      end
  60
+      puts "Written configuration example to #{tiny_mce_yaml_filepath}"
  61
+    end
47 62
   end
48 63
 
49 64
   module Base
13  lib/tiny_mce/base.rb
@@ -11,12 +11,17 @@ module ClassMethods
11 11
       # Takes options hash, raw_options string, and any normal params you
12 12
       # can send to a before_filter (only, except etc)
13 13
       def uses_tiny_mce(options = {})
14  
-        filepath = File.join(RAILS_ROOT, 'config', 'tiny_mce.yml')
15  
-        config = begin YAML::load(IO.read(filepath)) rescue {} end
16  
-
17  
-        tiny_mce_options = (options.delete(:options) || {}).reverse_merge config
  14
+        tiny_mce_options = options.delete(:options) || {}
18 15
         raw_tiny_mce_options = options.delete(:raw_options) || ''
19 16
 
  17
+        # Allow users to have default options in config/tiny_mce.yml so that
  18
+        # they do not need to specify the same options over all controllers
  19
+        tiny_mce_yaml_filepath = File.join(RAILS_ROOT, 'config', 'tiny_mce.yml')
  20
+        if File.exist?(tiny_mce_yaml_filepath)
  21
+          yaml_options = YAML::load(IO.read(tiny_mce_yaml_filepath)) rescue Hash.new
  22
+          tiny_mce_options = yaml_options.merge(tiny_mce_options)
  23
+        end
  24
+
20 25
         # If the tiny_mce plugins includes the spellchecker, then form a spellchecking path,
21 26
         # add it to the tiny_mce_options, and include the SpellChecking module
22 27
         if !tiny_mce_options[:plugins].blank? && tiny_mce_options[:plugins].include?('spellchecker')

0 notes on commit 944b21b

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