caboose-cms 0.3.67 → 0.3.68

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
- Y2I0NzE2M2NkNDMwOTYzZDc0NGI2MjcyYWI2ODYyMTVkMDdmNjQ0Nw==
4
+ NzU5ZTdiY2ZkNjU3ZDRhMDY0NmZkNzI2OWYwMTFjMGViYzVhZmM3ZQ==
5
5
  data.tar.gz: !binary |-
6
- YzZlNzg0NzVlODhjOTQ5NmJlNWJmZDg4MWYxNzQxYzUzNWFhNWQwNw==
6
+ ODMyOTBmMTBiNDRmNTZkN2Q4MDcxNDE0ODcxOWU2ZmY3OWVkYTlkZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjQ1ODJiNTJhOTQyOTgwZjljNjg2OTc2ZTY5MmUwZDQ2NTlmMjRlOGMyYjgx
10
- NTVmNzhiNTBiMTNmNzU4YzlkY2M1OWRiMzU3MjcxYzU5NDhiZGJlZjQ3OTA2
11
- ZThhYjNjMGUxYWM3YmExMzM5MmZkODEwNzdhOTdiN2I4ZjAwOTQ=
9
+ Njg0NmM3YmU4YmE5Y2E3ZTI5MzVkZGViNGZhMzliYmFjODNiZDFhZDBmNzI3
10
+ YmUzNDdmODE3NmI5N2M4OTlhYWU1MDk5NWI3OTNmNzk2ZTdiMDQwYTI3ZDcw
11
+ NGRjYmIxZDM4OWQ1NTMzNTBiMzNiZjI4ZWJmOWNmY2I4NThmMDk=
12
12
  data.tar.gz: !binary |-
13
- NGQ5ZGY5ODg3ZTQyOWExOTNhOWYzYzM1ZTVmYjY4YmY5YTA1Y2RmNmRkOTc5
14
- ZTRmODE5ZTc5NmM0NGZjMTg0MWQzOGRiMzQ1MjJhMTA4MGIzMmI4MjJkNTJk
15
- ZWZlZGFiYTU1ZTUxZDEwMmQ1MmY2ZjE2ZDJlNDEwNGQ3ZTY5OWI=
13
+ MjNmNDZlMGQ2OWQ5YTFlM2M4NTY0YzZmM2Q3MjEwMTRhMTY3OWFlMjhhZTg2
14
+ YWZmOWJlZmZmMTEwZTViMzMwZGVjNmRlNDEyYjAxOWVjYmI0YWRhZTIzMDBj
15
+ Y2JiM2M4ZDY2MDQwMGQ2NzMzYTkwNjhkMTBjYTJhZTBhOWFmOTI=
@@ -28,7 +28,8 @@ Attribute.prototype = {
28
28
 
29
29
  update_url: false,
30
30
  options_url: false,
31
- options: false,
31
+ options: false,
32
+ s3: false,
32
33
 
33
34
  save: function(after) {
34
35
  if (this.before_update) this.before_update();
@@ -0,0 +1,142 @@
1
+
2
+ BoundS3Image = BoundControl.extend({
3
+
4
+ //el: false,
5
+ //model: false,
6
+ //attribute: false,
7
+ //binder: false,
8
+
9
+ width: 100,
10
+ style: 'medium',
11
+ authenticity_token: false,
12
+
13
+ init: function(params) {
14
+ for (var thing in params)
15
+ this[thing] = params[thing];
16
+
17
+ this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
18
+
19
+ if (!this.attribute.update_url)
20
+ this.attribute.update_url = this.model.update_url;
21
+
22
+ var this2 = this;
23
+ $('#'+this.el).wrap($('<div/>')
24
+ .attr('id', this.el + '_container')
25
+ .addClass('mb_container')
26
+ .css('position', 'relative')
27
+ );
28
+ $('#'+this.el+'_container').empty();
29
+
30
+ $('#'+this.el+'_container').append($('<img/>')
31
+ .attr('src', this.attribute.value)
32
+ .css('width', this.width)
33
+ .css('float', 'left')
34
+ .css('margin-right', 10)
35
+ );
36
+
37
+
38
+ $('#'+this.el+'_container')
39
+ .append($('<form target="' + this.el + '_iframe"></form>')
40
+ .attr('id', this.el + '_form')
41
+ .attr('action', this.attribute.update_url)
42
+ .attr('method', 'post')
43
+ .attr('enctype', 'multipart/form-data')
44
+ .attr('encoding', 'multipart/form-data')
45
+ //.attr('target', this.el + '_iframe')
46
+ .on('submit', function() {
47
+ $('#'+this2.el+'_message').html("<p class='loading'>Uploading...</p>");
48
+ $('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
49
+ return true;
50
+ })
51
+ .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
52
+ .append($('<div/>')
53
+ .attr('id', this.el + '_fake_file_input')
54
+ .addClass('mb_fake_file_input')
55
+ .append($('<input/>')
56
+ .attr('type', 'button')
57
+ .attr('id', this.el + '_update_button')
58
+ .val('Update ' + this.attribute.nice_name)
59
+ .click(function() { $('#'+this2.el+'_file').click(); })
60
+ )
61
+ .append($('<input/>')
62
+ .attr('type', 'file')
63
+ .attr('id', this.el + '_file')
64
+ .attr('name', this.attribute.name)
65
+ .change(function() { $('#'+this2.el+'_form').trigger('submit'); })
66
+ )
67
+ .append($('<input/>')
68
+ .attr('type', 'submit')
69
+ .val('Submit')
70
+ )
71
+ )
72
+ );
73
+ $('#'+this.el+'_container').append($('<div/>')
74
+ .attr('id', this.el + '_message')
75
+ );
76
+ iframe = $("<iframe name=\"" + this.el + "_iframe\" id=\"" + this.el + "_iframe\" src=''></iframe>");
77
+ if (this.attribute.debug)
78
+ iframe.css('width', '100%').css('height', 600).css('background', '#fff');
79
+ else
80
+ iframe.css('width', 0).css('height', 0).css('border', 0);
81
+ $('#'+this.el+'_container').append(iframe);
82
+ $('#'+this.el+'_container').append($('<br/>').css('clear', 'both'));
83
+
84
+ var w = $('#' + this.el + '_update_button').outerWidth(true);
85
+ $('#' + this.el + '_fake_file_input').css('width', '' + w + 'px');
86
+ },
87
+
88
+ post_upload: function() {
89
+ $('#'+this.el+'_message').empty();
90
+
91
+ var str = frames[this.el+'_iframe'].document.documentElement.innerHTML;
92
+ str = str.replace(/[\s\S]*?{([\s\S]*?)/, '{$1');
93
+ str = str.substr(0, str.lastIndexOf('}')+1);
94
+ var resp = $.parseJSON(str);
95
+ if (resp.success)
96
+ {
97
+ if (resp.attributes && resp.attributes[this.attribute.name])
98
+ for (var thing in resp.attributes[this.attribute.name])
99
+ this.attribute[thing] = resp.attributes[this.attribute.name][thing];
100
+ this.attribute.value_clean = this.attribute.value;
101
+ }
102
+
103
+ if (resp.error)
104
+ this.error(resp.error);
105
+ else
106
+ {
107
+ if (this.attribute.image_refresh_delay)
108
+ {
109
+ var that = this;
110
+ setTimeout(function() { that.refresh_image(); }, this.attribute.image_refresh_delay);
111
+ }
112
+ else
113
+ {
114
+ this.refresh_image();
115
+ }
116
+ }
117
+ },
118
+
119
+ refresh_image: function() {
120
+ var src = this.attribute.value;
121
+ if (src.indexOf('?') > 0)
122
+ src = src.split('?')[0];
123
+ src = src + '?' + Math.random();
124
+ $('#'+this.el+'_container img').attr('src', src);
125
+ },
126
+
127
+ error: function(str) {
128
+ if (!$('#'+this.el+'_message').length)
129
+ {
130
+ $('#'+this.el+'_container').append($('<div/>')
131
+ .attr('id', this.el + '_message')
132
+ .css('width', $('#'+this.el).outerWidth())
133
+ );
134
+ }
135
+ $('#'+this.el+'_message').hide();
136
+ $('#'+this.el+'_message').html("<p class='note error'>" + str + "</p>");
137
+ $('#'+this.el+'_message').slideDown();
138
+ var this2 = this;
139
+ setTimeout(function() { $('#'+this2.el+'_message').slideUp(function() { $(this).empty(); }); }, 3000);
140
+ }
141
+
142
+ });
@@ -0,0 +1,29 @@
1
+
2
+ var S3 = function(params) {
3
+ for (var thing in params)
4
+ this[thing] = params[thing];
5
+ };
6
+
7
+ S3.prototype = {
8
+ access_key_id: '',
9
+ secret_access_key: '',
10
+
11
+ acl: 'public-read',
12
+ key: '',
13
+ policy: '',
14
+ 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
+
27
+ };
28
+
29
+
@@ -68,18 +68,11 @@ module Caboose
68
68
  save = true
69
69
  params.each do |name, value|
70
70
  case name
71
- when 'category_id'
72
- post.category_id = value
73
- when 'title'
74
- post.title = value
75
- when 'body'
76
- post.body = value
77
- when 'image'
78
- post.image = value
79
- when 'published'
80
- post.published = value.to_i == 1
81
- when 'created_at'
82
- post.created_at = DateTime.parse(value)
71
+ when 'category_id' then post.category_id = value
72
+ when 'title' then post.title = value
73
+ when 'body' then post.body = value
74
+ when 'published' then post.published = value.to_i == 1
75
+ when 'created_at' then post.created_at = DateTime.parse(value)
83
76
  end
84
77
  end
85
78
  resp.success = save && post.save
@@ -89,6 +82,19 @@ module Caboose
89
82
  render :json => resp
90
83
  end
91
84
 
85
+ # POST /admin/posts/:id/image
86
+ def admin_update_image
87
+ return if !user_is_allowed('posts', 'edit')
88
+
89
+ resp = Caboose::StdClass.new
90
+ post = Post.find(params[:id])
91
+ post.image = params[:image]
92
+ resp.success = post.save
93
+ resp.attributes = { 'image' => { 'value' => post.image.url(:thumb) }}
94
+
95
+ render :text => resp.to_json
96
+ end
97
+
92
98
  # GET /admin/posts/new
93
99
  def admin_new
94
100
  return if !user_is_allowed('posts', 'new')
@@ -57,10 +57,10 @@ module Caboose
57
57
  return if !user_is_allowed('users', 'view')
58
58
 
59
59
  @gen = PageBarGenerator.new(params, {
60
- 'first_name' => '',
61
- 'last_name' => '',
62
- 'username' => '',
63
- 'email' => '',
60
+ 'first_name_like' => '',
61
+ 'last_name_like' => '',
62
+ 'username_like' => '',
63
+ 'email_like' => '',
64
64
  },{
65
65
  'model' => 'Caboose::User',
66
66
  'sort' => 'last_name, first_name',
@@ -18,5 +18,6 @@ class Caboose::Post < ActiveRecord::Base
18
18
  :thumb => '150x150>',
19
19
  :large => '400x400>'
20
20
  }
21
+ do_not_validate_attachment_file_type :image
21
22
 
22
23
  end
@@ -20,7 +20,7 @@ $(document).ready(function() {
20
20
  attributes: [
21
21
  { name: 'published' , nice_name: 'Published' , type: 'checkbox' , value: <%= raw @post.published ? true : false %>, width: 600 },
22
22
  { name: 'title' , nice_name: 'Title' , type: 'text' , value: <%= raw Caboose.json(@post.title) %>, width: 600 },
23
- { name: 'image' , nice_name: 'Image' , type: 'image' , value: <%= raw Caboose.json(@post.image.url(:thumb)) %>, width: 600 }
23
+ { name: 'image' , nice_name: 'Image' , type: 'image' , value: <%= raw Caboose.json(@post.image.url(:thumb)) %>, width: 600, update_url: '/admin/posts/<%= @post.id %>/image' }
24
24
  ]
25
25
  });
26
26
  });
@@ -1,7 +1,10 @@
1
1
  <h1>Users</h1>
2
2
 
3
3
  <form action='/admin/users' method='get' class='search_form'>
4
- <input type='text' name='search' placeholder='Search' />
4
+ <input type='text' name='first_name_like' placeholder='First name' />
5
+ <input type='text' name='last_name_like' placeholder='Last name' />
6
+ <input type='text' name='email_like' placeholder='Email' />
7
+ <input type='submit' value='Search' />
5
8
  </form>
6
9
 
7
10
  <table class='data' id='users_table'>
data/config/routes.rb CHANGED
@@ -121,7 +121,7 @@ Caboose::Engine.routes.draw do
121
121
  get "admin/posts/:id/remove-from-category" => "posts#admin_remove_from_category"
122
122
  get "admin/posts/:id/delete" => "posts#admin_delete_form"
123
123
  put "admin/posts/:id" => "posts#admin_update"
124
- post "admin/posts/:id" => "posts#admin_update"
124
+ post "admin/posts/:id/image" => "posts#admin_update_image"
125
125
  get "admin/posts" => "posts#admin_index"
126
126
  post "admin/posts" => "posts#admin_add"
127
127
  delete "admin/posts/:id" => "posts#admin_delete"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.3.67'
2
+ VERSION = '0.3.68'
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.67
4
+ version: 0.3.68
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-03-17 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -171,12 +171,14 @@ files:
171
171
  - app/assets/javascripts/caboose/model/bound_file.js
172
172
  - app/assets/javascripts/caboose/model/bound_image.js
173
173
  - app/assets/javascripts/caboose/model/bound_richtext.js
174
+ - app/assets/javascripts/caboose/model/bound_s3_image.js
174
175
  - app/assets/javascripts/caboose/model/bound_select.js
175
176
  - app/assets/javascripts/caboose/model/bound_text.js
176
177
  - app/assets/javascripts/caboose/model/bound_textarea.js
177
178
  - app/assets/javascripts/caboose/model/class.js
178
179
  - app/assets/javascripts/caboose/model/model.js
179
180
  - app/assets/javascripts/caboose/model/model_binder.js
181
+ - app/assets/javascripts/caboose/model/s3.js
180
182
  - app/assets/javascripts/caboose/model.form.page.js
181
183
  - app/assets/javascripts/caboose/model.form.user.js
182
184
  - app/assets/javascripts/caboose/shortcut.js