caboose-cms 0.3.89 → 0.3.90

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
- ZmYwNzdhZTIzMjlhMzhjMzg0MGZlNTMwODk2M2RkNjc1NDg3MTM4Nw==
4
+ ZTUzNGI0MTc3Mzc3Njg0ZGMyZWRmNDM1OThjOTU4YTUwMWIxZjMyOQ==
5
5
  data.tar.gz: !binary |-
6
- MzZmMTAxMWUyZjA2YWVmNGE5MTNlYTEyMzI0NjJhOTdjNmFlMmYxZQ==
6
+ NmJlMDY1NDE5OTg1YzlmZjRmYmJkNmFmODE2ZGQ4MDczOGRlODM3Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Zjk2ZTY3MTFjYmRkZTM4MTg2N2Q3YTk0NWFlY2FjYWY4YWZjMGQ3MzRkMDM5
10
- NzdiZWM3YjJlYWY4OGFkMTk5MTFiMDM0ZDY4ZWM0NDIxOWEwY2YzM2NjOTIx
11
- OTQ2ZjIxYmJmN2U5M2NlZjYzYzcyYjRmZWViODRmN2VmZGQ5MWY=
9
+ NzdiYmNlNDFhZTg2YWE2NTFhNDlmMzA0YjhmZGE0MTI0ZjVhNTBjMTU3NzY5
10
+ N2UyNWUxNDU1MGE1ZDViMTJkNTIyODFkNjU1ZWM2MTY3Y2RmOGZhMzAxMGVi
11
+ NjJlMzAyNTkyMDg5OTU0MGYyNjg1N2FmNTJhMjRlMzYyOTg5ODg=
12
12
  data.tar.gz: !binary |-
13
- MTY3NGU0M2U2Yzc4MDc3YTkzMjk2YjY3ZjdkNDE0Y2FlODJiZWQ3MzgxYjFi
14
- NDk0M2U5ZTA1YzczMjdiNzhkYThjZDUwNzhlZmFiMjg1NTQ3ZmFkMWY1N2Fh
15
- OTk4MTJkNzAwZDc0MDhkOGFjZjNhMWQ4NzhiNWQzNGMxM2M5Yzg=
13
+ ZGJjZGI5MmIzOWZlODAzOTAwODQ3M2JmNDNkMzY3ZjRmNTEzMDBmODE0ZjYw
14
+ N2YyN2RmYTY2YjU4YTA1MDMyMzNhZDUyZDA4NWIxYThkNjdhODE2NmU1Yjgz
15
+ ZTg0MzYyMTgzODM5NGRjYTdhZTYyZWIwMzcwYWYwMTRiMjI0YzA=
@@ -1,11 +1,13 @@
1
1
  //= require caboose/model/class
2
2
  //= require caboose/model/model
3
+ //= require caboose/model/s3
3
4
  //= require caboose/model/attribute
4
5
  //= require caboose/model/model_binder
5
6
  //= require caboose/model/bound_control
6
7
  //= require caboose/model/bound_checkbox
7
8
  //= require caboose/model/bound_checkbox_multiple
8
9
  //= require caboose/model/bound_image
10
+ //= require caboose/model/bound_s3_image
9
11
  //= require caboose/model/bound_file
10
12
  //= require caboose/model/bound_select
11
13
  //= require caboose/model/bound_text
@@ -1,3 +1,33 @@
1
+ /*
2
+ {
3
+ "expiration": "2007-12-01T12:00:00.000Z",
4
+ "conditions": [
5
+ {"bucket": "johnsmith"},
6
+ ["starts-with", "$key", "user/eric/"],
7
+ {"acl": "public-read"},
8
+ {"success_action_redirect": "http://johnsmith.s3.amazonaws.com/successful_upload.html"},
9
+ ["starts-with", "$Content-Type", "image/"],
10
+ {"x-amz-meta-uuid": "14365123651274"},
11
+ ["starts-with", "$x-amz-meta-tag", ""]
12
+ ]
13
+ }
14
+ key = '1234'
15
+ signature = 'abcdef'
16
+ return Base64.encode64(OpenSSL::HMAC.digest('sha1', key, signature))
17
+
18
+ <form action="http://johnsmith.s3.amazonaws.com/" method="post" enctype="multipart/form-data">
19
+ <input type="hidden" name="AWSAccessKeyId" value="AKIAIOSFODNN7EXAMPLE" />
20
+ <input type="hidden" name="acl" value="public-read" />
21
+ <input type="hidden" name="policy" value="POLICY" />
22
+ <input type="hidden" name="Signature" value="SIGNATURE" />
23
+ <input type="hidden" name="success_action_status" value="200" />
24
+ <input type="hidden" name="key" value="uploads/1.jpg" />
25
+
26
+ File: <input type="file" name="file" /><br />
27
+
28
+ <input type="submit" name="submit" value="Upload to Amazon S3" />
29
+ </form>
30
+ */
1
31
 
2
32
  BoundS3Image = BoundControl.extend({
3
33
 
@@ -34,21 +64,33 @@ BoundS3Image = BoundControl.extend({
34
64
  .css('margin-right', 10)
35
65
  );
36
66
 
37
-
67
+ var s3 = this.attribute.s3;
38
68
  $('#'+this.el+'_container')
39
69
  .append($('<form target="' + this.el + '_iframe"></form>')
40
70
  .attr('id', this.el + '_form')
41
- .attr('action', this.attribute.update_url)
71
+ .attr('action', 'http://' + this.attribute.s3.bucket + '.s3.amazonaws.com/')
42
72
  .attr('method', 'post')
43
73
  .attr('enctype', 'multipart/form-data')
44
- .attr('encoding', 'multipart/form-data')
45
- //.attr('target', this.el + '_iframe')
74
+ .attr('encoding', 'multipart/form-data')
46
75
  .on('submit', function() {
47
76
  $('#'+this2.el+'_message').html("<p class='loading'>Uploading...</p>");
48
- $('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
77
+ $('#'+this2.el+'_iframe').on('load', function() {
78
+ $.ajax({
79
+ url: this2.attribute.update_url,
80
+ type: 'post',
81
+ success: function(resp) {
82
+ this2.post_upload();
83
+ }
84
+ });
85
+ });
49
86
  return true;
50
87
  })
51
- .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
88
+ .append($('<input/>').attr('type','hidden').attr('name', "AWSAccessKeyId" ).val(s3.access_key_id))
89
+ .append($('<input/>').attr('type','hidden').attr('name', "acl" ).val(s3.acl))
90
+ .append($('<input/>').attr('type','hidden').attr('name', "policy" ).val(s3.policy))
91
+ .append($('<input/>').attr('type','hidden').attr('name', "Signature" ).val(s3.signature))
92
+ .append($('<input/>').attr('type','hidden').attr('name', "success_action_status" ).val("200"))
93
+ .append($('<input/>').attr('type','hidden').attr('name', "key" ).val(s3.key))
52
94
  .append($('<div/>')
53
95
  .attr('id', this.el + '_fake_file_input')
54
96
  .addClass('mb_fake_file_input')
@@ -61,7 +103,7 @@ BoundS3Image = BoundControl.extend({
61
103
  .append($('<input/>')
62
104
  .attr('type', 'file')
63
105
  .attr('id', this.el + '_file')
64
- .attr('name', this.attribute.name)
106
+ .attr('name', 'file')
65
107
  .change(function() { $('#'+this2.el+'_form').trigger('submit'); })
66
108
  )
67
109
  .append($('<input/>')
@@ -4,26 +4,11 @@ var S3 = function(params) {
4
4
  this[thing] = params[thing];
5
5
  };
6
6
 
7
- S3.prototype = {
8
- access_key_id: '',
9
- secret_access_key: '',
10
-
7
+ S3.prototype = {
8
+ bucket: '',
9
+ access_key_id: '',
11
10
  acl: 'public-read',
12
- key: '',
13
11
  policy: '',
14
12
  signature: '',
15
- redirect: ''
16
-
17
- access_key_id: '', // AWSAccessKeyId
18
- acl: 'public-read',
19
- bucket: '',
20
- key: '',
21
- policy: '',
22
- redirect: '', // success_action_redirect
23
- signature: '',
24
- security_token: '', // x-amz-security-token
25
- file
26
-
13
+ key: ''
27
14
  };
28
-
29
-
@@ -12,6 +12,12 @@ module Caboose
12
12
  # Modify the built-in params array with URL params if necessary
13
13
  parse_url_params if Caboose.use_url_params
14
14
 
15
+ # Make sure someone is logged in
16
+ if !logged_in?
17
+ elo = User.find(User::LOGGED_OUT_USER_ID)
18
+ login_user(elo)
19
+ end
20
+
15
21
  session['use_redirect_urls'] = true if session['use_redirect_urls'].nil?
16
22
 
17
23
  # Initialize AB Testing
@@ -76,7 +82,7 @@ module Caboose
76
82
  def logged_in?
77
83
  validate_token
78
84
  validate_cookie
79
- return true if !session["app_user"].nil? && session["app_user"] != false && session["app_user"].id != -1
85
+ return true if !session["app_user"].nil? && session["app_user"] != false && session["app_user"].id != -1 && session["app_user"].id != User::LOGGED_OUT_USER_ID
80
86
  return false
81
87
  end
82
88
 
@@ -19,9 +19,9 @@ module Caboose
19
19
  return
20
20
  end
21
21
 
22
- user = logged_in_user
22
+ user = logged_in_user
23
23
  if !user.is_allowed(page, 'view')
24
- if user.id == User.logged_out_user_id
24
+ if user.id == User::LOGGED_OUT_USER_ID
25
25
  redirect_to "/modal/login?return_url=" + URI.encode(request.fullpath)
26
26
  return
27
27
  else
@@ -229,7 +229,11 @@ class Caboose::Schema < Caboose::Utilities::Schema
229
229
  admin_user.password = Digest::SHA1.hexdigest(Caboose::salt + 'caboose')
230
230
  admin_user.save
231
231
  end
232
- admin_user = Caboose::User.where(:username => 'admin').first if admin_user.nil?
232
+ admin_user = Caboose::User.where(:username => 'admin').first if admin_user.nil?
233
+
234
+ if !Caboose::User.where(:id => Caboose::User::LOGGED_OUT_USER_ID).exists?
235
+ Caboose::User.create(:id => Caboose::User::LOGGED_OUT_USER_ID, :first_name => 'Logged', :last_name => 'Out', :username => 'elo', :email => 'elo@nine.is')
236
+ end
233
237
 
234
238
  Caboose::Role.create(:parent_id => -1 , :name => 'Admin' ) if !Caboose::Role.exists?(:name => 'Admin' )
235
239
  admin_role = Caboose::Role.where(:name => 'Admin' ).first
@@ -12,8 +12,11 @@ class Caboose::User < ActiveRecord::Base
12
12
  :large => '600x800>'
13
13
  }
14
14
  do_not_validate_attachment_file_type :image
15
- attr_accessible :email, :first_name, :last_name, :username, :token, :password, :phone
16
-
15
+ attr_accessible :id, :email, :first_name, :last_name, :username, :token, :password, :phone
16
+
17
+ ADMIN_USER_ID = 1
18
+ LOGGED_OUT_USER_ID = 2
19
+
17
20
  before_save do
18
21
  self.email = self.email.downcase if self.email
19
22
  end
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.3.89'
2
+ VERSION = '0.3.90'
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.3.89
4
+ version: 0.3.90
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails