caboose-cms 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzNlNGVmNDBkYzVhNzViNzY1MThlMmI0NmVmMjU3ZmQ3MjhiNmYyNQ==
4
+ NDAwMWQ4M2NiYWExMWY4ZjMzN2RkYTQxMzhkZTAzOTZjNmUzNDYyZg==
5
5
  data.tar.gz: !binary |-
6
- YjZiODExNDc0ZjA0MjY5ZjE5NDZmM2NjNzRjZmY3OWFkYmMzZTU4MA==
6
+ OWUzNGE4OGZjOWVlNWQ0MWYyMmI0OTIyZmMzZjQwNGE1YTE1Njg5YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTI3ZTZiOTY5MmZjNmI4NzAzOGE3MTYxNWYzZDY1ZTRmZjNhNjlkOGM1ZTRk
10
- MGM5NWZmNzExYTY4ODk4MWQ0MmQ4ZWQ2MzEzYmNjN2E0ZWNhNDEwZjM5ZWY2
11
- NTBiOTUxN2FkODNmNzE5MjZiMWZjNDlhYzIyMTFhZGRmMzMzNDE=
9
+ MjBiNDY1NmU4NjdlYzcyODA2OWQxYWM1OTQ3MDQ1NWFlMTk2NTdkNmJhOTMz
10
+ ZWRhODAzMWQ2NTRkNDQzODU2ZWJhZWQzNWIzZjg5ZjQ4ZmQyYzQyOTExNjk3
11
+ OGU3YzQzMmViZGE5NThlOWI1ZDk1NjFhZWIzMTkyMTRmNGRmYWQ=
12
12
  data.tar.gz: !binary |-
13
- Yjc4NmY0NjdhYzBkM2Y0OTdiZWFiNjIwYjg4ZDQxYzk5MzhjOGNhNGVmYmYx
14
- ZjFjNDE5YTZkOGZkZjk3ODJkNjkxZGM5ZTM5NGQ5OGFhYjRlNDdiZTE0MDYx
15
- OWY2NzI5ZGUxMjUyMjMxMDZhODYzYWIzZjI5NDg4NmM0Y2JlNmE=
13
+ YTcxN2FiNDcwYjBhOGQ2NjUwMzJkZTVkZDAzOTFlNjViYjNiN2M3ZjBmMWJm
14
+ M2YxMTVlYmVkMWNjZGY3ZWVmZTZmNjRmZTRmM2I2OWFhYWVmZmM4NjQ4OTFh
15
+ MTNjZjY3NGQ0MmUxMTcxNDFmY2FmYmNiOTBhMzM3YjQyZTQ4MWI=
@@ -15,6 +15,10 @@ MediaController.prototype = {
15
15
  uploader: false,
16
16
  refresh_unprocessed_images: false,
17
17
 
18
+
19
+
20
+
21
+
18
22
  init: function(params) {
19
23
  var that = this;
20
24
  for (var i in params)
@@ -37,6 +41,7 @@ MediaController.prototype = {
37
41
  that.refresh_categories();
38
42
  that.refresh_media();
39
43
  that.print_controls();
44
+
40
45
  },
41
46
 
42
47
  toggle_uploader: function()
@@ -115,6 +120,8 @@ MediaController.prototype = {
115
120
  async: false,
116
121
  success: function(resp) {
117
122
  that.categories = resp;
123
+ if (!that.cat_id)
124
+ that.cat_id = that.categories[0].id;
118
125
  that.print_categories();
119
126
  if (after) after();
120
127
  }
@@ -144,8 +151,7 @@ MediaController.prototype = {
144
151
  var ul = $('<ul/>');
145
152
  if (that.categories.length > 0)
146
153
  {
147
- $.each(that.categories, function(i, cat) {
148
-
154
+ $.each(that.categories, function(i, cat) {
149
155
  var li = $('<li/>')
150
156
  .addClass('category')
151
157
  .attr('id', 'cat' + cat.id)
@@ -241,7 +247,7 @@ MediaController.prototype = {
241
247
  .append($('<span/>').addClass('name').html(m.name).click(function(e) {
242
248
  e.stopPropagation();
243
249
  that.edit_media_description($(this).parent().data('media_id'));
244
- }))
250
+ }));
245
251
  if (m.image_urls)
246
252
  li.append($('<img/>').attr('src', m.image_urls.tiny_url));
247
253
  if (that.selected_media.indexOf(m.id) > -1)
@@ -280,6 +286,16 @@ MediaController.prototype = {
280
286
  that.selected_media[that.selected_media.length] = media_id;
281
287
  $('#media' + media_id).addClass('selected ui-selected').css('top', '0').css('left', '0');
282
288
  }
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
283
299
  },
284
300
 
285
301
  select_all_media: function()
@@ -6,26 +6,114 @@ BlockMediaController.prototype = {
6
6
  post_id: false,
7
7
  page_id: false,
8
8
  block_parent_id: false,
9
- block_id: false,
9
+ block_id: false,
10
+ media_id: false,
10
11
  top_cat_id: false,
11
12
  cat: false,
12
- cat_id: false,
13
+ cat_id: false,
14
+ categories: false,
15
+ s3_upload_url: false,
16
+ aws_access_key_id: false,
17
+ policy: false,
18
+ signature: false,
19
+ selected_media: false,
20
+ uploader: false,
21
+ refresh_unprocessed_images: false,
22
+ upload_extensions: "jpg,jpeg,png,gif,tif,tiff,pdf,doc,docx,odt,odp,ods,ppt,pptx,xls,xlsx,zip,tgz,csv,txt",
23
+ file_view: 'thumbnail',
13
24
 
14
25
  init: function(params) {
15
26
  var that = this;
16
27
  for (var i in params)
17
- this[i] = params[i];
28
+ this[i] = params[i];
29
+
30
+ $("#uploader")
31
+ .empty()
32
+ //.append($('<p/>')
33
+ // .append($('<a/>').attr('href', '#').html('Upload').click(function(e) { e.preventDefault(); that.toggle_uploader(); }))
34
+ // .append(' | ')
35
+ // .append($('<a/>').attr('href', '#').html('Toggle Thumbnail/List View').click(function(e) { e.preventDefault(); that.toggle_view(); }))
36
+ //)
37
+ .append($('<div/>').attr('id', 'the_uploader'));
18
38
  that.refresh();
19
39
  },
20
40
 
21
41
  refresh: function()
22
42
  {
23
- var that = this;
43
+ var that = this;
24
44
  that.refresh_categories(function() {
25
45
  that.refresh_media();
26
46
  });
47
+ that.print_controls();
27
48
  },
28
-
49
+
50
+ toggle_uploader: function()
51
+ {
52
+ var that = this;
53
+ if (that.uploader)
54
+ {
55
+ $("#the_uploader").slideUp(400, function() {
56
+ $("#the_uploader").plupload('destroy');
57
+ that.uploader = false;
58
+ });
59
+ }
60
+ else
61
+ {
62
+ $("#the_uploader").hide();
63
+ that.uploader = $("#the_uploader").plupload({
64
+ runtimes: 'html5,flash,silverlight',
65
+ url: that.s3_upload_url,
66
+ multipart: true,
67
+ multipart_params: {
68
+ key: that.cat_id + '_${filename}', // use filename as a key
69
+ Filename: that.cat_id + '_${filename}', // adding this to keep consistency across the runtimes
70
+ acl: 'public-read',
71
+ //'Content-Type': 'image/jpeg',
72
+ AWSAccessKeyId: that.aws_access_key_id,
73
+ policy: that.policy,
74
+ signature: that.signature
75
+ },
76
+ file_data_name: 'file', // optional, but better be specified directly
77
+ filters: {
78
+ max_file_size: '100mb', // Maximum file size
79
+ mime_types: [{ title: "Upload files", extensions: that.upload_extensions }] // Specify what files to browse for
80
+ },
81
+ flash_swf_url: '../../js/Moxie.swf', // Flash settings
82
+ silverlight_xap_url: '../../js/Moxie.xap', // Silverlight settings
83
+ init: {
84
+ BeforeUpload: function(up, file) {
85
+ $.ajax({
86
+ url: '/admin/media/pre-upload',
87
+ type: 'post',
88
+ data: {
89
+ media_category_id: that.cat_id,
90
+ name: file.name
91
+ },
92
+ success: function(resp) {},
93
+ async: false
94
+ });
95
+ controller.refresh();
96
+ },
97
+ FileUploaded: function(ip, file)
98
+ {
99
+ that.refresh();
100
+ },
101
+ UploadComplete: function(up, files) {
102
+ that.refresh();
103
+ if (that.uploader)
104
+ {
105
+ $("#the_uploader").slideUp(400, function() {
106
+ $("#the_uploader").plupload('destroy');
107
+ that.uploader = false;
108
+ });
109
+ }
110
+ }
111
+ }
112
+ });
113
+ $("#the_uploader").slideDown();
114
+ }
115
+ },
116
+
29
117
  refresh_categories: function(after)
30
118
  {
31
119
  var that = this;
@@ -79,30 +167,66 @@ BlockMediaController.prototype = {
79
167
  }
80
168
  else
81
169
  ul = $('<p/>').html("There are no media categories.");
82
- $('#categories').empty().append(ul);
170
+ $('#categories').empty().append(ul);
171
+ },
172
+
173
+ print_controls: function()
174
+ {
175
+ var that = this;
176
+ $('#controls').empty()
177
+ //.append($('<p/>').append($('<a/>').attr('href', '#').html('New Category').click(function(e) { e.preventDefault(); that.add_category(); })))
178
+ //.append($('<div/>').attr('id', 'new_cat_message'))
179
+ //.append($('<p/>').append($('<a/>').attr('href', '#').html('Upload').click(function(e) { e.preventDefault(); that.toggle_uploader(); })))
180
+ //.append($('<p/>').append($('<a/>').attr('href', '#').html('Toggle Thumbnail/List View').click(function(e) { e.preventDefault(); that.toggle_file_view(); })));
181
+ .append($('<p/>')
182
+ .append($('<a/>').attr('href', '#').html('New Category').click(function(e) { e.preventDefault(); that.add_category(); })).append(' | ')
183
+ .append($('<a/>').attr('href', '#').html('Upload to this Category' ).click(function(e) { e.preventDefault(); that.toggle_uploader(); })).append(' | ')
184
+ .append($('<a/>').attr('href', '#').html(that.file_view == 'thumbnail' ? 'List View' : 'Thumbnail View').click(function(e) { e.preventDefault(); that.toggle_file_view(); }))
185
+ )
186
+ .append($('<div/>').attr('id', 'new_cat_message'));
83
187
  },
84
188
 
85
189
  print_media: function()
86
190
  {
87
191
  var that = this;
88
- var ul = $('<ul/>');
192
+ var ul = $('<ul/>').addClass(that.file_view + '_view');
193
+ var processing = false;
194
+ var d = new Date();
195
+ d = d.getTime();
196
+
89
197
  if (that.cat.media.length > 0)
90
198
  {
91
- $.each(that.cat.media, function(i, m) {
199
+ $.each(that.cat.media, function(i, m) {
200
+ if (m.media_type == 'image' && m.processed == false)
201
+ processing = true
92
202
  var li = $('<li/>')
93
203
  .attr('id', 'media' + m.id)
94
204
  .addClass('media')
95
205
  .data('media_id', m.id)
96
206
  .click(function(e) { that.select_media($(this).data('media_id')); })
97
- .append($('<span/>').addClass('name').html(m.name));
207
+ .append($('<span/>').addClass('name').html(m.original_name));
98
208
  if (m.image_urls)
99
- li.append($('<img/>').attr('src', m.image_urls.tiny_url));
209
+ li.append($('<img/>').attr('src', m.image_urls.tiny_url + '?' + d));
210
+ //if (that.selected_media.indexOf(m.id) > -1)
211
+ // li.addClass('selected ui-selected');
212
+ if (m.id == that.media_id)
213
+ li.addClass('selected ui-selected');
100
214
  ul.append(li);
101
215
  });
102
216
  }
103
217
  else
104
218
  ul = $('<p/>').html("This category is empty.");
105
- $('#media').empty().append(ul);
219
+ $('#media').empty().append(ul);
220
+ if (that.refresh_unprocessed_images == true && processing)
221
+ setTimeout(function() { that.refresh(); }, 2000);
222
+
223
+ $.each(that.cat.media, function(i, m) {
224
+ $('li.media').draggable({
225
+ multiple: true,
226
+ revert: 'invalid',
227
+ start: function() { $(this).data("origPosition", $(this).position()); }
228
+ });
229
+ });
106
230
  },
107
231
 
108
232
  //============================================================================
@@ -117,8 +241,10 @@ BlockMediaController.prototype = {
117
241
  success: function(resp) {
118
242
  window.location = '/admin/pages/' + that.page_id + '/blocks/' + that.block_parent_id + '/edit';
119
243
  }
120
- });
121
- },
244
+ });
245
+ },
246
+
247
+ //============================================================================
122
248
 
123
249
  select_category: function(cat_id)
124
250
  {
@@ -126,6 +252,47 @@ BlockMediaController.prototype = {
126
252
  that.cat_id = cat_id;
127
253
  that.print_categories();
128
254
  that.refresh_media();
129
- }
255
+ },
256
+
257
+ add_category: function(name)
258
+ {
259
+ var that = this;
260
+ if (!name)
261
+ {
262
+ if (!$('#new_cat_message').is(':empty'))
263
+ {
264
+ $('#new_cat_message').empty();
265
+ return;
266
+ }
267
+ var div = $('<p/>').addClass('note warning')
268
+ .append('Name: ')
269
+ .append($('<input/>').attr('type', 'text').attr('id', 'new_cat_name')).append(" ")
270
+ .append($('<input/>').attr('type', 'button').val('Add').click(function() { that.add_category($('#new_cat_name').val()); })).append(" ")
271
+ .append($('<input/>').attr('type', 'button').val('Cancel').click(function() { $('#new_cat_message').empty(); }));
272
+ $('#new_cat_message').empty().append(div);
273
+ return;
274
+ }
275
+ $('#new_cat_message').empty().html("<p class='loading'>Adding category...</p>");
276
+ $.ajax({
277
+ url: '/admin/media-categories',
278
+ type: 'post',
279
+ data: {
280
+ parent_id: that.cat.id,
281
+ name: name
282
+ },
283
+ success: function(resp) {
284
+ if (resp.error) $('#new_cat_message').empty().html("<p class='note error'>" + resp.error + "</p>");
285
+ if (resp.refresh) { that.cat_id = resp.new_id; that.refresh(); }
286
+ }
287
+ });
288
+ },
289
+
290
+ toggle_file_view: function()
291
+ {
292
+ var that = this;
293
+ that.file_view = (that.file_view == 'thumbnail' ? 'list' : 'thumbnail');
294
+ that.print_controls();
295
+ that.print_media();
296
+ },
130
297
 
131
298
  };
@@ -13,9 +13,10 @@
13
13
  //= require_tree ../../templates
14
14
  //= require jquery
15
15
  //= require jquery_ujs
16
+ //= require jquery-ui
16
17
  //= require colorbox-rails
17
18
  //= require caboose/jquery.datetimepicker
18
19
  //= require caboose/jquery.placeholder
19
20
  //= require caboose/jquery.detect
20
21
  //= require caboose/modal_integration
21
- //= require caboose/admin_main
22
+ //= require caboose/admin_main
@@ -1,11 +1,11 @@
1
1
 
2
2
  #left_content {
3
- width: 280px;
3
+ width: 200px;
4
4
  float: left;
5
5
  }
6
6
 
7
7
  #right_content {
8
- margin-left: 300px;
8
+ margin-left: 220px;
9
9
  max-height: 600px;
10
10
  overflow-y: scroll;
11
11
  }
@@ -67,13 +67,13 @@
67
67
  }
68
68
  }
69
69
 
70
- #the_uploader {
70
+ #uploader {
71
71
  margin-bottom: 20px;
72
- padding-right: 20px;
73
72
  }
74
-
73
+
75
74
  #media {
76
- ul {
75
+
76
+ ul.thumbnail_view {
77
77
  list-style: none;
78
78
  margin: 0 0 20px 0;
79
79
  padding: 0;
@@ -114,4 +114,38 @@
114
114
  }
115
115
  }
116
116
  }
117
+
118
+ ul.list_view {
119
+ list-style: none;
120
+ margin: 0;
121
+ padding: 0;
122
+
123
+ li {
124
+ position: relative;
125
+ list-style: none;
126
+ margin: 4px;
127
+ padding: 4px;
128
+ background-color: #666;
129
+ background-position: center;
130
+ background-size: contain;
131
+ background-repeat: no-repeat;
132
+ border: #666 4px solid;
133
+
134
+ span.name {
135
+ display: block;
136
+ color: #fff;
137
+ text-decoration: none !important;
138
+ }
139
+ &:hover {
140
+ background-color: #fff799;
141
+ border: #fff799 4px solid;
142
+ span { background-color: #fff799; color: #000; }
143
+ }
144
+ &.selected {
145
+ background-color: #90dbf9;
146
+ border: #90dbf9 4px solid;
147
+ span { background-color: #90dbf9; color: #000; }
148
+ }
149
+ }
150
+ }
117
151
  }
@@ -17,6 +17,9 @@ module Caboose
17
17
  # Get the site we're working with
18
18
  domain = Domain.where(:domain => request.host_with_port).first
19
19
  @site = domain ? domain.site : nil
20
+
21
+ # Set the site in any mailers
22
+ CabooseMailer.site = @site
20
23
 
21
24
  # Make sure someone is logged in
22
25
  if !logged_in?
@@ -83,8 +83,8 @@ module Caboose
83
83
  bob.password_reset_id = rand
84
84
  bob.password_reset_sent = DateTime.now
85
85
  bob.save
86
-
87
- LoginMailer.configure_for_site(@site.id).forgot_password_email(bob).deliver
86
+
87
+ LoginMailer.forgot_password_email(bob).deliver
88
88
 
89
89
  resp.success = "We just sent you an email. The reset link inside is good for 3 days."
90
90
  render :json => resp
@@ -40,6 +40,7 @@ module Caboose
40
40
  if !cat.save
41
41
  resp.error = cat.errors.first[1]
42
42
  else
43
+ resp.new_id = cat.id
43
44
  resp.refresh = true
44
45
  end
45
46
 
@@ -0,0 +1,22 @@
1
+ module Caboose
2
+ class CabooseMailer < ActionMailer::Base
3
+ include AbstractController::Callbacks
4
+
5
+ default :from => Caboose::email_from
6
+
7
+ cattr_accessor :site
8
+ @@site = nil
9
+
10
+ before_filter do |mailer|
11
+ config = SmtpConfig.where(:site_id => @@site.id).first
12
+ self.smtp_settings['user_name'] = config.user_name
13
+ self.smtp_settings['password'] = config.password
14
+ self.smtp_settings['address'] = config.address
15
+ self.smtp_settings['port'] = config.port
16
+ self.smtp_settings['domain'] = config.domain
17
+ self.smtp_settings['authentication'] = config.authentication
18
+ self.smtp_settings['enable_starttls_auto'] = config.enable_starttls_auto
19
+ end
20
+
21
+ end
22
+ end
@@ -1,10 +1,10 @@
1
1
  module Caboose
2
- class LoginMailer < ActionMailer::Base
3
- default :from => Caboose::email_from
4
-
2
+ class LoginMailer < CabooseMailer #ActionMailer::Base
3
+
5
4
  def forgot_password_email(user)
6
5
  @user = user
7
6
  mail(:to => user.email, :subject => "#{Caboose::website_name} Forgot Password")
8
7
  end
8
+
9
9
  end
10
10
  end
@@ -10,10 +10,10 @@ class Caboose::Block < ActiveRecord::Base
10
10
  belongs_to :block_type
11
11
  belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::Block'
12
12
  has_many :children, :foreign_key => 'parent_id', :class_name => 'Caboose::Block', :dependent => :delete_all, :order => 'sort_order'
13
- has_attached_file :file, :path => ':path_prefixuploads/:block_file_upload_name.:extension'
13
+ has_attached_file :file, :path => ':caboose_prefixuploads/:block_file_upload_name.:extension'
14
14
  do_not_validate_attachment_file_type :file
15
15
  has_attached_file :image,
16
- :path => ':path_prefixuploads/:block_image_upload_name_:style.:extension',
16
+ :path => ':caboose_prefixuploads/:block_image_upload_name_:style.:extension',
17
17
  :default_url => "http://placehold.it/300x300",
18
18
  :styles => {
19
19
  :tiny => '160x120>',
@@ -15,7 +15,7 @@ module Caboose
15
15
  has_many :category_memberships
16
16
 
17
17
  has_attached_file :image,
18
- :path => ':path_prefixcategories/:id_:style.:extension',
18
+ :path => ':caboose_prefixcategories/:id_:style.:extension',
19
19
  :default_url => 'http://placehold.it/300x300',
20
20
  :s3_protocol => :https,
21
21
  :styles => {
@@ -5,10 +5,10 @@ class Caboose::Media < ActiveRecord::Base
5
5
 
6
6
  self.table_name = "media"
7
7
  belongs_to :media_category
8
- has_attached_file :file, :path => ':path_prefixmedia/:id_:media_name.:extension'
8
+ has_attached_file :file, :path => ':caboose_prefixmedia/:id_:media_name.:extension'
9
9
  do_not_validate_attachment_file_type :file
10
10
  has_attached_file :image,
11
- :path => ':path_prefixmedia/:id_:media_name_:style.:extension',
11
+ :path => ':caboose_prefixmedia/:id_:media_name_:style.:extension',
12
12
  :default_url => 'http://placehold.it/300x300',
13
13
  :styles => {
14
14
  :tiny => '160x120>',
@@ -72,13 +72,14 @@ class Caboose::Media < ActiveRecord::Base
72
72
 
73
73
  def api_hash
74
74
  {
75
- :id => self.id,
76
- :name => self.name,
77
- :description => self.description,
78
- :processed => self.processed,
79
- :image_urls => self.image_urls,
80
- :file_url => self.file ? self.file.url : nil,
81
- :media_type => self.is_image? ? 'image' : 'file'
75
+ :id => self.id,
76
+ :name => self.name,
77
+ :original_name => self.original_name,
78
+ :description => self.description,
79
+ :processed => self.processed,
80
+ :image_urls => self.image_urls,
81
+ :file_url => self.file ? self.file.url : nil,
82
+ :media_type => self.is_image? ? 'image' : 'file'
82
83
  }
83
84
  end
84
85
 
@@ -20,7 +20,7 @@ class Caboose::Post < ActiveRecord::Base
20
20
  :updated_at
21
21
 
22
22
  has_attached_file :image,
23
- :path => ':path_prefixposts/:id_:style.:extension',
23
+ :path => ':caboose_prefixposts/:id_:style.:extension',
24
24
  :default_url => 'http://placehold.it/300x300',
25
25
  :styles => {
26
26
  :tiny => '75x75>',
@@ -20,7 +20,7 @@ module Caboose
20
20
  :square_scale_factor
21
21
 
22
22
  has_attached_file :image,
23
- :path => ':path_prefixproducts/:product_id_:id_:style.:extension',
23
+ :path => ':caboose_prefixproducts/:product_id_:id_:style.:extension',
24
24
  :default_url => 'http://placehold.it/300x300',
25
25
  :s3_protocol => :https,
26
26
  :styles => {
@@ -11,7 +11,7 @@ class Caboose::Site < ActiveRecord::Base
11
11
  has_many :post_categories, :class_name => 'Caboose::PostCategory'
12
12
  has_one :store_config
13
13
  has_attached_file :logo,
14
- :path => ':path_prefixsite_logos/:id_:style.:extension',
14
+ :path => ':caboose_prefixsite_logos/:id_:style.:extension',
15
15
  :default_url => 'http://placehold.it/300x300',
16
16
  :styles => {
17
17
  :tiny => '150x200>',
@@ -17,6 +17,10 @@ class Caboose::SmtpConfig < ActiveRecord::Base
17
17
  AUTH_LOGIN = 'login'
18
18
  AUTH_MD5 = 'cram_md5'
19
19
 
20
+ def self.configure_for_site(mailer, site_id)
21
+ return self.configure_mailer_for_site(mailer, site_id)
22
+ end
23
+
20
24
  def self.configure_mailer_for_site(mailer, site_id)
21
25
  c = self.where(:site_id => site_id).first
22
26
 
@@ -29,6 +33,6 @@ class Caboose::SmtpConfig < ActiveRecord::Base
29
33
  mailer.smtp_settings['enable_starttls_auto'] = c.enable_starttls_auto
30
34
 
31
35
  return mailer
32
- end
36
+ end
33
37
 
34
38
  end
@@ -5,7 +5,7 @@ class Caboose::User < ActiveRecord::Base
5
5
  has_many :role_memberships
6
6
  has_many :roles, :through => :role_memberships
7
7
  has_attached_file :image,
8
- :path => ':path_prefixusers/:id_:style.:extension',
8
+ :path => ':caboose_prefixusers/:id_:style.:extension',
9
9
  :default_url => 'http://placehold.it/300x300',
10
10
  :styles => {
11
11
  :tiny => '150x200>',
@@ -6,7 +6,7 @@ module Caboose
6
6
  belongs_to :site
7
7
  has_many :products
8
8
  has_attached_file :image,
9
- :path => ':path_prefixvendors/:id_:style.:extension',
9
+ :path => ':caboose_prefixvendors/:id_:style.:extension',
10
10
  :default_url => 'http://placehold.it/300x300',
11
11
  :styles => {
12
12
  :tiny => '150x200>',
@@ -1,4 +1,27 @@
1
1
  <%
2
+ config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
3
+ access_key = config['access_key_id']
4
+ secret_key = config['secret_access_key']
5
+ bucket = config['bucket']
6
+ policy = {
7
+ "expiration" => 1.hour.from_now.utc.xmlschema,
8
+ "conditions" => [
9
+ { "bucket" => "#{bucket}-uploads" },
10
+ { "acl" => "public-read" },
11
+ [ "starts-with", "$key", '' ],
12
+ #[ "starts-with", "$Content-Type", 'image/' ],
13
+ [ 'starts-with', '$name', '' ],
14
+ [ 'starts-with', '$Filename', '' ],
15
+ ]
16
+ }
17
+ @policy = Base64.encode64(policy.to_json).gsub(/\n/,'')
18
+ @signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key, @policy)).gsub("\n","")
19
+ @s3_upload_url = "https://#{bucket}-uploads.s3.amazonaws.com/"
20
+ @aws_access_key_id = access_key
21
+ @top_media_category = Caboose::MediaCategory.top_category(@site.id)
22
+
23
+ #===============================================================================
24
+
2
25
  base_url = @block.page_id ? "/admin/pages/#{@block.page_id}/blocks" : "/admin/posts/#{@block.post_id}/blocks"
3
26
  crumbs = []
4
27
  b = @block
@@ -9,36 +32,19 @@ while b
9
32
  b = b.parent
10
33
  end
11
34
 
12
- url = nil
13
- name = nil
14
- if @block.media
15
- url = @block.media.file_url
16
- name = @block.media.file_file_name
17
- name = @block.media.image_file_name if name.nil?
18
- elsif @block.image
19
- url = @block.file.url
20
- name = @block.file_file_name
21
- end
22
-
23
35
  %>
24
36
  <h2 style='margin-top: 0; padding-top: 0;'><%= raw crumbs.reverse.join(' > ') %></h2>
25
37
 
26
38
  <div id='left_content'>
27
- <div id='categories'></div>
28
- <div id='controls'>
29
- <% if url.nil? || url.include?('missing') %>
30
- <p>Please select a file.</p>
31
- <% else %>
32
- <p>Current File</p>
33
- <p><%= name %></p>
34
- <% end %>
35
- </div>
39
+ <div id='categories'></div>
36
40
  </div>
37
41
  <div id='right_content'>
42
+ <div id='controls'></div>
38
43
  <div id='uploader'></div>
39
44
  <div id='media'></div>
40
45
  </div>
41
46
 
47
+ <p style='clear: both;'>&nbsp;</p>
42
48
  <p>
43
49
  <input type='button' value='< Back' onclick="window.location='/admin/pages/<%= @block.page_id %>/blocks/<%= @block.parent_id %>/edit';" />
44
50
  <input type='button' value='Close' onclick="parent.controller.render_blocks(); modal.close();" />
@@ -47,11 +53,22 @@ end
47
53
 
48
54
  <% content_for :caboose_css do %>
49
55
  <%= stylesheet_link_tag 'caboose/admin_block_edit_image' %>
56
+ <%= stylesheet_link_tag 'plupload/jquery.ui.plupload/css/jquery.ui.plupload.css' %>
50
57
  <% end %>
51
58
 
52
59
  <% content_for :caboose_js do %>
53
60
  <%= javascript_include_tag "caboose/model/all" %>
54
61
  <%= javascript_include_tag "caboose/block_media_controller" %>
62
+ <%= javascript_include_tag 'caboose/jquery-ui.drag-multiple.min.js' %>
63
+
64
+ <%= javascript_include_tag 'plupload/plupload.full.min.js' %>
65
+ <%= javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js' %>
66
+ <%
67
+ #javascript_include_tag 'plupload/moxie.js'
68
+ #javascript_include_tag 'plupload/plupload.dev.js'
69
+ #javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js'
70
+ %>
71
+
55
72
  <script type='text/javascript'>
56
73
 
57
74
  var modal = false;
@@ -61,11 +78,19 @@ $(window).load(function() {
61
78
 
62
79
  var controller = false;
63
80
  $(document).ready(function() {
64
- controller = new BlockMediaController({
81
+ controller = new BlockMediaController({
65
82
  <% if @block.page_id %>page_id: <%= @block.page_id %><% else %>post_id: <%= @block.post_id %><% end %>,
66
- block_id: <%= @block.id %>,
67
- block_parent_id: <%= @block.parent_id %>,
68
- authenticity_token: '<%= form_authenticity_token %>'
83
+ block_id: <%= @block.id %>,
84
+ block_parent_id: <%= @block.parent_id %>,
85
+ media_id: <% if @block.media_id %><%= @block.media_id %><% else %>false<% end %>,
86
+ authenticity_token: '<%= form_authenticity_token %>',
87
+ top_cat_id: <%= raw Caboose.json(@top_media_category.id) %>,
88
+ cat_id: <% if @block.media_id %><%= @block.media.media_category_id %><% else %><%= @top_media_category.id %><% end %>,
89
+ s3_upload_url: '<%= raw @s3_upload_url %>',
90
+ aws_access_key_id: '<%= raw @aws_access_key_id %>',
91
+ policy: '<%= raw @policy %>',
92
+ signature: '<%= raw @signature %>',
93
+ refresh_unprocessed_images: false
69
94
  });
70
95
  });
71
96
 
@@ -1,4 +1,27 @@
1
- <%
1
+ <%
2
+ config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
3
+ access_key = config['access_key_id']
4
+ secret_key = config['secret_access_key']
5
+ bucket = config['bucket']
6
+ policy = {
7
+ "expiration" => 1.hour.from_now.utc.xmlschema,
8
+ "conditions" => [
9
+ { "bucket" => "#{bucket}-uploads" },
10
+ { "acl" => "public-read" },
11
+ [ "starts-with", "$key", '' ],
12
+ #[ "starts-with", "$Content-Type", 'image/' ],
13
+ [ 'starts-with', '$name', '' ],
14
+ [ 'starts-with', '$Filename', '' ],
15
+ ]
16
+ }
17
+ @policy = Base64.encode64(policy.to_json).gsub(/\n/,'')
18
+ @signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), secret_key, @policy)).gsub("\n","")
19
+ @s3_upload_url = "https://#{bucket}-uploads.s3.amazonaws.com/"
20
+ @aws_access_key_id = access_key
21
+ @top_media_category = Caboose::MediaCategory.top_category(@site.id)
22
+
23
+ #===============================================================================
24
+
2
25
  base_url = @block.page_id ? "/admin/pages/#{@block.page_id}/blocks" : "/admin/posts/#{@block.post_id}/blocks"
3
26
  crumbs = []
4
27
  b = @block
@@ -9,32 +32,19 @@ while b
9
32
  b = b.parent
10
33
  end
11
34
 
12
- url = nil
13
- if @block.media
14
- url = @block.media.image.url(:tiny)
15
- elsif @block.image
16
- url = @block.image.url(:tiny)
17
- end
18
-
19
35
  %>
20
36
  <h2 style='margin-top: 0; padding-top: 0;'><%= raw crumbs.reverse.join(' > ') %></h2>
21
37
 
22
38
  <div id='left_content'>
23
- <div id='categories'></div>
24
- <div id='controls'>
25
- <% if url.nil? %>
26
- <p>Please upload an image.</p>
27
- <% else %>
28
- <p>Current Image</p>
29
- <p><img src='<%= raw url %>' /></p>
30
- <% end %>
31
- </div>
39
+ <div id='categories'></div>
32
40
  </div>
33
41
  <div id='right_content'>
42
+ <div id='controls'></div>
34
43
  <div id='uploader'></div>
35
44
  <div id='media'></div>
36
45
  </div>
37
46
 
47
+ <p style='clear: both;'>&nbsp;</p>
38
48
  <p>
39
49
  <input type='button' value='< Back' onclick="window.location='/admin/pages/<%= @block.page_id %>/blocks/<%= @block.parent_id %>/edit';" />
40
50
  <input type='button' value='Close' onclick="parent.controller.render_blocks(); modal.close();" />
@@ -43,27 +53,46 @@ end
43
53
 
44
54
  <% content_for :caboose_css do %>
45
55
  <%= stylesheet_link_tag 'caboose/admin_block_edit_image' %>
56
+ <%= stylesheet_link_tag 'plupload/jquery.ui.plupload/css/jquery.ui.plupload.css' %>
46
57
  <% end %>
47
58
 
48
59
  <% content_for :caboose_js do %>
49
60
  <%= javascript_include_tag "caboose/model/all" %>
50
61
  <%= javascript_include_tag "caboose/block_media_controller" %>
62
+ <%= javascript_include_tag 'caboose/jquery-ui.drag-multiple.min.js' %>
63
+
64
+ <%= javascript_include_tag 'plupload/plupload.full.min.js' %>
65
+ <%= javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js' %>
66
+ <%
67
+ #javascript_include_tag 'plupload/moxie.js'
68
+ #javascript_include_tag 'plupload/plupload.dev.js'
69
+ #javascript_include_tag 'plupload/jquery.ui.plupload/jquery.ui.plupload.js'
70
+ %>
71
+
51
72
  <script type='text/javascript'>
52
73
 
53
74
  var modal = false;
54
75
  $(window).load(function() {
55
- modal = new CabooseModal(800);
76
+ modal = new CabooseModal(900);
56
77
  });
57
-
78
+
58
79
  var controller = false;
59
- $(document).ready(function() {
60
- controller = new BlockMediaController({
80
+ $(document).ready(function() {
81
+ controller = new BlockMediaController({
61
82
  <% if @block.page_id %>page_id: <%= @block.page_id %><% else %>post_id: <%= @block.post_id %><% end %>,
62
- block_id: <%= @block.id %>,
63
- block_parent_id: <%= @block.parent_id %>,
64
- authenticity_token: '<%= form_authenticity_token %>'
65
- });
66
- });
83
+ block_id: <%= @block.id %>,
84
+ block_parent_id: <%= @block.parent_id %>,
85
+ media_id: <% if @block.media_id %><%= @block.media_id %><% else %>false<% end %>,
86
+ authenticity_token: '<%= form_authenticity_token %>',
87
+ top_cat_id: <%= raw Caboose.json(@top_media_category.id) %>,
88
+ cat_id: <% if @block.media_id %><%= @block.media.media_category_id %><% else %><%= @top_media_category.id %><% end %>,
89
+ s3_upload_url: '<%= raw @s3_upload_url %>',
90
+ aws_access_key_id: '<%= raw @aws_access_key_id %>',
91
+ policy: '<%= raw @policy %>',
92
+ signature: '<%= raw @signature %>',
93
+ refresh_unprocessed_images: false
94
+ });
95
+ });
67
96
 
68
97
  </script>
69
98
  <% end %>
@@ -127,20 +127,20 @@ module Caboose
127
127
  end
128
128
 
129
129
  # These are used so that both local filestorage and S3 can work without having to change paperclip paths in models
130
- Paperclip.interpolates :path_prefix do |attachment, style|
130
+ Paperclip.interpolates :caboose_prefix do |attachment, style|
131
131
  return "#{Rails.root}/public/" if Caboose::cdn_domain.nil? || Caboose::cdn_domain == '/'
132
132
  return ''
133
133
  end
134
134
 
135
- Paperclip.interpolates :model_url do |attachment, style|
136
- # Local file storeage
137
- if Caboose::cdn_domain.nil? || Caboose::cdn_domain == '/'
138
- p = attachment.path.gsub("#{Rails.root}/public/", '')
139
- return "/#{p}"
140
- end
141
- # Otherwise S3
142
- return "#{Caboose::cdn_domain}/#{attachment.path}"
143
- end
135
+ #Paperclip.interpolates :model_url do |attachment, style|
136
+ # # Local file storeage
137
+ # if Caboose::cdn_domain.nil? || Caboose::cdn_domain == '/'
138
+ # p = attachment.path.gsub("#{Rails.root}/public/", '')
139
+ # return "/#{p}"
140
+ # end
141
+ # # Otherwise S3
142
+ # return "#{Caboose::cdn_domain}/#{attachment.path}"
143
+ #end
144
144
 
145
145
  Paperclip.interpolates :block_file_upload_name do |attachment, style|
146
146
  b = attachment.instance
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.6.9'
2
+ VERSION = '0.6.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -657,6 +657,7 @@ files:
657
657
  - app/helpers/caboose/pages_helper.rb
658
658
  - app/helpers/caboose/permissions_helper.rb
659
659
  - app/helpers/caboose/products_helper.rb
660
+ - app/mailers/caboose/caboose_mailer.rb
660
661
  - app/mailers/caboose/login_mailer.rb
661
662
  - app/mailers/caboose/orders_mailer.rb
662
663
  - app/models/caboose/ab_option.rb