alchemy_cms 2.0 → 2.0.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.
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
- - 1.9.3
4
+ #- 1.9.3
5
5
  branches:
6
6
  only:
7
7
  - master
@@ -16,7 +16,7 @@ class Admin::ClipboardController < AlchemyController
16
16
  @clipboard = get_clipboard(params[:remarkable_type].tableize)
17
17
  @item = params[:remarkable_type].classify.constantize.find(params[:remarkable_id])
18
18
  unless @clipboard.include?(params[:remarkable_id])
19
- @clipboard.push(params[:remarkable_id])
19
+ @clipboard.push({:id => params[:remarkable_id], :action => params[:remove] ? 'cut' : 'copy'})
20
20
  end
21
21
  respond_to do |format|
22
22
  format.js
@@ -28,7 +28,7 @@ class Admin::ClipboardController < AlchemyController
28
28
  def remove
29
29
  @clipboard = get_clipboard(params[:remarkable_type].tableize)
30
30
  @item = params[:remarkable_type].classify.constantize.find(params[:remarkable_id])
31
- @clipboard.delete(params[:remarkable_id])
31
+ @clipboard.delete_if { |i| i[:id] == params[:remarkable_id] }
32
32
  respond_to do |format|
33
33
  format.js
34
34
  end
@@ -10,7 +10,7 @@ class Admin::ElementsController < AlchemyController
10
10
  @page = Page.find(params[:page_id], :include => {:elements => :contents})
11
11
  @cells = @page.cells
12
12
  if @cells.blank?
13
- @elements = @page.elements
13
+ @elements = @page.elements.not_trashed
14
14
  else
15
15
  @elements = @page.elements_grouped_by_cells
16
16
  end
@@ -37,28 +37,20 @@ class Admin::ElementsController < AlchemyController
37
37
  end
38
38
 
39
39
  # Creates a element as discribed in config/alchemy/elements.yml on page via AJAX.
40
- # If a Ferret::FileNotFoundError raises we catch it and rebuilding the index.
41
40
  def create
42
- @page = Page.find(params[:element][:page_id])
43
- if params[:paste_from_clipboard].blank?
44
- @element = Element.new_from_scratch(params[:element])
45
- cell_definition = Cell.definition_for(params[:element][:name].split('#').last)
46
- else
47
- source_element = Element.find(params[:paste_from_clipboard].to_i)
48
- cell_definition = Cell.definition_for(params[:paste_from_clipboard].split('#').last)
49
- if source_element.page_id == blank? # aka. move
50
- @element = source_element
51
- else
52
- @element = Element.copy(source_element, {:page_id => @page.id})
53
- end
54
- end
55
- # if page has cells, put element in cell
56
- if @page.has_cells?
57
- if cell_definition
58
- @cell = @page.cells.find_or_create_by_name(cell_definition['name'])
59
- end
60
- @element.cell = @cell
61
- end
41
+ @page = Page.find(params[:element][:page_id])
42
+ @paste_from_clipboard = !params[:paste_from_clipboard].blank?
43
+ if @paste_from_clipboard
44
+ source_element = Element.find(element_from_clipboard[:id])
45
+ @element = Element.copy(source_element, {:page_id => @page.id})
46
+ if element_from_clipboard[:action] == 'cut'
47
+ source_element.destroy
48
+ @clipboard.delete_if { |i| i[:id].to_i == source_element.id }
49
+ end
50
+ else
51
+ @element = Element.new_from_scratch(params[:element])
52
+ end
53
+ put_element_in_cell if @page.can_have_cells?
62
54
  @element.page = @page
63
55
  if @element.save
64
56
  render :action => :create
@@ -113,11 +105,12 @@ class Admin::ElementsController < AlchemyController
113
105
  end
114
106
 
115
107
  def order
116
- page = Page.find(params[:page_id])
117
108
  params[:element_ids].each do |element_id|
118
109
  element = Element.find(element_id)
