rails_kindeditor 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1646a9cc4af470cf7ff498125e965fccf45c09a6
4
- data.tar.gz: 1598b87d18c480a7808c4be83a5e1ca6f60b573b
3
+ metadata.gz: 9eeb13a10bad2a05a9ddf3cb1d5c2b4269056cf6
4
+ data.tar.gz: a00c51c53c5f5cc75ab8cde62492f5134c15535c
5
5
  SHA512:
6
- metadata.gz: 478d1d2302dc65481cd4d09cbbc1772de6473b53f94c2072965d04c987f38d339b6a783268d172ccf9447cf29f36b0df341da2b1a440928ca947e259bb010be8
7
- data.tar.gz: 608345c25a88ad695f677cb282b56faecb17b34fd34a1b9ea231090d957166877470a7faeb6c47304755c21a024963f4e39e758443100a3dd219aba5949ad4c7
6
+ metadata.gz: 9536a6323d3bd998be4ffd0b1c673ae0f8d830737b3529eabfc85ee4f926f1a0b49ad15e5a954b35d4b946c32ed042b1253d03e3821d9f45598b523920fae665
7
+ data.tar.gz: da032a5b3563971b0bbc80f39a8eb06af52ba830d40ffda2084d4f303cba21a6ffdbc63aa6369a89d51271279b0798d6ca31238dd9cdbe94bb56214fedca9f54
data/Gemfile CHANGED
@@ -2,5 +2,6 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'jquery-rails'
5
6
  gem 'carrierwave'
6
7
  gem 'mini_magick'
data/README.md CHANGED
@@ -10,8 +10,10 @@ rails_kindeditor will helps your rails app integrate with kindeditor, includes i
10
10
  ### Add this to your Gemfile
11
11
 
12
12
  ```ruby
13
+ gem 'jquery-rails'
13
14
  gem 'rails_kindeditor'
14
15
  ```
16
+ notice: Rails 5.1 has dropped dependency on jQuery from the default,but rails_kindeditor need 'jquery-rails'.
15
17
 
16
18
  ### Run "bundle" command.
17
19
 
@@ -112,7 +114,7 @@ Warning: Kindeditor will be load when the others have been loaded.
112
114
  # or
113
115
  <%= form.input :content, :as => :kindeditor, :label => false, :input_html => { :width => 800, :height => 300 } %>
114
116
  ```
115
-
117
+
116
118
  ### formtastic:
117
119
 
118
120
  ```ruby
@@ -139,7 +141,7 @@ You can get content like this:
139
141
  ## Upload options configuration
140
142
 
141
143
  When you run "rails generate rails_kindeditor:install", installer will copy configuration files in config/initializers folder.
142
- You can customize some option for uploading.
144
+ You can customize some option for uploading.
143
145
 
144
146
  ```ruby
145
147
  # Specify the subfolders in public directory.
@@ -195,7 +197,7 @@ rails_kindeditor can save upload file information into database.
195
197
 
196
198
  You can specify the owner for uploaded files, when the owner was destroying, all the uploaded files(belongs to the owner) will be destroyed automatically.
197
199
 
198
- ####1. specify the owner_id for kindeditor
200
+ ###1. specify the owner_id for kindeditor
199
201
 
200
202
  ```ruby
201
203
  <%= form_for @article do |f| %>
@@ -209,7 +211,7 @@ You can specify the owner for uploaded files, when the owner was destroying, all
209
211
  Warnning: the @article must be created before this scene, the @article.id should not be empty.
210
212
  ```
211
213
 
212
- ####2. add has_many_kindeditor_assets in your own model
214
+ ###2. add has_many_kindeditor_assets in your own model
213
215
 
214
216
  ```ruby
215
217
  class Article < ActiveRecord::Base
@@ -219,7 +221,7 @@ Warnning: the @article must be created before this scene, the @article.id should
219
221
  end
220
222
  ```
221
223
 
222
- ####3. relationship
224
+ ###3. relationship
223
225
 
224
226
  ```ruby
225
227
  article = Article.first
@@ -250,8 +252,10 @@ rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和
250
252
  ### 将下面代码加入Gemfile:
251
253
 
252
254
  ```ruby
255
+ gem 'jquery-rails'
253
256
  gem 'rails_kindeditor'
254
257
  ```
258
+ 注意:Rails 5.1 已没有将jQuery作为默认设置,但rails_kindeditor需要'jquery-rails'.
255
259
 
