tb_photos 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +8 -8
  2. data/README.markdown +15 -12
  3. data/Rakefile +1 -1
  4. data/app/assets/images/{spud → admin}/photos/buttons/cog_16x16.png +0 -0
  5. data/app/assets/images/{spud → admin}/photos/buttons/x_16x16.png +0 -0
  6. data/app/assets/images/{spud → admin}/photos/photo_albums_thumb.png +0 -0
  7. data/app/assets/images/{spud → admin}/photos/photo_albums_thumb@2x.png +0 -0
  8. data/app/assets/javascripts/admin/photos/application.js +1 -0
  9. data/app/assets/javascripts/{spud/admin → admin/photos}/photos.js +105 -46
  10. data/app/assets/stylesheets/{spud/admin/photos.css → admin/photos/application.css.scss} +8 -8
  11. data/app/controllers/{spud/admin → admin}/photo_albums_controller.rb +6 -7
  12. data/app/controllers/{spud/admin → admin}/photo_galleries_controller.rb +6 -7
  13. data/app/controllers/{spud/admin → admin}/photos_controller.rb +3 -4
  14. data/app/controllers/photo_albums_controller.rb +5 -16
  15. data/app/controllers/photo_galleries_controller.rb +1 -1
  16. data/app/helpers/admin/photo_albums_helper.rb +2 -0
  17. data/app/helpers/admin/photo_galleries_helper.rb +2 -0
  18. data/app/helpers/{spud/admin → admin}/photos_helper.rb +1 -1
  19. data/app/models/spud_photo.rb +10 -6
  20. data/app/models/spud_photo_album.rb +1 -1
  21. data/app/views/{spud/admin → admin}/photo_albums/_album.html.erb +2 -2
  22. data/app/views/{spud/admin → admin}/photo_albums/_form.html.erb +3 -3
  23. data/app/views/{spud/admin → admin}/photo_albums/destroy.js.erb +0 -0
  24. data/app/views/admin/photo_albums/edit.html.erb +1 -0
  25. data/app/views/{spud/admin → admin}/photo_albums/index.html.erb +1 -1
  26. data/app/views/admin/photo_albums/new.html.erb +1 -0
  27. data/app/views/{spud/admin → admin}/photo_galleries/_form.html.erb +2 -2
  28. data/app/views/admin/photo_galleries/destroy.js.erb +1 -0
  29. data/app/views/admin/photo_galleries/edit.html.erb +1 -0
  30. data/app/views/{spud/admin → admin}/photo_galleries/index.html.erb +3 -3
  31. data/app/views/admin/photo_galleries/new.html.erb +1 -0
  32. data/app/views/{spud/admin → admin}/photos/_form.html.erb +2 -2
  33. data/app/views/{spud/admin → admin}/photos/_photo.html.erb +1 -1
  34. data/app/views/admin/photos/destroy.js.erb +1 -0
  35. data/app/views/{spud/admin → admin}/photos/edit.html.erb +0 -0
  36. data/app/views/{spud/admin → admin}/photos/index.html.erb +0 -0
  37. data/app/views/{spud/admin → admin}/photos/new.html.erb +0 -0
  38. data/app/views/{spud/admin → admin}/photos/show.js.erb +2 -2
  39. data/app/views/layouts/admin/spud_photos.html.erb +8 -0
  40. data/app/views/photo_albums/show.html.erb +2 -2
  41. data/app/views/photo_galleries/index.html.erb +2 -2
  42. data/config/routes.rb +6 -8
  43. data/lib/spud_photos/configuration.rb +9 -2
  44. data/lib/spud_photos/engine.rb +8 -6
  45. data/lib/spud_photos/version.rb +1 -1
  46. metadata +36 -35
  47. data/app/helpers/spud/admin/photo_albums_helper.rb +0 -2
  48. data/app/helpers/spud/admin/photo_galleries_helper.rb +0 -2
  49. data/app/views/layouts/spud/admin/spud_photos.html.erb +0 -8
  50. data/app/views/spud/admin/photo_albums/edit.html.erb +0 -1
  51. data/app/views/spud/admin/photo_albums/new.html.erb +0 -1
  52. data/app/views/spud/admin/photo_galleries/destroy.js.erb +0 -1
  53. data/app/views/spud/admin/photo_galleries/edit.html.erb +0 -1
  54. data/app/views/spud/admin/photo_galleries/new.html.erb +0 -1
  55. data/app/views/spud/admin/photos/destroy.js.erb +0 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmE0OWRiMGJhZjFhYzljNGVkZjQxMGFhMzY2N2I4ZTZiMTNjYzFjYw==
4
+ ZjFmN2JiMjcyNjEwN2ViZTk2MmEwMjZiZTNiYWI1NjNhYjk4ZjQzZQ==
5
5
  data.tar.gz: !binary |-
6
- YzlkMWY1OTAzNmFkZDI4OWQ1NzMwM2ViNDA1NTYxOGNkMTVkOGJjYw==
6
+ N2EyNjE5N2FiZGNlZTdlYjBkMGQ3NGQ1MTQ4NDFlOGUxOTQ2OGNhZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGI5YzQ2YmRiMzI0YmU3YTgyYzBmMDBhN2Y1NGMwM2U5YzIzODNiNWVjZjYx
10
- ZTUxMTRhOGZlMTI3YjJjNDg1NWE2Nzc5NGRkZjRiMjc3MzEwMDZmODAwMzBi
11
- ODgxYTU1NjgwMDg5ZjZkYmY1MjMxNWI3Y2FhYjM2ZDA1MzI3OGQ=
9
+ ZTE1ZDhkODYxYTU4ODg1YmYyYTQ3ZjA1ZDUxZDA4OWFiZWEzNmE0ZmZhM2U0
10
+ M2Y4NDExYTBkZTkxMjMzNjJiOTkyNjBiNmVhYWFjN2NiYjQzZjQyMjE4MGEz
11
+ YjZkMzMwMDYwNDQ4OTcwNmRmMDZlYjdmZTU1NTNiYzkzZDEwMGM=
12
12
  data.tar.gz: !binary |-
13
- MmFhZmU3NGRmYTdkODJiNGMxMWJiMjgyNTJlNWE1ZWVjMGZiMjg0OTdhYzhi
14
- M2RiNDM2YWIzMDcyMDQwMzZkY2Q5OWIwNGQ2YTBjOGZkYWJlNDE3YjY4NmU2
15
- MDk1NTMxMjZiYzIzOWZmZmNjNWU1ZWJjODdjMTdkNzYzZWY3MWI=
13
+ ZjE0ZTllMzIwMGIwYmU3Y2IxNGZhM2RmMWEzZDBlYTYxZjJiYjY5ODA5OTc2
14
+ ZTU3MzkyMjlmZjAwMDMwZDk3NDdlYmU2NmVjOWY3ZmY1OWQ0YzA4ZDg3YmJh
15
+ YjJhNDNhNDIwZTEyYjljN2I1YzUwYjdjMDI2ZmNmYWRhMmFjMjc=
data/README.markdown CHANGED
@@ -1,12 +1,12 @@
1
- # Spud Photos
1
+ # Twice Baked Photos
2
2
 
3
- Spud Photos is an engine for creating and managing photo galleries, designed for use with [Spud][1].
3
+ TB Photos is an engine for creating and managing photo galleries, designed for use with [Twice Baked][1].
4
4
 
5
5
  ## Installation/Usage
6
6
 
7
7
  1. In your Gemfile add the following
8
8
 
9
- gem 'spud_photos'
9
+ gem 'tb_photos'
10
10
 
11
11
  2. Run bundle install
12
12
  3. Copy in database migrations to your new rails project
