refinerycms-image_rotators 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  module Refinery
2
2
  module ImageRotators
3
3
  def self.version
4
- %{0.1.3}
4
+ %{0.2.0}
5
5
  end
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module Refinery
7
7
  initializer "static assets" do |app|
8
8
  app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
9
9
  end
10
-
10
+
11
11
  config.after_initialize do
12
12
  Refinery::Plugin.register do |plugin|
13
13
  plugin.name = "image_rotators"
@@ -15,6 +15,12 @@ module Refinery
15
15
  plugin.activity = {:class => ImageRotator, :title => 'title'}
16
16
  end
17
17
  end
18
+
19
+ config.to_prepare do
20
+ Image.class_eval do
21
+ has_many :image_rotator_images, :dependent => :destroy
22
+ end
23
+ end
18
24
  end
19
25
  end
20
26
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-image_rotators
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacob Swanner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-21 00:00:00 -04:00
18
+ date: 2011-04-07 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -30,7 +30,6 @@ extra_rdoc_files: []
30
30
  files:
31
31
  - app/controllers/admin/image_rotator_images_controller.rb
32
32
  - app/controllers/admin/image_rotators_controller.rb
33
- - app/models/image.rb
34
33
  - app/models/image_rotator.rb
35
34
  - app/models/image_rotator_image.rb
36
35
  - app/views/admin/image_rotator_images/_form.html.erb
@@ -1,68 +0,0 @@
1
- class Image < ActiveRecord::Base
2
-
3
- has_many :image_rotator_images, :dependent => :destroy
4
-
5
- # What is the max image size a user can upload
6
- MAX_SIZE_IN_MB = 20
7
-
8
- image_accessor :image
9
-
10
- validates :image, :presence => { :message => ::I18n.t('image_specify_for_upload') },
11
- :length => { :maximum => MAX_SIZE_IN_MB.megabytes,
12
- :message => ::I18n.t('image_should_be_smaller_than_max_image_size',
13
- :max_image_size => MAX_SIZE_IN_MB.megabytes) }
14
- validates_property :mime_type, :of => :image, :in => %w(image/jpeg image/png image/gif),
15
- :message => ::I18n.t('image_must_be_these_formats')
16
-
17
- # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
18
- acts_as_indexed :fields => [:title]
19
-
20
- # when a dialog pops up with images, how many images per page should there be
21
- PAGES_PER_DIALOG = 18
22
-
23
- # when a dialog pops up with images, but that dialog has image resize options
24
- # how many images per page should there be
25
- PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS = 12
26
-
27
- # when listing images out in the admin area, how many images should show per page
28
- PAGES_PER_ADMIN_INDEX = 20
29
-
30
- delegate :size, :mime_type, :url, :width, :height, :to => :image
31
-
32
- class << self
33
- # How many images per page should be displayed?
34
- def per_page(dialog = false, has_size_options = false)
35
- if dialog
36
- unless has_size_options
37
- PAGES_PER_DIALOG
38
- else
39
- PAGES_PER_DIALOG_THAT_HAS_SIZE_OPTIONS
40
- end
41
- else
42
- PAGES_PER_ADMIN_INDEX
43
- end
44
- end
45
- end
46
-
47
- # Get a thumbnail job object given a geometry.
48
- def thumbnail(geometry = nil)
49
- if geometry.is_a?(Symbol)
50
- if (sizes = RefinerySetting.find_or_set(:image_thumbnails, {})) and sizes.keys.include?(geometry)
51
- geometry = sizes[geometry].presence
52
- end
53
- end
54
-
55
- if geometry.present? && !geometry.is_a?(Symbol)
56
- self.image.thumb(geometry)
57
- else
58
- self.image
59
- end
60
- end
61
-
62
- # Returns a titleized version of the filename
63
- # my_file.jpg returns My File
64
- def title
65
- CGI::unescape(self.image_name).gsub(/\.\w+$/, '').titleize
66
- end
67
-
68
- end