119
110
  if element.trashed?
120
- element.page = page
111
+ element.page_id = params[:page_id]
112
+ element.cell_id = params[:cell_id] if params[:cell_id]
113
+ element.position = 1
121
114
  end
122
115
  element.move_to_bottom
123
116
  end
@@ -129,9 +122,28 @@ class Admin::ElementsController < AlchemyController
129
122
  @element = Element.find(params[:id])
130
123
  @page = @element.page
131
124
  @element.folded = !@element.folded
132
- @element.save(false)
125
+ @element.save
133
126
  rescue Exception => e
134
127
  exception_handler(e)
135
128
  end
136
129
 
130
+ private
131
+
132
+ def put_element_in_cell
133
+ element_with_cell_name = @paste_from_clipboard ? params[:paste_from_clipboard] : params[:element][:name]
134
+ cell_definition = Cell.definition_for(element_with_cell_name.split('#').last) if !element_with_cell_name.blank?
135
+ if cell_definition
136
+ @cell = @page.cells.find_or_create_by_name(cell_definition['name'])
137
+ @element.cell = @cell
138
+ return true
139
+ else
140
+ return false
141
+ end
142
+ end
143
+
144
+ def element_from_clipboard
145
+ @clipboard = get_clipboard(:elements)
146
+ @clipboard.detect { |i| i[:id].to_i == params[:paste_from_clipboard].to_i }
147
+ end
148
+
137
149
  end
@@ -10,6 +10,8 @@ class Admin::TrashController < AlchemyController
10
10
  @elements = Element.trashed
11
11
  @page = Page.find_by_id(params[:page_id])
12
12
  @allowed_elements = Element.all_for_page(@page)
13
+ @draggable_trash_items = {}
14
+ @elements.each { |e| @draggable_trash_items["element_#{e.id}"] = e.belonging_cellnames(@page) }
13
15
  render :layout => false
14
16
  rescue Exception => e
15
17
  exception_handler(e)
@@ -56,21 +56,6 @@ module Admin::ElementsHelper
56
56
  )
57
57
  end
58
58
 
59
- def clipboard_select_tag(items, html_options = {})
60
- options = [[_('Please choose'), ""]]
61
- items.each do |item|
62
- options << [item.class.to_s == 'Element' ? item.display_name_with_preview_text : item.name, item.id]
63
- end
64
- select_tag(
65
- 'paste_from_clipboard',
66
- @page.has_cells? ? grouped_elements_for_select(items, :id) : options_for_select(options),
67
- {
68
- :class => html_options[:class] || 'very_long',
69
- :style => html_options[:style]
70
- }
71
- )
72
- end
73
-
74
59
  # Returns all elements that could be placed on that page because of the pages layout.
75
60
  # The elements are returned as an array to be used in alchemy_selectbox form builder.
76
61
  def elements_for_select(elements)
@@ -92,23 +77,31 @@ module Admin::ElementsHelper
92
77
  celled_elements += cell_elements
93
78
  optgroup_label = Cell.translated_label_for(cell['name'])
94
79
  options[optgroup_label] = cell_elements.map do |e|
95
- [
96
- I18n.t("alchemy.element_names.#{e['name']}", :default => e['name'].capitalize),
97
- (e.class.name == 'Element' ? e.send(object_method).to_s : e[object_method]) + "##{cell['name']}"
98
- ]
80
+ element_array_for_options(e, object_method, cell)
99
81
  end
100
82
  end
101
83
  other_elements = elements - celled_elements
102
84
  unless other_elements.blank?
103
85
  optgroup_label = _('other Elements')
104
86
  options[optgroup_label] = other_elements.map do |e|
105
- [
106
- I18n.t("alchemy.element_names.#{e['name']}", :default => e['name'].capitalize),
107
- e.class.name == 'Element' ? e.send(object_method) : e[object_method]
108
- ]
87
+ element_array_for_options(e, object_method)
109
88
  end
110
89
  end
111
90
  return grouped_options_for_select(options)
112
91
  end
113
92
 
93
+ def element_array_for_options(e, object_method, cell = nil)
94
+ if e.class.name == 'Element'
95
+ [
96
+ e.display_name_with_preview_text,
97
+ e.send(object_method).to_s + (cell ? "##{cell['name']}" : "")
98
+ ]
99
+ else
100
+ [
101
+ I18n.t("alchemy.element_names.#{e['name']}", :default => e['name'].capitalize),
102
+ e[object_method] + (cell ? "##{cell['name']}" : "")
103
+ ]
104
+ end
105
+ end
106
+
114
107
  end
@@ -339,4 +339,19 @@ module AlchemyHelper
339
339
  end
340
340
  end
341
341
 
342
+ def clipboard_select_tag(items, html_options = {})
343
+ options = [[_('Please choose'), ""]]
344
+ items.each do |item|
345
+ options << [item.class.to_s == 'Element' ? item.display_name_with_preview_text : item.name, item.id]
346
+ end
347
+ select_tag(
348
+ 'paste_from_clipboard',
349
+ !@page.new_record? && @page.can_have_cells? ? grouped_elements_for_select(items, :id) : options_for_select(options),
350
+ {
351
+ :class => html_options[:class] || 'very_long',
352
+ :style => html_options[:style]
353
+ }
354
+ )
355
+ end
356
+
342
357
  end
data/app/models/cell.rb CHANGED
@@ -37,19 +37,15 @@ class Cell < ActiveRecord::Base
37
37
  Element.all_definitions_for(element_names.uniq)
38
38
  end
39
39
 
40
- def self.definition_for_element(element_name)
41
- definitions_for_element(element_name).first
42
- end
43
-
44
40
  def self.definitions_for_element(element_name)
45
41
  return [] if definitions.blank?
46
42
  definitions.select { |d| d['elements'].include?(element_name) }
47
43
  end
48
44
 
49
- def self.name_for_element(element_name)
50
- definition = definition_for_element(element_name)
51
- return nil if definition.blank?
52
- definition['name']
45
+ def self.names_for_element(element_name)
46
+ definitions = definitions_for_element(element_name)
47
+ return nil if definitions.blank?
48
+ definitions.collect { |d| d['name'] }
53
49
  end
54
50
 
55
51
  def name_for_label
@@ -17,6 +17,7 @@ class Element < ActiveRecord::Base
17
17
 
18
18
  # TODO: add a trashed column to elements table
19
19
  scope :trashed, where(:page_id => nil).order('updated_at DESC')
20
+ scope :not_trashed, where('`elements`.`page_id` IS NOT NULL')
20
21
  scope :published, where(:public => true)
21
22
  scope :named, lambda { |names| where(arel_table[:name].in(names)) }
22
23
  scope :excluded, lambda { |names| where(arel_table[:name].not_in(names)) }
@@ -52,11 +53,15 @@ class Element < ActiveRecord::Base
52
53
 
53
54
  # nullifies the page_id aka. trashs it.
54
55
  def trash
55
- self.update_attributes({
56
- :page_id => nil,
57
- :folded => true,
58
- :public => false
59
- })
56
+ self.attributes = {
57
+ :page_id => nil,
58
+ :cell_id => nil,
59
+ :folded => true,
60
+ :public => false
61
+ }
62
+ # If we validate the element, it will not get trashed if another element with same postion is already trashed.
63
+ # And we cannot remove the position, because it will not be reordered in the list if its position is nil.
64
+ self.remove_from_list
60
65
  end
61
66
 
62
67
  def trashed?
@@ -286,7 +291,7 @@ class Element < ActiveRecord::Base
286
291
 
287
292
  def self.all_from_clipboard(clipboard)
288
293
  return [] if clipboard.nil?
289
- self.find_all_by_id(clipboard)
294
+ self.find_all_by_id(clipboard.collect { |i| i[:id] })
290
295
  end
291
296
 
292
297
  def self.all_from_clipboard_for_page(clipboard, page)
@@ -399,12 +404,12 @@ class Element < ActiveRecord::Base
399
404
  alias_method :richtext_contents, :rtf_contents
400
405
 
401
406
  # The name of the cell the element could be placed in.
402
- def belonging_cellname
403
- cellname = Cell.name_for_element(name)
404
- if cellname.blank?
405
- return 'for_other_elements'
407
+ def belonging_cellnames(page)
408
+ cellnames = Cell.names_for_element(name)
409
+ if cellnames.blank? || !page.has_cells?
410
+ return ['for_other_elements']
406
411
  else
407
- return cellname
412
+ return cellnames
408
413
  end
409
414
  end
410
415
 
data/app/models/page.rb CHANGED
@@ -111,8 +111,8 @@ class Page < ActiveRecord::Base
111
111
 
112
112
  def elements_grouped_by_cells
113
113
  group = ActiveSupport::OrderedHash.new
114
- cells.each { |cell| group[cell] = cell.elements }
115
- group[Cell.new({:name => 'for_other_elements'})] = elements.find_all_by_cell_id(nil)
114
+ cells.each { |cell| group[cell] = cell.elements.not_trashed }
115
+ group[Cell.new({:name => 'for_other_elements'})] = elements.not_trashed.where(:cell_id => nil)
116
116
  return group
117
117
  end
118
118
 
@@ -302,17 +302,18 @@ class Page < ActiveRecord::Base
302
302
  end
303
303
  end
304
304
 
305
- # Returns the self#page_layout description from config/alchemy/page_layouts.yml file.
306
- def layout_description
307
- page_layout = Alchemy::PageLayout.get(self.page_layout)
308
- if page_layout.nil?
309
- logger.warn("\n+++++++++++ Warning! Alchemy::PageLayout description not found for layout: #{self.page_layout}\n")
310
- return nil
311
- else
312
- return page_layout
313
- end
314
- end
315
- alias_method :definition, :layout_description
305
+ # Returns the self#page_layout description from config/alchemy/page_layouts.yml file.
306
+ def layout_description
307
+ description = Alchemy::PageLayout.get(self.page_layout)
308
+ if self.root?
309
+ return {}
310
+ elsif description.nil?
311
+ raise "Description could not be found for page layout named #{self.page_layout}. Please check page_layouts.yml file."
312
+ else
313
+ description
314
+ end
315
+ end
316
+ alias_method :definition, :layout_description
316
317
 
317
318
  # Returns translated name of the pages page_layout value.
318
319
  # Page layout names are defined inside the config/alchemy/page_layouts.yml file.
@@ -338,16 +339,12 @@ class Page < ActiveRecord::Base
338
339
  end
339
340
 
340
341
  def contains_feed?
341
- desc = self.layout_description
342
- return false if desc.blank?
343
- desc["feed"]
342
+ definition["feed"]
344
343
  end
345
344
 
346
345
  # Returns true or false if the pages layout_description for config/alchemy/page_layouts.yml contains redirects_to_external: true
347
346
  def redirects_to_external?
348
- desc = self.layout_description
349
- return false if desc.blank?
350
- desc["redirects_to_external"]
347
+ definition["redirects_to_external"]
351
348
  end
352
349
 
353
350
  # Returns an array of all pages currently locked by user
@@ -432,7 +429,7 @@ class Page < ActiveRecord::Base
432
429
 
433
430
  def self.all_from_clipboard(clipboard)
434
431
  return [] if clipboard.blank?
435
- self.find_all_by_id(clipboard)
432
+ self.find_all_by_id(clipboard.collect { |i| i[:id] })
436
433
  end
437
434
 
438
435
  def self.all_from_clipboard_for_select(clipboard, language_id, layoutpage = false)
@@ -459,11 +456,13 @@ class Page < ActiveRecord::Base
459
456
  end
460
457
 
