caboose-cms 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/app/controllers/caboose/block_type_sources_controller.rb +104 -0
- data/app/controllers/caboose/block_types_controller.rb +19 -0
- data/app/models/caboose/block_type.rb +26 -0
- data/app/models/caboose/block_type_source.rb +64 -0
- data/app/models/caboose/core_plugin.rb +7 -6
- data/app/models/caboose/schema.rb +8 -21
- data/app/views/caboose/block_type_sources/admin_edit.html.erb +75 -0
- data/app/views/caboose/block_type_sources/admin_index.html.erb +24 -0
- data/app/views/caboose/block_type_sources/admin_new.html.erb +31 -0
- data/app/views/caboose/blocks/_layout_basic_content.html.erb +4 -2
- data/app/views/layouts/caboose/application.html.erb +18 -4
- data/config/routes.rb +9 -0
- data/lib/caboose/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
NmUxYjBmZTQ2NTYxZDQ4YWQzMWJlMGY0NzE1MDUzM2JlYmM1ZTBiYg==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
M2M2MWIwYTkyZmEyYWFkZDM2NWQ3ZjEwOGI5YjBlNWE0NjNjNDNjNg==
|
|
7
7
|
!binary "U0hBNTEy":
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
MzVlNmYzZjU1MWM2Yjc0NjRkMDA2MTc2NjAzOWI1MDVhZmMyZTkxYjY4Mjk2
|
|
10
|
+
Y2JmMGJkZmRkNDI0YTY2OTE4OTJjMGNkNWZkMWQwNDgxYWRhMGU3MjJlMzg3
|
|
11
|
+
YjhlMjRiNzBhOTE0NDdiZmE1M2ZiZGZlMjg2OTc3NzFmNTVkZTI=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
NmEyOWFhYTg2MTdkZDdlNmY2ODc4MTliMTIwZTJiMDE4NzUwYmY2YTUxMjYw
|
|
14
|
+
YTQxOTQwZjhkZGI3MjFlOTFkMzU3YTllZTNkY2JhYWM3MDdkZWZhNDVmZDYy
|
|
15
|
+
ZjQ4ZDA4YzRlY2Y2ZWI1NmU5ZTQ3YTZjMTc5MjdhNWE3NzM3YWE=
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module Caboose
|
|
2
|
+
class BlockTypeSourcesController < ApplicationController
|
|
3
|
+
|
|
4
|
+
#===========================================================================
|
|
5
|
+
# Admin actions
|
|
6
|
+
#===========================================================================
|
|
7
|
+
|
|
8
|
+
# GET /admin/block-type-sources
|
|
9
|
+
def admin_index
|
|
10
|
+
return if !user_is_allowed('blocktypesources', 'view')
|
|
11
|
+
@block_type_sources = BlockTypeSource.reorder("priority, name").all
|
|
12
|
+
render :layout => 'caboose/admin'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# GET /admin/block-type-sources/new
|
|
16
|
+
def admin_new
|
|
17
|
+
return unless user_is_allowed('blocktypesources', 'add')
|
|
18
|
+
render :layout => 'caboose/admin'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# GET /admin/block-type-sources/:id/edit
|
|
22
|
+
def admin_edit
|
|
23
|
+
return unless user_is_allowed('blocktypesources', 'edit')
|
|
24
|
+
@block_type_source = BlockTypeSource.find(params[:id])
|
|
25
|
+
render :layout => 'caboose/admin'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# POST /admin/block-type-sources
|
|
29
|
+
def admin_create
|
|
30
|
+
return unless user_is_allowed('blocktypesources', 'add')
|
|
31
|
+
|
|
32
|
+
resp = Caboose::StdClass.new
|
|
33
|
+
max_priority = BlockTypeSource.maximum(:priority)
|
|
34
|
+
max_priority = 0 if max_priority.nil?
|
|
35
|
+
bts = BlockTypeSource.new(
|
|
36
|
+
:name => params[:name],
|
|
37
|
+
:priority => max_priority + 1,
|
|
38
|
+
:active => true
|
|
39
|
+
)
|
|
40
|
+
bts.save
|
|
41
|
+
|
|
42
|
+
# Send back the response
|
|
43
|
+
resp.redirect = "/admin/block-type-sources/#{bts.id}/edit"
|
|
44
|
+
render :json => resp
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# PUT /admin/block-type-sources/:id
|
|
48
|
+
def admin_update
|
|
49
|
+
return unless user_is_allowed('blocktypesources', 'edit')
|
|
50
|
+
|
|
51
|
+
resp = StdClass.new({'attributes' => {}})
|
|
52
|
+
bts = BlockTypeSource.find(params[:id])
|
|
53
|
+
save = true
|
|
54
|
+
|
|
55
|
+
params.each do |k,v|
|
|
56
|
+
case k
|
|
57
|
+
when 'name' then bts.name = v
|
|
58
|
+
when 'url' then bts.url = v
|
|
59
|
+
when 'token' then bts.token = v
|
|
60
|
+
when 'priority' then bts.priority = v
|
|
61
|
+
when 'active' then bts.active = v
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
resp.success = save && bts.save
|
|
66
|
+
render :json => resp
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# DELETE /admin/block-type-sources/:id
|
|
70
|
+
def admin_delete
|
|
71
|
+
return unless user_is_allowed('blocktypesources', 'delete')
|
|
72
|
+
BlockTypeSource.find(params[:id]).destroy
|
|
73
|
+
resp = StdClass.new({
|
|
74
|
+
'redirect' => "/admin/block-type-sources"
|
|
75
|
+
})
|
|
76
|
+
render :json => resp
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# GET /admin/block-type-sources/:id/refresh
|
|
80
|
+
def admin_refresh
|
|
81
|
+
return unless user_is_allowed('blocktypesources', 'edit')
|
|
82
|
+
|
|
83
|
+
resp = StdClass.new
|
|
84
|
+
|
|
85
|
+
bts = BlockTypeSource.find(params[:id])
|
|
86
|
+
if bts.refresh
|
|
87
|
+
resp.success = "Block types from the source have been refreshed successfully."
|
|
88
|
+
else
|
|
89
|
+
resp.error = "There was an error refreshing block types from the source."
|
|
90
|
+
end
|
|
91
|
+
render :json => resp
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# GET /admin/block-type-sources/options
|
|
95
|
+
def admin_options
|
|
96
|
+
return unless user_is_allowed('blocktypesources', 'edit')
|
|
97
|
+
options = BlockType.reorder(:name).all.collect do |bts|
|
|
98
|
+
{ 'value' => bts.id, 'text' => bts.name }
|
|
99
|
+
end
|
|
100
|
+
render :json => options
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -158,6 +158,25 @@ module Caboose
|
|
|
158
158
|
admin_tree_options_helper(options, bt2, " - #{prefix}")
|
|
159
159
|
end
|
|
160
160
|
end
|
|
161
|
+
|
|
162
|
+
#===========================================================================
|
|
163
|
+
# Public Repo Actions
|
|
164
|
+
#===========================================================================
|
|
165
|
+
|
|
166
|
+
# GET /caboose/block-types
|
|
167
|
+
def api_block_type_list
|
|
168
|
+
arr = BlockType.where("parent_id is null and share = ?", true).reorder(:name).all.collect do |bt|
|
|
169
|
+
{ 'name' => bt.name, 'description' => bt.description }
|
|
170
|
+
end
|
|
171
|
+
render :json => arr
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# GET /caboose/block-types/:name
|
|
175
|
+
def api_block_type
|
|
176
|
+
bt = BlockType.where(:name => params[:name]).first
|
|
177
|
+
render :json => { 'error' => 'Invalid block type.' } if bt.nil?
|
|
178
|
+
render :json => bt.api_hash
|
|
179
|
+
end
|
|
161
180
|
|
|
162
181
|
end
|
|
163
182
|
end
|
|
@@ -26,5 +26,31 @@ class Caboose::BlockType < ActiveRecord::Base
|
|
|
26
26
|
def render_options(empty_text = nil)
|
|
27
27
|
return eval(self.options_function)
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
def api_hash
|
|
31
|
+
return {
|
|
32
|
+
:name => self.name,
|
|
33
|
+
:description => self.description,
|
|
34
|
+
:block_type_category_id => self.block_type_category_id,
|
|
35
|
+
:render_function => self.render_function,
|
|
36
|
+
:use_render_function => self.use_render_function,
|
|
37
|
+
:use_render_function_for_layout => self.use_render_function_for_layout,
|
|
38
|
+
:allow_child_blocks => self.allow_child_blocks,
|
|
39
|
+
:field_type => self.field_type,
|
|
40
|
+
:default => self.default,
|
|
41
|
+
:width => self.width,
|
|
42
|
+
:height => self.height,
|
|
43
|
+
:fixed_placeholder => self.fixed_placeholder,
|
|
44
|
+
:options => self.options,
|
|
45
|
+
:options_function => self.options_function,
|
|
46
|
+
:options_url => self.options_url,
|
|
47
|
+
:children => self.api_hash_children
|
|
48
|
+
}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def api_hash_children
|
|
52
|
+
return nil if self.children.nil? || self.children.count == 0
|
|
53
|
+
return self.children.collect { |bt| bt.api_hash }
|
|
54
|
+
end
|
|
29
55
|
|
|
30
56
|
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
|
|
3
|
+
class Caboose::BlockTypeSource < ActiveRecord::Base
|
|
4
|
+
self.table_name = "block_type_sources"
|
|
5
|
+
|
|
6
|
+
has_many :block_types, :class_name => 'Caboose::BlockType', :order => 'name'
|
|
7
|
+
attr_accessible :id,
|
|
8
|
+
:name,
|
|
9
|
+
:url,
|
|
10
|
+
:token,
|
|
11
|
+
:priority,
|
|
12
|
+
:active
|
|
13
|
+
|
|
14
|
+
def refresh
|
|
15
|
+
resp = nil
|
|
16
|
+
begin
|
|
17
|
+
resp = HTTParty.get("#{self.url}/block-types?token=#{self.token}")
|
|
18
|
+
rescue HTTParty::Error => e
|
|
19
|
+
Caboose.log(e.message)
|
|
20
|
+
return false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
block_types = nil
|
|
24
|
+
begin
|
|
25
|
+
block_types = JSON.parse(resp.body)
|
|
26
|
+
rescue
|
|
27
|
+
Caboose.log("Response body isn't valid JSON.")
|
|
28
|
+
return false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
#block_types.each do |bt|
|
|
32
|
+
# Caboose.log(
|
|
33
|
+
# next if Caboose::BlockType.where(:name => bt.name).exists?
|
|
34
|
+
# #self.recursive_add(bt)
|
|
35
|
+
#end
|
|
36
|
+
|
|
37
|
+
return true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def recursive_add(bt, parent_id = nil)
|
|
41
|
+
bt2 = Caboose::BlockType.create(
|
|
42
|
+
:parent_id => parent_id,
|
|
43
|
+
:name => bt.name,
|
|
44
|
+
:description => bt.description,
|
|
45
|
+
:block_type_category_id => bt.block_type_category_id,
|
|
46
|
+
:render_function => bt.render_function,
|
|
47
|
+
:use_render_function => bt.use_render_function,
|
|
48
|
+
:use_render_function_for_layout => bt.use_render_function_for_layout,
|
|
49
|
+
:allow_child_blocks => bt.allow_child_blocks,
|
|
50
|
+
:field_type => bt.field_type,
|
|
51
|
+
:default => bt.default,
|
|
52
|
+
:width => bt.width,
|
|
53
|
+
:height => bt.height,
|
|
54
|
+
:fixed_placeholder => bt.fixed_placeholder,
|
|
55
|
+
:options => bt.options,
|
|
56
|
+
:options_function => bt.options_function,
|
|
57
|
+
:options_url => bt.options_url
|
|
58
|
+
)
|
|
59
|
+
bt.children.each do |bt3|
|
|
60
|
+
self.recursive_add(bt3, bt2.id)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
@@ -21,12 +21,13 @@ class Caboose::CorePlugin < Caboose::CaboosePlugin
|
|
|
21
21
|
'children' => []
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
item['children'] << { 'id' => 'users'
|
|
25
|
-
item['children'] << { 'id' => 'roles'
|
|
26
|
-
item['children'] << { 'id' => 'permissions'
|
|
27
|
-
item['children'] << { 'id' => 'blocktypes'
|
|
28
|
-
item['children'] << { 'id' => 'variables'
|
|
29
|
-
item['children'] << { 'id' => 'blocktypes'
|
|
24
|
+
item['children'] << { 'id' => 'users' , 'text' => 'Users' , 'href' => '/admin/users' , 'modal' => false } if user.is_allowed('users' , 'view')
|
|
25
|
+
item['children'] << { 'id' => 'roles' , 'text' => 'Roles' , 'href' => '/admin/roles' , 'modal' => false } if user.is_allowed('roles' , 'view')
|
|
26
|
+
item['children'] << { 'id' => 'permissions' , 'text' => 'Permissions' , 'href' => '/admin/permissions' , 'modal' => false } if user.is_allowed('permissions' , 'view')
|
|
27
|
+
item['children'] << { 'id' => 'blocktypes' , 'text' => 'AB Test Variants' , 'href' => '/admin/ab-variants' , 'modal' => false } if user.is_allowed('abvariants' , 'view')
|
|
28
|
+
item['children'] << { 'id' => 'variables' , 'text' => 'Variables' , 'href' => '/admin/settings' , 'modal' => false } if user.is_allowed('settings' , 'view')
|
|
29
|
+
item['children'] << { 'id' => 'blocktypes' , 'text' => 'Block Types' , 'href' => '/admin/block-types' , 'modal' => false } if user.is_allowed('blocktypes' , 'view')
|
|
30
|
+
item['children'] << { 'id' => 'blocktypesources' , 'text' => 'Block Type Sources' , 'href' => '/admin/block-type-sources' , 'modal' => false } if user.is_allowed('blocktypesources' , 'view')
|
|
30
31
|
|
|
31
32
|
nav << item if item['children'].count > 0
|
|
32
33
|
|
|
@@ -63,7 +63,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
|
63
63
|
[ :utc_offset , :float , { :default => -5 }],
|
|
64
64
|
#[ :timezone , :string , { :default => 'America/Chicago' }],
|
|
65
65
|
[ :timezone_id , :integer , { :defualt => 381 }], # Defaults to 'America/Chicago'
|
|
66
|
-
[ :password , :string ],
|
|
66
|
+
[ :password , :string ],
|
|
67
67
|
[ :password_reset_id , :string ],
|
|
68
68
|
[ :password_reset_sent , :datetime ],
|
|
69
69
|
[ :token , :string ],
|
|
@@ -154,26 +154,13 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
|
154
154
|
[ :parent_id , :integer ],
|
|
155
155
|
[ :name , :string ]
|
|
156
156
|
],
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
#Caboose::FieldType => [
|
|
165
|
-
# [ :block_type_id , :integer ],
|
|
166
|
-
# [ :name , :string ],
|
|
167
|
-
# [ :field_type , :string ],
|
|
168
|
-
# [ :nice_name , :string ],
|
|
169
|
-
# [ :default , :text ],
|
|
170
|
-
# [ :width , :integer ],
|
|
171
|
-
# [ :height , :integer ],
|
|
172
|
-
# [ :fixed_placeholder , :boolean ],
|
|
173
|
-
# [ :options , :text ],
|
|
174
|
-
# [ :options_function , :text ],
|
|
175
|
-
# [ :options_url , :string ]
|
|
176
|
-
#],
|
|
157
|
+
Caboose::BlockTypeSource => [
|
|
158
|
+
[ :name , :string ],
|
|
159
|
+
[ :url , :string ],
|
|
160
|
+
[ :token , :string ],
|
|
161
|
+
[ :priority , :integer, { :default => 0 }],
|
|
162
|
+
[ :active , :boolean, { :default => true }],
|
|
163
|
+
],
|
|
177
164
|
Caboose::Post => [
|
|
178
165
|
[ :title , :text ],
|
|
179
166
|
[ :body , :text ],
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<%
|
|
2
|
+
bts = @block_type_source
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<h1>Edit Source</h1>
|
|
6
|
+
<p><div id='blocktypesource_<%= bts.id %>_name' ></div></p>
|
|
7
|
+
<p><div id='blocktypesource_<%= bts.id %>_url' ></div></p>
|
|
8
|
+
<p><div id='blocktypesource_<%= bts.id %>_token' ></div></p>
|
|
9
|
+
<p><div id='blocktypesource_<%= bts.id %>_priority' ></div></p>
|
|
10
|
+
<p><div id='blocktypesource_<%= bts.id %>_active' ></div></p>
|
|
11
|
+
|
|
12
|
+
<div id='message'></div>
|
|
13
|
+
<p>
|
|
14
|
+
<input type='button' value='< Back' onclick="window.location='/admin/block-type-sources';" />
|
|
15
|
+
<input type='button' value='Refresh Block Types' onclick="refresh_block_types(<%= bts.id %>);" />
|
|
16
|
+
<input type='button' value='Delete Source' onclick="delete_block_type_source(<%= bts.id %>);" />
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<% content_for :caboose_js do %>
|
|
20
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
|
21
|
+
<script type="text/javascript">
|
|
22
|
+
|
|
23
|
+
function delete_block_type_source(bts_id, confirm)
|
|
24
|
+
{
|
|
25
|
+
if (!confirm)
|
|
26
|
+
{
|
|
27
|
+
var p = $('<p/>').addClass('note warning')
|
|
28
|
+
.append('Are you sure you want to delete the source?')
|
|
29
|
+
.append($('<input/>').attr('type', 'button').val('Yes').click(function() { delete_block_type_source(bts_id, true); })).append(" ")
|
|
30
|
+
.append($('<input/>').attr('type', 'button').val('No' ).click(function() { $('#message').empty(); }));
|
|
31
|
+
$('#message').empty().append(p);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
$('#message').empty().append($('<p/>').addClass('loading').html('Deleting source...'));
|
|
35
|
+
$.ajax({
|
|
36
|
+
url: '/admin/block-type-sources/' + bts_id,
|
|
37
|
+
type: 'delete',
|
|
38
|
+
success: function(resp) {
|
|
39
|
+
if (resp.error) $('#message').empty().append($('<p/>').addClass('note error').html(resp.error));
|
|
40
|
+
if (resp.redirect) window.location = resp.redirect;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function refresh_block_types(bts_id)
|
|
46
|
+
{
|
|
47
|
+
$('#message').empty().append($('<p/>').addClass('loading').html('Refreshing block types from source...'));
|
|
48
|
+
$.ajax({
|
|
49
|
+
url: '/admin/block-type-sources/' + bts_id + '/refresh',
|
|
50
|
+
type: 'get',
|
|
51
|
+
success: function(resp) {
|
|
52
|
+
if (resp.error) $('#message').empty().append($('<p/>').addClass('note error').html(resp.error));
|
|
53
|
+
if (resp.success) $('#message').empty().append($('<p/>').addClass('note success').html(resp.error));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
$(document).ready(function() {
|
|
59
|
+
m = new ModelBinder({
|
|
60
|
+
name: 'BlockTypeSource',
|
|
61
|
+
id: <%= bts.id %>,
|
|
62
|
+
update_url: '/admin/block-type-sources/<%= bts.id %>',
|
|
63
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
|
64
|
+
attributes: [
|
|
65
|
+
{ name: 'name' , nice_name: 'Name' , type: 'text' , value: <%= raw Caboose.json(bts.name) %>, width: 400 },
|
|
66
|
+
{ name: 'url' , nice_name: 'URL' , type: 'text' , value: <%= raw Caboose.json(bts.url) %>, width: 400 },
|
|
67
|
+
{ name: 'token' , nice_name: 'Token' , type: 'text' , value: <%= raw Caboose.json(bts.token) %>, width: 400 },
|
|
68
|
+
{ name: 'priority' , nice_name: 'Priority' , type: 'text' , value: <%= raw Caboose.json(bts.priority) %>, width: 400 },
|
|
69
|
+
{ name: 'active' , nice_name: 'Active' , type: 'checkbox' , value: <%= bts.active ? 'true' : 'false' %>, width: 400 }
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
</script>
|
|
75
|
+
<% end %>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<h1>Block Type Sources</h1>
|
|
2
|
+
|
|
3
|
+
<p><a href='/admin/block-type-sources/new'>New Source</a></p>
|
|
4
|
+
|
|
5
|
+
<% if (@block_type_sources.count > 0) %>
|
|
6
|
+
|
|
7
|
+
<table class='data'>
|
|
8
|
+
<tr>
|
|
9
|
+
<th>Name</th>
|
|
10
|
+
<th>URL</th>
|
|
11
|
+
</tr>
|
|
12
|
+
<% @block_type_sources.each do |bts| %>
|
|
13
|
+
<tr onclick="window.location='/admin/block-type-sources/<%= bts.id %>/edit';">
|
|
14
|
+
<td><%= bts.name %></td>
|
|
15
|
+
<td><%= bts.url %></td>
|
|
16
|
+
</tr>
|
|
17
|
+
<% end %>
|
|
18
|
+
</table>
|
|
19
|
+
|
|
20
|
+
<% else %>
|
|
21
|
+
|
|
22
|
+
<p>There are no sources.</p>
|
|
23
|
+
|
|
24
|
+
<% end %>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
<h1>New Source</h1>
|
|
3
|
+
<form action='/admin/block-type-sources' method='post' id='new_source_form'>
|
|
4
|
+
<input type='hidden' name='authenticity_token' value='<%= form_authenticity_token %>' />
|
|
5
|
+
<p><input type='text' id='name' name='name' placeholder='Name' /></p>
|
|
6
|
+
<div id='message'></div>
|
|
7
|
+
<p>
|
|
8
|
+
<input type='button' value='< Back' onclick="window.location='/admin/block-type-sources';" />
|
|
9
|
+
<input type='button' value='Add Source' onclick="add_block_type_source();" />
|
|
10
|
+
</p>
|
|
11
|
+
</form>
|
|
12
|
+
|
|
13
|
+
<% content_for :caboose_js do %>
|
|
14
|
+
<script type='text/javascript'>
|
|
15
|
+
|
|
16
|
+
function add_block_type_source()
|
|
17
|
+
{
|
|
18
|
+
$('#message').empty().append($('<p/>').addClass('loading').html('Adding source...'));
|
|
19
|
+
$.ajax({
|
|
20
|
+
url: '/admin/block-type-sources',
|
|
21
|
+
type: 'post',
|
|
22
|
+
data: $('#new_source_form').serialize(),
|
|
23
|
+
success: function(resp) {
|
|
24
|
+
if (resp.error) $('#message').empty().append($('<p/>').addClass('note error').html(resp.error));
|
|
25
|
+
if (resp.redirect) window.location = resp.redirect;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
</script>
|
|
31
|
+
<% end %>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<div class="content_wrapper" id='block_<%= block.id %>'>
|
|
2
|
-
<div class="content_body">
|
|
3
|
-
<% if
|
|
2
|
+
<div class="content_body">
|
|
3
|
+
<% if controller_view_content %>
|
|
4
|
+
<%= raw controller_view_content %>
|
|
5
|
+
<% elsif block.children.count > 0 %>
|
|
4
6
|
<% block.children.each do |b| %><%= raw block.render(b, local_assigns) %><% end %>
|
|
5
7
|
<% end %>
|
|
6
8
|
<% if editing %><%= raw block.child_block_link %><% end %>
|
|
@@ -16,11 +16,25 @@
|
|
|
16
16
|
|
|
17
17
|
<%
|
|
18
18
|
|
|
19
|
-
if yield && yield.strip.length > 0
|
|
20
|
-
%><%= yield %><%
|
|
21
|
-
elsif !@page.nil? && @page.title != 'Access Denied'
|
|
19
|
+
#if yield && yield.strip.length > 0
|
|
20
|
+
# %><%= yield %><%
|
|
21
|
+
#elsif !@page.nil? && @page.title != 'Access Denied'
|
|
22
|
+
# @page.top_level_blocks.each do |b|
|
|
23
|
+
# %><%= raw b.render(b, {
|
|
24
|
+
# :modal => false,
|
|
25
|
+
# :empty_text => '',
|
|
26
|
+
# :editing => defined?(@editing) ? @editing : false,
|
|
27
|
+
# :css => yield(:css),
|
|
28
|
+
# :js => yield(:js),
|
|
29
|
+
# :csrf_meta_tags => csrf_meta_tags
|
|
30
|
+
# }) %><%
|
|
31
|
+
# end
|
|
32
|
+
#end
|
|
33
|
+
|
|
34
|
+
if !@page.nil? && @page.title != 'Access Denied'
|
|
22
35
|
@page.top_level_blocks.each do |b|
|
|
23
36
|
%><%= raw b.render(b, {
|
|
37
|
+
:controller_view_content => yield,
|
|
24
38
|
:modal => false,
|
|
25
39
|
:empty_text => '',
|
|
26
40
|
:editing => defined?(@editing) ? @editing : false,
|
|
@@ -29,6 +43,6 @@ elsif !@page.nil? && @page.title != 'Access Denied'
|
|
|
29
43
|
:csrf_meta_tags => csrf_meta_tags
|
|
30
44
|
}) %><%
|
|
31
45
|
end
|
|
32
|
-
end
|
|
46
|
+
end
|
|
33
47
|
|
|
34
48
|
%>
|
data/config/routes.rb
CHANGED
|
@@ -136,6 +136,15 @@ Caboose::Engine.routes.draw do
|
|
|
136
136
|
|
|
137
137
|
get "admin/block-type-categories/tree-options" => "block_type_categories#admin_tree_options"
|
|
138
138
|
|
|
139
|
+
get "admin/block-type-sources" => "block_type_sources#admin_index"
|
|
140
|
+
get "admin/block-type-sources/new" => "block_type_sources#admin_new"
|
|
141
|
+
get "admin/block-type-sources/options" => "block_type_sources#admin_options"
|
|
142
|
+
get "admin/block-type-sources/:id/edit" => "block_type_sources#admin_edit"
|
|
143
|
+
get "admin/block-type-sources/:id/refresh" => "block_type_sources#admin_refresh"
|
|
144
|
+
post "admin/block-type-sources" => "block_type_sources#admin_create"
|
|
145
|
+
put "admin/block-type-sources/:id" => "block_type_sources#admin_update"
|
|
146
|
+
delete "admin/block-type-sources/:id" => "block_type_sources#admin_delete"
|
|
147
|
+
|
|
139
148
|
get "posts" => "posts#index"
|
|
140
149
|
get "posts/:id" => "posts#detail"
|
|
141
150
|
get "admin/posts/category-options" => "posts#admin_category_options"
|
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.4.
|
|
4
|
+
version: 0.4.6
|
|
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-06-
|
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -246,6 +246,7 @@ files:
|
|
|
246
246
|
- app/controllers/caboose/admin_controller.rb
|
|
247
247
|
- app/controllers/caboose/application_controller.rb
|
|
248
248
|
- app/controllers/caboose/block_type_categories_controller.rb
|
|
249
|
+
- app/controllers/caboose/block_type_sources_controller.rb
|
|
249
250
|
- app/controllers/caboose/block_types_controller.rb
|
|
250
251
|
- app/controllers/caboose/blocks_controller.rb
|
|
251
252
|
- app/controllers/caboose/login_controller.rb
|
|
@@ -275,6 +276,7 @@ files:
|
|
|
275
276
|
- app/models/caboose/block.rb
|
|
276
277
|
- app/models/caboose/block_type.rb
|
|
277
278
|
- app/models/caboose/block_type_category.rb
|
|
279
|
+
- app/models/caboose/block_type_source.rb
|
|
278
280
|
- app/models/caboose/caboose_plugin.rb
|
|
279
281
|
- app/models/caboose/core_plugin.rb
|
|
280
282
|
- app/models/caboose/database_session.rb
|
|
@@ -304,6 +306,9 @@ files:
|
|
|
304
306
|
- app/views/caboose/ab_variants/admin_new.html.erb
|
|
305
307
|
- app/views/caboose/admin/index.html.erb
|
|
306
308
|
- app/views/caboose/application/show.html.erb
|
|
309
|
+
- app/views/caboose/block_type_sources/admin_edit.html.erb
|
|
310
|
+
- app/views/caboose/block_type_sources/admin_index.html.erb
|
|
311
|
+
- app/views/caboose/block_type_sources/admin_new.html.erb
|
|
307
312
|
- app/views/caboose/block_types/admin_edit.html.erb
|
|
308
313
|
- app/views/caboose/block_types/admin_index.html.erb
|
|
309
314
|
- app/views/caboose/block_types/admin_new.html.erb
|