tinymce-rails 3.5.8.2 → 3.5.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2011-12 by Sam Pohlenz
1
+ Copyright (C) 2011-13 by Sam Pohlenz
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -3,7 +3,9 @@ Rails Integration for TinyMCE
3
3
 
4
4
  The `tinymce-rails` gem integrates the [TinyMCE](http://www.tinymce.com/) editor with the Rails asset pipeline.
5
5
 
6
- This gem is compatible with Rails 3.1.1 and higher. Support for TinyMCE 4 is currently under development in the [tinymce-4 branch](https://github.com/spohlenz/tinymce-rails/tree/tinymce-4).
6
+ This gem is compatible with Rails 3.1.1 and higher (including Rails 4).
7
+
8
+ Support for TinyMCE 4 is currently available in the [tinymce-4 branch](https://github.com/spohlenz/tinymce-rails/tree/tinymce-4). For the time being, parallel versions of TinyMCE (3.5.x and 4.x) will be maintained. However TinyMCE 4 will eventually be promoted to the master branch.
7
9
 
8
10
  [![Build Status](https://travis-ci.org/spohlenz/tinymce-rails.png?branch=master)](https://travis-ci.org/spohlenz/tinymce-rails)
9
11
 
@@ -30,6 +32,8 @@ Be sure to add to the global group, not the `assets` group. Then run `bundle ins
30
32
  - table
31
33
  - fullscreen
32
34
 
35
+ The Rails server no longer needs to be restarted when this file is updated in development mode.
36
+
33
37
  To define multiple configuration sets, follow this syntax (a default configuration must be specified):
34
38
 
35
39
  default:
@@ -47,7 +51,7 @@ To define multiple configuration sets, follow this syntax (a default configurati
47
51
  plugins:
48
52
  - table
49
53
 
50
- See the [TinyMCE Documentation](http://www.tinymce.com/wiki.php/Configuration) for a full list of configuration options.
54
+ See the [TinyMCE 3 Documentation](http://www.tinymce.com/wiki.php/Configuration3x) for a full list of configuration options.
51
55
 
52
56
 
53
57
  **3. Include the TinyMCE assets**
@@ -87,12 +91,6 @@ Alternate configurations defined in 'config/tinymce.yml' can be used with:
87
91
  <%= tinymce :alternate %>
88
92
 
89
93
 
90
- Language Packs
91
- --------------
92
-
93
- See the [tinymce-rails-langs](https://github.com/spohlenz/tinymce-rails-langs) gem for additional language packs for TinyMCE. The `tinymce` helper will use the current locale as the language if available, falling back to English if the core language files are missing.
94
-
95
-
96
94
  Manual Initialization
97
95
  ---------------------
98
96
 
@@ -108,6 +106,12 @@ Using the `tinymce` helper and global configuration file is entirely optional. T
108
106
  </script>
109
107
 
110
108
 
109
+ Language Packs
110
+ --------------
111
+
112
+ See the [tinymce-rails-langs](https://github.com/spohlenz/tinymce-rails-langs) gem for additional language packs for TinyMCE. The `tinymce` helper will use the current locale as the language if available, falling back to English if the core language files are missing.
113
+
114
+
111
115
  Custom Plugins & Skins
112
116
  ----------------------
113
117
 
@@ -3,9 +3,11 @@ assets_task = Rake::Task.task_defined?('assets:precompile:primary') ? 'assets:pr
3
3
  Rake::Task[assets_task].enhance do
4
4
  require "tinymce/rails/asset_installer"
5
5
 
6
+ assets = Pathname.new(File.expand_path(File.dirname(__FILE__) + "/../../vendor/assets/javascripts/tinymce"))
7
+
6
8
  config = Rails.application.config
7
9
  target = File.join(Rails.public_path, config.assets.prefix)
8
10
  manifest = config.assets.manifest
9
11
 
10
- TinyMCE::Rails::AssetInstaller.new(target, manifest).install
12
+ TinyMCE::Rails::AssetInstaller.new(assets, target, manifest).install
11
13
  end
@@ -3,10 +3,12 @@ module TinyMCE
3
3
  require 'tinymce/rails/engine'
4
4
  require 'tinymce/rails/version'
5
5
  require "tinymce/rails/configuration"
6
+ require "tinymce/rails/configuration_file"
6
7
  require "tinymce/rails/helper"
7
8
 
8
9
  def self.configuration
9
- @configuration ||= Configuration.load(::Rails.root.join("config/tinymce.yml"))
10
+ @configuration ||= ConfigurationFile.new(::Rails.root.join("config/tinymce.yml"))
11
+ @configuration.respond_to?(:configuration) ? @configuration.configuration : @configuration
10
12
  end
11
13
 
12
14
  def self.configuration=(configuration)
@@ -3,9 +3,8 @@ require "tinymce/rails/asset_manifest"
3
3
  module TinyMCE
4
4
  module Rails
5
5
  class AssetInstaller
6
- ASSETS = Pathname.new(File.expand_path(File.dirname(__FILE__) + "/../../../vendor/assets/javascripts/tinymce"))
7
-
8
- def initialize(target, manifest_path)
6
+ def initialize(assets, target, manifest_path)
7
+ @assets = assets
9
8
  @target = target
10
9
  @manifest_path = manifest_path || target
11
10
  end
@@ -34,7 +33,7 @@ module TinyMCE
34
33
  end
35
34
 
36
35
  def copy_assets
37
- FileUtils.cp_r(ASSETS, @target, :preserve => true)
36
+ FileUtils.cp_r(@assets, @target, :preserve => true)
38
37
  end
39
38
 
40
39
  def append_to_manifest
@@ -44,11 +43,11 @@ module TinyMCE
44
43
  end
45
44
 
46
45
  def asset_files
47
- Pathname.glob("#{ASSETS}/**/*").select(&:file?)
46
+ Pathname.glob("#{@assets}/**/*").select(&:file?)
48
47
  end
49
48
 
50
49
  def logical_path(file)
51
- file.relative_path_from(ASSETS.parent).to_s
50
+ file.relative_path_from(@assets.parent).to_s
52
51
  end
53
52
 
54
53
  def move_asset(src, dest)
@@ -50,18 +50,6 @@ module TinyMCE::Rails
50
50
  self.class.new(self.options.merge(options))
51
51
  end
52
52
 
53
- def self.load(filename)
54
- return new_with_defaults if !File.exists?(filename)
55
-
56
- options = load_yaml(filename)
57
-
58
- if options.has_key?('default')
59
- MultipleConfiguration.new(options)
60
- else
61
- new_with_defaults(options)
62
- end
63
- end
64
-
65
53
  # Default language falls back to English if current locale is not available.
66
54
  def self.default_language
67
55
  available_languages.include?(I18n.locale.to_s) ? I18n.locale.to_s : "en"
@@ -81,10 +69,6 @@ module TinyMCE::Rails
81
69
  def self.assets
82
70
  Rails.application.assets
83
71
  end
84
-
85
- def self.load_yaml(filename)
86
- YAML::load(ERB.new(IO.read(filename)).result)
87
- end
88
72
  end
89
73
 
90
74
  class MultipleConfiguration < ActiveSupport::HashWithIndifferentAccess
@@ -0,0 +1,49 @@
1
+ module TinyMCE::Rails
2
+ class ConfigurationFile
3
+ attr_reader :path
4
+
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+
9
+ def configuration
10
+ @configuration = load_configuration if reload?
11
+ @configuration
12
+ end
13
+
14
+ def reload?
15
+ @configuration.nil? || (reloadable? && changed?)
16
+ end
17
+
18
+ def changed?
19
+ @last_loaded != last_updated
20
+ end
21
+
22
+ private
23
+ def reloadable?
24
+ !::Rails.application.config.cache_classes
25
+ end
26
+
27
+ def last_updated
28
+ File.exists?(path) && File.mtime(path)
29
+ end
30
+
31
+ def load_configuration
32
+ @last_loaded = last_updated
33
+
34
+ return Configuration.new_with_defaults if !File.exists?(path)
35
+
36
+ options = load_yaml(path)
37
+
38
+ if options && options.has_key?('default')
39
+ MultipleConfiguration.new(options)
40
+ else
41
+ Configuration.new_with_defaults(options)
42
+ end
43
+ end
44
+
45
+ def load_yaml(path)
46
+ YAML::load(ERB.new(IO.read(path)).result)
47
+ end
48
+ end
49
+ end
@@ -21,6 +21,12 @@ module TinyMCE::Rails
21
21
 
22
22
  # Returns the JavaScript code required to initialize TinyMCE.
23
23
  def tinymce_javascript(config=:default, options={})
24
+ "tinyMCE.init(#{tinymce_configuration(config, options).to_json});".html_safe
25
+ end
26
+
27
+ # Returns the TinyMCE configuration as a hash.
28
+ # It should be converted to JSON (via #to_json) for use within JavaScript.
29
+ def tinymce_configuration(config=:default, options={})
24
30
  options, config = config, :default if config.is_a?(Hash)
25
31
  options.stringify_keys!
26
32
 
@@ -30,9 +36,7 @@ module TinyMCE::Rails
30
36
  base_configuration = base_configuration.fetch(config)
31
37
  end
32
38
 
33
- configuration = base_configuration.merge(options)
34
-
35
- "tinyMCE.init(#{configuration.options_for_tinymce.to_json});".html_safe
39
+ base_configuration.merge(options).options_for_tinymce
36
40
  end
37
41
 
38
42
  # Includes TinyMCE javascript assets via a script tag.
@@ -1,6 +1,6 @@
1
1
  module TinyMCE
2
2
  module Rails
3
- VERSION = "3.5.8.2"
3
+ VERSION = "3.5.8.3"
4
4
  TINYMCE_VERSION = "3.5.8"
5
5
  end
6
6
  end
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.2
4
+ version: 3.5.8.3
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: 2013-05-06 00:00:00.000000000 Z
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -44,6 +44,7 @@ files:
44
44
  - lib/tinymce/rails/asset_installer.rb
45
45
  - lib/tinymce/rails/asset_manifest.rb
46
46
  - lib/tinymce/rails/configuration.rb
47
+ - lib/tinymce/rails/configuration_file.rb
47
48
  - lib/tinymce/rails/engine.rb
48
49
  - lib/tinymce/rails/helper.rb
49
50
  - lib/tinymce/rails/version.rb