caboose-cms 0.3.129 → 0.4.1

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.
Files changed (72) hide show
  1. checksums.yaml +8 -8
  2. data/app/assets/javascripts/caboose/admin_block_edit.js +267 -0
  3. data/app/assets/javascripts/caboose/admin_page_edit_content.js +71 -45
  4. data/app/assets/javascripts/caboose/admin_page_edit_content_bak.js +164 -0
  5. data/app/assets/javascripts/caboose/admin_page_new_blocks.js +4 -4
  6. data/app/assets/stylesheets/caboose/admin_page_edit_content.css +37 -16
  7. data/app/controllers/caboose/block_types_controller.rb +162 -0
  8. data/app/controllers/caboose/blocks_controller.rb +293 -0
  9. data/app/controllers/caboose/edit_controller.rb +33 -0
  10. data/app/controllers/caboose/pages_controller.rb +4 -3
  11. data/app/controllers/caboose/posts_controller.rb +1 -1
  12. data/app/models/caboose/block.rb +222 -0
  13. data/app/models/caboose/block_type.rb +28 -0
  14. data/app/models/caboose/core_plugin.rb +6 -6
  15. data/app/models/caboose/page.rb +8 -4
  16. data/app/models/caboose/schema.rb +90 -59
  17. data/app/models/caboose/utilities/schema.rb +3 -3
  18. data/app/views/caboose/block_types/admin_edit.html.erb +111 -0
  19. data/app/views/caboose/{page_block_types → block_types}/admin_index.html.erb +2 -2
  20. data/app/views/caboose/{page_block_types → block_types}/admin_new.html.erb +9 -6
  21. data/app/views/caboose/blocks/_block.html.erb +8 -0
  22. data/app/views/caboose/blocks/_heading.html.erb +7 -0
  23. data/app/views/caboose/blocks/_html.html.erb +7 -0
  24. data/app/views/caboose/blocks/_image.html.erb +0 -0
  25. data/app/views/caboose/blocks/_layout_default.html.erb +33 -0
  26. data/app/views/caboose/blocks/_layout_default_content.html.erb +16 -0
  27. data/app/views/caboose/blocks/_layout_default_footer.html.erb +20 -0
  28. data/app/views/caboose/blocks/_layout_default_header.html.erb +32 -0
  29. data/app/views/caboose/blocks/_richtext.html.erb +7 -0
  30. data/app/views/caboose/{page_blocks/_richtext.html.erb → blocks/_text.html.erb} +1 -2
  31. data/app/views/caboose/blocks/admin_edit.html.erb +106 -0
  32. data/app/views/caboose/{page_blocks → blocks}/admin_edit_custom.html.erb +0 -0
  33. data/app/views/caboose/{page_blocks → blocks}/admin_edit_h1.html.erb +0 -0
  34. data/app/views/caboose/{page_blocks → blocks}/admin_edit_h2.html.erb +0 -0
  35. data/app/views/caboose/{page_blocks → blocks}/admin_edit_h3.html.erb +0 -0
  36. data/app/views/caboose/{page_blocks → blocks}/admin_edit_h4.html.erb +0 -0
  37. data/app/views/caboose/{page_blocks → blocks}/admin_edit_h5.html.erb +0 -0
  38. data/app/views/caboose/{page_blocks → blocks}/admin_edit_h6.html.erb +0 -0
  39. data/app/views/caboose/{page_blocks → blocks}/admin_edit_richtext.html.erb +0 -0
  40. data/app/views/caboose/blocks/admin_new.html.erb +55 -0
  41. data/app/views/caboose/pages/_admin_header.html.erb +1 -1
  42. data/app/views/caboose/pages/_content.html.erb +1 -1
  43. data/app/views/caboose/pages/_new_block_header.html.erb +13 -0
  44. data/app/views/caboose/pages/admin_edit_content.html.erb +24 -20
  45. data/app/views/caboose/pages/show.html.erb +13 -30
  46. data/app/views/layouts/caboose/application.html.erb +26 -14
  47. data/config/routes.rb +38 -30
  48. data/lib/caboose/engine.rb +2 -2
  49. data/lib/caboose/version.rb +1 -1
  50. metadata +33 -35
  51. data/app/controllers/caboose/page_block_field_values_controller.rb +0 -55
  52. data/app/controllers/caboose/page_block_fields_controller.rb +0 -123
  53. data/app/controllers/caboose/page_block_types_controller.rb +0 -100
  54. data/app/controllers/caboose/page_blocks_controller.rb +0 -165
  55. data/app/models/caboose/page_block.rb +0 -49
  56. data/app/models/caboose/page_block_field.rb +0 -21
  57. data/app/models/caboose/page_block_field_value.rb +0 -39
  58. data/app/models/caboose/page_block_renderers/h1.rb +0 -5
  59. data/app/models/caboose/page_block_renderers/h2.rb +0 -5
  60. data/app/models/caboose/page_block_renderers/h3.rb +0 -5
  61. data/app/models/caboose/page_block_renderers/h4.rb +0 -5
  62. data/app/models/caboose/page_block_renderers/h5.rb +0 -5
  63. data/app/models/caboose/page_block_renderers/h6.rb +0 -5
  64. data/app/models/caboose/page_block_renderers/p.rb +0 -5
  65. data/app/models/caboose/page_block_renderers/richtext.rb +0 -5
  66. data/app/models/caboose/page_block_type.rb +0 -12
  67. data/app/views/caboose/page_block_fields/admin_edit.html.erb +0 -77
  68. data/app/views/caboose/page_block_fields/admin_new.html.erb +0 -30
  69. data/app/views/caboose/page_block_types/admin_edit.html.erb +0 -82
  70. data/app/views/caboose/page_blocks/_heading.html.erb +0 -7
  71. data/app/views/caboose/page_blocks/_partial.html.erb +0 -11
  72. data/app/views/caboose/page_blocks/admin_edit.html.erb +0 -69
@@ -0,0 +1,33 @@
1
+
2
+ module Caboose
3
+ class EditController < ApplicationController
4
+
5
+ helper :application
6
+
7
+ # GET /edit/.*
8
+ def index
9
+ return unless user_is_allowed('pages', 'add')
10
+
11
+ # Find the page with an exact URI match
12
+ @page = Page.page_with_uri(request.fullpath.gsub('/edit'), false)
13
+
14
+ @user = logged_in_user
15
+ if !user.is_allowed(@page, 'view')
16
+ if user.id == User::LOGGED_OUT_USER_ID
17
+ redirect_to "/modal/login?return_url=" + URI.encode(request.fullpath)
18
+ return
19
+ else
20
+ @page.title = 'Access Denied'
21
+ end
22
+ end
23
+
24
+ @editmode = !params['edit'].nil? && user.is_allowed('pages', 'edit') ? true : false
25
+ @crumb_trail = Caboose::Page.crumb_trail(@page)
26
+ @subnav = Caboose::Page.subnav(@page, session['use_redirect_urls'], @user)
27
+
28
+ #@subnav.links = @tasks.collect {|href, task| {'href' => href, 'text' => task, 'is_current' => uri == href}}
29
+ render :file ':layout => 'caboose/admin'
30
+ end
31
+
32
+ end
33
+ end
@@ -131,8 +131,9 @@ module Caboose
131
131
  def admin_edit_content
132
132
  return unless user_is_allowed('pages', 'edit')
133
133
  @page = Page.find(params[:id])
134
- @block_types = Caboose::PageBlockType.reorder(:name).all
135
- render :layout => 'caboose/admin'
134
+ #@block_types = Caboose::BlockType.reorder(:name).all
135
+ #render :layout => 'caboose/admin'
136
+ @editing = true
136
137
  end
137
138
 
138
139
  # GET /admin/pages/:id/block-order
@@ -148,7 +149,7 @@ module Caboose
148
149
  block_ids = params[:block_ids]
149
150
  i = 0
150
151
  block_ids.each do |block_id|
151
- b = PageBlock.find(block_id)
152
+ b = Block.find(block_id)
152
153
  b.sort_order = i
153
154
  b.save
154
155
  i = i + 1
@@ -59,7 +59,7 @@ module Caboose
59
59
 
60
60
  # POST /admin/posts/:id
61
61
  def admin_update
62
- Caboose.log(params)
62
+ #Caboose.log(params)
63
63
  return if !user_is_allowed('posts', 'edit')