461
458
  # Returns true or false if the page has a page_layout that has cells.
462
- def has_cells?
463
- pagelayout = Alchemy::PageLayout.get(self.page_layout)
464
- return false if pagelayout.blank?
465
- !pagelayout['cells'].blank?
459
+ def can_have_cells?
460
+ !definition['cells'].blank?
466
461
  end
462
+
463
+ def has_cells?
464
+ cells.any?
465
+ end
467
466
 
468
467
  def self.link_target_options
469
468
  options = [
@@ -522,7 +521,6 @@ private
522
521
  # Looks in the layout_descripion, if there are elements to autogenerate.
523
522
  # If so, it generates them.
524
523
  def autogenerate_elements
525
- return true if self.layout_description.blank?
526
524
  elements = self.layout_description["autogenerate"]
527
525
  unless (elements.blank?)
528
526
  elements.each do |element|
@@ -538,7 +536,7 @@ private
538
536
  end
539
537
 
540
538
  def create_cells
541
- return true if !has_cells?
539
+ return false if !can_have_cells?
542
540
  definition['cells'].each do |cellname|
543
541
  cells.create({:name => cellname})
544
542
  end
@@ -1,4 +1,4 @@
1
- <div class="element_editor<%= element.folded ? ' folded' : '' %> <%= defined?(draggable) && !draggable ? 'not-draggable' : 'draggable' %>" id="element_<%= element.id %>">
1
+ <div class="element_editor<%= element.folded ? ' folded' : '' %> <%= defined?(draggable) && !draggable ? 'not-draggable' : 'draggable' %>" id="element_<%= element.id %>" data-element-id="<%= element.id %>">
2
2
  <%= render :partial => "admin/elements/element_head", :locals => {:element => element} %>
3
3
  <%- if !element.folded? -%>
4
4
  <%= form_for(
@@ -12,7 +12,7 @@
12
12
  <span style="margin-right: 16px"><%= _("element_of_type") %>:</span>
13
13
  <%= form.select(
14
14
  'name',
15
- @page.has_cells? ? grouped_elements_for_select(@elements) : elements_for_select(@elements),
15
+ @page.can_have_cells? ? grouped_elements_for_select(@elements) : elements_for_select(@elements),
16
16
  {:prompt => _('select_element')},
17
17
  {:class => 'very_long'}
18
18
  ) -%>
@@ -1,6 +1,6 @@
1
1
  (function($) {
2
2
 
3
- <%- if @page.has_cells? -%>
3
+ <%- if @page.can_have_cells? -%>
4
4
  Alchemy.selectOrCreateCellTab('<%= @cell.nil? ? "for_other_elements" : @cell.name -%>', '<%= @cell.nil? ? _("other Elements") : @cell.name_for_label -%>');
5
5
  <%- end -%>
6
6
  $('#cell_<%= @cell.nil? ? "for_other_elements" : @cell.name -%>').append('<%= escape_javascript render(:partial => "element", :object => @element, :locals => {:draggable => true}) -%>');
@@ -12,9 +12,13 @@
12
12
  <%- end -%>
13
13
  Alchemy.PreviewWindow.refresh();
14
14
  Alchemy.ElementEditorSelector.init();
15
- $('#element_<%= @element.id -%>').trigger('Alchemy.SelectElementEditor');
15
+ $('.element_editor[data-element-id="<%= @element.id -%>"]').trigger('Alchemy.SelectElementEditor');
16
16
  Alchemy.ElementDirtyObserver('#element_<%= @element.id -%>');
17
17
  Alchemy.SelectBox('#element_<%= @element.id -%> select');
18
18
  Alchemy.ButtonObserver('#element_<%= @element.id -%> button.button');
19
-
19
+
20
+ <%- if @clipboard.blank? -%>
21
+ $('#clipboard_button .icon.clipboard').removeClass('full');
22
+ <%- end -%>
23
+
20
24
  })(jQuery);
@@ -1,5 +1,5 @@
1
1
  (function($) {
2
- $('#element_<%= @element.id -%>').remove();
2
+ $('.element_editor[data-element-id="<%= @element.id -%>"]').remove();
3
3
  Alchemy.growl('<%= _("element_deleted_successful") -%>');
4
4
  $('#element_area').sortable('refresh');
5
5
  Alchemy.PreviewWindow.refresh();
@@ -6,10 +6,12 @@
6
6
 
7
7
  <%- else -%>
8
8
 
9
- $('#element_<%= @element.id -%>').replaceWith('<%= escape_javascript render(:partial => "element", :object => @element) -%>');
10
- $('#element_area').sortable('refresh');
9
+ $('.element_editor[data-element-id="<%= @element.id -%>"]').replaceWith('<%= escape_javascript render(:partial => "element", :object => @element) -%>');
10
+ $('#element_area .sortable_cell').sortable('refresh');
11
11
  Alchemy.ElementEditorSelector.bindEvent('#element_<%= @element.id -%>');
12
-
12
+
13
+ $('.element_editor[data-element-id="<%= @element.id -%>"]');
14
+
13
15
  <%- if @element.folded -%>
14
16
 
15
17
  <%- @element.rtf_contents.each do |content| -%>
@@ -22,7 +24,7 @@
22
24
 
23
25
  <%- else -%>
24
26
 
25
- $('#element_<%= @element.id -%>').trigger('Alchemy.SelectElementEditor');
27
+ $('.element_editor[data-element-id="<%= @element.id -%>"]').trigger('Alchemy.SelectElementEditor');
26
28
  Alchemy.SelectBox('#element_<%= @element.id -%> select');
27
29
 
28
30
  <%- @element.rtf_contents.each do |content| -%>
@@ -11,13 +11,13 @@
11
11
  <%- end -%>
12
12
  </ul>
13
13
  <%- @elements.each do |cell, elements| -%>
14
- <div id="cell_<%= cell.name %>" class="sortable_cell">
14
+ <div id="cell_<%= cell.name %>" class="sortable_cell <%= cell.name %>_cell" data-cell-id="<%= cell.id %>">
15
15
  <%= render :partial => 'element', :collection => elements, :locals => {:draggable => true} %>
16
16
  </div>
17
17
  <%- end -%>
18
18
  </div>
19
19
  <%- else -%>
20
- <div class="sortable_cell" id="cell_for_other_elements">
20
+ <div class="sortable_cell for_other_elements_cell" id="cell_for_other_elements">
21
21
  <%= render :partial => @elements, :locals => {:draggable => true} %>
22
22
  </div>
23
23
  <%- end -%>
@@ -1,6 +1,6 @@
1
1
  (function($) {
2
2
 
3
- $("#element_<%= @element.id -%>").remove();
3
+ $('.element_editor[data-element-id="<%= @element.id -%>"]').remove();
4
4
  Alchemy.growl('<%= _("Element trashed") -%>');
5
5
  $('#element_area').sortable('refresh');
6
6
  Alchemy.refreshTrashWindow(<%= @page_id -%>);
@@ -1,7 +1,7 @@
1
1
  (function($) {
2
2
  $('div#element_<%= @element.id -%> div.element_handle span.icon').removeClass('element_<%= @element.public? ? "draft" : "public" -%>').addClass('element_<%= @element.public? ? "public" : "draft" -%>');
3
- $('#element_<%= @element.id -%> .element_heading .preview_text_element_name').text('<%= @element.display_name -%>');
4
- $('#element_<%= @element.id -%> .element_heading .preview_text_quote').text('<%= escape_javascript(@element.preview_text) -%>');
3
+ $('.element_editor[data-element-id="<%= @element.id -%>"] .element_heading .preview_text_element_name').text('<%= @element.display_name -%>');
4
+ $('.element_editor[data-element-id="<%= @element.id -%>"] .element_heading .preview_text_quote').text('<%= escape_javascript(@element.preview_text) -%>');
5
5
  $('div.content_editor').removeClass('validation_failed');
6
6
  $("#element_<%= @element.id -%>_errors").hide();
7
7
  Alchemy.setElementSaved('#element_<%= @element.id -%>');
@@ -19,7 +19,5 @@
19
19
  <%- end -%>
20
20
  </div>
21
21
  <script type="text/javascript" charset="utf-8">
22
- <%- cells_items = {} %>
23
- <%- @elements.each { |e| cells_items["element_#{e.id}"] = e.belonging_cellname }; -%>
24
- Alchemy.DraggableTrashItems(<%= cells_items.to_json.html_safe %>);
22
+ Alchemy.DraggableTrashItems(<%= @draggable_trash_items.to_json.html_safe %>);
25
23
  </script>
@@ -549,8 +549,10 @@ if (typeof(Alchemy) === 'undefined') {
549
549
  tolerance: 'pointer',
550
550
  update: function(event, ui) {
551
551
  var ids = $.map($(event.target).children(), function(child) {
552
- return child.id.replace(/element_/, '');
552
+ return $(child).attr('data-element-id');
553
553
  });
554
+ var params_string = '';
555
+ var cell_id = $(event.target).attr('data-cell-id');
554
556
  // Is the trash window open?
555
557
  if ($('#alchemyTrashWindow').length > 0) {
556
558
  // updating the trash icon
@@ -560,10 +562,14 @@ if (typeof(Alchemy) === 'undefined') {
560
562
  }
561
563
  }
562
564
  $(event.target).css("cursor", "progress");
565
+ params_string = "page_id=" + page_id + "&authenticity_token=" + encodeURIComponent(form_token) + "&" + $.param({element_ids: ids});
566
+ if (cell_id) {
567
+ params_string += "&cell_id=" + cell_id;
568
+ }
563
569
  $.ajax({
564
570
  url: '/admin/elements/order',
565
571
  type: 'POST',
566
- data: "page_id=" + page_id + "&authenticity_token=" + encodeURIComponent(form_token) + "&" + $.param({element_ids: ids}),
572
+ data: params_string,
567
573
  complete: function () {
568
574
  $(event.target).css("cursor", "auto");
569
575
  Alchemy.refreshTrashWindow(page_id);
@@ -788,10 +794,15 @@ if (typeof(Alchemy) === 'undefined') {
788
794
 
789
795
  DraggableTrashItems: function (items_n_cells) {
790
796
  $("#trash_items div.draggable").each(function () {
797
+ var cell_classes = '';
798
+ var cell_names = items_n_cells[this.id];
799
+ $.each(cell_names, function (i) {
800
+ cell_classes += '.' + this + '_cell' + ', ';
801
+ });
791
802
  $(this).draggable({
792
803
  helper: 'clone',
793
804
  iframeFix: 'iframe#alchemyPreviewWindow',
794
- connectToSortable: '#cell_' + items_n_cells[this.id],
805
+ connectToSortable: cell_classes,
795
806
  start: function(event, ui) {
796
807
  $(this).hide().addClass('dragged');
797
808
  ui.helper.css({width: '300px'});
@@ -30,9 +30,6 @@ module Alchemy
30
30
  # Returns the page_layout description found by name in page_layouts.yml
31
31
  def self.get(name = "")
32
32
  self.get_layouts.detect{ |a| a["name"].downcase == name.downcase }
33
- rescue Exception => e
34
- Rails.logger.error("++++++ ERROR\n#{e}")
35
- return nil
36
33
  end
37
34
 
38
35
  # Returns page layouts ready for Rails' select form helper.
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.0"
3
+ VERSION = "2.0.1"
4
4
 
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Installing Alchemy Gem
4
4
 
5
- gem 'alchemy_cms', '>= 2.0.rc5'
5
+ gem 'alchemy_cms'
6
6
  gem 'ruby-debug', :group => :development, :platform => :ruby_18
7
7
  gem 'ruby-debug19', :group => :development, :platform => :ruby_19
8
8
 
data/locale/de/alchemy.po CHANGED
@@ -71,7 +71,7 @@ msgstr "Seite wählen"
71
71
 
72
72
  #: app/controllers/admin/trash_controller.rb:15
73
73
  msgid "Cleared trash"
74
- msgstr "Der Papierkorb wurde entleert"
74
+ msgstr "Der Papierkorb wurde geleert"
75
75
 
76
76
  #: app/views/admin/pictures/_picture.html.erb:35
77
77
  msgid "Click to rename"
@@ -106,11 +106,11 @@ msgstr "Bild löschen"
106
106
 
107
107
  #: app/views/admin/clipboard/index.html.erb:15
108
108
  msgid "Do you really want to clear the clipboard?"
109
- msgstr "Wollen Sie die Zwischenablage wirklich entleeren?"
109
+ msgstr "Wollen Sie die Zwischenablage wirklich leeren?"
110
110
 
111
111
  #: app/views/admin/trash/index.html.erb:16
112
112
  msgid "Do you really want to clear the trash?"
113
- msgstr "Wollen Sie den Papierkorb wirklich entleeren?"
113
+ msgstr "Wollen Sie den Papierkorb wirklich leeren?"
114
114
 
115
115
  #: app/views/essences/_essence_text_editor.html.erb:50
116
116
  msgid "Do you really want to delete this content?"
@@ -932,11 +932,11 @@ msgstr "Bitte wählen Sie eine Datei zum Verlinken aus."
932
932
 
933
933
  #: app/views/admin/clipboard/index.html.erb:15
934
934
  msgid "clear clipboard"
935
- msgstr "Zwischenablage entleeren"
935
+ msgstr "Zwischenablage leeren"
936
936
 
937
937
  #: app/views/admin/trash/index.html.erb:16
938
938
  msgid "clear trash"
939
- msgstr "Papierkorb entleeren"
939
+ msgstr "Papierkorb leeren"
940
940
 
941
941
  #: app/helpers/alchemy_helper.rb:790
942
942
  #: app/views/admin/partials/_remote_search_form.html.erb:30
@@ -23,7 +23,7 @@ describe ElementsHelper do
23
23
  helper.element_dom_id(@element).should == "#{@element.name}_#{@element.id}"
24
24
  end
25
25
 
26
- it "should render elements for a cell", :focus => true do
26
+ it "should render elements for a cell" do
27
27
  cell = Factory(:cell)
28
28
  Factory(:element, :cell_id => cell.id)
29
29
  helper.stub(:configuration).and_return(true)
@@ -7,7 +7,28 @@ describe Page do
7
7
  before(:each) do
8
8
  @rootpage = Page.rootpage
9
9
  @language = Language.get_default
10
- @language_root = Factory(:page, :parent_id => @rootpage.id, :language => @language, :language_root => true)
10
+ @language_root = Factory(:page, :parent_id => @rootpage.id, :language => @language, :language_root => true, :page_layout => 'intro')
11
+ end
12
+
13
+ describe ".layout_description" do
14
+
15
+ context "for a language root page" do
16
+
17
+ it "should return the page layout description as hash" do
18
+ @language_root.layout_description['name'].should == 'intro'
19
+ end
20
+
21
+ it "should return an empty hash for root page" do
22
+ @rootpage.layout_description.should == {}
23
+ end
24
+
25
+ end
26
+
27
+ it "should raise Exception if the page_layout could not be found in the definition file" do
28
+ @page = mock(:page, :page_layout => 'foo')
29
+ expect { @page.layout_description }.to raise_error
30
+ end
31
+
11
32
  end
12
33
 
13
34
  it "should contain one rootpage" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "2.0"
5
+ version: 2.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas von Deyen
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2011-11-02 00:00:00 Z
15
+ date: 2011-11-03 00:00:00 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails