activeadmin_images 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/activeadmin_images/version.rb +1 -1
- data/lib/generators/active_admin/images/install/install_generator.rb +9 -2
- data/lib/generators/active_admin/images/install/templates/{model.rb → model_ar.rb} +0 -0
- data/{test/tmp/app/models/custom_image.rb → lib/generators/active_admin/images/install/templates/model_mongo.rb} +4 -4
- data/test/generators/instal_generator_test.rb +2 -2
- metadata +73 -82
- data/config/routes.rb +0 -2
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -59
- data/test/tmp/app/admin/custom_image.rb +0 -57
- data/test/tmp/app/views/admin/custom_images/_add_images.html.erb +0 -9
- data/test/tmp/db/migrate/20131129135954_create_table_custom_images.rb +0 -8
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 387abfb0bfbb25d7f9c5036cdd926f82eacd046a
|
4
|
+
data.tar.gz: 3ffe5a28c6ece1fc90f847d489c2b3eaa054b7c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e91ec179bafbe54262cbb03467fc65049937510e430f6536ad67877f04c7c4af3ba591d2fbf26c8a356c8726acef31982da0610f7990be2e3c0b9b1e43d885eb
|
7
|
+
data.tar.gz: ed0f9da34901c4cd9fcb9bdba35fea0a9e011ce45676f9155ade9148dbefecefbdbd606e88d41b6d22a536db0b466aa47681ce880b47058d435e153efd858db5
|
@@ -3,14 +3,21 @@ require 'rails/generators/active_record'
|
|
3
3
|
module ActiveAdmin
|
4
4
|
module Images
|
5
5
|
class InstallGenerator < ActiveRecord::Generators::Base
|
6
|
+
argument :name, type: :string, default: ''
|
7
|
+
argument :db_type, type: :string, default: 'ActiveRecord'
|
8
|
+
|
6
9
|
source_root File.expand_path('../templates', __FILE__)
|
7
10
|
|
8
11
|
def create_model
|
9
|
-
|
12
|
+
if db_type == 'ActiveRecord'
|
13
|
+
template 'model_ar.rb', "app/models/#{name.gsub('/', '_').underscore}.rb"
|
14
|
+
else
|
15
|
+
template 'model_mongo.rb', "app/models/#{name.gsub('/', '_').underscore}.rb"
|
16
|
+
end
|
10
17
|
end
|
11
18
|
|
12
19
|
def manifest
|
13
|
-
migration_template
|
20
|
+
migration_template('migration.rb', "db/migrate/create_table_#{name.underscore.gsub('/', '_').pluralize}.rb") unless db_type == 'MongoId'
|
14
21
|
end
|
15
22
|
|
16
23
|
def create_register
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class
|
1
|
+
class <%= name%>
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Paperclip
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
has_attached_file :attachment,
|
5
|
+
has_mongoid_attached_file :attachment,
|
6
6
|
:styles => {
|
7
7
|
:thumb => ["50x50#", :png]
|
8
8
|
},
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'test_helper'
|
1
|
+
require '../test_helper'
|
2
2
|
require 'generators/active_admin/images/install/install_generator'
|
3
3
|
|
4
|
-
class
|
4
|
+
class InstallGeneratorTest < Rails::Generators::TestCase
|
5
5
|
tests ActiveAdmin::Images::InstallGenerator
|
6
6
|
destination File.expand_path("../../tmp", __FILE__)
|
7
7
|
setup :prepare_destination
|
metadata
CHANGED
@@ -1,38 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kernel Web
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: 4.0.1
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.1
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: activeadmin
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
description: Active Admin plugin for generate the model of image
|
37
42
|
email:
|
38
43
|
- mk@kernel-corp.com
|
@@ -40,127 +45,113 @@ executables: []
|
|
40
45
|
extensions: []
|
41
46
|
extra_rdoc_files: []
|
42
47
|
files:
|
43
|
-
-
|
44
|
-
-
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- lib/activeadmin_images.rb
|
45
52
|
- lib/activeadmin_images/engine.rb
|
46
|
-
- lib/
|
53
|
+
- lib/activeadmin_images/version.rb
|
47
54
|
- lib/assets/javascripts/fileuploader.js
|
48
55
|
- lib/assets/stylesheets/fileuploader.css
|
49
56
|
- lib/generators/active_admin/images/install/USAGE
|
50
57
|
- lib/generators/active_admin/images/install/install_generator.rb
|
51
|
-
- lib/generators/active_admin/images/install/templates/migration.rb
|
52
|
-
- lib/generators/active_admin/images/install/templates/model.rb
|
53
58
|
- lib/generators/active_admin/images/install/templates/form.rb
|
59
|
+
- lib/generators/active_admin/images/install/templates/migration.rb
|
60
|
+
- lib/generators/active_admin/images/install/templates/model_ar.rb
|
61
|
+
- lib/generators/active_admin/images/install/templates/model_mongo.rb
|
54
62
|
- lib/generators/active_admin/images/install/templates/register.rb
|
55
|
-
- lib/
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
- test/
|
60
|
-
- test/
|
61
|
-
- test/
|
62
|
-
- test/
|
63
|
-
- test/
|
63
|
+
- lib/tasks/activeadmin_images_tasks.rake
|
64
|
+
- test/activeadmin_images_test.rb
|
65
|
+
- test/dummy/README.rdoc
|
66
|
+
- test/dummy/Rakefile
|
67
|
+
- test/dummy/app/assets/javascripts/application.js
|
68
|
+
- test/dummy/app/assets/stylesheets/application.css
|
69
|
+
- test/dummy/app/controllers/application_controller.rb
|
70
|
+
- test/dummy/app/helpers/application_helper.rb
|
71
|
+
- test/dummy/app/views/layouts/application.html.erb
|
72
|
+
- test/dummy/bin/bundle
|
73
|
+
- test/dummy/bin/rails
|
74
|
+
- test/dummy/bin/rake
|
64
75
|
- test/dummy/config.ru
|
65
|
-
- test/dummy/config/
|
66
|
-
- test/dummy/config/
|
76
|
+
- test/dummy/config/application.rb
|
77
|
+
- test/dummy/config/boot.rb
|
78
|
+
- test/dummy/config/database.yml
|
79
|
+
- test/dummy/config/environment.rb
|
67
80
|
- test/dummy/config/environments/development.rb
|
68
|
-
- test/dummy/config/environments/test.rb
|
69
81
|
- test/dummy/config/environments/production.rb
|
70
|
-
- test/dummy/config/
|
71
|
-
- test/dummy/config/database.yml
|
72
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
73
|
-
- test/dummy/config/initializers/mime_types.rb
|
82
|
+
- test/dummy/config/environments/test.rb
|
74
83
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
75
84
|
- test/dummy/config/initializers/filter_parameter_logging.rb
|
76
85
|
- test/dummy/config/initializers/inflections.rb
|
86
|
+
- test/dummy/config/initializers/mime_types.rb
|
77
87
|
- test/dummy/config/initializers/secret_token.rb
|
78
88
|
- test/dummy/config/initializers/session_store.rb
|
79
|
-
- test/dummy/config/
|
80
|
-
- test/dummy/config/
|
81
|
-
- test/dummy/
|
82
|
-
- test/dummy/public/422.html
|
89
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
90
|
+
- test/dummy/config/locales/en.yml
|
91
|
+
- test/dummy/config/routes.rb
|
83
92
|
- test/dummy/public/404.html
|
93
|
+
- test/dummy/public/422.html
|
84
94
|
- test/dummy/public/500.html
|
85
95
|
- test/dummy/public/favicon.ico
|
86
|
-
- test/dummy/log/test.log
|
87
|
-
- test/dummy/README.rdoc
|
88
|
-
- test/dummy/bin/bundle
|
89
|
-
- test/dummy/bin/rake
|
90
|
-
- test/dummy/bin/rails
|
91
|
-
- test/dummy/db/test.sqlite3
|
92
|
-
- test/dummy/app/controllers/application_controller.rb
|
93
|
-
- test/dummy/app/assets/javascripts/application.js
|
94
|
-
- test/dummy/app/assets/stylesheets/application.css
|
95
|
-
- test/dummy/app/views/layouts/application.html.erb
|
96
|
-
- test/dummy/app/helpers/application_helper.rb
|
97
96
|
- test/generators/instal_generator_test.rb
|
98
|
-
- test/activeadmin_images_test.rb
|
99
97
|
- test/integration/navigation_test.rb
|
98
|
+
- test/test_helper.rb
|
100
99
|
homepage: https://github.com/KernelCorp/activeadmin_images.git
|
101
100
|
licenses: []
|
101
|
+
metadata: {}
|
102
102
|
post_install_message:
|
103
103
|
rdoc_options: []
|
104
104
|
require_paths:
|
105
105
|
- lib
|
106
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
107
|
requirements:
|
109
|
-
- -
|
108
|
+
- - '>='
|
110
109
|
- !ruby/object:Gem::Version
|
111
110
|
version: '0'
|
112
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
112
|
requirements:
|
115
|
-
- -
|
113
|
+
- - '>='
|
116
114
|
- !ruby/object:Gem::Version
|
117
115
|
version: '0'
|
118
116
|
requirements: []
|
119
117
|
rubyforge_project:
|
120
|
-
rubygems_version:
|
118
|
+
rubygems_version: 2.2.2
|
121
119
|
signing_key:
|
122
|
-
specification_version:
|
120
|
+
specification_version: 4
|
123
121
|
summary: Active Admin plugin for generate the model of image
|
124
122
|
test_files:
|
125
|
-
- test/
|
126
|
-
- test/
|
127
|
-
- test/
|
128
|
-
- test/
|
129
|
-
- test/
|
130
|
-
- test/dummy/
|
131
|
-
- test/dummy/
|
132
|
-
- test/dummy/
|
123
|
+
- test/generators/instal_generator_test.rb
|
124
|
+
- test/integration/navigation_test.rb
|
125
|
+
- test/dummy/bin/rails
|
126
|
+
- test/dummy/bin/bundle
|
127
|
+
- test/dummy/bin/rake
|
128
|
+
- test/dummy/public/500.html
|
129
|
+
- test/dummy/public/404.html
|
130
|
+
- test/dummy/public/422.html
|
131
|
+
- test/dummy/public/favicon.ico
|
133
132
|
- test/dummy/config/environments/development.rb
|
134
133
|
- test/dummy/config/environments/test.rb
|
135
134
|
- test/dummy/config/environments/production.rb
|
135
|
+
- test/dummy/config/application.rb
|
136
136
|
- test/dummy/config/environment.rb
|
137
|
+
- test/dummy/config/locales/en.yml
|
137
138
|
- test/dummy/config/database.yml
|
138
|
-
- test/dummy/config/
|
139
|
+
- test/dummy/config/boot.rb
|
140
|
+
- test/dummy/config/routes.rb
|
139
141
|
- test/dummy/config/initializers/mime_types.rb
|
140
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
141
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
142
142
|
- test/dummy/config/initializers/inflections.rb
|
143
|
-
- test/dummy/config/initializers/
|
143
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
144
144
|
- test/dummy/config/initializers/session_store.rb
|
145
|
-
- test/dummy/config/
|
146
|
-
- test/dummy/config/
|
145
|
+
- test/dummy/config/initializers/secret_token.rb
|
146
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
147
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
147
148
|
- test/dummy/Rakefile
|
148
|
-
- test/dummy/public/422.html
|
149
|
-
- test/dummy/public/404.html
|
150
|
-
- test/dummy/public/500.html
|
151
|
-
- test/dummy/public/favicon.ico
|
152
|
-
- test/dummy/log/test.log
|
153
|
-
- test/dummy/README.rdoc
|
154
|
-
- test/dummy/bin/bundle
|
155
|
-
- test/dummy/bin/rake
|
156
|
-
- test/dummy/bin/rails
|
157
|
-
- test/dummy/db/test.sqlite3
|
158
149
|
- test/dummy/app/controllers/application_controller.rb
|
159
150
|
- test/dummy/app/assets/javascripts/application.js
|
160
151
|
- test/dummy/app/assets/stylesheets/application.css
|
161
|
-
- test/dummy/app/views/layouts/application.html.erb
|
162
152
|
- test/dummy/app/helpers/application_helper.rb
|
163
|
-
- test/
|
153
|
+
- test/dummy/app/views/layouts/application.html.erb
|
154
|
+
- test/dummy/config.ru
|
155
|
+
- test/dummy/README.rdoc
|
156
|
+
- test/test_helper.rb
|
164
157
|
- test/activeadmin_images_test.rb
|
165
|
-
- test/integration/navigation_test.rb
|
166
|
-
has_rdoc:
|
data/config/routes.rb
DELETED
data/test/dummy/db/test.sqlite3
DELETED
File without changes
|
data/test/dummy/log/test.log
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
Connecting to database specified by database.yml
|
2
|
-
Connecting to database specified by database.yml
|
3
|
-
Connecting to database specified by database.yml
|
4
|
-
[1m[36m (1.1ms)[0m [1mbegin transaction[0m
|
5
|
-
[1m[35m (16.0ms)[0m rollback transaction
|
6
|
-
Connecting to database specified by database.yml
|
7
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
8
|
-
[1m[35m (0.3ms)[0m rollback transaction
|
9
|
-
Connecting to database specified by database.yml
|
10
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
11
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
12
|
-
Connecting to database specified by database.yml
|
13
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
14
|
-
[1m[35m (1.0ms)[0m rollback transaction
|
15
|
-
Connecting to database specified by database.yml
|
16
|
-
[1m[36m (0.5ms)[0m [1mbegin transaction[0m
|
17
|
-
[1m[35m (0.4ms)[0m rollback transaction
|
18
|
-
Connecting to database specified by database.yml
|
19
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
20
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
21
|
-
Connecting to database specified by database.yml
|
22
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
23
|
-
[1m[35m (0.2ms)[0m rollback transaction
|
24
|
-
Connecting to database specified by database.yml
|
25
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
26
|
-
[1m[35m (0.3ms)[0m rollback transaction
|
27
|
-
Connecting to database specified by database.yml
|
28
|
-
[1m[36m (17.3ms)[0m [1mbegin transaction[0m
|
29
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
30
|
-
Connecting to database specified by database.yml
|
31
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
32
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
33
|
-
Connecting to database specified by database.yml
|
34
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
35
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
36
|
-
Connecting to database specified by database.yml
|
37
|
-
[1m[36m (0.5ms)[0m [1mbegin transaction[0m
|
38
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
39
|
-
Connecting to database specified by database.yml
|
40
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
41
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
42
|
-
Connecting to database specified by database.yml
|
43
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
44
|
-
[1m[35m (0.2ms)[0m rollback transaction
|
45
|
-
Connecting to database specified by database.yml
|
46
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
47
|
-
[1m[35m (0.3ms)[0m rollback transaction
|
48
|
-
Connecting to database specified by database.yml
|
49
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
50
|
-
[1m[35m (0.2ms)[0m rollback transaction
|
51
|
-
Connecting to database specified by database.yml
|
52
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
53
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
54
|
-
Connecting to database specified by database.yml
|
55
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
56
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
57
|
-
Connecting to database specified by database.yml
|
58
|
-
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
59
|
-
[1m[35m (0.1ms)[0m rollback transaction
|
@@ -1,57 +0,0 @@
|
|
1
|
-
ActiveAdmin.register CustomImage do
|
2
|
-
actions :all, except: [:edit]
|
3
|
-
|
4
|
-
collection_action :add_files, method: :post do
|
5
|
-
@custom_image = CustomImage.new(attachment: @raw_file)
|
6
|
-
if @custom_image.save!
|
7
|
-
render json: { success: true, :url => @custom_image.attachment.url(:thumb), :id => @custom_image.id }
|
8
|
-
else
|
9
|
-
render json: { success: false }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
controller do
|
14
|
-
before_filter :parse_raw_upload, only: [:add_files]
|
15
|
-
|
16
|
-
private
|
17
|
-
def parse_raw_upload
|
18
|
-
if env['HTTP_X_FILE_UPLOAD'] == 'true'
|
19
|
-
@raw_file = env['rack.input']
|
20
|
-
@raw_file.class.class_eval { attr_accessor :original_filename, :content_type }
|
21
|
-
@raw_file.original_filename = env['HTTP_X_FILE_NAME']
|
22
|
-
@raw_file.content_type = env['HTTP_X_MIME_TYPE']
|
23
|
-
if @raw_file.class.name == 'Unicorn::TeeInput'
|
24
|
-
@raw_file = Paperclip::StringioAdapter.new(@raw_file)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
index do
|
32
|
-
selectable_column
|
33
|
-
column :title do |image|
|
34
|
-
link_to image.attachment_file_name, admin_custom_image_path(image)
|
35
|
-
end
|
36
|
-
|
37
|
-
column :preview do |image|
|
38
|
-
image_tag image.attachment.url(:thumb)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
show do
|
43
|
-
attributes_table do
|
44
|
-
row :title do |image|
|
45
|
-
image.attachment_file_name
|
46
|
-
end
|
47
|
-
row :preview do |image|
|
48
|
-
image_tag image.attachment.url(:original)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
form partial: 'add_images'
|
57
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<div id="my_file_uploader"></div>
|
2
|
-
<script type="text/javascript">
|
3
|
-
var uploader = new qq.FileUploader({
|
4
|
-
element: document.getElementById('my_file_uploader'),
|
5
|
-
action: "<%= add_files_admin_custom_images_path %>",
|
6
|
-
params: { "authenticity_token": "<%= form_authenticity_token %>" },
|
7
|
-
customHeaders: { "X-File-Upload": "true" }
|
8
|
-
});
|
9
|
-
</script>
|