photo_folder 1.1.0 → 1.1.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.
@@ -149,4 +149,12 @@ class PhotoCollection < ActiveRecord::Base
149
149
  end
150
150
  end
151
151
  end
152
+
153
+ def set_oldest_date
154
+ update_attribute :oldest_date, photos.collect(&:date).reject(&:nil?).min || 0
155
+ end
156
+
157
+ def set_newest_date
158
+ update_attribute :newest_date, photos.collect(&:date).reject(&:nil?).max || 0
159
+ end
152
160
  end
@@ -75,6 +75,8 @@ module PhotoFolder
75
75
  t.string "path"
76
76
  t.integer "parent_id"
77
77
  t.integer "position"
78
+ t.integer "oldest_date"
79
+ t.integer "newest_date"
78
80
  t.text "meta"
79
81
  end
80
82
  schema_created = true
@@ -251,9 +253,13 @@ module PhotoFolder
251
253
  if photos_to_add.length > 0
252
254
  photos_to_add.each do |path|
253
255
  puts "Adding photo: #{path}"
254
- photo = Photo.create :path => path
255
- if photo.set_meta
256
- puts "Setting meta data for #{path} from #{photo.meta_file_path}"
256
+ begin
257
+ photo = Photo.create :path => path
258
+ if photo.set_meta
259
+ puts "Setting meta data for #{path} from #{photo.meta_file_path}"
260
+ end
261
+ rescue
262
+ puts "Unable to add photo: #{path}"
257
263
  end
258
264
  end
259
265
  else
@@ -318,7 +324,10 @@ module PhotoFolder
318
324
  puts "Adding title card to root from #{PhotoCollection.title_card_path}"
319
325
  end
320
326
  PhotoCollection.set_correct_positions(PhotoCollection.find_all_by_parent_id(0))
327
+ puts "Setting oldest and newest dates for collections."
321
328
  PhotoCollection.find(:all).each do |photo_collection|
329
+ photo_collection.set_oldest_date
330
+ photo_collection.set_newest_date
322
331
  if photo_collection.positions
323
332
  puts "Setting positions for #{photo_collection.name} from #{photo_collection.positions_file_path}"
324
333
  photo_collection.set_correct_positions
@@ -337,4 +346,4 @@ module PhotoFolder
337
346
  PhotoFolder::write_database_to_file(json_location)
338
347
  end
339
348
  end
340
- end
349
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "photo_folder"
3
- s.version = "1.1.0"
3
+ s.version = "1.1.1"
4
4
  s.date = "2010-05-27"
5
5
  s.summary = "JavaScript gallery"
6
6
  s.email = "ryan@syntacticx.com"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photo_folder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Johnson