@@ -14,11 +14,11 @@ Spud Photos is an engine for creating and managing photo galleries, designed for
14
14
  bundle exec rake railties:install:migrations
15
15
  rake db:migrate
16
16
 
17
- 4. Run a rails server instance and point your browser to /spud/admin
17
+ 4. Run a rails server instance and point your browser to `/admin`
18
18
 
19
19
  ## Configuration
20
20
 
21
- Spud Photos accepts the following configuration options:
21
+ TB Photos accepts the following configuration options:
22
22
 
23
23
  Spud::Photos.configure do |config|
24
24
  config.base_layout = 'application'
@@ -30,12 +30,15 @@ Spud Photos accepts the following configuration options:
30
30
  :large => '400x400#',
31
31
  :huge => '600x600'
32
32
  }
33
+ config.max_image_upload_size = 2.megabytes
33
34
  config.paperclip_storage = :filesystem #use :s3 to use s3 storage (aws gem required)
34
35
  config.s3_credentials = "#{Rails.root}/config/s3.yml"
35
36
  config.storage_path = ":rails_root/public/system/spud_photos/:id/:style/:basename.:extension"
36
37
  config.storage_url = "/system/spud_photos/:id/:style/:basename.:extension"
37
38
  end
38
39
 
40
+ The `max_image_upload_size` should match with the apache/nginx max upload size for the public directory. Set the config to 0 for no size limit.
41
+
39
42
  The `photo_styles` option will be passed to [Paperclip][2], so any valid paperclip styles can be added here.
40
43
 
41
44
  ## Galleries
@@ -48,16 +51,12 @@ A number of built-in views have been provided to help you get started with the f
48
51
 
49
52
  rails generate spud:photos:views
50
53
 
51
- __NOTE:__ The built-in views are likely to undergo changes as features are added to the photos engine. If a new version of Spud Photos does not play nicely with your customized views, try backing up your views to an alternate location and running the views generator again to see what has changed.
52
-
53
-
54
- [1]:https://github.com/davydotcom/spud_core_admin
55
- [2]:https://github.com/thoughtbot/paperclip
54
+ __NOTE:__ The built-in views are likely to undergo changes as features are added to the photos engine. If a new version of TB Photos does not play nicely with your customized views, try backing up your views to an alternate location and running the views generator again to see what has changed.
56
55
 
57
56
  Testing
58
57
  -----------------
59
58
 
60
- Spud uses RSpec for testing. Get the tests running with a few short commands:
59
+ Twice Baked uses RSpec for testing. Get the tests running with a few short commands:
61
60
 
62
61
  1. Create and migrate the databases:
63
62
 
@@ -72,4 +71,8 @@ Spud uses RSpec for testing. Get the tests running with a few short commands:
72
71
 
73
72
  rspec spec
74
73
 
75
- After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
74
+ After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
75
+
76
+
77
+ [1]:https://bitbucket.org/westlakedesign/tb_core
78
+ [2]:https://github.com/thoughtbot/paperclip
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ end
14
14
 
15
15
  RDoc::Task.new(:rdoc) do |rdoc|
16
16
  rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'SpudPhotos'
17
+ rdoc.title = 'TbPhotos'
18
18
  rdoc.options << '--line-numbers'
19
19
  rdoc.rdoc_files.include('README.rdoc')
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -0,0 +1 @@
1
+ //= require ./photos
@@ -1,12 +1,11 @@
1
- Spud = (typeof(Spud) == 'undefined') ? {} : Spud;
2
- Spud.Admin = (typeof(Spud.Admin) == 'undefined') ? {} : Spud.Admin;
1
+ (function(){
3
2
 
4
- Spud.Admin.Photos = new function(){
3
+ spud.admin.photos = {};
4
+ var self = spud.admin.photos;
5
5
 
6
- var self = this;
7
- var html5upload = false;
6
+ self.html5upload = false;
8
7
 
9
- this.init = function(){
8
+ self.init = function(){
10
9
  // event handlers
11
10
  $('.spud_admin_photo_ui_thumbs_sortable').sortable({
12
11
  connectWith:'.spud_admin_photo_ui_thumbs_sortable'
@@ -23,7 +22,7 @@ Spud.Admin.Photos = new function(){
23
22
 
24
23
  // html5 drag and drop file
25
24
  if(typeof(FormData) != 'undefined' && typeof(XMLHttpRequest) != 'undefined' && (droparea = document.getElementById('spud_admin_photo_upload_queue'))){
26
- html5upload = true;
25
+ self.html5upload = true;
27
26
  $('#spud_admin_photo_upload_queue').show();
28
27
  droparea.addEventListener('dragenter', self.stopDndPropagation, false);
29
28
  droparea.addEventListener('dragexit', self.stopDndPropagation, false);
@@ -39,29 +38,48 @@ Spud.Admin.Photos = new function(){
39
38
  }
40
39
  };
41
40
 
42
- this.submittedPhotoAlbumForm = function(e){
41
+ self.submittedPhotoAlbumForm = function(e){
43
42
 
44
43
  };
45
44
 
46
- this.submittedPhotoGalleryForm = function(e){
45
+ self.submittedPhotoGalleryForm = function(e){
47
46
  $('#spud_admin_photo_albums_available .spud_admin_photo_ui_thumb').remove();
48
47
  };
49
48
 
50
- this.clickedPhotoRemoveFromAlbum = function(e){
49
+ self.clickedPhotoRemoveFromAlbum = function(e){
51
50
  $(this).parents('.spud_admin_photo_ui_thumb').fadeOut(200, function(){
52
51
  $(this).remove();
53
52
  });
54
53
  return false;
55
54
  };
56
55
 
56
+ self.validatePhoto = function(file) {
57
+ var errors = [];
58
+
59
+ if(file) {
60
+ var allowedTypes = ["image/jpeg", "image/png", "image/gif", "image/bmp"];
61
+ if(allowedTypes.indexOf(file.type) < 0) {
62
+ errors.push("Unsupported file format");
63
+ }
64
+ var maxAllowedSize = spud.admin.photos.max_image_upload_size_bytes;
65
+ if(maxAllowedSize && file.size > maxAllowedSize) {
66
+ errors.push("Your file size of " + self.getFileSizeHumanized(file.size) + " exceeded the maximum limit of " + spud.admin.photos.max_image_upload_size_humanized);
67
+ }
68
+ }
69
+ else {
70
+ errors.push("No file found");
71
+ }
72
+ return errors;
73
+ };
74
+
57
75
  /* Handle file uploads passed via iframe (legacy support)
58
76
  * -------------------------------------------------------- */
59
77
 
60
- this.photoLegacyUploadErrors = function(html){
78
+ self.photoLegacyUploadErrors = function(html){
61
79
  $('#spud_admin_photo_form').replaceWith(html);
62
80
  };
63
81
 
64
- this.photoLegacyUploadComplete = function(id, html){
82
+ self.photoLegacyUploadComplete = function(id, html){
65
83
  var element = $('#spud_admin_photo_' + id);
66
84
  if(element.length > 0){
67
85
  element.replaceWith(html);
@@ -73,7 +91,7 @@ Spud.Admin.Photos = new function(){
73
91
  hideModalDialog();
74
92
  };
75
93
 
76
- this.selectedPhotoUiThumb = function(e){
94
+ self.selectedPhotoUiThumb = function(e){
77
95
  var thumb = $(this);
78
96
  if(thumb.hasClass('spud_admin_photo_ui_thumb_selected')){
79
97
  $(this).removeClass('spud_admin_photo_ui_thumb_selected');
@@ -83,21 +101,21 @@ Spud.Admin.Photos = new function(){
83
101
  }
84
102
  };
85
103
 
86
- this.markPhotoAsDeleted = function(photo_id){
104
+ self.markPhotoAsDeleted = function(photo_id){
87
105
  var photo = $('#spud_admin_photo_' + photo_id);
88
106
  photo.fadeOut(200, function(){
89
107
  photo.remove();
90
108
  });
91
109
  };
92
110
 
93
- this.markPhotoAlbumAsDeleted = function(photo_album_id){
111
+ self.markPhotoAlbumAsDeleted = function(photo_album_id){
94
112
  var photo_album = $('#spud_admin_photo_album_' + photo_album_id);
95
113
  photo_album.fadeOut(200, function(){
96
114
  photo_album.remove();
97
115
  });
98
116
  };
99
117
 
100
- this.markPhotoGalleryAsDeleted = function(photo_gallery_id){
118
+ self.markPhotoGalleryAsDeleted = function(photo_gallery_id){
101
119
  var photo_gallery = $('#spud_admin_photo_gallery_' + photo_gallery_id);
102
120
  photo_gallery.fadeOut(200, function(){
103
121
  photo_gallery.remove();
@@ -108,13 +126,47 @@ Spud.Admin.Photos = new function(){
108
126
  * Single-Photo Form Upload
109
127
  -------------------------------- */
110
128
 
111
- this.submittedPhotoForm = function(e){
129
+ self.generateFileUploadErrors = function(errors, opts) {
130
+
131
+ if(typeof errors == "string") {
132
+ errors = [errors];
133
+ }
134
+ var totalErrors = errors.length;
135
+ var errorMsg = totalErrors + " errors prohibited you from saving:";
136
+ if(totalErrors == 1) {
137
+ errorMsg = "1 error prohibited you from saving:";
138
+ }
139
+ if(opts && opts.showAsDialog) {
140
+ alert(errorMsg + '\n\t' + errors.join('\n\t'));
141
+ return false;
142
+ }
143
+
144
+ $(".spud_admin_form_error_list").remove();
145
+ $("#spud_admin_photo_form").find("[for=spud_photo_photo]").css("color","black");
146
+ $("#spud_admin_photo_form").before('<div class="spud_admin_form_error_list"><ul><h4>' + errorMsg +'</h4></ul></div>');
147
+ $("#spud_admin_photo_form").find("[for=spud_photo_photo]").css("color","red");
148
+ for(var i = 0; i < errors.length; i++) {
149
+ $(".spud_admin_form_error_list > ul").append("<li>"+ errors[i] + "</li>");
150
+ }
151
+ return false;
152
+ };
153
+
154
+ self.getFileSizeHumanized = function(bytes) {
155
+ var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
156
+ if(bytes === 0){
157
+ return 'n/a';
158
+ }
159
+ var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
160
+ return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i];
161
+ };
162
+
163
+ self.submittedPhotoForm = function(e){
112
164
  // disable submit button
113
165
  // not working in updated bootstrap!
114
166
  // var submit = $(this).find('input[type=submit]');
115
167
  // submit.attr('disabled', 'disabled').val(submit.attr('data-loading-text'));
116
168
 
117
- if(html5upload){
169
+ if(self.html5upload){
118
170
  // create a FormData object and attach form values
119
171
  var fd = new FormData();
120
172
  var form = $(this);
@@ -126,14 +178,14 @@ Spud.Admin.Photos = new function(){
126
178
  // progress bar to send events to
127
179
  var progressBar;
128
180
  var file = form.find('#spud_photo_photo')[0].files[0];
129
- if(file){
130
- progressBar = self.progressBarForUpload(file.name);
131
- fd.append('spud_photo[photo]', file);
132
- form.append(progressBar);
133
- }
134
- else{
135
- progressBar = self.progressBarForUpload('');
181
+ var photoValidationErrors = self.validatePhoto(file);
182
+ if(photoValidationErrors.length) {
183
+ return self.generateFileUploadErrors(photoValidationErrors);
136
184
  }
185
+
186
+ progressBar = self.progressBarForUpload(file.name);
187
+ fd.append('spud_photo[photo]', file);
188
+ form.append(progressBar);
137
189
 
138
190
  // send FormData object as ajax request
139
191
  var xhr = new XMLHttpRequest();
@@ -152,7 +204,7 @@ Spud.Admin.Photos = new function(){
152
204
  * Upload Progress Monitoring
153
205
  -------------------------------- */
154
206
 
155
- this.progressBarForUpload = function(fileName){
207
+ self.progressBarForUpload = function(fileName){
156
208
  var html = [
157
209
  '<div class="spud_admin_photo_progress">',
158
210
  '<h6>',
@@ -167,7 +219,7 @@ Spud.Admin.Photos = new function(){
167
219
  return $(html);
168
220
  };
169
221
 
170
- this.onPhotoUploadProgress = function(e, progressBar){
222
+ self.onPhotoUploadProgress = function(e, progressBar){
171
223
  var percent = Math.round(e.loaded * 100 / e.total);
172
224
  progressBar.find('.bar').css({width: percent + '%'});
173
225
  if(percent == 100){
@@ -176,7 +228,7 @@ Spud.Admin.Photos = new function(){
176
228
  }
177
229
  };
178
230
 
179
- this.onPhotoUploadComplete = function(e, progressBar){
231
+ self.onPhotoUploadComplete = function(e, progressBar){
180
232
  // success
181
233
  var photo = $.parseJSON(e.target.response);
182
234
  if(e.target.status == 200){
@@ -198,7 +250,7 @@ Spud.Admin.Photos = new function(){
198
250
  }
199
251
  };
200
252
 
201
- this.onPhotoUploadCancel = function(e, progressBar){
253
+ self.onPhotoUploadCancel = function(e, progressBar){
202
254
  progressBar.find('.spud_admin_photo_progress_status').text('Done!');
203
255
  progressBar.find('.progress').addClass('progress-danger');
204
256
  };
@@ -206,7 +258,7 @@ Spud.Admin.Photos = new function(){
206
258
  /*
207
259
  * Photo Upload/Edit Form
208
260
  ------------------------------- */
209
- this.clickedPhotoAddOrEdit = function(e){
261
+ self.clickedPhotoAddOrEdit = function(e){
210
262
  var url = this.href;
211
263
  $.ajax({
212
264
  url:url,
@@ -215,18 +267,19 @@ Spud.Admin.Photos = new function(){
215
267
  return false;
216
268
  };
217
269
 
218
- this.photoUploadFormLoaded = function(html){
270
+ self.photoUploadFormLoaded = function(html){
219
271
  displayModalDialogWithOptions({
220
272
  title: 'Upload Photo',
221
273
  html: html
222
274
  });
275
+ $("#fileUploadSizeLegend").html('File Upload <span class="split-pane-item-meta">max allowed size : '+ spud.admin.photos.max_image_upload_size_humanized +'</span>');
223
276
  };
224
277
 
225
278
  /*
226
279
  * Add From Photo Library
227
280
  ------------------------------- */
228
281
 
229
- this.clickedPhotoLibrary = function(e){
282
+ self.clickedPhotoLibrary = function(e){
230
283
  var url = this.href;
231
284
  $.ajax({
232
285
  url:url,
@@ -235,7 +288,7 @@ Spud.Admin.Photos = new function(){
235
288
  return false;
236
289
  };
237
290
 
238
- this.photoLibraryLoaded = function(html){
291
+ self.photoLibraryLoaded = function(html){
239
292
  var dialog = $('#modal_window');
240
293
  $('#spud_admin_photos_selected .spud_admin_photo_ui_thumb').each(function(){
241
294
  var id = $(this).attr('id');
@@ -254,7 +307,7 @@ Spud.Admin.Photos = new function(){
254
307
  });
255
308
  };
256
309
 
257
- this.addSelectedPhotosFromLibrary = function(e){
310
+ self.addSelectedPhotosFromLibrary = function(e){
258
311
  $('#spud_admin_photo_library .spud_admin_photo_ui_thumb_selected')
259
312
  .removeClass('spud_admin_photo_ui_thumb_selected')
260
313
  .prependTo('#spud_admin_photos_selected')
@@ -263,13 +316,13 @@ Spud.Admin.Photos = new function(){
263
316
  hideModalDialog();
264
317
  };
265
318
 
266
- this.deleteSelectedPhotosFromLibrary = function(e){
319
+ self.deleteSelectedPhotosFromLibrary = function(e){
267
320
  var ids = $.map($('.spud_admin_photo_ui_thumb_selected'), function(val, i){
268
321
  return $(val).attr('rel');
269
322
  });
270
323
  $.ajax({
271
324
  type: 'POST',
272
- url: '/spud/admin/photos/mass_destroy',
325
+ url: '/admin/photos/mass_destroy',
273
326
  data: {spud_photo_ids:ids},
274
327
  success: function(data, textStatus, jqXHR){
275
328
  $('.spud_admin_photo_ui_thumb_selected').fadeOut(200, function(){
@@ -288,24 +341,29 @@ Spud.Admin.Photos = new function(){
288
341
  * Drag & Drop File Upload Queue
289
342
  -------------------------------- */
290
343
 
291
- this.fileQueue = [];
292
- this.fileQueueStarted = false;
344
+ self.fileQueue = [];
345
+ self.fileQueueStarted = false;
293
346
 
294
347
  // prevent default browser behavior of opening the dropped file
295
- this.stopDndPropagation = function(e){
348
+ self.stopDndPropagation = function(e){
296
349
  e.stopPropagation();
297
350
  e.preventDefault();
298
351
  };
299
352
 
300
353
  // add files to queue. starts queue if not started already
301
- this.droppedFile = function(e){
354
+ self.droppedFile = function(e){
302
355
  e.stopPropagation();
303
356
  e.preventDefault();
304
357
  $('#spud_admin_photo_upload_queue').show();
305
358
  var files = e.dataTransfer.files;
306
359
  var i = 0;
307
360
  while(i < files.length){
308
- self.fileQueue.push(files[i]);
361
+ var file = files[i];
362
+ var photoValidationErrors = self.validatePhoto(file);
363
+ if(photoValidationErrors.length) {
364
+ return self.generateFileUploadErrors(photoValidationErrors, {showAsDialog: true});
365
+ }
366
+ self.fileQueue.push(file);
309
367
  i++;
310
368
  }
311
369
  self.updateQueueCountLabel();
@@ -317,11 +375,11 @@ Spud.Admin.Photos = new function(){
317
375
  }
318
376
  };
319
377
 
320
- this.updateQueueCountLabel = function(){
378
+ self.updateQueueCountLabel = function(){
321
379
  $('#spud_admin_photo_upload_queue_label span').text(self.fileQueue.length);
322
380
  };
323
381
 
324
- this.uploadNextPhoto = function(){
382
+ self.uploadNextPhoto = function(){
325
383
  if(self.fileQueue.length === 0){
326
384
  self.fileQueueStarted = false;
327
385
  return;
@@ -343,14 +401,15 @@ Spud.Admin.Photos = new function(){
343
401
  xhr.addEventListener('load', function(e){ self.onQueuedPhotoUploadComplete(e, progressBar); }, false);
344
402
  xhr.addEventListener('error', function(e){ self.onPhotoUploadFailure(e, progressBar); }, false);
345
403
  xhr.addEventListener('abort', function(e){ self.onPhotoUploadCancel(e, progressBar); }, false);
346
- xhr.open('POST', '/spud/admin/photos');
404
+ xhr.open('POST', '/admin/photos');
347
405
  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
348
406
  xhr.send(fd);
349
407
  };
350
408
 
351
- this.onQueuedPhotoUploadComplete = function(e, progressBar){
409
+ self.onQueuedPhotoUploadComplete = function(e, progressBar){
352
410
  self.onPhotoUploadComplete(e, progressBar);
353
411
  self.updateQueueCountLabel();
354
412
  self.uploadNextPhoto();
355
413
  };
356
- };
414
+
415
+ })();
@@ -1,5 +1,5 @@
1
- /* Thumbnails
2
- ---------------------------- */
1
+ // Thumbnails
2
+ //////////////
3
3
  .spud_admin_photo_ui_thumbs{
4
4
  height: 300px;
5
5
  padding: 0;
@@ -75,7 +75,7 @@
75
75
  border-bottom-right-radius: 15px;
76
76
  }
77
77
  .spud_admin_photos_btn_remove, .spud_admin_photos_btn_delete{
78
- background: url('/assets/spud/photos/buttons/x_16x16.png');
78
+ background: image-url('admin/photos/buttons/x_16x16.png');
79
79
  height: 16px;
80
80
  width: 16px;
81
81
  text-indent: -7777px;
@@ -83,7 +83,7 @@
83
83
  margin: 0 4px;
84
84
  }
85
85
  .spud_admin_photos_btn_edit{
86
- background: url('/assets/spud/photos/buttons/cog_16x16.png');
86
+ background: image-url('admin/photos/buttons/cog_16x16.png');
87
87
  height: 16px;
88
88
  width: 16px;
89
89
  text-indent: -7777px;
@@ -91,8 +91,8 @@
91
91
  margin: 0 4px;
92
92
  }
93
93
 
94
- /* Upload Queue
95
- ---------------------------- */
94
+ // Upload Queue
95
+ //////////////
96
96
  .spud_admin_photo_progress{
97
97
  margin: 10px 0;
98
98
  }
@@ -108,8 +108,8 @@
108
108
  overflow-y: scroll;
109
109
  }
110
110
 
111
- /* Gallery Form
112
- ---------------------------- */
111
+ // Gallery Form
112
+ //////////////
113
113
  .spud_admin_photos_selection_left{
114
114
  width: 520px;
115
115
  margin-right: 18px;
@@ -1,9 +1,8 @@
1
- class Spud::Admin::PhotoAlbumsController < Spud::Admin::ApplicationController
1
+ class Admin::PhotoAlbumsController < Admin::ApplicationController
2
2
 
3
3
  before_filter :get_album, :only => [:show, :edit, :update, :destroy, :library]
4
- add_breadcrumb 'Photo Albums', :spud_admin_photo_albums_path
5
- respond_to :html, :json, :xml
6
- layout 'spud/admin/spud_photos'
4
+ add_breadcrumb 'Photo Albums', :admin_photo_albums_path
5
+ layout 'admin/spud_photos'
7
6
  cache_sweeper :spud_photo_sweeper, :only => [:create, :update, :destroy]
8
7
 
9
8
  def index
@@ -25,7 +24,7 @@ class Spud::Admin::PhotoAlbumsController < Spud::Admin::ApplicationController
25
24
  if @photo_album.save
26
25
  set_photo_order
27
26
  end
28
- respond_with @photo_album, :location => spud_admin_photo_albums_path
27
+ respond_with @photo_album, :location => admin_photo_albums_path
29
28
  end
30
29
 
31
30
  def edit
@@ -38,12 +37,12 @@ class Spud::Admin::PhotoAlbumsController < Spud::Admin::ApplicationController
38
37
  set_photo_order
39
38
  flash[:notice] = 'SpudPhotoAlbum updated successfully'
40
39
  end
41
- respond_with @photo_album, :location => spud_admin_photo_albums_path
40
+ respond_with @photo_album, :location => admin_photo_albums_path
42
41
  end
43
42
 
44
43
  def destroy
45
44
  flash[:notice] = 'SpudPhotoAlbum deleted successfully' if @photo_album.destroy
46
- respond_with @photo_album, :location => spud_admin_photo_albums_path
45
+ respond_with @photo_album, :location => admin_photo_albums_path
47
46
  end
48
47
 
49
48
  def get_album
@@ -1,10 +1,9 @@
1
- class Spud::Admin::PhotoGalleriesController < Spud::Admin::ApplicationController
1
+ class Admin::PhotoGalleriesController < Admin::ApplicationController
2
2
 
3
3
  before_filter :get_gallery, :only => [:show, :edit, :update, :destroy]
4
4
  before_filter :get_albums, :only => [:new, :create, :edit, :update]
5
- add_breadcrumb 'Photo Galleries', :spud_admin_photo_galleries_path
6
- respond_to :html, :json, :xml
7
- layout 'spud/admin/spud_photos'
5
+ add_breadcrumb 'Photo Galleries', :admin_photo_galleries_path
6
+ layout 'admin/spud_photos'
8
7
  cache_sweeper :spud_photo_sweeper, :only => [:create, :update, :destroy]
9
8
 
10
9
  def index
@@ -24,7 +23,7 @@ class Spud::Admin::PhotoGalleriesController < Spud::Admin::ApplicationController
24
23
  def create
25
24
  @photo_gallery = SpudPhotoGallery.new(params[:spud_photo_gallery])
26
25
  flash[:notice] = 'SpudPhotoGallery created successfully' if @photo_gallery.save
27
- respond_with @photo_gallery, :location => spud_admin_photo_galleries_path
26
+ respond_with @photo_gallery, :location => admin_photo_galleries_path
28
27
  end
29
28
 
30
29
  def edit
@@ -34,12 +33,12 @@ class Spud::Admin::PhotoGalleriesController < Spud::Admin::ApplicationController
34
33
  def update
35
34
  @photo_gallery.update_attributes(params[:spud_photo_gallery])
36
35
  flash[:notice] = 'SpudPhotoGallery updated successfully' if @photo_gallery.save
37
- respond_with @photo_gallery, :location => spud_admin_photo_galleries_path
36
+ respond_with @photo_gallery, :location => admin_photo_galleries_path
38
37
  end
39
38
 
40
39
  def destroy
41
40
  flash[:notice] = 'SpudPhotoGallery deleted successfully' if @photo_gallery.destroy
42
- respond_with @photo_gallery, :location => spud_admin_photo_galleries_path
41
+ respond_with @photo_gallery, :location => admin_photo_galleries_path
43
42
  end
44
43
 
45
44
  def get_gallery
@@ -1,9 +1,8 @@
1
- class Spud::Admin::PhotosController < Spud::Admin::ApplicationController
1
+ class Admin::PhotosController < Admin::ApplicationController
2
2
 
3
3
  include RespondsToParent
4
4
 
5
5
  before_filter :get_photo, :only => [:show, :edit, :update, :destroy]
6
- respond_to :html, :json, :xml, :js
7
6
  layout false
8
7
  cache_sweeper :spud_photo_sweeper, :only => [:create, :update, :destroy]
9
8
 
@@ -61,13 +60,13 @@ class Spud::Admin::PhotosController < Spud::Admin::ApplicationController
61
60
 
62
61
  def destroy
63
62
  flash[:notice] = 'SpudPhoto deleted successfully' if @photo.destroy
64
- respond_with @photo, :location => spud_admin_photos_path
63
+ respond_with @photo, :location => admin_photos_path
65
64
  end
66
65
 
67
66
  def mass_destroy
68
67
  @photos = SpudPhoto.where(:id => params[:spud_photo_ids])
69
68
  flash[:notice] = 'Photos deleted successfully' if @photos.destroy_all
70
- respond_with @photos, :location => spud_admin_photos_path
69
+ respond_with @photos, :location => admin_photos_path
71
70
  end
72
71
 
73
72
  private
@@ -23,14 +23,9 @@ class PhotoAlbumsController < ApplicationController
23
23
  end
24
24
 
25
25
  def show
26
- @photo_album = SpudPhotoAlbum.find_by_url_name(params[:id])
26
+ @photo_album = SpudPhotoAlbum.where(:url_name => params[:id]).first
27
27
  if @photo_album.blank?
28
- flash[:error] = "Could not find the requested Photo Album"
29
- if params[:photo_gallery_id]
30
- redirect_to photo_gallery_photo_albums_path(params[:photo_gallery_id])
31
- else
32
- redirect_to photo_albums_path
33
- end
28
+ raise Spud::NotFoundError.new(:item => 'photo album')
34
29
  else
35
30
  respond_with @photo_album
36
31
  end
@@ -39,16 +34,10 @@ class PhotoAlbumsController < ApplicationController
39
34
  private
40
35
 
41
36
  def get_gallery
42
- @photo_gallery = SpudPhotoGallery.find_by_url_name(params[:photo_gallery_id])
37
+ @photo_gallery = SpudPhotoGallery.where(:url_name => params[:photo_gallery_id]).first
43
38
  if @photo_gallery.blank?
44
- flash[:error] = "Could not find the requested Photo Gallery"
45
- if request.xhr?
46
- render :nothing => true, :status => 404
47
- else
48
- redirect_to photo_galleries_path
49
- end
50
- return false
39
+ raise Spud::NotFoundError.new(:item => 'photo gallery')
51
40
  end
52
41
  end
53
42
 
54
- end
43
+ end
@@ -14,4 +14,4 @@ class PhotoGalleriesController < ApplicationController
14
14
  respond_with @photo_galleries
15
15
  end
16
16
 
17
- end
17
+ end
@@ -0,0 +1,2 @@
1
+ module Admin::PhotoAlbumsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module Admin::PhotoGalleriesHelper
2
+ end
@@ -1,4 +1,4 @@
1
- module Spud::Admin::PhotosHelper
1
+ module Admin::PhotosHelper
2
2
 
3
3
  def photo_is_selected
4
4
  return (@photo_album && @photo_album.photo_ids.include?(photo.id))
@@ -1,5 +1,7 @@
1
1
  class SpudPhoto < ActiveRecord::Base
2
2
 
3
+ extend ActionView::Helpers::NumberHelper
4
+
3
5
  attr_accessible :title, :caption, :photo
4
6
 
5
7
  has_many :spud_photo_albums_photos, :dependent => :destroy
@@ -9,21 +11,23 @@ class SpudPhoto < ActiveRecord::Base
9
11
 
10
12
  has_attached_file :photo,
11
13
  :styles => lambda { |attachment| attachment.instance.dynamic_styles },
12
- :convert_options => Spud::Photos.config.convert_options,
14
+ :convert_options => Spud::Photos.convert_options,
15
+ :source_file_options => Spud::Photos.source_file_options,
13
16
  :storage => Spud::Photos.paperclip_storage,
14
17
  :s3_credentials => Spud::Photos.s3_credentials,
15
18
  :url => Spud::Photos.storage_url,
16
19
  :path => Spud::Photos.storage_path
17
20
 
18
- validates_attachment_presence :photo
21
+ validates_attachment :photo,
22
+ :presence => true,
23
+ :size => {:less_than => Spud::Photos.max_image_upload_size, :message => "size cannot exceed " + number_to_human_size(Spud::Photos.max_image_upload_size), :if => Proc.new{|p| Spud::Photos.max_image_upload_size > 0}}
19
24
 
20
25
  def dynamic_styles
21
- compress = '-strip -density 72x72'
22
26
  admin_styles = {
23
- :spud_admin_small => {:geometry => '125x125#', :convert_options => compress},
24
- :spud_admin_medium => {:geometry => '300x200', :convert_options => compress}
27
+ :spud_admin_small => {:geometry => '125x125#', :format => :jpg, :source_file_options => '-density 72', :convert_options => '-strip -quality 85'},
28
+ :spud_admin_medium => {:geometry => '300x200', :format => :jpg, :source_file_options => '-density 72', :convert_options => '-strip -quality 85'}
25
29
  }
26
30
  return admin_styles.merge(Spud::Photos.config.photo_styles)
27
31
  end
28
32
 
29
- end
33
+ end
@@ -19,7 +19,7 @@ class SpudPhotoAlbum < ActiveRecord::Base
19
19
  after_save :update_photo_order
20
20
 
21
21
  def top_photo_url(style)
22
- unless photos.empty?
22
+ if photos.length > 0
23
23
  return photos.first.photo.url(style)
24
24
  end
25
25
  end
@@ -4,7 +4,7 @@
4
4
  <%= hidden_field_tag 'spud_photo_gallery[album_ids][]', album.id %>
5
5
  </div>
6
6
  <div class="spud_admin_photo_ui_thumb_controls">
7
- <%= link_to 'Edit', edit_spud_admin_photo_album_path(album), :class => 'spud_admin_photos_btn_edit' %>
8
- <%= link_to 'Delete', spud_admin_photo_album_path(album), :method => :delete, :class => 'spud_admin_photos_btn_delete', :remote => true, :confirm => 'Are you sure?' %>
7
+ <%= link_to 'Edit', edit_admin_photo_album_path(album), :class => 'spud_admin_photos_btn_edit' %>
8
+ <%= link_to 'Delete', admin_photo_album_path(album), :method => :delete, :class => 'spud_admin_photos_btn_delete', :remote => true, :confirm => 'Are you sure?' %>
9
9
  </div>
10
10
  </div>
@@ -15,8 +15,8 @@
15
15
  <fieldset class="spud_admin_photos_album_fieldset">
16
16
  <legend>Selected Photos</legend>
17
17
  <div id="spud_admin_photo_album_actions" class="control-group">
18
- <%= link_to "Photo Library", spud_admin_photos_path, :class => "btn btn-primary", :id => 'spud_admin_photo_album_action_library' %>
19
- <%= link_to "Upload Photo", new_spud_admin_photo_path, :class => "btn btn-success", :id => 'spud_admin_photo_album_action_upload' %>
18
+ <%= link_to "Photo Library", admin_photos_path, :class => "btn btn-primary", :id => 'spud_admin_photo_album_action_library' %>
19
+ <%= link_to "Upload Photo", new_admin_photo_path, :class => "btn btn-success", :id => 'spud_admin_photo_album_action_upload' %>
20
20
  </div>
21
21
  <div id="spud_admin_photo_upload_queue">
22
22
  <p>Drag and drop photos here to upload</p>
@@ -24,7 +24,7 @@
24
24
  <div id="spud_admin_photo_upload_queue_bars"></div>
25
25
  </div>
26
26
  <div id="spud_admin_photos_selected" class="control-group spud_admin_photo_ui_thumbs spud_admin_photo_ui_thumbs_sortable">
27
- <%= render :partial => '/spud/admin/photos/photo', :collection => @photo_album.photos %>
27
+ <%= render :partial => '/admin/photos/photo', :collection => @photo_album.photos %>
28
28
  </div>
29
29
  </fieldset>
30
30
 
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => admin_photo_album_path(@photo_album)} %>
@@ -1,5 +1,5 @@
1
1
  <%= content_for :data_controls do %>
2
- <%= link_to "New Photo Album", new_spud_admin_photo_album_path, :class => "btn btn-primary", :title => "New Photo Album" %>
2
+ <%= link_to "New Photo Album", new_admin_photo_album_path, :class => "btn btn-primary", :title => "New Photo Album" %>
3
3
  <% end %>
4
4
 
5
5
  <%= content_for :detail do %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => admin_photo_albums_path} %>
@@ -20,13 +20,13 @@
20
20
  <div id="spud_admin_photo_albums_selected" class="spud_admin_photos_selection_left">
21
21
  <h4>Selected:</h4>
22
22
  <div class="spud_admin_photo_ui_thumbs spud_admin_photo_ui_thumbs_sortable">
23
- <%= render :partial => '/spud/admin/photo_albums/album', :collection => @photo_gallery.albums %>
23
+ <%= render :partial => '/admin/photo_albums/album', :collection => @photo_gallery.albums %>
24
24
  </div>
25
25
  </div>
26
26
  <div id="spud_admin_photo_albums_available" class="spud_admin_photos_selection_right">
27
27
  <h4>Available:</h4>
28
28
  <div class="spud_admin_photo_ui_thumbs spud_admin_photo_ui_thumbs_sortable">
29
- <%= render :partial => '/spud/admin/photo_albums/album', :collection => @photo_gallery.albums_available %>
29
+ <%= render :partial => '/admin/photo_albums/album', :collection => @photo_gallery.albums_available %>
30
30
  </div>
31
31
  </div>
32
32
  </fieldset>
@@ -0,0 +1 @@
1
+ spud.admin.photos.markPhotoGalleryAsDeleted(<%= @photo_gallery.id %>);
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => admin_photo_gallery_path(@photo_gallery)} %>
@@ -1,5 +1,5 @@
1
1
  <%= content_for :data_controls do %>
2
- <%= link_to "New Photo Gallery", new_spud_admin_photo_gallery_path, :class => "btn btn-primary", :title => "New Photo Gallery" %>
2
+ <%= link_to "New Photo Gallery", new_admin_photo_gallery_path, :class => "btn btn-primary", :title => "New Photo Gallery" %>
3
3
  <% end %>
4
4
 
5
5
  <%= content_for :detail do %>
@@ -8,8 +8,8 @@
8
8
  <div id="spud_admin_photo_gallery_<%= gallery.id %>" class="spud_admin_photo_ui_thumb" style="background-image:url('<%= gallery.top_photo_url(:spud_admin_small) %>')">
9
9
  <h5><%= gallery.title %></h5>
10
10
  <div class="spud_admin_photo_ui_thumb_controls">
11
- <%= link_to 'Edit', edit_spud_admin_photo_gallery_path(gallery), :class => 'spud_admin_photos_btn_edit' %>
12
- <%= link_to 'Delete', spud_admin_photo_gallery_path(gallery), :method => :delete, :class => 'spud_admin_photos_btn_delete', :remote => true, :confirm => 'Are you sure?' %>
11
+ <%= link_to 'Edit', edit_admin_photo_gallery_path(gallery), :class => 'spud_admin_photos_btn_edit' %>
12
+ <%= link_to 'Delete', admin_photo_gallery_path(gallery), :method => :delete, :class => 'spud_admin_photos_btn_delete', :remote => true, :confirm => 'Are you sure?' %>
13
13
  </div>
14
14
  </div>
15
15
  <% end %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => admin_photo_galleries_path} %>
@@ -1,4 +1,4 @@
1
- <%= form_for @photo, :url => (@photo.new_record? ? spud_admin_photos_path : spud_admin_photo_path(@photo)), :html => {:id => 'spud_admin_photo_form', :target => 'spud_admin_photo_form_target', :class => 'form-horizontal'} do |f| %>
1
+ <%= form_for @photo, :url => (@photo.new_record? ? admin_photos_path : admin_photo_path(@photo)), :html => {:id => 'spud_admin_photo_form', :target => 'spud_admin_photo_form_target', :class => 'form-horizontal'} do |f| %>
2
2
 
3
3
  <%=error_messages_for(f.object)%>
4
4
 
@@ -19,7 +19,7 @@
19
19
  </fieldset>
20
20
 
21
21
  <fieldset>
22
- <legend>File Upload</legend>
22
+ <legend id="fileUploadSizeLegend">File Upload</span></legend>
23
23
  <div class="control-group">
24
24
  <%= f.label :photo, :class => "control-label" %>
25
25
  <div class="controls">
@@ -7,7 +7,7 @@
7
7
  <%= hidden_field_tag 'spud_photo_album[photo_ids][]', photo.id %>
8
8
  </div>
9
9
  <div class="spud_admin_photo_ui_thumb_controls">
10
- <%= link_to 'Edit', edit_spud_admin_photo_path(photo), :class => 'spud_admin_photos_btn_edit' %>
10
+ <%= link_to 'Edit', edit_admin_photo_path(photo), :class => 'spud_admin_photos_btn_edit' %>
11
11
  <%= link_to 'Delete', '#', :class => 'spud_admin_photos_btn_remove' %>
12
12
  </div>
13
13
  <% end %>
@@ -0,0 +1 @@
1
+ spud.admin.photos.markPhotoAsDeleted(<%= @photo.id %>);
File without changes
@@ -1,5 +1,5 @@
1
1
  <% if @photo.errors.any? %>
2
- Spud.Admin.Photos.photoLegacyUploadErrors("<%= escape_javascript(render 'form') %>");
2
+ spud.admin.photos.photoLegacyUploadErrors("<%= escape_javascript(render 'form') %>");
3
3
  <% else %>
4
- Spud.Admin.Photos.photoLegacyUploadComplete(<%= @photo.id %>, "<%= escape_javascript(render :partial => 'photo', :locals => {:photo => @photo}) %>");
4
+ spud.admin.photos.photoLegacyUploadComplete(<%= @photo.id %>, "<%= escape_javascript(render :partial => 'photo', :locals => {:photo => @photo}) %>");
5
5
  <% end %>
@@ -0,0 +1,8 @@
1
+ <%= content_for :head do %>
2
+ <script type="text/javascript">
3
+ $(document).ready(spud.admin.photos.init);
4
+ spud.admin.photos.max_image_upload_size_humanized = spud.admin.photos.getFileSizeHumanized(<%= Spud::Photos.max_image_upload_size %>);
5
+ spud.admin.photos.max_image_upload_size_bytes = <%= Spud::Photos.max_image_upload_size %>;
6
+ </script>
7
+ <% end %>
8
+ <%= render :template => 'layouts/admin/detail' %>
@@ -9,7 +9,7 @@
9
9
  <h2>Photo Album: <%= @photo_album.title %></h2>
10
10
 
11
11
  <% if @photo_gallery %>
12
- <% if @photo_gallery.albums.count == 1 %>
12
+ <% if @photo_gallery.albums.length == 1 %>
13
13
  <p><%= link_to 'Back to Galleries', photo_galleries_path %>
14
14
  <% else %>
15
15
  <p><%= link_to 'Back to Gallery', photo_gallery_photo_albums_path(@photo_gallery.url_name) %>
@@ -24,4 +24,4 @@
24
24
  <%= link_to image_tag(photo.photo.url(:small), :alt => photo.caption, :title => photo.title), photo.photo.url(:large) %>
25
25
  </div>
26
26
  <% end %>
27
- </div>
27
+ </div>
@@ -11,8 +11,8 @@
11
11
  <div id="spud_photo_galleries">
12
12
  <% @photo_galleries.each do |gallery| %>
13
13
  <div class="spud_photo_gallery_thumbnail">
14
- <h3><%= link_to gallery.title, (gallery.albums.length == 1 ? photo_gallery_photo_album_path(gallery.url_name, gallery.albums.first.url_name) : photo_gallery_photo_albums_path(gallery.url_name)) %></h3>
14
+ <h3><%= link_to gallery.title, photo_gallery_photo_albums_path(gallery.url_name) %></h3>
15
15
  <%= image_tag gallery.top_photo_url(:medium), :title => gallery.title %>
16
16
  </div>
17
17
  <% end %>
18
- </div>
18
+ </div>
data/config/routes.rb CHANGED
@@ -1,14 +1,12 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- namespace :spud do
4
- namespace :admin do
5
- resources :photos do
6
- get 'library', :on => :collection
7
- post 'mass_destroy', :on => :collection
8
- end
9
- resources :photo_albums
10
- resources :photo_galleries
3
+ namespace :admin do
4
+ resources :photos do
5
+ get 'library', :on => :collection
6
+ post 'mass_destroy', :on => :collection
11
7
  end
8
+ resources :photo_albums
9
+ resources :photo_galleries
12
10
  end
13
11
 
14
12
  scope Spud::Photos.config.base_path do
@@ -1,13 +1,19 @@
1
1
  module Spud
2
2
  module Photos
3
3
  include ActiveSupport::Configurable
4
- config_accessor :photo_styles, :convert_options, :galleries_enabled, :base_layout, :base_path,:s3_credentials,:storage_path,:storage_url,:paperclip_storage, :enable_full_page_caching, :page_caches_to_sweep
4
+ require 'active_support/core_ext/numeric/bytes'
5
+ config_accessor :photo_styles, :convert_options, :source_file_options, :galleries_enabled, :base_layout, :base_path,:s3_credentials,:storage_path,:storage_url,:paperclip_storage, :enable_full_page_caching, :page_caches_to_sweep, :max_image_upload_size
5
6
  self.photo_styles = {
6
7
  :small => '50x50#',
7
8
  :medium => '200x200#',
8
9
  :large => '400x400#'
9
10
  }
10
- self.convert_options = {}
11
+ self.convert_options = {
12
+ :all => '-strip'
13
+ }
14
+ self.source_file_options = {
15
+ :all => '-density 72'
16
+ }
11
17
  self.galleries_enabled = false
12
18
  self.base_layout = 'application'
13
19
  self.base_path = 'photos'
@@ -17,5 +23,6 @@ module Spud
17
23
  self.storage_url = "/system/spud_photos/:id/:style/:basename.:extension"
18
24
  self.enable_full_page_caching = false
19
25
  self.page_caches_to_sweep = []
26
+ self.max_image_upload_size = 2.megabytes
20
27
  end
21
28
  end
@@ -6,13 +6,15 @@ module Spud
6
6
  class Engine < Rails::Engine
7
7
  engine_name :tb_photos
8
8
  initializer :assets_photos do |config|
9
- Rails.application.config.assets.precompile += ["spud/admin/photos*"]
9
+ Rails.application.config.assets.precompile += ["admin/photos/application*"]
10
+ Spud::Core.append_admin_javascripts("admin/photos/application")
11
+ Spud::Core.append_admin_stylesheets("admin/photos/application")
10
12
  end
11
13
  initializer :admin_photos do
12
14
  Spud::Core.config.admin_applications += [{
13
15
  :name => 'Photo Albums',
14
- :thumbnail => 'spud/photos/photo_albums_thumb.png',
15
- :url => '/spud/admin/photo_albums',
16
+ :thumbnail => 'admin/photos/photo_albums_thumb.png',
17
+ :url => '/admin/photo_albums',
16
18
  :retina => true,
17
19
  :order => 82
18
20
  # },{
@@ -25,8 +27,8 @@ module Spud
25
27
  if Spud::Photos.config.galleries_enabled
26
28
  Spud::Core.config.admin_applications += [{
27
29
  :name => 'Photo Galleries',
28
- :thumbnail => 'spud/photos/photo_albums_thumb.png',
29
- :url => '/spud/admin/photo_galleries',
30
+ :thumbnail => 'admin/photos/photo_albums_thumb.png',
31
+ :url => '/admin/photo_galleries',
30
32
  :retina => true,
31
33
  :order => 81
32
34
  }]
@@ -34,4 +36,4 @@ module Spud
34
36
  end
35
37
  end
36
38
  end
37
- end
39
+ end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Photos
3
- VERSION = "1.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_photos
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-19 00:00:00.000000000 Z
11
+ date: 2013-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -173,50 +173,51 @@ executables: []
173
173
  extensions: []
174
174
  extra_rdoc_files: []
175
175
  files:
176
- - app/assets/images/spud/photos/buttons/cog_16x16.png
177
- - app/assets/images/spud/photos/buttons/x_16x16.png
178
- - app/assets/images/spud/photos/photo_albums_thumb.png
179
- - app/assets/images/spud/photos/photo_albums_thumb@2x.png
180
- - app/assets/javascripts/spud/admin/photos.js
181
- - app/assets/stylesheets/spud/admin/photos.css
176
+ - app/assets/images/admin/photos/buttons/cog_16x16.png
177
+ - app/assets/images/admin/photos/buttons/x_16x16.png
178
+ - app/assets/images/admin/photos/photo_albums_thumb.png
179
+ - app/assets/images/admin/photos/photo_albums_thumb@2x.png
180
+ - app/assets/javascripts/admin/photos/application.js
181
+ - app/assets/javascripts/admin/photos/photos.js
182
+ - app/assets/stylesheets/admin/photos/application.css.scss
183
+ - app/controllers/admin/photo_albums_controller.rb
184
+ - app/controllers/admin/photo_galleries_controller.rb
185
+ - app/controllers/admin/photos_controller.rb
182
186
  - app/controllers/photo_albums_controller.rb
183
187
  - app/controllers/photo_galleries_controller.rb
184
- - app/controllers/spud/admin/photo_albums_controller.rb
185
- - app/controllers/spud/admin/photo_galleries_controller.rb
186
- - app/controllers/spud/admin/photos_controller.rb
188
+ - app/helpers/admin/photo_albums_helper.rb
189
+ - app/helpers/admin/photo_galleries_helper.rb
190
+ - app/helpers/admin/photos_helper.rb
187
191
  - app/helpers/photo_albums_helper.rb
188
192
  - app/helpers/photo_galleries_helper.rb
189
- - app/helpers/spud/admin/photo_albums_helper.rb
190
- - app/helpers/spud/admin/photo_galleries_helper.rb
191
- - app/helpers/spud/admin/photos_helper.rb
192
193
  - app/models/spud_photo.rb
193
194
  - app/models/spud_photo_album.rb
194
195
  - app/models/spud_photo_albums_photo.rb
195
196
  - app/models/spud_photo_galleries_album.rb
196
197
  - app/models/spud_photo_gallery.rb
197
198
  - app/models/spud_photo_sweeper.rb
198
- - app/views/layouts/spud/admin/spud_photos.html.erb
199
+ - app/views/admin/photo_albums/_album.html.erb
200
+ - app/views/admin/photo_albums/_form.html.erb
201
+ - app/views/admin/photo_albums/destroy.js.erb
202
+ - app/views/admin/photo_albums/edit.html.erb
203
+ - app/views/admin/photo_albums/index.html.erb
204
+ - app/views/admin/photo_albums/new.html.erb
205
+ - app/views/admin/photo_galleries/_form.html.erb
206
+ - app/views/admin/photo_galleries/destroy.js.erb
207
+ - app/views/admin/photo_galleries/edit.html.erb
208
+ - app/views/admin/photo_galleries/index.html.erb
209
+ - app/views/admin/photo_galleries/new.html.erb
210
+ - app/views/admin/photos/_form.html.erb
211
+ - app/views/admin/photos/_photo.html.erb
212
+ - app/views/admin/photos/destroy.js.erb
213
+ - app/views/admin/photos/edit.html.erb
214
+ - app/views/admin/photos/index.html.erb
215
+ - app/views/admin/photos/new.html.erb
216
+ - app/views/admin/photos/show.js.erb
217
+ - app/views/layouts/admin/spud_photos.html.erb
199
218
  - app/views/photo_albums/index.html.erb
200
219
  - app/views/photo_albums/show.html.erb
201
220
  - app/views/photo_galleries/index.html.erb
202
- - app/views/spud/admin/photo_albums/_album.html.erb
203
- - app/views/spud/admin/photo_albums/_form.html.erb
204
- - app/views/spud/admin/photo_albums/destroy.js.erb
205
- - app/views/spud/admin/photo_albums/edit.html.erb
206
- - app/views/spud/admin/photo_albums/index.html.erb
207
- - app/views/spud/admin/photo_albums/new.html.erb
208
- - app/views/spud/admin/photo_galleries/_form.html.erb
209
- - app/views/spud/admin/photo_galleries/destroy.js.erb
210
- - app/views/spud/admin/photo_galleries/edit.html.erb
211
- - app/views/spud/admin/photo_galleries/index.html.erb
212
- - app/views/spud/admin/photo_galleries/new.html.erb
213
- - app/views/spud/admin/photos/_form.html.erb
214
- - app/views/spud/admin/photos/_photo.html.erb
215
- - app/views/spud/admin/photos/destroy.js.erb
216
- - app/views/spud/admin/photos/edit.html.erb
217
- - app/views/spud/admin/photos/index.html.erb
218
- - app/views/spud/admin/photos/new.html.erb
219
- - app/views/spud/admin/photos/show.js.erb
220
221
  - config/routes.rb
221
222
  - db/migrate/20120228232120_create_spud_photos.rb
222
223
  - db/migrate/20120228232329_create_spud_photo_albums.rb
@@ -232,7 +233,7 @@ files:
232
233
  - MIT-LICENSE
233
234
  - Rakefile
234
235
  - README.markdown
235
- homepage: http://www.github.com/gregawoods/spud_photos
236
+ homepage: http://bitbucket.org/westlakedesign/tb_photos
236
237
  licenses: []
237
238
  metadata: {}
238
239
  post_install_message:
@@ -251,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
252
  version: '0'
252
253
  requirements: []
253
254
  rubyforge_project:
254
- rubygems_version: 2.0.3
255
+ rubygems_version: 2.0.7
255
256
  signing_key:
256
257
  specification_version: 4
257
258
  summary: Twice Baked Engine
@@ -1,2 +0,0 @@
1
- module Spud::Admin::PhotoAlbumsHelper
2
- end
@@ -1,2 +0,0 @@
1
- module Spud::Admin::PhotoGalleriesHelper
2
- end
@@ -1,8 +0,0 @@
1
- <%= content_for :head do %>
2
- <%= javascript_include_tag "spud/admin/photos" %>
3
- <%= stylesheet_link_tag 'spud/admin/photos' %>
4
- <script type="text/javascript">
5
- $(document).ready(Spud.Admin.Photos.init);
6
- </script>
7
- <% end %>
8
- <%= render :template => 'layouts/spud/admin/detail' %>
@@ -1 +0,0 @@
1
- <%= render :partial => 'form', :locals => {:path => spud_admin_photo_album_path(@photo_album)} %>
@@ -1 +0,0 @@
1
- <%= render :partial => 'form', :locals => {:path => spud_admin_photo_albums_path} %>
@@ -1 +0,0 @@
1
- Spud.Admin.Photos.markPhotoGalleryAsDeleted(<%= @photo_gallery.id %>);
@@ -1 +0,0 @@
1
- <%= render :partial => 'form', :locals => {:path => spud_admin_photo_gallery_path(@photo_gallery)} %>
@@ -1 +0,0 @@
1
- <%= render :partial => 'form', :locals => {:path => spud_admin_photo_galleries_path} %>
@@ -1 +0,0 @@
1
- Spud.Admin.Photos.markPhotoAsDeleted(<%= @photo.id %>);