caboose-cms 0.3.42 → 0.3.43

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
- ZDg5NmI3YTFlZWU3MDg5NTlkMzM2NWFjMDcxZmE0MTAxZjE0NTk5Yw==
4
+ YTQ2YzZjNzlhNjJkMWU2NjllMmI1MGQ2M2M1ZDE1M2E0OGZkNDQxOQ==
5
5
  data.tar.gz: !binary |-
6
- NzFkMTM5ZGYzYWU1ZTUwNmNmY2ZmMTBjMTkxM2VjZjc0OWZkNDQ5OQ==
6
+ ZjYwZjFiYmRkNWY2OWY2ZDAwNjkyYjAxNGE0Y2FhZTFkNmZlNzk0Nw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- N2VmZTNhYTgyYTU2Y2UyMzJiOTk0MmNjYWFhNzczMmRkNTRjZmZlZWNmZjYz
10
- MDVmZDAxNzcyZGE0YmI1Yzc3ZjViZWNmNWZiM2ZhMmMxMmU3ZWEyODNkMThk
11
- Njg3NzM4NzI3MjA3MWRhMzQwOGY1ZGMwMzA5MGMxYmYwNGQ0Yjk=
9
+ N2IwMDAzMTMzOGVlNWZkZGIyZGM1OGUyZTI4MTJmZjk5MGIwYzBhYWM1NjIy
10
+ YjE5Mjc4MjEyMzViY2VmYTRmODIwNDBkYjQwODZjMmQwMTk1NTExMDJiYTNj
11
+ OTJkZDdiM2RmOWNiY2ZlZjY2NWI2M2Q5OTZlNWIwODE1NDdhZTc=
12
12
  data.tar.gz: !binary |-
13
- Y2YxN2RkOTZjMTY4OTA2YmZhZTExZmY2ZTZjNTY0N2NhZTY2NDdlZDkxNzQ0
14
- NjFhMjI0MzcwMTdmNjlkODAxZTZlN2EzZjcyNjE4Nzg5ZWE4NGY2OTBlMWU3
15
- ZGVlMDczMDBmMmUxMGNlOGUxNGVmZjE1MzYxMjhjZDA4NTdiNjE=
13
+ ZjY3N2JiNWU2NjE3NjcwZTIxYmRjZDUxMWVlZjllN2VlMzk1MWUzMmVkYzgx
14
+ OWM1NjgwY2MyNjIyNWRmYjEzOGIyZjkwNDNiZTBmZGY4MzA3MTFmOWM3YWU5
15
+ OTNjYTAxZDRhNGNkODRlOTI2ZjRiNjZkNDM4YTA1YjNmNWY3NWU=
@@ -24,6 +24,7 @@ Attribute.prototype = {
24
24
  debug: false,
25
25
  download_text: false,
26
26
  upload_text: false,
27
+ image_refresh_delay: false,
27
28
 
28
29
  update_url: false,
29
30
  options_url: false,
@@ -72,7 +72,7 @@ BoundFile = BoundControl.extend({
72
72
  $('#'+this.el+'_container').append($('<div/>')
73
73
  .attr('id', this.el + '_message')
74
74
  );
75
- iframe = $("<iframe name='" + this.el + "_iframe' />")
75
+ iframe = $("<iframe name=\"" + this.el + "_iframe\"></iframe>")
76
76
  .attr('name', this.el + '_iframe')
77
77
  .attr('id', this.el + '_iframe');
78
78
  if (this.attribute.debug)
@@ -73,7 +73,7 @@ BoundImage = BoundControl.extend({
73
73
 
74
74
  var resp = $.parseJSON(str);
75
75
  if (resp.success)
76
- {
76
+ {
77
77
  if (resp.attributes && resp.attributes[this.attribute.name])
78
78
  for (var thing in resp.attributes[this.attribute.name])
79
79
  this.attribute[thing] = resp.attributes[this.attribute.name][thing];
@@ -83,7 +83,25 @@ BoundImage = BoundControl.extend({
83
83
  if (resp.error)
84
84
  this.error(resp.error);
85
85
  else
86
- $('#'+this.el+'_container img').attr('src', this.attribute.value + '?' + Math.random());
86
+ {
87
+ if (this.attribute.image_refresh_delay)
88
+ {
89
+ var that = this;
90
+ setTimeout(function() { that.refresh_image(); }, this.attribute.image_refresh_delay);
91
+ }
92
+ else
93
+ {
94
+ this.refresh_image();
95
+ }
96
+ }
97
+ },
98
+
99
+ refresh_image: function() {
100
+ var src = this.attribute.value;
101
+ if (src.indexOf('?') > 0)
102
+ src = src.split('?')[0];
103
+ src = src + '?' + Math.random();
104
+ $('#'+this.el+'_container img').attr('src', src);
87
105
  },
88
106
 
89
107
  error: function(str) {
@@ -22,6 +22,32 @@ module Caboose
22
22
  resp.success = save && fv.save
23
23
  render :json => resp
24
24
  end
25
+
26
+ # POST /admin/page-block-field-values/:id/image
27
+ def admin_update_image
28
+ return unless user_is_allowed('pages', 'edit')
29
+
30
+ resp = StdClass.new({'attributes' => {}})
31
+ fv = PageBlockFieldValue.find(params[:id])
32
+ fv.image = params[:value]
33
+ fv.save
34
+ resp.success = true
35
+ resp.attributes = { 'value' => { 'value' => fv.image.url(:tiny) }}
36
+
37
+ render :json => resp
38
+ end
39
+
40
+ # POST /admin/page-block-field-values/:id/image
41
+ def admin_update_file
42
+ return unless user_is_allowed('pages', 'edit')
43
+
44
+ resp = StdClass.new({'attributes' => {}})
45
+ fv = PageBlockFieldValue.find(params[:id])
46
+ fv.file = params[:value]
47
+ resp.success = fv.save
48
+
49
+ render :json => resp
50
+ end
25
51
 
26
52
  end
27
53
  end
@@ -13,7 +13,12 @@ class Caboose::PageBlock < ActiveRecord::Base
13
13
 
14
14
  def field_value(name)
15
15
  page_block_field_values.each do |fv|
16
- return fv.value if fv.page_block_field.name == name
16
+ if fv.page_block_field.name == name
17
+ if fv.page_block_field.field_type == 'image' then return fv.image
18
+ elsif fv.page_block_field.field_type == 'file' then return fv.file
19
+ else return fv.value
20
+ end
21
+ end
17
22
  end
18
23
  return nil
19
24
  end
@@ -4,6 +4,18 @@ class Caboose::PageBlockFieldValue < ActiveRecord::Base
4
4
 
5
5
  belongs_to :page_block
6
6
  belongs_to :page_block_field
7
+
8
+ has_attached_file :file, :path => '/uploads/:id.:extension'
9
+ do_not_validate_attachment_file_type :file
10
+ has_attached_file :image,
11
+ :path => 'uploads/:id_:image_updated_at_:style.:extension',
12
+ :styles => {
13
+ :tiny => '160x120>',
14
+ :thumb => '400x300>',
15
+ :large => '640x480>'
16
+ }
17
+ do_not_validate_attachment_file_type :image
18
+
7
19
  attr_accessible :id, :page_block_id, :page_block_field_id, :value
8
20
 
9
21
  end
@@ -120,9 +120,11 @@ class Caboose::Schema < Caboose::Utilities::Schema
120
120
  [ :options_url , :string ]
121
121
  ],
122
122
  Caboose::PageBlockFieldValue => [
123
- [ :page_block_id , :integer ],
124
- [ :page_block_field_id , :integer ],
125
- [ :value , :text ]
123
+ [ :page_block_id , :integer ],
124
+ [ :page_block_field_id , :integer ],
125
+ [ :value , :text ],
126
+ [ :file , :attachment ],
127
+ [ :image , :attachment ]
126
128
  ],
127
129
  Caboose::Post => [
128
130
  [ :title , :text ],
@@ -1,9 +1,15 @@
1
+ <%
2
+ update_on_close = false
3
+ @block.page_block_type.fields.each do |f|
4
+ update_on_close = true if f.field_type == 'image' || f.field_type == 'file'
5
+ end
6
+ %>
1
7
  <h2 style='margin-top: 0; padding-top: 0;'>Edit <%= @block.page_block_type.description %></h2>
2
8
  <% @block.page_block_type.fields.each do |f| %>
3
9
  <% fv = @block.field_value_object(f.name) %>
4
10
  <div id='pageblockfieldvalue_<%= fv.id %>_value'></div>
5
11
  <% end %>
6
- <p><input type='button' value='Close' onclick="modal.close();" /></p>
12
+ <p><input type='button' value='Close' onclick="<% if update_on_close %>parent.controller.render_blocks();<% end %>modal.close();" /></p>
7
13
 
8
14
  <% content_for :caboose_js do %>
9
15
  <%= javascript_include_tag "caboose/model/all" %>
@@ -27,14 +33,23 @@ $(document).ready(function() {
27
33
  attributes: [{
28
34
  name: 'value',
29
35
  type: <%= raw Caboose.json(f.field_type) %>,
30
- value: <% if f.field_type == 'checkbox' %><%= fv.value ? 'true' : 'false' %><% else %><%= raw Caboose.json(fv.value) %><% end %>,
36
+ value: <%
37
+ if f.field_type == 'checkbox' %><%= fv.value ? 'true' : 'false' %><%
38
+ elsif f.field_type == 'image' %><%= raw Caboose.json(fv.image.url(:tiny)) %><%
39
+ elsif f.field_type == 'file' %><%= raw Caboose.json(fv.image.url) %><%
40
+ else %><%= raw Caboose.json(fv.value) %><%
41
+ end %>,
31
42
  <% if f.field_type == 'select' %>text: <%= raw Caboose.json(fv.value) %>,<% end %>
32
43
  nice_name: <%= raw Caboose.json(f.nice_name ? f.nice_name : f.name) %>,
33
44
  width: <% if f.width %><%= raw Caboose.json(f.width) %><% else %>780<% end %>,
34
- <% if f.height %>height: <%= raw Caboose.json(f.height) %>,<% end %>
35
- <% if f.fixed_placeholder %>fixed_placeholder: <%= raw Caboose.json(f.fixed_placeholder) %>,<% end %>
36
- <% if f.options %>options_url: '/admin/page-block-fields/<%= f.id %>/options',<%
37
- elsif f.options_url %>options_url: <%= raw Caboose.json(f.options_url) %>,<% end %>
45
+ <% if f.height %>height: <%= raw Caboose.json(f.height) %>,<% end %>
46
+ <% if f.fixed_placeholder %>fixed_placeholder: <%= raw Caboose.json(f.fixed_placeholder) %>,<% end %>
47
+ <% if f.options %>options_url: '/admin/page-block-fields/<%= f.id %>/options',<%
48
+ elsif f.options_url %>options_url: <%= raw Caboose.json(f.options_url) %>,<% end %>
49
+ <% if f.field_type == 'image' %>update_url: '/admin/page-block-field-values/<%= fv.id %>/image',
50
+ image_refresh_delay: 100,
51
+ <% end %>
52
+ <% if f.field_type == 'file' %>update_url: '/admin/page-block-field-values/<%= fv.id %>/file',<% end %>
38
53
  after_update: function() { parent.controller.render_blocks(); },
39
54
  after_cancel: function() { parent.controller.render_blocks(); }
40
55
  }]
@@ -87,7 +87,9 @@ Caboose::Engine.routes.draw do
87
87
  put "admin/pages/:page_id/blocks/:id" => "page_blocks#admin_update"
88
88
  delete "admin/pages/:page_id/blocks/:id" => "page_blocks#admin_delete"
89
89
 
90
- put "admin/page-block-field-values/:id" => "page_block_field_values#admin_update"
90
+ put "admin/page-block-field-values/:id" => "page_block_field_values#admin_update"
91
+ post "admin/page-block-field-values/:id/image" => "page_block_field_values#admin_update_image"
92
+ post "admin/page-block-field-values/:id/file" => "page_block_field_values#admin_update_file"
91
93
 
92
94
  get "admin/page-block-types/new" => "page_block_types#admin_new"
93
95
  get "admin/page-block-types/:id/edit" => "page_block_types#admin_edit"
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.3.42'
2
+ VERSION = '0.3.43'
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.42
4
+ version: 0.3.43
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-02-24 00:00:00.000000000 Z
11
+ date: 2014-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails