tb_cms 1.0.3 → 1.1.0

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 (81) hide show
  1. checksums.yaml +6 -14
  2. data/README.markdown +1 -1
  3. data/app/controllers/admin/menu_items_controller.rb +5 -5
  4. data/app/controllers/admin/menus_controller.rb +8 -2
  5. data/app/controllers/admin/pages_controller.rb +7 -21
  6. data/app/controllers/admin/snippets_controller.rb +7 -4
  7. data/app/controllers/cms/sitemaps_controller.rb +0 -2
  8. data/app/controllers/pages_controller.rb +1 -10
  9. data/app/helpers/cms/application_helper.rb +90 -98
  10. data/app/models/spud_menu.rb +2 -3
  11. data/app/models/spud_menu_item.rb +1 -4
  12. data/app/models/spud_page.rb +6 -8
  13. data/app/models/spud_page_partial.rb +6 -21
  14. data/app/models/spud_page_partial_revision.rb +1 -1
  15. data/app/models/spud_snippet.rb +3 -19
  16. data/app/views/admin/menu_items/_menu_item_row.html.erb +2 -2
  17. data/app/views/admin/menus/index.html.erb +6 -9
  18. data/app/views/admin/pages/_page_row.html.erb +16 -16
  19. data/app/views/admin/pages/edit.html.erb +1 -1
  20. data/app/views/admin/snippets/index.html.erb +1 -1
  21. data/app/views/pages/show.html.erb +27 -22
  22. data/config/routes.rb +1 -4
  23. data/db/migrate/20121119030136_change_liquid_tags_to_polymorphic.rb +4 -2
  24. data/db/migrate/20140110142037_drop_spud_page_liquid_tags.rb +31 -0
  25. data/lib/spud_cms/engine.rb +1 -9
  26. data/lib/spud_cms/page_route.rb +2 -4
  27. data/lib/spud_cms/version.rb +1 -1
  28. data/spec/controllers/admin/menu_items_controller_spec.rb +0 -2
  29. data/spec/controllers/cms/sitemaps_controller_spec.rb +11 -17
  30. data/spec/dummy/config/application.rb +1 -0
  31. data/spec/dummy/config/environments/test.rb +9 -2
  32. data/spec/dummy/config/initializers/secret_token.rb +1 -0
  33. data/spec/dummy/db/migrate/{20120307002859_create_spud_admin_permissions.spud_core.rb → 20140110051449_create_spud_admin_permissions.tb_core.rb} +1 -1
  34. data/spec/dummy/db/migrate/{20120307002860_create_spud_users.spud_core.rb → 20140110051450_create_spud_users.tb_core.rb} +1 -1
  35. data/spec/dummy/db/migrate/{20120610123555_add_time_zone_to_spud_user.spud_core.rb → 20140110051451_add_time_zone_to_spud_user.tb_core.rb} +1 -1
  36. data/spec/dummy/db/migrate/20140110051452_add_scope_to_spud_admin_permissions.tb_core.rb +7 -0
  37. data/spec/dummy/db/migrate/{20120610123557_create_spud_user_settings.spud_core.rb → 20140110051453_create_spud_user_settings.tb_core.rb} +1 -1
  38. data/spec/dummy/db/migrate/20140110051454_create_spud_roles.tb_core.rb +11 -0
  39. data/spec/dummy/db/migrate/20140110051455_create_spud_permissions.tb_core.rb +11 -0
  40. data/spec/dummy/db/migrate/20140110051456_create_spud_role_permissions.tb_core.rb +12 -0
  41. data/spec/dummy/db/migrate/20140110051457_drop_spud_admin_permissions.tb_core.rb +16 -0
  42. data/spec/dummy/db/migrate/20140110051458_create_spud_liquid_tags.tb_core.rb +13 -0
  43. data/spec/dummy/db/migrate/20140110051459_create_spud_permalinks.tb_permalinks.rb +12 -0
  44. data/spec/dummy/db/migrate/20140110051460_add_site_id_to_spud_permalinks.tb_permalinks.rb +7 -0
  45. data/spec/dummy/db/migrate/20140110051461_modify_site_id_for_spud_permalinks.tb_permalinks.rb +12 -0
  46. data/spec/dummy/db/migrate/20140110051462_create_spud_pages.tb_cms.rb +20 -0
  47. data/spec/dummy/db/migrate/20140110051463_create_spud_menus.tb_cms.rb +11 -0
  48. data/spec/dummy/db/migrate/20140110051464_create_spud_menu_items.tb_cms.rb +18 -0
  49. data/spec/dummy/db/migrate/20140110051465_create_spud_templates.tb_cms.rb +12 -0
  50. data/spec/dummy/db/migrate/20140110051466_create_spud_page_partials.tb_cms.rb +14 -0
  51. data/spec/dummy/db/migrate/20140110051467_add_visibility_to_spud_pages.tb_cms.rb +7 -0
  52. data/spec/dummy/db/migrate/20140110051468_add_menu_name_to_spud_menu_items.tb_cms.rb +6 -0
  53. data/spec/dummy/db/migrate/20140110051469_add_use_custom_url_name_to_spud_pages.tb_cms.rb +6 -0
  54. data/spec/dummy/db/migrate/20140110051470_add_notes_to_spud_pages.tb_cms.rb +6 -0
  55. data/spec/dummy/db/migrate/20140110051471_add_menu_id_to_spud_menu_items.tb_cms.rb +8 -0
  56. data/spec/dummy/db/migrate/20140110051472_add_classes_to_spud_menu_items.tb_cms.rb +7 -0
  57. data/spec/dummy/db/migrate/20140110051473_add_site_id_to_spud_pages.tb_cms.rb +7 -0
  58. data/spec/dummy/db/migrate/20140110051474_add_site_id_to_spud_templates.tb_cms.rb +7 -0
  59. data/spec/dummy/db/migrate/20140110051475_add_site_id_to_spud_menus.tb_cms.rb +7 -0
  60. data/spec/dummy/db/migrate/20140110051476_create_spud_page_partial_revisions.tb_cms.rb +14 -0
  61. data/spec/dummy/db/migrate/20140110051477_add_symbol_name_to_spud_page_partials.tb_cms.rb +6 -0
  62. data/spec/dummy/db/migrate/20140110051478_modify_site_id_for_spud_pages.tb_cms.rb +16 -0
  63. data/spec/dummy/db/migrate/20140110051479_add_content_processed_to_spud_page_partials.tb_cms.rb +6 -0
  64. data/spec/dummy/db/migrate/20140110051480_add_layout_to_spud_pages.tb_cms.rb +9 -0
  65. data/spec/dummy/db/migrate/20140110051481_create_spud_page_liquid_tags.tb_cms.rb +12 -0
  66. data/spec/dummy/db/migrate/20140110051482_create_spud_snippets.tb_cms.rb +18 -0
  67. data/spec/dummy/db/migrate/20140110051483_change_liquid_tags_to_polymorphic.tb_cms.rb +20 -0
  68. data/spec/dummy/db/migrate/20140110051484_drop_spud_page_liquid_tags.tb_cms.rb +30 -0
  69. data/spec/dummy/db/schema.rb +96 -79
  70. data/spec/helpers/cms/application_helper_spec.rb +11 -9
  71. data/spec/models/spud_page_partial_spec.rb +3 -3
  72. data/spec/models/spud_page_spec.rb +3 -4
  73. metadata +115 -77
  74. data/app/models/spud_page_liquid_tag.rb +0 -4
  75. data/app/observers/page_sweeper.rb +0 -48
  76. data/app/observers/snippet_sweeper.rb +0 -41
  77. data/spec/dummy/db/migrate/20120307003559_create_spud_permalinks.spud_permalinks.rb +0 -12
  78. data/spec/dummy/db/migrate/20120610123556_add_scope_to_spud_admin_permissions.spud_core.rb +0 -7
  79. data/spec/dummy/db/migrate/20120610123615_add_site_id_to_spud_permalinks.spud_permalinks.rb +0 -7
  80. data/spec/dummy/log/test.log +0 -11310
  81. data/spec/models/spud_page_liquid_tag_spec.rb +0 -5