256
260
  ### 运行"bundle"命令:
257
261
 
@@ -301,7 +305,7 @@ Precompiling assets不再自动从vendor/assets和lib/assets拷贝非JS/CSS文
301
305
  f.kindeditor :content, :simple_mode => true
302
306
  f.input :content, :as => :kindeditor, :input_html => { :simple_mode => true } # simple_form & formtastic
303
307
  ```
304
-
308
+
305
309
  完毕!
306
310
 
307
311
  ### 如何在Turbolinks5下使用
@@ -429,7 +433,7 @@ rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应
429
433
 
430
434
  你可以为上传的文件指定归属,比如一名用户,或者一篇文章,当用户或者文章被删除时,所有属于该用户或者该文章的上传文件将会被自动删除。
431
435
 
432
- ####1. 为kindeditor指定owner_id
436
+ ###1. 为kindeditor指定owner_id
433
437
 
434
438
  ```ruby
435
439
  <%= form_for @article do |f| %>
@@ -443,7 +447,7 @@ rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应
443
447
  警告: @article应该事先被创建,@article.id不应该是空的。
444
448
  ```
445
449
 
446
- ####2. 在你自己的模型里加入has_many_kindeditor_assets
450
+ ###2. 在你自己的模型里加入has_many_kindeditor_assets
447
451
 
448
452
  ```ruby
449
453
  class Article < ActiveRecord::Base
@@ -453,7 +457,7 @@ rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应
453
457
  end
454
458
  ```
455
459
 
456
- ####3. 相互关系
460
+ ###3. 相互关系
457
461
 
458
462
  ```ruby
459
463
  article = Article.first
@@ -470,4 +474,4 @@ rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应
470
474
 
471
475
  ## License
472
476
 
473
- MIT License.
477
+ MIT License.
@@ -1,7 +1,7 @@
1
1
  #coding: utf-8
2
2
  require "find"
3
3
  class Kindeditor::AssetsController < ApplicationController
4
- skip_before_filter :verify_authenticity_token
4
+ skip_before_action :verify_authenticity_token
5
5
  def create
6
6
  @imgFile, @dir = params[:imgFile], params[:dir]
7
7
  unless @imgFile.nil?
@@ -13,7 +13,7 @@ class Kindeditor::AssetsController < ApplicationController
13
13
  logger.warn '========= Warning: the owner have not been created, "delete uploaded files automatically" will not work. =========' if defined?(logger) && @asset.owner_id == 0
14
14
  @asset.asset_type = @dir
15
15
  if @asset.save
16
- render :text => ({:error => 0, :url => @asset.asset.url}.to_json)
16
+ render :plain => ({:error => 0, :url => @asset.asset.url}.to_json)
17
17
  else
18
18
  show_error(@asset.errors.full_messages)
19
19
  end
@@ -24,7 +24,7 @@ class Kindeditor::AssetsController < ApplicationController
24
24
  begin
25
25
  uploader = "Kindeditor::#{@dir.camelize}Uploader".constantize.new
26
26
  uploader.store!(@imgFile)
27
- render :text => ({:error => 0, :url => uploader.url}.to_json)
27
+ render :plain => ({:error => 0, :url => uploader.url}.to_json)
28
28
  rescue CarrierWave::UploadError => e
29
29
  show_error(e.message)
30
30
  rescue Exception => e
@@ -42,7 +42,7 @@ class Kindeditor::AssetsController < ApplicationController
42
42
  @img_ext = Kindeditor::AssetUploader::EXT_NAMES[:image]
43
43
  @dir = params[:dir].strip || ""
44
44
  unless Kindeditor::AssetUploader::EXT_NAMES.keys.map(&:to_s).push("").include?(@dir)
45
- render :text => "Invalid Directory name."
45
+ render :plain => "Invalid Directory name."
46
46
  return
47
47
  end
48
48
 
@@ -71,15 +71,15 @@ class Kindeditor::AssetsController < ApplicationController
71
71
  end
72
72
  @order = %w(name size type).include?(params[:order].downcase) ? params[:order].downcase : "name"
73
73
  if !@current_path.match(/\.\./).nil?
74
- render :text => "Access is not allowed."
74
+ render :plain => "Access is not allowed."
75
75
  return
76
76
  end
77
77
  if @current_path.match(/\/$/).nil?
78
- render :text => "Parameter is not valid."
78
+ render :plain => "Parameter is not valid."
79
79
  return
80
80
  end
81
81
  if !File.exist?(@current_path) || !File.directory?(@current_path)
82
- render :text => "Directory does not exist."
82
+ render :plain => "Directory does not exist."
83
83
  return
84
84
  end
85
85
  @file_list = []
@@ -116,12 +116,12 @@ class Kindeditor::AssetsController < ApplicationController
116
116
  @result[:current_url] = @current_url
117
117
  @result[:total_count] = @file_list.count
118
118
  @result[:file_list] = @file_list
119
- render :text => @result.to_json
119
+ render :plain => @result.to_json
120
120
  end
121
121
 
122
122
  private
123
123
  def show_error(msg)
124
- render :text => ({:error => 1, :message => msg}.to_json)
124
+ render :plain => ({:error => 1, :message => msg}.to_json)
125
125
  end
126
126
 
127
127
  end
@@ -11,13 +11,22 @@ module RailsKindeditor
11
11
  template "rails_kindeditor.rb", "config/initializers/rails_kindeditor.rb"
12
12
  end
13
13
  end
14
-
14
+
15
15
  def insert_or_copy_js_files
16
16
  if File.exist?('app/assets/javascripts/application.js')
17
- insert_into_file "app/assets/javascripts/application.js", "//= require kindeditor\n", :after => "jquery_ujs\n"
17
+ insert_into_file "app/assets/javascripts/application.js", "//= require jquery\n//= require jquery_ujs\n//= require kindeditor\n", :before => "//= require_tree ."
18
18
  else
19
19
  copy_file "application.js", "app/assets/javascripts/application.js"
20
20
  end
21
21
  end
22
+
23
+ def copy_load_kindeditor_coffeescript
24
+ if ::Rails.version < "3.1.0"
25
+ warn "Warning: rails_kindeditor ~> v0.3.0 only support Rails3.1+!"
26
+ warn "If you're using rails3.0.x, please check rails_kindeditor v0.2.8"
27
+ else
28
+ template "load_kindeditor.coffee", "app/assets/javascripts/load_kindeditor.coffee"
29
+ end
30
+ end
22
31
  end
23
- end
32
+ end
@@ -1,17 +1,18 @@
1
1
  // This is a manifest file that'll be compiled into application.js, which will include all the files
2
2
  // listed below.
3
3
  //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
5
+ // vendor/assets/javascripts directory can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
9
  //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
12
  //
13
+ //= require rails-ujs
14
+ //= require turbolinks
13
15
  //= require jquery
14
16
  //= require jquery_ujs
15
17
  //= require kindeditor
16
18
  //= require_tree .
17
-
@@ -0,0 +1,6 @@
1
+ $(document).on 'turbolinks:before-cache', ->
2
+ KindEditor.remove('.rails_kindeditor')
3
+
4
+ $(document).on 'turbolinks:load', ->
5
+ $('.rails_kindeditor').each ->
6
+ KindEditor.create "##{$(this).attr('id')}", "allowFileManager": true, "uploadJson": $(this).data('upload'), "fileManagerJson": $(this).data('filemanager'), "width": '100%', "height": '300'
@@ -1,4 +1,3 @@
1
1
  module RailsKindeditor
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
4
-
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
20
  s.require_paths = ["lib"]
21
21
 
22
+ s.add_dependency("jquery-rails")
22
23
  s.add_dependency("carrierwave")
23
24
  s.add_dependency("mini_magick")
24
- end
25
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_kindeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Macrow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-02 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jquery-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: carrierwave
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,6 +74,7 @@ files:
60
74
  - lib/generators/rails_kindeditor/install/USAGE
61
75
  - lib/generators/rails_kindeditor/install/install_generator.rb
62
76
  - lib/generators/rails_kindeditor/install/templates/application.js
77
+ - lib/generators/rails_kindeditor/install/templates/load_kindeditor.coffee
63
78
  - lib/generators/rails_kindeditor/install/templates/rails_kindeditor.rb
64
79
  - lib/generators/rails_kindeditor/migration/USAGE
65
80
  - lib/generators/rails_kindeditor/migration/migration_generator.rb
@@ -304,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
304
319
  version: '0'
305
320
  requirements: []
306
321
  rubyforge_project: rails_kindeditor
307
- rubygems_version: 2.5.1
322
+ rubygems_version: 2.6.13
308
323
  signing_key:
309
324
  specification_version: 4
310
325
  summary: Kindeditor for Ruby on Rails