64
64
 
65
65
  resp = Caboose::StdClass.new({'attributes' => {}})
@@ -0,0 +1,222 @@
1
+
2
+ class Caboose::Block < ActiveRecord::Base
3
+ self.table_name = "blocks"
4
+
5
+ belongs_to :page
6
+ belongs_to :block_type
7
+ belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::Block'
8
+ has_many :children, :foreign_key => 'parent_id', :class_name => 'Caboose::Block', :dependent => :delete_all, :order => 'sort_order'
9
+ has_attached_file :file, :path => '/uploads/:id.:extension'
10
+ do_not_validate_attachment_file_type :file
11
+ has_attached_file :image,
12
+ :path => 'uploads/:id_:style.:extension',
13
+ :styles => {
14
+ :tiny => '160x120>',
15
+ :thumb => '400x300>',
16
+ :large => '640x480>'
17
+ }
18
+ do_not_validate_attachment_file_type :image
19
+
20
+ attr_accessible :id,
21
+ :page_id,
22
+ :parent_id,
23
+ :block_type_id,
24
+ :sort_order,
25
+ :name,
26
+ :value
27
+
28
+ after_initialize do |b|
29
+ # Do whatever we need to do to set the value to be correct for the field type we have.
30
+ # Most field types are fine with the raw value in the database
31
+ if b.block_type.nil?
32
+ bt = Caboose::BlockType.where(:field_type => 'text').first
33
+ b.block_type_id = bt.id
34
+ end
35
+ if b.block_type.field_type.nil?
36
+ b.block_type.field_type = 'text'
37
+ b.save
38
+ end
39
+ case b.block_type.field_type
40
+ when 'checkbox' then b.value = (b.value == 1 || b.value == '1' || b.value == true ? true : false)
41
+ end
42
+ end
43
+
44
+ before_save :caste_value
45
+ def caste_value
46
+ case self.block_type.field_type
47
+ when 'checkbox'
48
+ if self.value.nil? then self.value = false
49
+ else self.value = (self.value == 1 || self.value == '1' || self.value == true ? 1 : 0)
50
+ end
51
+ end
52
+ end
53
+
54
+ def child_value(name)
55
+ b = child(name)
56
+ return nil if b.nil?
57
+ return b.image if b.block_type.field_type == 'image'
58
+ return b.file if b.block_type.field_type == 'file'
59
+ return b.value
60
+ end
61
+
62
+ def child(name)
63
+ Caboose::Block.where("parent_id = ? and name = ?", self.id, name).first
64
+ end
65
+
66
+ def create_children(block_type_override = nil)
67
+ bt = block_type_override ? block_type_override : block_type
68
+ bt.children.each do |bt2|
69
+ bt_id = bt2.id
70
+ #if bt2.parent_id
71
+ # new_bt_id = Caboose::BlockType.where(:name => bt2.field_type).first.id
72
+ #end
73
+ if self.child(bt2.name).nil?
74
+ b = Caboose::Block.create(
75
+ :page_id => self.page_id,
76
+ :parent_id => self.id,
77
+ :block_type_id => bt_id,
78
+ :name => bt2.name,
79
+ :value => bt2.default
80
+ )
81
+ b.create_children(bt2)
82
+ end
83
+ end
84
+ end
85
+
86
+ def render(block, options)
87
+ Caboose.log("block.render\nself.id = #{self.id}\nblock = #{block}\noptions.class = #{options.class}\noptions = #{options}")
88
+
89
+ if block && block.is_a?(String)
90
+ Caboose.log("Block #{block} is a string, finding block object... self.id = #{self.id}")
91
+ b = self.child(block)
92
+ if b.nil?
93
+ self.create_children
94
+ b = self.child(block)
95
+ if b.nil?
96
+ Caboose.log("No block exists with name \"#{block}\".")
97
+ return false
98
+ end
99
+ end
100
+ block = b
101
+ end
102
+ str = ""
103
+
104
+ defaults = {
105
+ :modal => false,
106
+ :empty_text => "",
107
+ :editing => false,
108
+ :css => nil,
109
+ :js => nil,
110
+ :block => block
111
+ }
112
+ options2 = nil
113
+ #Caboose.log(options.class)
114
+ if options.is_a?(Hash)
115
+ options2 = defaults.merge(options)
116
+ #elsif options.is_a?(ActionView::Base)
117
+ # options2 = {
118
+ # :modal => options.modal,
119
+ # :empty_text => options.empty_text,
120
+ # :editing => options.editing,
121
+ # :css => options.css,
122
+ # :js => options.js
123
+ # }
124
+ else
125
+ options2 = {
126
+ :modal => options.modal,
127
+ :empty_text => options.empty_text,
128
+ :editing => options.editing,
129
+ :css => options.css,
130
+ :js => options.js
131
+ }
132
+ end
133
+ options2[:block] = block
134
+
135
+ #options2.modal = false if options2.modal.nil?
136
+ #options2.empty_text = "" if options2.empty_text.nil?
137
+ #options2.editing = false if options2.editing.nil?
138
+ #options[:css => nil,
139
+ #options[:js => nil
140
+ #}.merge(options)
141
+ #options2.block = block
142
+
143
+ if block.block_type.use_render_function && block.block_type.render_function
144
+ #Caboose.log("Rendering from function")
145
+ str = block.render_from_function(options2)
146
+ else
147
+ view = ActionView::Base.new(ActionController::Base.view_paths)
148
+ begin
149
+ #Caboose.log("Rendering caboose/blocks/#{block.name}")
150
+ str = view.render(:partial => "caboose/blocks/#{block.name}", :locals => options2)
151
+ rescue
152
+ #Caboose.log("Error rendering caboose/blocks/#{block.name}")
153
+ begin
154
+ #Caboose.log("Rendering caboose/blocks/#{block.block_type.name}")
155
+ str = view.render(:partial => "caboose/blocks/#{block.block_type.name}", :locals => options2)
156
+ rescue
157
+ #Caboose.log("Error rendering caboose/blocks/#{block.block_type.name}")
158
+ #Caboose.log("Rendering caboose/blocks/#{block.block_type.field_type}")
159
+ str = view.render(:partial => "caboose/blocks/#{block.block_type.field_type}", :locals => options2)
160
+ end
161
+ end
162
+ end
163
+ #return str if block.parent_id.nil?
164
+ #return str if options[:editing].nil? || options[:editing] == false
165
+ #return "<div id='block_#{block.id}' class='block'>#{str}</div>"
166
+ return str
167
+ end
168
+
169
+ def render_from_function(options)
170
+ self.create_children
171
+ #locals = OpenStruct.new(:block => self, :empty_text => empty_text, :editing => editing)
172
+ locals = OpenStruct.new(options)
173
+ erb = ERB.new(block_type.render_function)
174
+ return erb.result(locals.instance_eval { binding })
175
+ end
176
+
177
+ def child_block_link
178
+ return "<div class='new_block' id='new_block_#{self.id}'>New Block</div>"
179
+ end
180
+
181
+ def js_hash
182
+ kids = self.children.collect { |b| b.js_hash }
183
+ bt = self.block_type
184
+ return {
185
+ 'id' => self.id,
186
+ 'page_id' => self.page_id,
187
+ 'parent_id' => self.parent_id,
188
+ 'block_type_id' => self.block_type_id,
189
+ 'sort_order' => self.sort_order,
190
+ 'name' => self.name,
191
+ 'value' => self.value,
192
+ 'children' => kids,
193
+ 'block_type' => {
194
+ 'id' => bt.id,
195
+ 'parent_id' => bt.parent_id,
196
+ 'name' => bt.name,
197
+ 'description' => bt.description,
198
+ 'render_function' => bt.render_function,
199
+ 'use_render_function' => bt.use_render_function,
200
+ 'use_render_function_for_layout' => bt.use_render_function_for_layout,
201
+ 'allow_child_blocks' => bt.allow_child_blocks,
202
+ 'field_type' => bt.field_type,
203
+ 'default' => bt.default,
204
+ 'width' => bt.width,
205
+ 'height' => bt.height,
206
+ 'fixed_placeholder' => bt.fixed_placeholder,
207
+ 'options' => bt.options,
208
+ 'options_function' => bt.options_function,
209
+ 'options_url' => bt.options_url
210
+ },
211
+ 'file' => {
212
+ 'url' => self.file.url
213
+ },
214
+ 'image' => {
215
+ 'tiny_url' => self.image.url(:tiny),
216
+ 'thumb_url' => self.image.url(:thumb),
217
+ 'large_url' => self.image.url(:large),
218
+ }
219
+ }
220
+ end
221
+
222
+ end
@@ -0,0 +1,28 @@
1
+
2
+ class Caboose::BlockType < ActiveRecord::Base
3
+ self.table_name = "block_types"
4
+
5
+ belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::BlockType'
6
+ has_many :children, :foreign_key => 'parent_id', :class_name => 'Caboose::BlockType', :dependent => :destroy
7
+ attr_accessible :id,
8
+ :parent_id,
9
+ :name,
10
+ :description,
11
+ :use_render_function,
12
+ :use_render_function_for_layout,
13
+ :allow_child_blocks,
14
+ :render_function,
15
+ :field_type,
16
+ :default,
17
+ :width,
18
+ :height,
19
+ :fixed_placeholder,
20
+ :options,
21
+ :options_function,
22
+ :options_url
23
+
24
+ def render_options(empty_text = nil)
25
+ return eval(self.options_function)
26
+ end
27
+
28
+ end
@@ -21,12 +21,12 @@ class Caboose::CorePlugin < Caboose::CaboosePlugin
21
21
  'children' => []
