polygallery 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2220d771dc5f8a3fd23774aa1634b548b19cf7f
4
- data.tar.gz: 59130d77b7a9a7911128fab5b9a43cd0a170b744
3
+ metadata.gz: e0a3c6b4e971bb81a4dd78e1a5ec302567ed4cb8
4
+ data.tar.gz: ec32be1af52c2330bc71e19c5c7fefe1661b4e30
5
5
  SHA512:
6
- metadata.gz: e0fca5ba2a6d89cd400816b01d69e27ce2b8511934094c2a1288051b9d02aa80b0b37329825bef633e5fd41c1c1bd9e88fe9d75d40e8317b29a463feefef8e34
7
- data.tar.gz: eec43e1ed442f0790aa38e306797eef002dcba0b454b0accdeda9901bf453c8af681c068d6aa01769bbac7a31e9da09c66d34a559f5860161f8d2d6225ca54cb
6
+ metadata.gz: d1610028948fd06e4aef2f24ac1e827abe7d0a847d0f402b282ca59f308bf9d9ef947f60ea77a137a855a49d90f4b07cc29755d51fba5ca394412d2f59823d2c
7
+ data.tar.gz: 20abcb8fa59f46442c4ca5d998f917122d6f6b570d74bc9ff8dd870edbba9aabd804c5490c8f430d7ef4daadcb0d1163b5d68608db1060307e9c7034fadbb175
@@ -114,6 +114,15 @@ module Polygallery
114
114
  self.class.init_attachment paperclip_settings
115
115
  end
116
116
 
117
+ def remote_url(style=nil)
118
+ host = ActionController::Base.asset_host
119
+ host = "http://#{host}" unless host.nil? || host =~ /^http/
120
+ path = photo.url(style)
121
+ url = (host||'') + (path||'')
122
+ url unless url.blank?
123
+ end
124
+ def thumb_url; remote_url(:thumb) end
125
+
117
126
  end
118
127
  end
119
128
  end
@@ -183,19 +183,13 @@ module Polygallery
183
183
  build_gallery_associations.map(&:build_first_photo)
184
184
  end
185
185
 
186
- def first_photo
187
- return unless self.class.has_polygallery?
188
- first_p = nil
189
- self.class.polygalleries.each do |pg|
190
- settings_for_this_gallery = send :"#{pg.to_s}_settings"
191
- ptos = send(settings_for_this_gallery[:association_names][:photos])
192
- .select{|p| p.photo.file? }
193
- next if ptos.empty?
194
- first_p = ptos.first.photo
195
- break
196
- end
197
- first_p || Photo.new.photo
186
+ def first_polyphoto
187
+ return Photo.new unless gallery_associations.any?
188
+ fg = gallery_associations.to_a.find{|pg| pg.photos.any? }
189
+ return Photo.new if fg.nil?
190
+ fg.first_photo
198
191
  end
192
+ def first_photo; first_polyphoto.photo end
199
193
 
200
194
  def ensure_galleryable_set
201
195
  gallery_associations.each do |ga|
@@ -211,6 +205,10 @@ module Polygallery
211
205
  def prune_empty_photos
212
206
  gallery_associations.each(&:prune_empty_photos) end
213
207
 
208
+ def remote_urls_for_polyphotos(style=nil)
209
+ gallery_associations.map{|ga| ga.remote_urls(style) }.flatten end
210
+ def thumb_url; first_polyphoto.thumb_url end
211
+
214
212
  end
215
213
  end
216
214
  end
@@ -165,6 +165,13 @@ module Polygallery
165
165
  end }
166
166
  end
167
167
 
168
+ def remote_urls(style=nil); photos.map{|p| p.remote_url style } || [] end
169
+ def thumb_url; first_photo.thumb_url end
170
+ def first_photo
171
+ # TODO: some kind of selection
172
+ photos.first || Photo.new
173
+ end
174
+
168
175
  end
169
176
  end
170
177
  end
@@ -1,3 +1,3 @@
1
1
  module Polygallery
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polygallery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MacKinley Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails