caboose-cms 0.4.41 → 0.4.42

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
- ODgxOTZjNGJiMDUxMzU4ODc5MTJmZjQ0NGJmODQ1NTgzYTU4NDFjYg==
4
+ ZWNmYTkwYTBkOTc0NTY2MzI2MzIzODI1MmU3NDAyNWY3ZDcwZjRhYg==
5
5
  data.tar.gz: !binary |-
6
- NTE2NzJlZmNiY2QwNzI3YTU3ZDY0MmE5ZmYyMTViNzZjODRjYzg2Mg==
6
+ MjFhOTA0OGNiOTUwMTIyNGZkZjBiOWUwMzAwYWNhZDBiZGM4OGVjMg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDBkMjk3ZjA1OTA1MmM3NDFmYjAyN2JhODI4MGMzMWNmMjlhZDM5YTIwMDg0
10
- Yzk4YTA0ZjEzMTg4MzU1NWU4OGFkODdkM2ZkYjNmYTdmMzVlMWI2MTZlNGIz
11
- NWI0ZTljZjA3Y2RlNzVlODllYTE0MDNjYzc1Nzg1ODMxZDE5ZjM=
9
+ ZDYxNjcyODcwM2YxMGUyM2IzOTFlODI4NjU5NzM0Y2EwY2Q3NmM3NGM5NDIx
10
+ ZDlhYWI2MWFkZWZlYmQ0ZTg2NjY1MDBhMjk1YTQ5ZjA2NDg5MjI3MDk3ODRm
11
+ ZGVjMmI4NDhhMTU0NzE5OTFhNzI1NDkwYzRiMzVlZjFjZjY2Mzc=
12
12
  data.tar.gz: !binary |-
13
- NWZkODkxNWEyMzFhYmNlN2YwMDExYjc2Nzk4ZmY1NzkzZGZhZWVjY2NmMGFh
14
- ZTcxZTYwMDhjNjkzMjljMDBhOTkzZjhjOGFhZDVhZDUyNDhhZGU2OWMzY2U4
15
- NDQ3ZTUzZWIxMjM3M2UwYjg1YWNmNzQyZjFjNmFlMGM2OWQzNjI=
13
+ M2NkY2FiNjlmNjc3YTk0YTE2MWFiYjAzZGUzZDE2MTQ0MGFkMTFjZmE2NDE2
14
+ NDMzMmQyMGQ3Y2M4OTY3OTNkNGRiMjMzNmFhZWVlZDE2ZDc0ZDQ4MTNjN2Ux
15
+ NzVmN2VjYzUyYmMzYThjYjQxYTM4NWMwZjJkMDE2ZmVmMDgyYzM=
@@ -1,4 +1,4 @@
1
-
1
+
2
2
  var PageContentController = function(page_id) { this.init(page_id); };
3
3
 
4
4
  PageContentController.prototype = {
@@ -10,9 +10,8 @@ PageContentController.prototype = {
10
10
  {
11
11
  this.page_id = page_id;
12
12
  var that = this;
13
- that.set_clickable();
14
- //this.render_blocks(function() {
15
- // that.sortable_blocks();
13
+ that.set_clickable();
14
+ that.sortable_blocks();
16
15
  // that.draggable_blocks();
17
16
  //});
18
17
  },
@@ -20,7 +19,7 @@ PageContentController.prototype = {
20
19
  sortable_blocks: function()
21
20
  {
22
21
  var that = this;
23
- $('#blocks').sortable({
22
+ $('.sortable').sortable({
24
23
  //hoverClass: "ui-state-active",
25
24
  placeholder: 'sortable-placeholder',
26
25
  forcePlaceholderSize: true,
@@ -40,11 +39,19 @@ PageContentController.prototype = {
40
39
  that.new_block_type_id = false;
41
40
  }
42
41
  else
43
- {
42
+ {
43
+ var ids = [];
44
+ $.each($(e.target).children(), function(i, el) {
45
+ var id = $(el).attr('id');
46
+ if (id.substr(0, 6) == 'block_') ids.push(id.substr(6));
47
+ });
48
+
44
49
  $.ajax({
45
50
  url: '/admin/pages/' + that.page_id + '/block-order',
46
51
  type: 'put',
47
- data: $('#blocks').sortable('serialize', { key: "block_ids[]" }),
52
+ data: {
53
+ block_ids: ids,
54
+ },
48
55
  success: function(resp) {}
49
56
  });
50
57
  }
@@ -78,12 +85,12 @@ PageContentController.prototype = {
78
85
  if (!confirm)
79
86
  {
80
87
  var p = $('<p/>')
81
- .addClass('note warning')
88
+ .addClass('caboose_note')
82
89
  .append("Are you sure you want to delete the block? ")
83
- .append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_block(block_id, true); })).append(" ")
84
- .append($('<input/>').attr('type', 'button').val('No').click(function() { that.render_block(block_id); }));
85
- $('#block_container_' + block_id).attr('onclick','').unbind('click');
86
- $('#block_container_' + block_id).empty().append(p);
90
+ .append($('<input/>').attr('type', 'button').val('Yes').click(function(e) { e.preventDefault(); e.stopPropagation(); that.delete_block(block_id, true); })).append(" ")
91
+ .append($('<input/>').attr('type', 'button').val('No').click(function(e) { e.preventDefault(); e.stopPropagation(); that.render_blocks(); }));
92
+ $('#block_' + block_id).attr('onclick','').unbind('click');
93
+ $('#block_' + block_id).empty().append(p);
87
94
  return;
88
95
  }
89
96
  $.ajax({
@@ -105,7 +112,7 @@ PageContentController.prototype = {
105
112
  url: '/admin/pages/' + this.page_id + '/blocks/render-second-level',
106
113
  success: function(blocks) {
107
114
  $(blocks).each(function(i, b) {
108
- $('#block_' + b.id).replaceWith(b.html);
115
+ $('#block_' + b.id).replaceWith(b.html);
109
116
  });
110
117
  that.set_clickable();
111
118
  }
@@ -119,36 +126,51 @@ PageContentController.prototype = {
119
126
  url: '/admin/pages/' + this.page_id + '/blocks/tree',
120
127
  success: function(blocks) {
121
128
  $(blocks).each(function(i,b) {
122
- that.set_clickable_helper(b);
123
- });
129
+ that.set_clickable_helper(b, false, false);
130
+ });
124
131
  }
125
132
  });
126
133
  },
127
134
 
128
- set_clickable_helper: function(b)
135
+ set_clickable_helper: function(b, parent_id, parent_allows_child_blocks)
129
136
  {
130
- var that = this;
137
+ var that = this;
138
+
139
+ $('#block_' + b.id)
140
+ .prepend($('<a/>').attr('id', 'block_' + b.id + '_sort_handle' ).addClass('sort_handle' ).append($('<span/>').addClass('ui-icon ui-icon-arrow-2-n-s')).click(function(e) { e.preventDefault(); e.stopPropagation(); }))
141
+ .prepend($('<a/>').attr('id', 'block_' + b.id + '_delete_handle').addClass('delete_handle').append($('<span/>').addClass('ui-icon ui-icon-close' )).click(function(e) { e.preventDefault(); e.stopPropagation(); that.delete_block(b.id); }));
142
+
143
+ if (parent_allows_child_blocks && (!b.name || b.name.length == 0))
144
+ {
145
+ $('#block_' + b.id).prepend($('<div/>')
146
+ .addClass('new_block_link')
147
+ .append($('<div/>').addClass('line'))
148
+ .append($('<a/>')
149
+ .attr('href', '#')
150
+ .html("New Block")
151
+ .click(function(e) {
152
+ e.preventDefault(); e.stopPropagation();
153
+ caboose_modal_url('/admin/pages/' + that.page_id + '/blocks/' + parent_id + '/new?before_id=' + b.id);
154
+ })
155
+ )
156
+ .mouseover(function(e) { $(this).addClass('new_block_link_over'); e.stopPropagation(); })
157
+ .mouseout(function(e) { $(this).removeClass('new_block_link_over'); e.stopPropagation(); })
158
+ );
159
+ }
160
+
131
161
  $('#block_' + b.id).attr('onclick','').unbind('click');
132
162
  $('#block_' + b.id).click(function(e) {
133
163
  e.stopPropagation();
134
164
  that.edit_block(b.id);
135
165
  });
136
- if (b.allow_child_blocks == true)
137
- {
138
- $('#new_block_' + b.id).replaceWith($('<input/>')
139
- .attr('type', 'button')
140
- .val('New Block')
141
- .click(function(e) { e.stopPropagation(); that.new_block(b.id);
142
- })
143
- );
144
- }
166
+
145
167
  var show_mouseover = true;
146
168
  if (b.children && b.children.length > 0)
147
169
  {
148
170
  $.each(b.children, function(i, b2) {
149
171
  if (b2.block_type_id = 34)
150
172
  show_mouseover = false;
151
- that.set_clickable_helper(b2);
173
+ that.set_clickable_helper(b2, b.id, b.allow_child_blocks);
152
174
  });
153
175
  }
154
176
  if (show_mouseover)
@@ -1,3 +1,4 @@
1
+ require 'nokogiri'
1
2
 
2
3
  module Caboose
3
4
  class BlocksController < ApplicationController
@@ -18,7 +19,9 @@ module Caboose
18
19
  def admin_new
19
20
  return unless user_is_allowed('pages', 'add')
20
21
  @page = Page.find(params[:page_id])
21
- @block = params[:id] ? Block.find(params[:id]) : Block.new(:page_id => params[:page_id])
22
+ @block = params[:id] ? Block.find(params[:id]) : Block.new(:page_id => params[:page_id])
23
+ @after_id = params[:after_id] ? params[:after_id] : nil
24
+ @before_id = params[:before_id] ? params[:before_id] : nil
22
25
  render :layout => 'caboose/modal'
23
26
  end
24
27
 
@@ -138,9 +141,12 @@ module Caboose
138
141
  @document_domain = request.host
139
142
  @document_domain.gsub('http://', '')
140
143
  @document_domain.gsub('https://', '')
141
-
142
- #render "caboose/blocks/admin_edit_#{@block.block_type}", :layout => 'caboose/modal'
143
- render :layout => 'caboose/modal'
144
+
145
+ begin
146
+ render "caboose/blocks/admin_edit_#{@block.block_type.full_name}", :layout => 'caboose/modal'
147
+ rescue
148
+ render :layout => 'caboose/modal'
149
+ end
144
150
  end
145
151
 
146
152
  # POST /admin/pages/:page_id/blocks
@@ -160,19 +166,39 @@ module Caboose
160
166
 
161
167
  if !params[:index].nil?
162
168
  b.sort_order = params[:index].to_i
169
+
170
+ i = 1
171
+ b.parent.children.where('sort_order >= ?', b.sort_order).reorder(:sort_order).all.each do |b3|
172
+ b3.sort_order = b.sort_order + i
173
+ b3.save
174
+ i = i + 1
175
+ end
176
+
177
+ elsif params[:before_id]
178
+ b2 = Block.find(params[:before_id].to_i)
179
+ b.sort_order = b2.sort_order
180
+
181
+ i = 1
182
+ b2.parent.children.where('sort_order >= ?', b.sort_order).reorder(:sort_order).all.each do |b3|
183
+ b3.sort_order = b.sort_order + i
184
+ b3.save
185
+ i = i + 1
186
+ end
187
+
163
188
  elsif params[:after_id]
164
189
  b2 = Block.find(params[:after_id].to_i)
165
190
  b.sort_order = b2.sort_order + 1
191
+
192
+ i = 1
193
+ b2.parent.children.where('sort_order >= ?', b.sort_order).reorder(:sort_order).all.each do |b3|
194
+ b3.sort_order = b.sort_order + i
195
+ b3.save
196
+ i = i + 1
197
+ end
198
+
166
199
  elsif params[:id]
167
- b.sort_order = Block.where(:parent_id => params[:id]).count
168
- end
169
-
170
- i = b.sort_order + 1
171
- Block.where("page_id = ? and sort_order >= ?", b.page_id, b.sort_order).reorder(:sort_order).each do |b2|
172
- b2.sort_order = i
173
- b2.save
174
- i = i + 1
175
- end
200
+ b.sort_order = Block.where(:parent_id => params[:id]).count
201
+ end
176
202
 
177
203
  # Save the block
178
204
  b.save
@@ -196,12 +222,17 @@ module Caboose
196
222
  save = true
197
223
  params.each do |k,v|
198
224
  case k
199
- when 'page_id' then b.page_id = v
225
+ #when 'page_id' then b.page_id = v
200
226
  when 'parent_id' then b.parent_id = v
201
227
  when 'block_type_id' then b.block_type_id = v
202
228
  when 'sort_order' then b.sort_order = v
203
229
  when 'name' then b.name = v
204
- when 'value' then b.value = v
230
+ when 'value' then
231
+ if b.block_type.field_type == 'richtext'
232
+ b = RichTextBlockParser.parse(b, v, request.host_with_port)
233
+ else
234
+ b.value = v
235
+ end
205
236
  end
206
237
  end
207
238
 
@@ -171,12 +171,10 @@ module Caboose
171
171
  # PUT /admin/pages/:id/block-order
172
172
  def admin_update_block_order
173
173
  return unless user_is_allowed('pages', 'edit')
174
- block_ids = params[:block_ids]
174
+ block_ids = params[:block_ids]
175
175
  i = 0
176
176
  block_ids.each do |block_id|
177
- b = Block.find(block_id)
178
- b.sort_order = i
179
- b.save
177
+ Block.find(block_id).update_attribute(:sort_order, i)
180
178
  i = i + 1
181
179
  end
182
180
  render :json => true
@@ -181,7 +181,15 @@ class Caboose::Block < ActiveRecord::Base
181
181
 
182
182
  def child_block_link
183
183
  return "<div class='new_block' id='new_block_#{self.id}'>New Block</div>"
184
- end
184
+ end
185
+
186
+ def new_block_before_link
187
+ return "<div class='new_block_before' id='new_block_before_#{self.id}'>New Block</div>"
188
+ end
189
+
190
+ def new_block_after_link
191
+ return "<div class='new_block_after' id='new_block_after_#{self.id}'>New Block</div>"
192
+ end
185
193
 
186
194
  def js_hash
187
195
  kids = self.children.collect { |b| b.js_hash }
@@ -25,6 +25,11 @@ class Caboose::BlockType < ActiveRecord::Base
25
25
  :share, # Whether or not to share the block type in the existing block store.
26
26
  :downloaded # Whether the full block type has been download or just the name and description.
27
27
 
28
+ def full_name
29
+ return name if parent_id.nil?
30
+ return "#{parent.full_name}_#{name}"
31
+ end
32
+
28
33
  def render_options(empty_text = nil)
29
34
  return eval(self.options_function)
30
35
  end
@@ -14,7 +14,7 @@ class Caboose::BlockTypeSource < ActiveRecord::Base
14
14
  # Just get the names and descriptions of all block types from the source
15
15
  def refresh_summaries
16
16
  resp = nil
17
- begin
17
+ begin
18
18
  resp = HTTParty.get("#{self.url}/caboose/block-types?token=#{self.token}")
19
19
  rescue HTTParty::Error => e
20
20
  Caboose.log(e.message)
@@ -0,0 +1,195 @@
1
+
2
+ module Caboose
3
+ class RichTextBlockParser
4
+
5
+ def self.parse(block, html, domain)
6
+
7
+ html = html.strip
8
+ page = Nokogiri::HTML("<div>#{html}</div>")
9
+ if page.css('div').children.count == 1
10
+ block.value = html
11
+ block.save
12
+ return block
13
+ end
14
+
15
+ nodes = []
16
+ page.css('div').children.each do |node|
17
+ case node.name.downcase
18
+ when 'h1' then nodes << node
19
+ when 'h2' then nodes << node
20
+ when 'h3' then nodes << node
21
+ when 'h4' then nodes << node
22
+ when 'h5' then nodes << node
23
+ when 'h6' then nodes << node
24
+ when 'p' then
25
+ str = node.inner_html.strip
26
+ nodes << node if str.length > 0 && str != "&#160;" && str != "&nbsp;"
27
+ when 'ul' then nodes << node
28
+ when 'div' then nodes << node
29
+ when 'a' then nodes << node
30
+ when 'img' then nodes << node
31
+ when 'table' then nodes << node
32
+ end
33
+ end
34
+
35
+ # Increment the sort order of any blocks after the current one
36
+ sort_order = block.sort_order + nodes.count
37
+ block.parent.children.where('sort_order > ?', block.sort_order).reorder(:sort_order).all.each do |b2|
38
+ b2.sort_order = sort_order
39
+ b2.save
40
+ sort_order = sort_order + 1
41
+ end
42
+
43
+ # Now add all the new blocks
44
+ sort_order = block.sort_order
45
+ new_first_block_id = false
46
+ paragraphs = []
47
+ nodes.each do |node|
48
+ b = Block.create(
49
+ :page_id => block.page_id,
50
+ :parent_id => block.parent_id,
51
+ :sort_order => sort_order
52
+ )
53
+ if sort_order == block.sort_order
54
+ new_first_block_id = b.id
55
+ end
56
+
57
+ case node.name.downcase
58
+ when 'h1'
59
+ b.block_type_id = BlockType.where(:name => 'heading').first.id
60
+ b.save
61
+ b.create_children
62
+ b.child('size').update_attribute(:value, 1)
63
+ b.child('text').update_attribute(:value, node.inner_html)
64
+ when 'h2'
65
+ b.block_type_id = BlockType.where(:name => 'heading').first.id
66
+ b.save
67
+ b.create_children
68
+ b.child('size').update_attribute(:value, 2)
69
+ b.child('text').update_attribute(:value, node.inner_html)
70
+ when 'h3'
71
+ b.block_type_id = BlockType.where(:name => 'heading').first.id
72
+ b.save
73
+ b.create_children
74
+ b.child('size').update_attribute(:value, 3)
75
+ b.child('text').update_attribute(:value, node.inner_html)
76
+ when 'h4'
77
+ b.block_type_id = BlockType.where(:name => 'heading').first.id
78
+ b.save
79
+ b.create_children
80
+ b.child('size').update_attribute(:value, 4)
81
+ b.child('text').update_attribute(:value, node.inner_html)
82
+ when 'h5'
83
+ b.block_type_id = BlockType.where(:name => 'heading').first.id
84
+ b.save
85
+ b.create_children
86
+ b.child('size').update_attribute(:value, 5)
87
+ b.child('text').update_attribute(:value, node.inner_html)
88
+ when 'h6'
89
+ b.block_type_id = BlockType.where(:name => 'heading').first.id
90
+ b.save
91
+ b.create_children
92
+ b.child('size').update_attribute(:value, 6)
93
+ b.child('text').update_attribute(:value, node.inner_html)
94
+ when 'p'
95
+ b.block_type_id = BlockType.where(:name => 'richtext').first.id
96
+ b.value = node.to_s
97
+ b.save
98
+ paragraphs << b
99
+ when 'ul'
100
+ b.block_type_id = BlockType.where(:name => 'richtext').first.id
101
+ b.value = node.to_s
102
+ b.save
103
+ when 'div'
104
+ b.block_type_id = BlockType.where(:name => 'richtext').first.id
105
+ b.value = node.to_s
106
+ b.save
107
+ when 'a'
108
+ b.block_type_id = BlockType.where(:name => 'richtext').first.id
109
+ b.value = "<p>#{node.to_s}</p>"
110
+ b.save
111
+ when 'img'
112
+ b.block_type_id = BlockType.where(:name => 'richtext').first.id
113
+ b.value = node.to_s
114
+ b.save
115
+ when 'table'
116
+ b.block_type_id = BlockType.where(:name => 'richtext').first.id
117
+ b.value = node.to_s
118
+ b.save
119
+ end
120
+ sort_order = sort_order + 1
121
+ end
122
+
123
+ paragraphs.each do |p|
124
+ self.parse_paragraph(p, domain)
125
+ end
126
+
127
+ # Now delete the original block
128
+ block.destroy
129
+ block = Block.find(new_first_block_id)
130
+ return block
131
+
132
+ end
133
+
134
+ def self.parse_paragraph(block, domain)
135
+
136
+ page = Nokogiri::HTML(block.value)
137
+ return if page.css('img').count == 0
138
+
139
+ image_count = page.css('img').count
140
+ sort_order = block.sort_order
141
+
142
+ # Increment the sort order of any blocks after and including the current one
143
+ i = 0
144
+ block.parent.children.where('sort_order >= ?', block.sort_order).reorder(:sort_order).all.each do |b2|
145
+ b2.sort_order = sort_order + image_count + i
146
+ b2.save
147
+ i = i + 1
148
+ end
149
+
150
+ # Create blocks for each image
151
+ i = 0
152
+ image_block_type_id = BlockType.where("name = ? and parent_id is null", 'image').first.id
153
+ page.css('img').each do |node|
154
+ b = Block.create(
155
+ :page_id => block.page_id,
156
+ :parent_id => block.parent_id,
157
+ :block_type_id => image_block_type_id,
158
+ :sort_order => sort_order + i
159
+ )
160
+ b.create_children
161
+
162
+ # Set the alignment
163
+ if node['align'] && node['align'].length > 0
164
+ align = node['align']
165
+ align[0] = align[0].capitalize
166
+ b.child('align').update_attribute(:value, align)
167
+ end
168
+
169
+ # Download the image
170
+ src = node['src']
171
+ src = "http://#{domain}#{src}" if src.starts_with?('/')
172
+ img = b.child('image_src')
173
+ img.image = URI.parse(src)
174
+ img.save
175
+
176
+ #b.child('image_style' ).update_attribute(:value, )
177
+ #b.child('link' ).update_attribute(:value, )
178
+ #b.child('width' ).update_attribute(:value, )
179
+ #b.child('height' ).update_attribute(:value, )
180
+ #b.child('margin_top' ).update_attribute(:value, )
181
+ #b.child('margin_bottom' ).update_attribute(:value, )
182
+ #b.child('margin_right' ).update_attribute(:value, )
183
+ #b.child('margin_left' ).update_attribute(:value, )
184
+
185
+ i = i + 1
186
+ end
187
+
188
+ # Now remove any images from the paragraph
189
+ page.search('.//img').remove
190
+ block.value = page.to_s
191
+ block.save
192
+
193
+ end
194
+ end
195
+ end
@@ -4,4 +4,5 @@ text = block.child('text').value
4
4
  size = 1 if size.nil?
5
5
  text = (empty_text ? empty_text : "") if text.nil? || text == ""
6
6
 
7
- %><h<%= size %>><%= raw text %></h<%= size %>>
7
+ if editing %><div id='block_<%= block.id %>'><h<%= size %>><%= raw text %></h<%= size %>></div><%
8
+ else %><h<%= size %> id='block_<%= block.id %>'><%= raw text %></h<%= size %>><% end %>
@@ -1,8 +1,7 @@
1
1
  <div class="content_wrapper" id='block_<%= block.id %>'>
2
- <div class="content_body">
3
- <% if block.children.count > 0 %>
4
- <% block.children.each do |b| %><%= raw block.render(b, local_assigns) %><% end %>
5
- <% end %>
6
- <% if editing %><%= raw block.child_block_link %><% end %>
2
+ <div class="content_body">
3
+ <% if editing %><div class='sortable'><% end %>
4
+ <% block.children.each do |b| %><%= raw block.render(b, local_assigns) %><% end %>
5
+ <% if editing %></div><% end %>
7
6
  </div>
8
7
  </div>
@@ -98,10 +98,7 @@ $(document).ready(function() {
98
98
  </script>
99
99
  <% if @block.block_type.field_type == 'richtext' %>
100
100
  <script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
101
- <%= tinymce :caboose,
102
- :width => '800px',
103
- :height => '300px'
104
- %>
101
+ <%= tinymce :caboose, :width => '800px', :height => '300px' %>
105
102
  <% end %>
106
103
 
107
104
  <% end %>
@@ -0,0 +1,52 @@
1
+ <%
2
+ crumbs = []
3
+ b = @block
4
+ while b
5
+ href = b.id == @block.id ? "#" : "/admin/pages/#{b.page_id}/blocks/#{b.id}/edit"
6
+ onclick = b.id == @block.id ? " onclick=\"$('#block_#{@block.id}_block_type_id_container').slideToggle(100, function() { modal.autosize(); });\"" : ''
7
+ text = b.name ? "#{b.block_type.description} (#{b.name})" : b.block_type.description
8
+ crumbs << "<a href=\"#{href}\"#{onclick}>#{text}</a>"
9
+ b = b.parent
10
+ end
11
+ %>
12
+ <h2 style='margin-top: 0; padding-top: 0;'><%= raw crumbs.reverse.join(' > ') %></h2>
13
+ <p id='block_type_container'><div id='block_<%= @block.id %>_block_type_id'></div></p>
14
+ <p><div id='block_<%= b.child('style').id %>_value'></div></p>
15
+ <p><div id='block_<%= b.child('size').id %>_value'></div></p>
16
+ <p><div id='block_<%= b.child('text').id %>_value'></div></p>
17
+
18
+ <div id='message'></div>
19
+ <p>
20
+ <input type='button' value='Close' onclick="modal.close();" />
21
+ <input type='button' value='Delete Block' onclick="controller.delete_block();" />
22
+ <input type='button' value='Move Up' onclick="controller.move_up();" />
23
+ <input type='button' value='Move Down' onclick="controller.move_down();" />
24
+ </p>
25
+
26
+ <% content_for :caboose_css do %>
27
+ <style type='text/css'>
28
+ .block { border: #ccc 1px dotted; }
29
+ #block_<%= @block.id %>_block_type_id_container { }
30
+ </style>
31
+ <% end %>
32
+ <% content_for :caboose_js do %>
33
+ <%= javascript_include_tag "caboose/model/all" %>
34
+ <%= javascript_include_tag "caboose/admin_block_edit" %>
35
+ <script type='text/javascript'>
36
+
37
+ var modal = false;
38
+ $(window).load(function() {
39
+ modal = new CabooseModal(800);
40
+ });
41
+
42
+ var controller = false;
43
+ $(document).ready(function() {
44
+ controller = new BlockController({
45
+ block: <%= raw Caboose.json(@block.js_hash) %>,
46
+ authenticity_token: '<%= form_authenticity_token %>',
47
+ modal: modal
48
+ });
49
+ });
50
+
51
+ </script>
52
+ <% end %>
@@ -16,6 +16,8 @@ b = @block
16
16
  <h1>New Block</h1>
17
17
  <form action='/admin/pages/<%= b.page_id %>/blocks/<%= b.id %>' method='post' id='new_block_form' onsubmit="add_child_block(); return false;">
18
18
  <input type='hidden' name='authenticity_token' value='<%= form_authenticity_token %>' />
19
+ <% if @before_id %><input type='hidden' name='before_id' value='<%= @before_id %>' /><% end %>
20
+ <% if @after_id %><input type='hidden' name='after_id' value='<%= @after_id %>' /><% end %>
19
21
  <p><select name='block_type_id'>
20
22
  <option value=''>-- Select a block type --</option>
21
23
  <% Caboose::BlockType.where("parent_id is null").reorder(:name).all.each do |bt| %>
@@ -1,5 +1,6 @@
1
1
 
2
2
  <% content_for :caboose_css do %>
3
+ <%= stylesheet_link_tag 'jquery.ui.all' %>
3
4
  <style type='text/css'>
4
5
  #tiny_header {
5
6
  display: block;
@@ -19,11 +20,29 @@
19
20
  color: #fff;
20
21
  padding: 16px 10px;
21
22
  }
22
- .block_over { background: #fff799; }
23
+ .block_over { background: #e3e3e3; }
24
+ .sort_handle { display: none; }
25
+ .delete_handle { display: none; }
26
+ .block_over .sort_handle { display: block; position: relative; }
27
+ .block_over .delete_handle { display: block; position: relative; }
28
+ .block_over .sort_handle span { position: absolute; top: 0; right: 18px; width: 18px; height: 18px; background-color: #fff; border: #ccc 1px solid; }
29
+ .block_over .delete_handle span { position: absolute; top: 0; right: 0px; width: 18px; height: 18px; background-color: #fff; border: #ccc 1px solid; }
30
+
31
+ .new_block_link { position: relative; width: 100%; }
32
+ .new_block_link .line { position: absolute; top: -11px; width: 100%; height: 2px; background: transparent; }
33
+ .new_block_link a { position: absolute; top: -20px; left: 45%; background: transparent; color: transparent; display: block; padding: 4px 8px; }
34
+
35
+ .new_block_link_over { position: relative; width: 100%; }
36
+ .new_block_link_over .line { position: absolute; top: -11px; width: 100%; height: 2px; background: #ccc; }
37
+ .new_block_link_over a { position: absolute; top: -22px; left: 45%; color: #fff; background: #666; display: block; padding: 2px 4px; text-decoration: none; font-size: 12px; }
38
+
39
+ .caboose_note { padding: 10px 20px; background: #990000; color: #fff; font-size: 16px; }
40
+
23
41
  </style>
24
42
  <% end %>
25
43
 
26
44
  <% content_for :caboose_js do %>
45
+ <%= javascript_include_tag 'jquery.ui.all' %>
27
46
  <%= javascript_include_tag 'caboose/admin_page_edit_content' %>
28
47
  <script type='text/javascript'>
29
48
 
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.4.41'
2
+ VERSION = '0.4.42'
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.4.41
4
+ version: 0.4.42
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-07-16 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -293,6 +293,7 @@ files:
293
293
  - app/models/caboose/post.rb
294
294
  - app/models/caboose/post_category.rb
295
295
  - app/models/caboose/post_category_membership.rb
296
+ - app/models/caboose/rich_text_block_parser.rb
296
297
  - app/models/caboose/role.rb
297
298
  - app/models/caboose/role_membership.rb
298
299
  - app/models/caboose/role_permission.rb
@@ -348,6 +349,7 @@ files:
348
349
  - app/views/caboose/blocks/admin_edit_h4.html.erb
349
350
  - app/views/caboose/blocks/admin_edit_h5.html.erb
350
351
  - app/views/caboose/blocks/admin_edit_h6.html.erb
352
+ - app/views/caboose/blocks/admin_edit_heading.html
351
353
  - app/views/caboose/blocks/admin_edit_richtext.html.erb
352
354
  - app/views/caboose/blocks/admin_new.html.erb
353
355
  - app/views/caboose/blocks/admin_render_second_level.json.erb