22
22
  }
23
23
 
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' => 'Page Block Types' , 'href' => '/admin/page-block-types' , 'modal' => false } if user.is_allowed('pageblocktypes' , 'view')
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' => 'Page Block Types' , 'href' => '/admin/block-types' , 'modal' => false } if user.is_allowed('blocktypes' , 'view')
30
30
 
31
31
  nav << item if item['children'].count > 0
32
32
 
@@ -4,8 +4,8 @@ class Caboose::Page < ActiveRecord::Base
4
4
 
5
5
  belongs_to :parent, :class_name => "Page"
6
6
  has_many :children, :class_name => "Page", :foreign_key => 'parent_id', :order => 'sort_order, title'
7
- has_many :page_permissions
8
- has_many :page_blocks, :order => 'sort_order'
7
+ has_many :page_permissions
8
+ has_many :blocks, :order => 'sort_order'
9
9
  attr_accessible :parent_id,
10
10
  :title,
11
11
  :menu_title,
@@ -39,8 +39,12 @@ class Caboose::Page < ActiveRecord::Base
39
39
  return ""
40
40
  end
41
41
 
42
- def blocks
43
- self.page_blocks
42
+ def block
43
+ Caboose::Block.where("page_id = ? and parent_id is null", self.id).first
44
+ end
45
+
46
+ def top_level_blocks
47
+ Caboose::Block.where("page_id = ? and parent_id is null", self.id).reorder(:sort_order).all
44
48
  end
45
49
 
46
50
  #def content
@@ -4,18 +4,33 @@ class Caboose::Schema < Caboose::Utilities::Schema
4
4
  # Tables (in order) that were renamed in the development of the gem.
5
5
  def self.renamed_tables
6
6
  {
7
- :roles_users => :role_memberships,
8
- :permissions_roles => :role_permissions
7
+ :roles_users => :role_memberships,
8
+ :permissions_roles => :role_permissions,
9
+ :page_block_field_values => :fields,
10
+ :page_block_fields => :field_types,
11
+ :page_block_types => :block_types,
12
+ :page_blocks => :blocks
13
+ }
14
+ end
15
+
16
+ def self.renamed_columns
17
+ {
18
+ #Caboose::Field => { :page_block_id => :block_id,
19
+ # :page_block_field_id => :field_type_id },
20
+ #Caboose::FieldType => { :page_block_type_id => :block_type_id },
21
+ Caboose::Block => { :page_block_type_id => :block_type_id }
9
22
  }
10
23
  end
11
24
 
12
25
  def self.removed_columns
13
26
  {
14
- Caboose::PageBlock => [:block_type, :value, :name],
15
- Caboose::PageBlockField => [:model_binder_options],
27
+ Caboose::Block => [:block_type],
28
+ #Caboose::FieldType => [:model_binder_options],
16
29
  Caboose::AbValue => [:i, :text],
17
30
  Caboose::AbOption => [:text],
18
- Caboose::User => [:timezone]
31
+ Caboose::User => [:timezone],
32
+ #Caboose::Field => [:child_block_id],
33
+ Caboose::BlockType => [:layout_function]
19
34
  }
20
35
  end
21
36
 
@@ -90,63 +105,79 @@ class Caboose::Schema < Caboose::Utilities::Schema
90
105
  [ :alias , :string ],
91
106
  [ :uri , :string ],
92
107
  [ :redirect_url , :string ],
93
- [ :hide , :boolean , :default => false ],
94
- [ :content_format , :integer , :default => Caboose::Page::CONTENT_FORMAT_HTML ],
108
+ [ :hide , :boolean , { :default => false }],
109
+ [ :content_format , :integer , { :default => Caboose::Page::CONTENT_FORMAT_HTML }],
95
110
  [ :custom_css , :text ],
96
111
  [ :custom_js , :text ],
97
112
  [ :linked_resources , :text ],
98
113
  [ :layout , :string ],
99
- [ :sort_order , :integer , :default => 0 ],
100
- [ :custom_sort_children , :boolean , :default => false ],
101
- [ :seo_title , :string , :limit => 70 ],
102
- [ :meta_description , :string , :limit => 156 ],
103
- [ :meta_robots , :string , :default => 'index, follow' ],
114
+ [ :sort_order , :integer , { :default => 0 }],
115
+ [ :custom_sort_children , :boolean , { :default => false }],
116
+ [ :seo_title , :string , { :limit => 70 }],
117
+ [ :meta_description , :string , { :limit => 156 }],
118
+ [ :meta_robots , :string , { :default => 'index, follow' }],
104
119
  [ :canonical_url , :string ],
105
- [ :fb_description , :string , :limit => 156 ],
106
- [ :gp_description , :string , :limit => 156 ]
107
- ],
108
- Caboose::PageBlock => [
109
- [ :page_id , :integer ],
110
- [ :page_block_type_id , :integer ],
111
- [ :sort_order , :integer , :default => 0 ],
112
- [ :name , :string ],
113
- [ :value , :text ]
120
+ [ :fb_description , :string , { :limit => 156 }],
121
+ [ :gp_description , :string , { :limit => 156 }]
114
122
  ],
