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 +8 -8
- data/app/assets/javascripts/caboose/model/attribute.js +1 -0
- data/app/assets/javascripts/caboose/model/bound_file.js +1 -1
- data/app/assets/javascripts/caboose/model/bound_image.js +20 -2
- data/app/controllers/caboose/page_block_field_values_controller.rb +26 -0
- data/app/models/caboose/page_block.rb +6 -1
- data/app/models/caboose/page_block_field_value.rb +12 -0
- data/app/models/caboose/schema.rb +5 -3
- data/app/views/caboose/page_blocks/admin_edit.html.erb +21 -6
- data/config/routes.rb +3 -1
- data/lib/caboose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTQ2YzZjNzlhNjJkMWU2NjllMmI1MGQ2M2M1ZDE1M2E0OGZkNDQxOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjYwZjFiYmRkNWY2OWY2ZDAwNjkyYjAxNGE0Y2FhZTFkNmZlNzk0Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2IwMDAzMTMzOGVlNWZkZGIyZGM1OGUyZTI4MTJmZjk5MGIwYzBhYWM1NjIy
|
10
|
+
YjE5Mjc4MjEyMzViY2VmYTRmODIwNDBkYjQwODZjMmQwMTk1NTExMDJiYTNj
|
11
|
+
OTJkZDdiM2RmOWNiY2ZlZjY2NWI2M2Q5OTZlNWIwODE1NDdhZTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjY3N2JiNWU2NjE3NjcwZTIxYmRjZDUxMWVlZjllN2VlMzk1MWUzMmVkYzgx
|
14
|
+
OWM1NjgwY2MyNjIyNWRmYjEzOGIyZjkwNDNiZTBmZGY4MzA3MTFmOWM3YWU5
|
15
|
+
OTNjYTAxZDRhNGNkODRlOTI2ZjRiNjZkNDM4YTA1YjNmNWY3NWU=
|
@@ -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
|
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
|
-
|
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
|
-
|
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: <%
|
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
|
35
|
-
<% if f.fixed_placeholder
|
36
|
-
<% if f.options
|
37
|
-
elsif f.options_url
|
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
|
}]
|
data/config/routes.rb
CHANGED
@@ -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"
|
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"
|
data/lib/caboose/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|