@@ -1,9 +1,8 @@
1
1
  class SpudMenu < ActiveRecord::Base
2
2
  validates :name,:presence => true
3
3
  validates_uniqueness_of :name, :scope => [:site_id]
4
- has_many :spud_menu_items,:as => :parent,:dependent => :destroy
5
- has_many :spud_menu_items_combined,:class_name => "SpudMenuItem",:foreign_key => :spud_menu_id,:dependent => :destroy
4
+ has_many :spud_menu_items, :as => :parent, :dependent => :destroy
5
+ has_many :spud_menu_items_combined, :class_name => "SpudMenuItem", :foreign_key => :spud_menu_id, :dependent => :destroy
6
6
 
7
- attr_protected :site_id
8
7
  scope :site, lambda {|sid| where(:site_id => sid)}
9
8
  end
@@ -1,6 +1,6 @@
1
1
  class SpudMenuItem < ActiveRecord::Base
2
2
  belongs_to :parent, :polymorphic=>true
3
- belongs_to :spud_menu
3
+ belongs_to :spud_menu, :touch => true
4
4
  belongs_to :spud_page
5
5
  has_many :spud_menu_items,:as => :parent,:dependent => :destroy
6
6
 
@@ -9,9 +9,6 @@ class SpudMenuItem < ActiveRecord::Base
9
9
  validates :parent_type,:presence => true
10
10
  validates :parent_id,:presence => true
11
11
 
12
-
13
- attr_accessible :name,:parent_type,:parent_id,:item_type,:spud_page_id,:menu_order,:url,:classes
14
-
15
12
  def get_url
16
13
  if !self.spud_page.blank?
17
14
  return self.spud_page.url_name
@@ -8,9 +8,6 @@ class SpudPage < ActiveRecord::Base
8
8
  belongs_to :created_by_user,:class_name => "SpudUser",:foreign_key => :created_by
9
9
  belongs_to :updated_by_user,:class_name => "SpudUser",:foreign_key => :updated_by
10
10
 
11
-
12
- attr_accessible :name,:url_name,:created_by,:updated_by,:layout,:visibility,:spud_page_id,:publish_at,:format,:meta_description,:meta_keywords,:page_order,:spud_page_partials_attributes,:use_custom_url_name,:published,:notes
13
-
14
11
  before_validation :generate_url_name
15
12
  validates :name,:presence => true
16
13
  validates_uniqueness_of :name, :scope => [:site_id,:spud_page_id]
@@ -18,10 +15,11 @@ class SpudPage < ActiveRecord::Base
18
15
  validates_uniqueness_of :url_name, :scope => :site_id
19
16
 
20
17
  accepts_nested_attributes_for :spud_page_partials, :allow_destroy => true
21
- scope :parent_pages, where(:spud_page_id => nil)
18
+
19
+ scope :parent_pages, ->{ where(:spud_page_id => nil)}
22
20
  scope :site, lambda {|sid| where(:site_id => sid)}
23
- scope :published_pages, where(:published => true)
24
- scope :public, where(:visibility => 0)
21
+ scope :published_pages, ->{ where(:published => true) }
22
+ scope :public, ->{ where(:visibility => 0) }
25
23
 
26
24
  def full_content_processed
27
25
  self.spud_page_partials.collect{|partial| partial.content_processed }.join(' ')
@@ -30,7 +28,7 @@ class SpudPage < ActiveRecord::Base
30
28
  def self.grouped(site_id=0)
31
29
 
32
30
  if(Spud::Core.multisite_mode_enabled)
33
- return site(site_id).all.group_by(&:spud_page_id)
31
+ return site(site_id).to_a.group_by(&:spud_page_id)
34
32
  else
35
33
  return all.group_by(&:spud_page_id)
36
34
  end
@@ -76,7 +74,7 @@ class SpudPage < ActiveRecord::Base
76
74
  if !self.id.blank?
77
75
  pages = pages.where("id != #{self.id}")
78
76
  end
79
- url_names = pages.site(self.site_id).all.collect{|p| p.url_name}
77
+ url_names = pages.site(self.site_id).load.collect{|p| p.url_name}
80
78
 
81
79
  counter = 1
82
80
  url_name_new = url_name
@@ -1,12 +1,11 @@
1
1
  class SpudPagePartial < ActiveRecord::Base
2
- belongs_to :spud_page
3
- has_many :spud_page_liquid_tags, :as => :attachment, :dependent => :destroy
2
+ belongs_to :spud_page, :touch => true
3
+ has_many :spud_liquid_tags, :as => :attachment, :dependent => :destroy
4
4
  validates :name,:presence => true
5
- attr_accessible :name, :spud_page_id, :content, :format, :content_processed
6
5
  before_save :maintain_revisions
7
6
  before_save :update_symbol_name
8
- before_save :postprocess_content
9
- after_save :update_taglist
7
+ acts_as_spud_liquid_content
8
+
10
9
  def update_symbol_name
11
10
  self.symbol_name = self.name.parameterize.underscore
12
11
  end
@@ -16,22 +15,8 @@ class SpudPagePartial < ActiveRecord::Base
16
15
  end
17
16
 
18
17
  def postprocess_content
19
- template = Liquid::Template.parse(self.content) # Parses and compiles the template
20
-
21
- self.content_processed = template.render('page' => self.spud_page)
22
- end
23
-
24
- def update_taglist
25
- template = Liquid::Template.parse(self.content) # Parses and compiles the template
26
-
27
- self.spud_page_liquid_tags.all.each do |tag|
28
- tag.destroy
29
- end
30
- template.root.nodelist.each do |node|
31
- if !node.is_a?(String) && defined?(node.tag_name) && defined?(node.tag_value)
32
- self.spud_page_liquid_tags.create(:tag_name => node.tag_name,:value => node.tag_value)
33
- end
34
- end
18
+ @_template = Liquid::Template.parse(self.content)
19
+ self.content_processed = @_template.render('page' => self.spud_page)
35
20
  end
36
21
 
37
22
  def content_processed=(content)
@@ -1,5 +1,5 @@
1
1
  class SpudPagePartialRevision < ActiveRecord::Base
2
2
  belongs_to :spud_page
3
3
 
4
- attr_accessible :name,:content,:format,:spud_page_id
4
+ #attr_accessible :name,:content,:format,:spud_page_id
5
5
  end
@@ -1,16 +1,14 @@
1
1
  class SpudSnippet < ActiveRecord::Base
2
- attr_accessible :content, :content_processed, :format, :name
3
- has_many :spud_page_liquid_tags, :as => :attachment, :dependent => :destroy
4
2
 
5
3
  validates :name, :presence => true
6
4
  validates_uniqueness_of :name, :scope => :site_id
7
5
 
8
6
  scope :site, lambda {|sid| where(:site_id => sid)}
9
7
 
10
- before_save :postprocess_content
11
- after_save :update_taglist
8
+ acts_as_spud_liquid_content
9
+
12
10
  def postprocess_content
13
- template = Liquid::Template.parse(self.content) # Parses and compiles the template
11
+ template = Liquid::Template.parse(self.content)
14
12
  self.content_processed = template.render()
15
13
  end
16
14
 
@@ -25,18 +23,4 @@ class SpudSnippet < ActiveRecord::Base
25
23
  return read_attribute(:content_processed)
26
24
  end
27
25
 
28
-
29
- def update_taglist
30
- template = Liquid::Template.parse(self.content) # Parses and compiles the template
31
-
32
- self.spud_page_liquid_tags.all.each do |tag|
33
- tag.destroy
34
- end
35
- template.root.nodelist.each do |node|
36
- if !node.is_a?(String) && defined?(node.tag_name) && defined?(node.tag_value)
37
- self.spud_page_liquid_tags.create(:tag_name => node.tag_name,:value => node.tag_value)
38
- end
39
- end
40
- end
41
-
42
26
  end
@@ -2,12 +2,12 @@
2
2
 
3
3
  <span class="row_meta"><%=prefix if defined? prefix%><%=link_to menu_item.name,edit_admin_menu_menu_item_path(:id => menu_item.id)%></span>
4
4
 
5
- <span class="edit_controls"><%=link_to "Edit",edit_admin_menu_menu_item_path(:id => menu_item.id), :title => "Edit Menu Item",:class => 'btn'%>&nbsp;&nbsp;<%=link_to "Remove",admin_menu_menu_item_path(:id => menu_item.id),:method => :delete,:class => 'btn btn-danger',:confirm => "Are you sure you want to remove this menu item?"%></span>
5
+ <span class="edit_controls"><%=link_to "Edit",edit_admin_menu_menu_item_path(:id => menu_item.id), :title => "Edit Menu Item",:class => 'btn'%>&nbsp;&nbsp;<%=link_to "Remove",admin_menu_menu_item_path(:id => menu_item.id),:method => :delete,:class => 'btn btn-danger', :data => {:confirm => "Are you sure you want to remove this menu item?"}%></span>
6
6
  <br style="clear:both;"/>
7
7
  </div>
8
8
  <ul class="menu_list subitem sortable connectedSortable">
9
9
 
10
- <%if !menu_item.spud_menu_items.all.blank?%>
10
+ <% if menu_item.spud_menu_items.length > 0 %>
11
11
 
12
12
 
13
13
  <%menu_item.spud_menu_items.order(:menu_order).each do |menu_item|%>
@@ -1,6 +1,6 @@
1
- <%=content_for :data_controls do%>
2
- <%=link_to "New Menu",new_admin_menu_path(),:class => "btn btn-primary",:title => "New Menu"%>
3
- <%end%>
1
+ <% content_for :data_controls do%>
2
+ <%= link_to "New Menu",new_admin_menu_path(),:class => "btn btn-primary",:title => "New Menu" %>
3
+ <% end %>
4
4
  <%=content_for :detail do%>
5
5
  <div class="page_list">
6
6
  <%@menus.each do |menu|%>
@@ -10,15 +10,12 @@
10
10
 
11
11
  <span class="edit_controls">
12
12
  <%=link_to "Edit",edit_admin_menu_path(:id => menu.id),:class => 'btn'%>
13
- <%=link_to "Remove",admin_menu_path(:id => menu.id),:method => :delete,:class => 'btn btn-danger',:confirm => "Are you sure you want to remove this menu and all items associated with it?"%>
13
+ <%=link_to 'Items', admin_menu_menu_items_path(:menu_id => menu.id), :class => 'btn' %>
14
+ <%=link_to "Remove",admin_menu_path(:id => menu.id),:method => :delete,:class => 'btn btn-danger', :data => {:confirm => "Are you sure you want to remove this menu and all items associated with it?"}%>
14
15
  </span>
15
16
  <br style="clear:both;"/>
16
17
  </div>
17
18
  <%end%>
18
19
  <%=will_paginate @menus%>
19
-
20
- </div>
21
-
22
-
23
-
20
+ </div>
24
21
  <%end%>
@@ -1,18 +1,18 @@
1
- <div class="page_row">
2
-
3
- <span class="row_meta"><%=prefix if defined? prefix%><%=link_to page.name,edit_admin_page_path(:id => page.id)%></span>
4
-
5
- <span class="edit_controls"><%=link_to "Preview",admin_page_path(:id => page.id), :title => "Preview",:class => 'btn'%>&nbsp;&nbsp;<%=link_to "Remove",admin_page_path(:id => page.id),:method => :delete,:class => 'btn btn-danger',:confirm => "Are you sure you want to remove this page?"%></span>
1
+ <div class="page_row">
2
+ <span class="row_meta">
3
+ <%=prefix if defined? prefix%><%=link_to page.name,edit_admin_page_path(:id => page.id)%>
4
+ </span>
5
+ <span class="edit_controls">
6
+ <%=link_to "Preview",admin_page_path(:id => page.id), :title => "Preview",:class => 'btn btn-mini'%>
7
+ <%=link_to "Remove",admin_page_path(:id => page.id),:method => :delete,:class => 'btn btn-mini btn-danger', :data =>{:confirm => "Are you sure you want to remove this page?"} %>
8
+ </span>
6
9
  <br style="clear:both;"/>
7
10
  </div>
8
- <%if !page.spud_pages.all.blank?%>
9
-
10
- <div class="left_guide">
11
-
12
- <%page.spud_pages.each do |spud_page|%>
13
- <%=render :partial => 'page_row',:locals => {:page => spud_page}%>
14
- <%end%>
15
-
16
- </div>
17
-
18
- <%end%>
11
+
12
+ <% if !page.spud_pages.load.blank? %>
13
+ <div class="left_guide">
14
+ <% page.spud_pages.each do |spud_page| %>
15
+ <%= render :partial => 'page_row', :locals => {:page => spud_page} %>
16
+ <%end%>
17
+ </div>
18
+ <% end %>
@@ -1,7 +1,7 @@
1
1
  <%=form_for @page,:url => admin_page_path(:id => @page.id),:html=>{:class=>"form-horizontal page_form",:target => "report" } do |f|%>
2
2
  <%=render :partial => "form",:locals => {:f => f}%>
3
3
  <div class="form-actions">
4
- <%=f.submit "Save Page", :class=>"btn btn-primary btn-save",:onclick => "savePage();"%>&nbsp;<%=f.submit "Preview", :class=>"btn btn-info btn-preview"%> or <%=link_to "cancel",admin_pages_path,:class => "btn"%>
4
+ <%=f.submit "Save Page", :class=>"btn btn-primary btn-save" %>&nbsp;<%=f.submit "Preview", :class=>"btn btn-info btn-preview"%> or <%=link_to "cancel",admin_pages_path,:class => "btn"%>
5
5
  </div>
6
6
  <%end%>
7
7
  <br />
@@ -10,7 +10,7 @@
10
10
 
11
11
  <span class="edit_controls">
12
12
 
13
- <%=link_to "Remove",admin_snippet_path(:id => snippet.id),:method => :delete,:class => 'btn btn-danger',:confirm => "Are you sure you want to remove this snippet?"%>
13
+ <%=link_to "Remove",admin_snippet_path(:id => snippet.id),:method => :delete,:class => 'btn btn-danger', :data => {:confirm => "Are you sure you want to remove this snippet?"} %>
14
14
  </span>
15
15
  <br style="clear:both;"/>
16
16
  </div>
@@ -1,24 +1,29 @@
1
- <%=content_for :title do%>
2
- <%= @page.name %> | <%=current_site_name%>
3
- <% end %>
4
- <%=content_for :head do%>
5
- <%if !@page.meta_description.blank?%>
6
- <meta name="description" content="<%=@page.meta_description%>" />
7
- <%end%>
8
-
9
- <meta name="keywords" content="<%=@page.meta_keywords%>" />
1
+ <% @page_title = @page.name %>
10
2
 
11
- <%end%>
3
+ <%= content_for :head do %>
4
+ <% cache([@page, 'head']) do %>
5
+ <% if @page.meta_description.present? %>
6
+ <meta name="description" content="<%= @page.meta_description %>" />
7
+ <% end %>
8
+ <% if @page.meta_keywords.present? %>
9
+ <meta name="keywords" content="<%= @page.meta_keywords %>" />
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
12
13
 
13
- <%if !@inline.blank?%>
14
- <%=render :inline => @inline%>
15
- <%end%>
16
- <%@page.spud_page_partials.each do |page_partial|%>
17
- <%if(page_partial.name.match(/^body$/i) && Spud::Cms.yield_body_as_content_block == false)%>
18
- <%=page_partial.content_processed.html_safe%>
19
- <%else%>
20
- <%=content_for page_partial.symbol_name.to_sym do%>
21
- <%=page_partial.content_processed.html_safe%>
22
- <%end%>
23
- <%end%>
24
- <%end%>
14
+ <% if !@inline.blank? %>
15
+ <%= render :inline => @inline %>
16
+ <% end %>
17
+ <% @page.spud_page_partials.each do |page_partial| %>
18
+ <% if(page_partial.name.match(/^body$/i) && Spud::Cms.yield_body_as_content_block == false) %>
19
+ <% cache(page_partial) do %>
20
+ <%= page_partial.content_processed.html_safe %>
21
+ <% end %>
22
+ <% else%>
23
+ <%= content_for page_partial.symbol_name.to_sym do %>
24
+ <% cache(page_partial) do %>
25
+ <%= page_partial.content_processed.html_safe %>
26
+ <% end %>
27
+ <% end %>
28
+ <% end %>
29
+ <% end %>
data/config/routes.rb CHANGED
@@ -16,13 +16,10 @@ Rails.application.routes.draw do
16
16
  end
17
17
 
18
18
  namespace :cms do
19
- resource :sitemap,:only => "show"
19
+ resource :sitemap, :only => "show"
20
20
  end
21
21
 
22
22
  root :to => 'pages#show'
23
23
 
24
- # This is located in lib/spud_cms/page_route.rb to make sure it is loaded last
25
- # match "*id", :controller => "pages",:action => "show", :as => "page"
26
-
27
24
  end
28
25
 
@@ -5,8 +5,10 @@ class ChangeLiquidTagsToPolymorphic < ActiveRecord::Migration
5
5
 
6
6
  add_index :spud_page_liquid_tags, [:attachment_type,:attachment_id]
7
7
 
8
- SpudPageLiquidTag.all.each do |f|
9
- f.update_attributes(:attachment_type => "SpudPagePartial")
8
+ if defined?(SpudPageLiquidTag)
9
+ SpudPageLiquidTag.all.each do |f|
10
+ f.update_attributes(:attachment_type => "SpudPagePartial")
11
+ end
10
12
  end
11
13
  end
12
14
 
@@ -0,0 +1,31 @@
1
+ class DropSpudPageLiquidTags < ActiveRecord::Migration
2
+
3
+ class SpudPageLiquidTag < ActiveRecord::Base
4
+ end
5
+
6
+ def up
7
+ if defined?(SpudLiquidTag)
8
+ SpudPageLiquidTag.all.each do |tag|
9
+ SpudLiquidTag.create({
10
+ :attachment_id => tag.attachment_id,
11
+ :attachment_type => tag.attachment_type,
12
+ :tag_name => tag.tag_name,
13
+ :value => tag.value
14
+ })
15
+ end
16
+ end
17
+ drop_table :spud_page_liquid_tags
18
+ end
19
+
20
+ def down
21
+ create_table :spud_page_liquid_tags do |t|
22
+ t.integer :attachment_id
23
+ t.string :attachment_type
24
+ t.string :tag_name
25
+ t.string :value
26
+ t.timestamps
27
+ end
28
+ add_index :spud_page_liquid_tags, [:tag_name,:value]
29
+ add_index :spud_page_liquid_tags, [:attachment_type,:attachment_id]
30
+ end
31
+ end
@@ -1,7 +1,7 @@
1
1
  require 'tb_core'
2
2
  require 'tb_permalinks'
3
3
  require 'codemirror-rails'
4
- require 'liquid'
4
+ require 'tb_liquid'
5
5
 
6
6
  module Spud
7
7
  module Cms
@@ -34,20 +34,12 @@ module Spud
34
34
  include Spud::Searchable
35
35
  end
36
36
  end
37
- initializer :cms_sweepers do |config|
38
- if ActiveRecord::Base.connection.tables.include?('spud_pages')
39
- Admin::ApplicationController.instance_eval do
40
- cache_sweeper :page_sweeper, :except => [:show,:index]
41
- end
42
- end
43
- end
44
37
 
45
38
  initializer :spud_cms_routes do |config|
46
39
  config.routes_reloader.paths << File.expand_path('../page_route.rb', __FILE__)
47
40
  end
48
41
 
49
42
  initializer :assets do |config|
50
- Rails.application.config.assets.precompile += ["admin/cms*"]
51
43
  Spud::Core.append_admin_javascripts('admin/cms/application')
52
44
  Spud::Core.append_admin_stylesheets('admin/cms/application')
53
45
  end
@@ -1,5 +1,3 @@
1
- Rails.application.routes.append do
2
- # constraints :path => /(?!assets)/ do
3
- match "*id", :controller => "pages",:action => "show", :as => "page"
4
- # end
1
+ Rails.application.routes.draw do
2
+ match "*id", :controller => "pages", :action => "show", :as => "page", :via => [:get, :post]
5
3
  end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Cms
3
- VERSION = "1.0.3"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -2,8 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Admin::MenuItemsController do
4
4
  before(:each) do
5
- ActiveRecord::Base.observers.disable(:page_sweeper)
6
-
7
5
  activate_authlogic
8
6
  u = SpudUser.new(:login => "testuser",:email => "test@testuser.com",:password => "test",:password_confirmation => "test")
9
7
  u.super_admin = true
@@ -3,23 +3,22 @@ require 'spec_helper'
3
3
  describe Cms::SitemapsController do
4
4
  describe :show do
5
5
  before(:each) do
6
- Spud::Core.configure do |config|
7
- config.site_name = "Test Site"
8
- config.multisite_mode_enabled = false
9
- config.multisite_config = []
10
- end
11
-
6
+ Spud::Core.configure do |config|
7
+ config.site_name = "Test Site"
8
+ config.multisite_mode_enabled = false
9
+ config.multisite_config = []
12
10
  end
13
- it "should return the sitemap urls" do
11
+ end
14
12
 
13
+ it "should return the sitemap urls" do
15
14
  get :show, :format => :xml
16
-
17
15
  assigns(:pages).should == SpudPage.published_pages.public.order(:spud_page_id)
18
16
  end
19
17
 
20
18
  it "should only respond to an XML format" do
21
- get :show
22
- response.response_code.should == 406
19
+ expect {
20
+ get :show
21
+ }.to raise_exception(ActionController::UnknownFormat)
23
22
  end
24
23
 
25
24
  describe :multisite do
@@ -32,17 +31,12 @@ describe Cms::SitemapsController do
32
31
  end
33
32
 
34
33
  it "should only assign pages for current site" do
35
- 2.times {|x| s = FactoryGirl.create(:spud_page)}
36
- 3.times {|x| s = FactoryGirl.create(:spud_page,:site_id => 1)}
37
-
34
+ 2.times {|x| FactoryGirl.create(:spud_page) }
35
+ 3.times {|x| FactoryGirl.create(:spud_page,:site_id => 1) }
38
36
  get :show, :format => :xml
39
-
40
37
  assigns(:pages).should == SpudPage.published_pages.public.order(:spud_page_id).site(1)
41
-
42
38
  end
43
39
 
44
40
  end
45
41
  end
46
-
47
-
48
42
  end