115
- Caboose::PageBlockType => [
123
+ Caboose::Block => [
124
+ [ :page_id , :integer ],
125
+ [ :parent_id , :integer ],
126
+ [ :block_type_id , :integer ],
127
+ [ :sort_order , :integer , { :default => 0 }],
116
128
  [ :name , :string ],
117
- [ :description , :string ],
118
- [ :use_render_function , :boolean , :default => false ],
119
- [ :render_function , :text ]
120
- ],
121
- Caboose::PageBlockField => [
122
- [ :page_block_type_id , :integer ],
123
- [ :name , :string ],
124
- [ :field_type , :string ],
125
- [ :nice_name , :string ],
126
- [ :default , :text ],
127
- [ :width , :integer ],
128
- [ :height , :integer ],
129
- [ :fixed_placeholder , :boolean ],
130
- [ :options , :text ],
131
- [ :options_function , :text ],
132
- [ :options_url , :string ]
129
+ [ :value , :text ],
130
+ [ :file , :attachment ],
131
+ [ :image , :attachment ]
133
132
  ],
134
- Caboose::PageBlockFieldValue => [
135
- [ :page_block_id , :integer ],
136
- [ :page_block_field_id , :integer ],
137
- [ :value , :text ],
138
- [ :file , :attachment ],
139
- [ :image , :attachment ]
133
+ Caboose::BlockType => [
134
+ [ :parent_id , :integer ],
135
+ [ :name , :string ],
136
+ [ :description , :string ],
137
+ [ :render_function , :text ],
138
+ [ :use_render_function , :boolean , { :default => false }],
139
+ [ :use_render_function_for_layout , :boolean , { :default => false }],
140
+ [ :allow_child_blocks , :boolean , { :default => false }],
141
+
142
+ # Used for field values
143
+ [ :field_type , :string ],
144
+ [ :default , :text ],
145
+ [ :width , :integer ],
146
+ [ :height , :integer ],
147
+ [ :fixed_placeholder , :boolean ],
148
+ [ :options , :text ],
149
+ [ :options_function , :text ],
150
+ [ :options_url , :string ]
140
151
  ],
152
+ #Caboose::Field => [
153
+ # [ :block_id , :integer ],
154
+ # [ :field_type_id , :integer ],
155
+ # [ :value , :text ],
156
+ # [ :file , :attachment ],
157
+ # [ :image , :attachment ]
158
+ #],
159
+ #Caboose::FieldType => [
160
+ # [ :block_type_id , :integer ],
161
+ # [ :name , :string ],
162
+ # [ :field_type , :string ],
163
+ # [ :nice_name , :string ],
164
+ # [ :default , :text ],
165
+ # [ :width , :integer ],
166
+ # [ :height , :integer ],
167
+ # [ :fixed_placeholder , :boolean ],
168
+ # [ :options , :text ],
169
+ # [ :options_function , :text ],
170
+ # [ :options_url , :string ]
171
+ #],
141
172
  Caboose::Post => [
142
- [ :title , :text ],
143
- [ :body , :text ],
144
- [ :hide , :boolean ],
145
- [ :image_url , :text ],
146
- [ :published , :boolean ],
147
- [ :created_at , :datetime ],
148
- [ :updated_at , :datetime ],
149
- [ :image , :attachment ]
173
+ [ :title , :text ],
174
+ [ :body , :text ],
175
+ [ :hide , :boolean ],
176
+ [ :image_url , :text ],
177
+ [ :published , :boolean ],
178
+ [ :created_at , :datetime ],
179
+ [ :updated_at , :datetime ],
180
+ [ :image , :attachment ]
150
181
  ],
151
182
  Caboose::PostCategory => [
152
183
  [ :name , :string ]
@@ -213,15 +244,15 @@ class Caboose::Schema < Caboose::Utilities::Schema
213
244
  # c.remove_column(:pages, :content)
214
245
  #end
215
246
 
216
- if !Caboose::PageBlockType.where(:name => 'heading').exists?
217
- bt = Caboose::PageBlockType.create(:name => 'heading', :description => 'Heading')
218
- Caboose::PageBlockField.create(:page_block_type_id => bt.id, :name => 'text', :field_type => 'text', :nice_name => 'Text', :default => '', :width => 800, :fixed_placeholder => false)
219
- Caboose::PageBlockField.create(:page_block_type_id => bt.id, :name => 'size', :field_type => 'text', :nice_name => 'Size', :default => 1, :width => 800, :fixed_placeholder => false, :options => "1|2|3|4|5|6")
247
+ if !Caboose::BlockType.where(:name => 'heading').exists?
248
+ bt = Caboose::BlockType.create(:name => 'heading', :description => 'Heading')
249
+ Caboose::FieldType.create(:block_type_id => bt.id, :name => 'text', :field_type => 'text', :nice_name => 'Text', :default => '', :width => 800, :fixed_placeholder => false)
250
+ Caboose::FieldType.create(:block_type_id => bt.id, :name => 'size', :field_type => 'text', :nice_name => 'Size', :default => 1, :width => 800, :fixed_placeholder => false, :options => "1|2|3|4|5|6")
220
251
  end
221
252
 
222
- if !Caboose::PageBlockType.where(:name => 'richtext').exists?
223
- bt = Caboose::PageBlockType.create(:name => 'richtext', :description => 'Rich Text')
224
- Caboose::PageBlockField.create(:page_block_type_id => bt.id, :name => 'text', :field_type => 'richtext', :nice_name => 'Text', :default => '', :width => 800, :height => 400, :fixed_placeholder => false)
253
+ if !Caboose::BlockType.where(:name => 'richtext').exists?
254
+ bt = Caboose::BlockType.create(:name => 'richtext', :description => 'Rich Text')
255
+ Caboose::FieldType.create(:block_type_id => bt.id, :name => 'text', :field_type => 'richtext', :nice_name => 'Text', :default => '', :width => 800, :height => 400, :fixed_placeholder => false)
225
256
  end
226
257
 
227
258
  admin_user = nil