adminpanel 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +0 -1
- data/README.md +9 -6
- data/Rakefile +1 -1
- data/app/helpers/adminpanel/application_helper.rb +2 -2
- data/app/helpers/adminpanel/custom_form_builder.rb +45 -9
- data/app/helpers/adminpanel/shared_pages_helper.rb +10 -3
- data/app/models/adminpanel/gallery.rb +6 -0
- data/app/models/adminpanel/image.rb +3 -8
- data/app/models/adminpanel/section.rb +16 -6
- data/app/uploaders/adminpanel/image_uploader.rb +2 -2
- data/app/views/adminpanel/categories/_categories_table.html.erb +1 -1
- data/app/views/adminpanel/categories/index.html.erb +9 -8
- data/app/views/adminpanel/galleries/edit.html.erb +3 -10
- data/app/views/adminpanel/galleries/index.html.erb +2 -2
- data/app/views/adminpanel/galleries/new.html.erb +3 -3
- data/app/views/adminpanel/sections/edit.html.erb +11 -15
- data/app/views/shared/_form_fields.html.erb +16 -9
- data/app/views/shared/_image_fields.html.erb +2 -23
- data/app/views/shared/_init_editor.html.erb +12 -12
- data/app/views/shared/show.html.erb +4 -3
- data/config/locales/es.yml +3 -0
- data/lib/adminpanel.rb +1 -1
- data/lib/adminpanel/active_record/adminpanel_extension.rb +142 -0
- data/lib/adminpanel/version.rb +1 -1
- data/lib/generators/adminpanel/gallery/gallery_generator.rb +41 -0
- data/lib/generators/adminpanel/gallery/templates/gallery_migration.rb +11 -0
- data/lib/generators/adminpanel/gallery/templates/gallery_template.rb +8 -0
- data/lib/generators/adminpanel/gallery/templates/uploader.rb +86 -0
- data/lib/generators/adminpanel/initialize/initialize_generator.rb +22 -12
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_categories_table.rb +1 -1
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb +3 -4
- data/lib/generators/adminpanel/initialize/templates/section_uploader.rb +86 -0
- data/lib/generators/adminpanel/resource/resource_generator.rb +72 -22
- data/lib/tasks/adminpanel/adminpanel.rake +1 -1
- data/spec/dummy/.gitignore +2 -1
- data/spec/dummy/app/controllers/adminpanel/categories_controller.rb +2 -2
- data/spec/dummy/app/controllers/adminpanel/products_controller.rb +3 -3
- data/spec/dummy/app/models/adminpanel/categorization.rb +17 -17
- data/spec/dummy/app/models/adminpanel/photo.rb +8 -0
- data/spec/dummy/app/models/adminpanel/product.rb +49 -26
- data/spec/dummy/app/uploader/adminpanel/photo_uploader.rb +86 -0
- data/spec/dummy/app/uploader/adminpanel/section_uploader.rb +86 -0
- data/spec/features/section_pages_spec.rb +4 -4
- data/spec/features/shared_pages_spec.rb +15 -15
- data/spec/generators/gallery_generator_spec.rb +53 -0
- data/spec/generators/initialize_generator_spec.rb +19 -12
- data/spec/generators/resource_generator_spec.rb +44 -37
- data/spec/support/define_factory_models.rb +3 -5
- data/spec/support/test_database.rb +8 -3
- data/spec/tasks/adminpanel_rake_spec.rb +5 -5
- metadata +18 -7
- data/app/helpers/adminpanel/class_definitions_helper.rb +0 -10
- data/app/views/adminpanel/sections/_image_fields.html.erb +0 -24
- data/lib/adminpanel/active_record_extension.rb +0 -123
@@ -17,7 +17,7 @@ class CreateAdminpanelTables < ActiveRecord::Migration
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def change
|
22
22
|
create_table :adminpanel_users do |t|
|
23
23
|
t.string :name
|
@@ -37,8 +37,7 @@ class CreateAdminpanelTables < ActiveRecord::Migration
|
|
37
37
|
|
38
38
|
create_table :adminpanel_images do |t|
|
39
39
|
t.string :file
|
40
|
-
t.integer :
|
41
|
-
t.string :model
|
40
|
+
t.integer :section_id
|
42
41
|
t.timestamps
|
43
42
|
end
|
44
43
|
|
@@ -54,4 +53,4 @@ class CreateAdminpanelTables < ActiveRecord::Migration
|
|
54
53
|
|
55
54
|
add_index :adminpanel_sections, [:key]
|
56
55
|
end
|
57
|
-
end
|
56
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Adminpanel
|
2
|
+
class SectionUploader < CarrierWave::Uploader::Base
|
3
|
+
include CarrierWave::RMagick
|
4
|
+
|
5
|
+
storage :file
|
6
|
+
|
7
|
+
def root
|
8
|
+
Rails.root.join 'public/'
|
9
|
+
end
|
10
|
+
|
11
|
+
def store_dir
|
12
|
+
"uploads/image/#{mounted_as}/#{model.id}"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Process files as they are uploaded:
|
16
|
+
# process :resize_to_fill => [1366, 768]
|
17
|
+
|
18
|
+
# THE THUMB VERSION IS NECESSARY!!!!
|
19
|
+
version :thumb do
|
20
|
+
process :resize_to_limit => [220, 220]
|
21
|
+
end
|
22
|
+
|
23
|
+
# however, you can create your own versions:
|
24
|
+
# version :awesome do
|
25
|
+
# process :reside_and_pad => [120, 900]
|
26
|
+
# end
|
27
|
+
|
28
|
+
# resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity)
|
29
|
+
#
|
30
|
+
# Resize the image to fit within the specified dimensions while retaining
|
31
|
+
# the original aspect ratio. If necessary, will pad the remaining area with
|
32
|
+
# the given color, which defaults to transparent (for gif and png, white for jpeg).
|
33
|
+
#
|
34
|
+
# width (Integer)
|
35
|
+
# the width to scale the image to
|
36
|
+
# height (Integer)
|
37
|
+
# the height to scale the image to
|
38
|
+
# background (String, :transparent)
|
39
|
+
# the color of the background as a hexcode, like “ff45de“
|
40
|
+
# gravity (Magick::GravityType)
|
41
|
+
# how to position the image
|
42
|
+
|
43
|
+
# resize_to_fill(width, height)
|
44
|
+
#
|
45
|
+
# From the RMagick documentation: “Resize the image to fit within the
|
46
|
+
# specified dimensions while retaining the aspect ratio of the original image.
|
47
|
+
# If necessary, crop the image in the larger dimension.“
|
48
|
+
#
|
49
|
+
# See even www.imagemagick.org/RMagick/doc/image3.html#resize_to_fill
|
50
|
+
#
|
51
|
+
# width (Integer)
|
52
|
+
# the width to scale the image to
|
53
|
+
# height (Integer)
|
54
|
+
# the height to scale the image to
|
55
|
+
|
56
|
+
# resize_to_fit(width, height)
|
57
|
+
#
|
58
|
+
# From the RMagick documentation: “Resize the image to fit within the
|
59
|
+
# specified dimensions while retaining the original aspect ratio. The image
|
60
|
+
# may be shorter or narrower than specified in the smaller dimension but
|
61
|
+
# will not be larger than the specified values.“
|
62
|
+
#
|
63
|
+
# See even www.imagemagick.org/RMagick/doc/image3.html#resize_to_fit
|
64
|
+
#
|
65
|
+
# width (Integer)
|
66
|
+
# the width to scale the image to
|
67
|
+
# height (Integer)
|
68
|
+
# the height to scale the image to
|
69
|
+
|
70
|
+
# resize_to_limit(width, height)
|
71
|
+
#
|
72
|
+
# Resize the image to fit within the specified dimensions while retaining
|
73
|
+
# the original aspect ratio. Will only resize the image if it is larger than
|
74
|
+
# the specified dimensions. The resulting image may be shorter or narrower
|
75
|
+
# than specified in the smaller dimension but will not be larger than the
|
76
|
+
# specified values.
|
77
|
+
#
|
78
|
+
# width (Integer)
|
79
|
+
# the width to scale the image to
|
80
|
+
# height (Integer)
|
81
|
+
# the height to scale the image to
|
82
|
+
def extension_white_list
|
83
|
+
%w(jpg jpeg png)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,17 +1,12 @@
|
|
1
|
-
require "action_view"
|
2
|
-
|
1
|
+
# require "action_view"
|
2
|
+
require 'rails/generators/active_record'
|
3
3
|
module Adminpanel
|
4
4
|
module Generators
|
5
|
-
class ResourceGenerator <
|
6
|
-
|
5
|
+
class ResourceGenerator < ActiveRecord::Generators::Base
|
7
6
|
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
argument :resource_name, :type => :string, :required => true
|
9
|
-
argument :fields, :type => :array, :default => "name:string"
|
10
7
|
desc "Generate the resource files necessary to use a model"
|
11
8
|
|
12
|
-
|
13
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
|
-
end
|
9
|
+
argument :fields, :type => :array, :default => "name:string"
|
15
10
|
|
16
11
|
def create_model
|
17
12
|
template 'resource.rb', "app/models/adminpanel/#{lower_name}.rb"
|
@@ -40,7 +35,7 @@ module Adminpanel
|
|
40
35
|
end
|
41
36
|
|
42
37
|
def lower_name
|
43
|
-
|
38
|
+
name.singularize.downcase
|
44
39
|
end
|
45
40
|
|
46
41
|
def capitalized_resource
|
@@ -88,7 +83,7 @@ module Adminpanel
|
|
88
83
|
assign_attributes_variables(attribute)
|
89
84
|
|
90
85
|
if @attr_type == "images"
|
91
|
-
attr_string = attr_string + "
|
86
|
+
attr_string = attr_string + ":#{@attr_field.pluralize.downcase}_attributes, "
|
92
87
|
elsif @attr_type == "belongs_to"
|
93
88
|
attr_string = "#{attr_string}:#{belongs_to_field(@attr_field)}, "
|
94
89
|
elsif @attr_type == "has_many" || @attr_type == "has_many_through"
|
@@ -115,17 +110,17 @@ module Adminpanel
|
|
115
110
|
assign_attributes_variables(attribute)
|
116
111
|
|
117
112
|
if @attr_type == "string" || @attr_type == "float"
|
118
|
-
form_hash = form_hash + "
|
113
|
+
form_hash = form_hash + "#{attribute_hash('text_field')}"
|
119
114
|
elsif @attr_type == "text" || @attr_type == "wysiwyg"
|
120
|
-
form_hash = form_hash + "
|
115
|
+
form_hash = form_hash + "#{attribute_hash('wysiwyg_field')}"
|
121
116
|
elsif @attr_type == "integer"
|
122
|
-
form_hash = form_hash + "
|
117
|
+
form_hash = form_hash + "#{attribute_hash('number_field')}"
|
123
118
|
elsif @attr_type == "datepicker"
|
124
|
-
form_hash = form_hash + "
|
119
|
+
form_hash = form_hash + "#{attribute_hash('datepicker')}"
|
125
120
|
elsif @attr_type == "images"
|
126
|
-
form_hash = form_hash + "
|
121
|
+
form_hash = form_hash + "#{file_field_hash}"
|
127
122
|
elsif @attr_type == "belongs_to"
|
128
|
-
form_hash = form_hash + "
|
123
|
+
form_hash = form_hash + "#{belongs_to_attribute_hash(belongs_to_field(@attr_field))}"
|
129
124
|
elsif @attr_type == "has_many" || @attr_type == "has_many_through"
|
130
125
|
if models_in_parameter(@attr_field).second.nil?
|
131
126
|
through_model = @attr_field
|
@@ -133,12 +128,64 @@ module Adminpanel
|
|
133
128
|
through_model = models_in_parameter(@attr_field).first
|
134
129
|
end
|
135
130
|
through_model = resource_class_name(through_model)
|
136
|
-
form_hash = form_hash + "
|
131
|
+
# form_hash = form_hash + "#{relational_attribute_hash('belongs_to')}"
|
132
|
+
form_hash = form_hash + "\n\t\t\t\t{'#{has_many_field(through_model)}' => {'type' => 'has_many', 'model' => 'Adminpanel::#{through_model}', 'name' => '#{has_many_field(through_model)}'}},"
|
137
133
|
end
|
138
134
|
end
|
139
135
|
form_hash
|
140
136
|
end
|
141
137
|
|
138
|
+
def attribute_hash(type)
|
139
|
+
"#{attribute_name} => {#{form_type(type)}," +
|
140
|
+
"#{name_type}," +
|
141
|
+
"#{label_type}," +
|
142
|
+
"#{placeholder_type}}\n\t\t\t},"
|
143
|
+
end
|
144
|
+
|
145
|
+
def file_field_hash
|
146
|
+
"#{starting_hash(@attr_field.downcase.pluralize)} => {#{form_type('adminpanel_file_field')}," +
|
147
|
+
"#{name_type}," +
|
148
|
+
"#{label_type}," +
|
149
|
+
"#{placeholder_type}}\n\t\t\t},"
|
150
|
+
end
|
151
|
+
|
152
|
+
def belongs_to_attribute_hash(name)
|
153
|
+
"#{starting_hash(name)} => {#{form_type('belongs_to')}," +
|
154
|
+
"#{model_type}," +
|
155
|
+
"#{name_type}," +
|
156
|
+
"#{label_type}," +
|
157
|
+
"#{placeholder_type}}\n\t\t\t},"
|
158
|
+
end
|
159
|
+
|
160
|
+
def attribute_name
|
161
|
+
"\n\t\t\t{\n\t\t\t\t'#{@attr_field}'"
|
162
|
+
end
|
163
|
+
|
164
|
+
def starting_hash(name)
|
165
|
+
"\n\t\t\t{\n\t\t\t\t'#{name}'"
|
166
|
+
end
|
167
|
+
|
168
|
+
def form_type(type)
|
169
|
+
"\n\t\t\t\t\t'type' => '#{type}'"
|
170
|
+
end
|
171
|
+
|
172
|
+
def name_type
|
173
|
+
"\n\t\t\t\t\t'name' => '#{@attr_field}'"
|
174
|
+
end
|
175
|
+
|
176
|
+
def label_type
|
177
|
+
"\n\t\t\t\t\t'label' => '#{@attr_field}'"
|
178
|
+
end
|
179
|
+
|
180
|
+
def placeholder_type
|
181
|
+
"\n\t\t\t\t\t'placeholder' => '#{@attr_field}'"
|
182
|
+
end
|
183
|
+
|
184
|
+
def model_type
|
185
|
+
"\n\t\t\t\t\t'model' => 'Adminpanel::#{resource_class_name(@attr_field)}'"
|
186
|
+
|
187
|
+
end
|
188
|
+
|
142
189
|
def migration_string(field, type)
|
143
190
|
if type == "datepicker"
|
144
191
|
"t.string :#{field}"
|
@@ -198,11 +245,14 @@ module Adminpanel
|
|
198
245
|
end
|
199
246
|
|
200
247
|
def image_association
|
201
|
-
|
202
|
-
|
203
|
-
"accepts_nested_attributes_for :images, :allow_destroy => true\n\t\t" +
|
204
|
-
"#remember to change the association if you change this model display_name\n\t\t"
|
248
|
+
generate_gallery
|
249
|
+
return "\n\t\tmount_images :#{@attr_field.pluralize.downcase}\n"
|
205
250
|
end
|
251
|
+
|
252
|
+
def generate_gallery
|
253
|
+
Rails::Generators.invoke("adminpanel:gallery", [@attr_field, lower_name])
|
254
|
+
end
|
255
|
+
|
206
256
|
end
|
207
257
|
end
|
208
258
|
end
|
@@ -2,7 +2,7 @@ namespace :adminpanel do
|
|
2
2
|
desc "Interact with adminpanel models :D"
|
3
3
|
|
4
4
|
task :section, [:section, :name, :type] => :environment do |t, args|
|
5
|
-
args.with_defaults(:section => "home", :name => "greeting", :type => "
|
5
|
+
args.with_defaults(:section => "home", :name => "greeting", :type => "")
|
6
6
|
puts "Creating #{args[:name]} in #{args[:section]} section"
|
7
7
|
|
8
8
|
s = Adminpanel::Section.new(
|
data/spec/dummy/.gitignore
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
|
3
|
-
|
4
|
-
end
|
2
|
+
class ProductsController < Adminpanel::ApplicationController
|
3
|
+
end
|
4
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
|
3
|
-
|
2
|
+
class Categorization < ActiveRecord::Base
|
3
|
+
attr_accessible :product_id, :category_id
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
belongs_to :product
|
6
|
+
belongs_to :category
|
7
7
|
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def self.display_name
|
17
|
-
"Categorization"
|
18
|
-
end
|
9
|
+
def self.form_attributes
|
10
|
+
[
|
11
|
+
{"product_id" => {"type" => "belongs_to", "model" => "Adminpanel::Product", "name" => "product_id"}},
|
12
|
+
{"category_id" => {"type" => "belongs_to", "model" => "Adminpanel::Category", "name" => "category_id"}},
|
13
|
+
]
|
14
|
+
end
|
19
15
|
|
20
|
-
|
21
|
-
|
22
|
-
# end
|
16
|
+
def self.display_name
|
17
|
+
"Categorization"
|
23
18
|
end
|
19
|
+
|
20
|
+
# def self.icon
|
21
|
+
# "icon-truck"
|
22
|
+
# end
|
23
|
+
end
|
24
24
|
end
|
@@ -1,33 +1,56 @@
|
|
1
1
|
module Adminpanel
|
2
|
-
|
3
|
-
|
4
|
-
has_many :images, :foreign_key => "foreign_key", :conditions => { :model => "product" }
|
5
|
-
has_many :categorizations
|
6
|
-
has_many :categories, :through => :categorizations, :dependent => :destroy
|
2
|
+
class Product < ActiveRecord::Base
|
3
|
+
attr_accessible :price, :name, :photos_attributes, :category_ids, :description
|
7
4
|
|
8
|
-
|
9
|
-
|
5
|
+
has_many :categorizations
|
6
|
+
has_many :categories, :through => :categorizations
|
7
|
+
mount_images :photos
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
validates_presence_of :name
|
10
|
+
validates_presence_of :price
|
11
|
+
validates_presence_of :description
|
14
12
|
|
15
|
-
|
16
|
-
[
|
17
|
-
{"category_ids" => {"type" => "has_many", "model" => "Adminpanel::Category", "name" => "category_ids"}},
|
18
|
-
{"price" => {"type" => "text_field", "name" => "price", "label" => "price", "placeholder" => "price"}},
|
19
|
-
{"name" => {"type" => "text_field", "name" => "name", "label" => "name", "placeholder" => "name"}},
|
20
|
-
{"description" => {"type" => "wysiwyg_field", "name" => "description", "label" => "description", "placeholder" => "description"}},
|
21
|
-
{"image" => {"type" => "adminpanel_file_field", "name" => "image"}},
|
22
|
-
]
|
23
|
-
end
|
13
|
+
def self.form_attributes
|
24
14
|
|
25
|
-
def self.display_name
|
26
|
-
"Product"
|
27
|
-
end
|
28
15
|
|
29
|
-
|
30
|
-
|
31
|
-
|
16
|
+
[
|
17
|
+
{"category_ids" => {"type" => "has_many", "model" => "Adminpanel::Category", "name" => "category_ids"}},
|
18
|
+
{
|
19
|
+
'name' => {
|
20
|
+
'type' => 'text_field',
|
21
|
+
'name' => 'name',
|
22
|
+
'label' => 'name',
|
23
|
+
'placeholder' => 'name'}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
'price' => {
|
27
|
+
'type' => 'text_field',
|
28
|
+
'name' => 'price'
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{
|
32
|
+
'photos' => {
|
33
|
+
'type' => 'adminpanel_file_field',
|
34
|
+
'name' => 'photo',
|
35
|
+
'label' => 'photo',
|
36
|
+
'placeholder' => 'photo'}
|
37
|
+
},
|
38
|
+
{
|
39
|
+
'description' => {
|
40
|
+
'type' => 'wysiwyg_field',
|
41
|
+
'name' => 'description',
|
42
|
+
'label' => 'description',
|
43
|
+
'placeholder' => 'description'}
|
44
|
+
},
|
45
|
+
]
|
32
46
|
end
|
33
|
-
|
47
|
+
|
48
|
+
def self.display_name
|
49
|
+
"Product"
|
50
|
+
end
|
51
|
+
|
52
|
+
# def self.icon
|
53
|
+
# "icon-truck"
|
54
|
+
# end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Adminpanel
|
2
|
+
class PhotoUploader < CarrierWave::Uploader::Base
|
3
|
+
include CarrierWave::RMagick
|
4
|
+
|
5
|
+
storage :file
|
6
|
+
|
7
|
+
def root
|
8
|
+
Rails.root.join 'public/'
|
9
|
+
end
|
10
|
+
|
11
|
+
def store_dir
|
12
|
+
"uploads/image/#{mounted_as}/#{model.id}"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Process files as they are uploaded:
|
16
|
+
# process :resize_to_fill => [1366, 768]
|
17
|
+
|
18
|
+
# THE THUMB VERSION IS NECESSARY!!!!
|
19
|
+
version :thumb do
|
20
|
+
process :resize_to_limit => [220, 220]
|
21
|
+
end
|
22
|
+
|
23
|
+
# however, you can create your own versions:
|
24
|
+
# version :awesome do
|
25
|
+
# process :reside_and_pad => [120, 900]
|
26
|
+
# end
|
27
|
+
|
28
|
+
# resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity)
|
29
|
+
#
|
30
|
+
# Resize the image to fit within the specified dimensions while retaining
|
31
|
+
# the original aspect ratio. If necessary, will pad the remaining area with
|
32
|
+
# the given color, which defaults to transparent (for gif and png, white for jpeg).
|
33
|
+
#
|
34
|
+
# width (Integer)
|
35
|
+
# the width to scale the image to
|
36
|
+
# height (Integer)
|
37
|
+
# the height to scale the image to
|
38
|
+
# background (String, :transparent)
|
39
|
+
# the color of the background as a hexcode, like “ff45de“
|
40
|
+
# gravity (Magick::GravityType)
|
41
|
+
# how to position the image
|
42
|
+
|
43
|
+
# resize_to_fill(width, height)
|
44
|
+
#
|
45
|
+
# From the RMagick documentation: “Resize the image to fit within the
|
46
|
+
# specified dimensions while retaining the aspect ratio of the original image.
|
47
|
+
# If necessary, crop the image in the larger dimension.“
|
48
|
+
#
|
49
|
+
# See even www.imagemagick.org/RMagick/doc/image3.html#resize_to_fill
|
50
|
+
#
|
51
|
+
# width (Integer)
|
52
|
+
# the width to scale the image to
|
53
|
+
# height (Integer)
|
54
|
+
# the height to scale the image to
|
55
|
+
|
56
|
+
# resize_to_fit(width, height)
|
57
|
+
#
|
58
|
+
# From the RMagick documentation: “Resize the image to fit within the
|
59
|
+
# specified dimensions while retaining the original aspect ratio. The image
|
60
|
+
# may be shorter or narrower than specified in the smaller dimension but
|
61
|
+
# will not be larger than the specified values.“
|
62
|
+
#
|
63
|
+
# See even www.imagemagick.org/RMagick/doc/image3.html#resize_to_fit
|
64
|
+
#
|
65
|
+
# width (Integer)
|
66
|
+
# the width to scale the image to
|
67
|
+
# height (Integer)
|
68
|
+
# the height to scale the image to
|
69
|
+
|
70
|
+
# resize_to_limit(width, height)
|
71
|
+
#
|
72
|
+
# Resize the image to fit within the specified dimensions while retaining
|
73
|
+
# the original aspect ratio. Will only resize the image if it is larger than
|
74
|
+
# the specified dimensions. The resulting image may be shorter or narrower
|
75
|
+
# than specified in the smaller dimension but will not be larger than the
|
76
|
+
# specified values.
|
77
|
+
#
|
78
|
+
# width (Integer)
|
79
|
+
# the width to scale the image to
|
80
|
+
# height (Integer)
|
81
|
+
# the height to scale the image to
|
82
|
+
def extension_white_list
|
83
|
+
%w(jpg jpeg png)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|