tb_cms 1.2.0.beta1 → 1.2.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/admin/menu_items_controller.rb +0 -3
  3. data/app/controllers/admin/menus_controller.rb +1 -6
  4. data/app/controllers/admin/pages_controller.rb +3 -7
  5. data/app/controllers/admin/snippets_controller.rb +0 -4
  6. data/app/controllers/cms/sitemaps_controller.rb +0 -4
  7. data/app/controllers/pages_controller.rb +3 -34
  8. data/app/helpers/cms/application_helper.rb +2 -18
  9. data/app/models/concerns/cms_deprecated_multisite.rb +21 -0
  10. data/app/models/spud_menu.rb +3 -3
  11. data/app/models/spud_page.rb +12 -20
  12. data/app/models/spud_snippet.rb +2 -3
  13. data/app/views/admin/menu_items/_form.html.erb +1 -1
  14. data/app/views/admin/pages/_form.html.erb +1 -1
  15. data/db/migrate/20121119030136_change_liquid_tags_to_polymorphic.rb +1 -3
  16. data/db/migrate/20150108162839_remove_site_id_from_cms_tables.rb +12 -0
  17. data/lib/spud_cms/engine.rb +0 -4
  18. data/lib/spud_cms/template_parser.rb +2 -30
  19. data/lib/spud_cms/version.rb +1 -1
  20. data/spec/{support/authlogic_helper.rb → authlogic_helper.rb} +1 -1
  21. data/spec/controllers/admin/menu_items_controller_spec.rb +28 -59
  22. data/spec/controllers/admin/menus_controller_spec.rb +32 -54
  23. data/spec/controllers/admin/pages_controller_spec.rb +26 -43
  24. data/spec/controllers/admin/snippets_controller_spec.rb +2 -2
  25. data/spec/controllers/pages_controller_spec.rb +11 -63
  26. data/spec/dummy/config/application.rb +5 -0
  27. data/spec/dummy/config/environments/production.rb +1 -1
  28. data/spec/dummy/config/environments/test.rb +1 -1
  29. data/spec/dummy/db/migrate/{20140110051458_create_spud_liquid_tags.tb_core.rb → 20141231214458_create_tb_liquid_spud_liquid_tags.tb_liquid.rb} +2 -2
  30. data/spec/dummy/db/migrate/{20140110051483_change_liquid_tags_to_polymorphic.tb_cms.rb → 20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb} +1 -3
  31. data/spec/dummy/db/migrate/{20140110051484_drop_spud_page_liquid_tags.tb_cms.rb → 20141231214481_drop_spud_page_liquid_tags.tb_cms.rb} +10 -8
  32. data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +13 -0
  33. data/spec/dummy/db/schema.rb +85 -93
  34. data/spec/helpers/cms/application_helper_spec.rb +23 -74
  35. data/spec/models/spud_menu_item_spec.rb +6 -6
  36. data/spec/models/spud_page_partial_revision_spec.rb +2 -2
  37. data/spec/models/spud_page_partial_spec.rb +9 -9
  38. data/spec/models/spud_page_spec.rb +20 -44
  39. data/spec/models/spud_snippet_spec.rb +2 -2
  40. data/spec/rails_helper.rb +72 -0
  41. data/spec/spec_helper.rb +77 -32
  42. metadata +104 -142
  43. data/spec/controllers/cms/sitemaps_controller_spec.rb +0 -41
  44. /data/spec/dummy/db/migrate/{20140110051449_create_spud_admin_permissions.tb_core.rb → 20141231214446_create_spud_admin_permissions.tb_core.rb} +0 -0
  45. /data/spec/dummy/db/migrate/{20140110051450_create_spud_users.tb_core.rb → 20141231214447_create_spud_users.tb_core.rb} +0 -0
  46. /data/spec/dummy/db/migrate/{20140110051451_add_time_zone_to_spud_user.tb_core.rb → 20141231214448_add_time_zone_to_spud_user.tb_core.rb} +0 -0
  47. /data/spec/dummy/db/migrate/{20140110051452_add_scope_to_spud_admin_permissions.tb_core.rb → 20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb} +0 -0
  48. /data/spec/dummy/db/migrate/{20140110051453_create_spud_user_settings.tb_core.rb → 20141231214450_create_spud_user_settings.tb_core.rb} +0 -0
  49. /data/spec/dummy/db/migrate/{20140110051454_create_spud_roles.tb_core.rb → 20141231214451_create_spud_roles.tb_core.rb} +0 -0
  50. /data/spec/dummy/db/migrate/{20140110051455_create_spud_permissions.tb_core.rb → 20141231214452_create_spud_permissions.tb_core.rb} +0 -0
  51. /data/spec/dummy/db/migrate/{20140110051456_create_spud_role_permissions.tb_core.rb → 20141231214453_create_spud_role_permissions.tb_core.rb} +0 -0
  52. /data/spec/dummy/db/migrate/{20140110051457_drop_spud_admin_permissions.tb_core.rb → 20141231214454_drop_spud_admin_permissions.tb_core.rb} +0 -0
  53. /data/spec/dummy/db/migrate/{20140110051459_create_spud_permalinks.tb_permalinks.rb → 20141231214455_create_spud_permalinks.tb_permalinks.rb} +0 -0
  54. /data/spec/dummy/db/migrate/{20140110051460_add_site_id_to_spud_permalinks.tb_permalinks.rb → 20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb} +0 -0
  55. /data/spec/dummy/db/migrate/{20140110051461_modify_site_id_for_spud_permalinks.tb_permalinks.rb → 20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb} +0 -0
  56. /data/spec/dummy/db/migrate/{20140110051462_create_spud_pages.tb_cms.rb → 20141231214459_create_spud_pages.tb_cms.rb} +0 -0
  57. /data/spec/dummy/db/migrate/{20140110051463_create_spud_menus.tb_cms.rb → 20141231214460_create_spud_menus.tb_cms.rb} +0 -0
  58. /data/spec/dummy/db/migrate/{20140110051464_create_spud_menu_items.tb_cms.rb → 20141231214461_create_spud_menu_items.tb_cms.rb} +0 -0
  59. /data/spec/dummy/db/migrate/{20140110051465_create_spud_templates.tb_cms.rb → 20141231214462_create_spud_templates.tb_cms.rb} +0 -0
  60. /data/spec/dummy/db/migrate/{20140110051466_create_spud_page_partials.tb_cms.rb → 20141231214463_create_spud_page_partials.tb_cms.rb} +0 -0
  61. /data/spec/dummy/db/migrate/{20140110051467_add_visibility_to_spud_pages.tb_cms.rb → 20141231214464_add_visibility_to_spud_pages.tb_cms.rb} +0 -0
  62. /data/spec/dummy/db/migrate/{20140110051468_add_menu_name_to_spud_menu_items.tb_cms.rb → 20141231214465_add_menu_name_to_spud_menu_items.tb_cms.rb} +0 -0
  63. /data/spec/dummy/db/migrate/{20140110051469_add_use_custom_url_name_to_spud_pages.tb_cms.rb → 20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb} +0 -0
  64. /data/spec/dummy/db/migrate/{20140110051470_add_notes_to_spud_pages.tb_cms.rb → 20141231214467_add_notes_to_spud_pages.tb_cms.rb} +0 -0
  65. /data/spec/dummy/db/migrate/{20140110051471_add_menu_id_to_spud_menu_items.tb_cms.rb → 20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb} +0 -0
  66. /data/spec/dummy/db/migrate/{20140110051472_add_classes_to_spud_menu_items.tb_cms.rb → 20141231214469_add_classes_to_spud_menu_items.tb_cms.rb} +0 -0
  67. /data/spec/dummy/db/migrate/{20140110051473_add_site_id_to_spud_pages.tb_cms.rb → 20141231214470_add_site_id_to_spud_pages.tb_cms.rb} +0 -0
  68. /data/spec/dummy/db/migrate/{20140110051474_add_site_id_to_spud_templates.tb_cms.rb → 20141231214471_add_site_id_to_spud_templates.tb_cms.rb} +0 -0
  69. /data/spec/dummy/db/migrate/{20140110051475_add_site_id_to_spud_menus.tb_cms.rb → 20141231214472_add_site_id_to_spud_menus.tb_cms.rb} +0 -0
  70. /data/spec/dummy/db/migrate/{20140110051476_create_spud_page_partial_revisions.tb_cms.rb → 20141231214473_create_spud_page_partial_revisions.tb_cms.rb} +0 -0
  71. /data/spec/dummy/db/migrate/{20140110051477_add_symbol_name_to_spud_page_partials.tb_cms.rb → 20141231214474_add_symbol_name_to_spud_page_partials.tb_cms.rb} +0 -0
  72. /data/spec/dummy/db/migrate/{20140110051478_modify_site_id_for_spud_pages.tb_cms.rb → 20141231214475_modify_site_id_for_spud_pages.tb_cms.rb} +0 -0
  73. /data/spec/dummy/db/migrate/{20140110051479_add_content_processed_to_spud_page_partials.tb_cms.rb → 20141231214476_add_content_processed_to_spud_page_partials.tb_cms.rb} +0 -0
  74. /data/spec/dummy/db/migrate/{20140110051480_add_layout_to_spud_pages.tb_cms.rb → 20141231214477_add_layout_to_spud_pages.tb_cms.rb} +0 -0
  75. /data/spec/dummy/db/migrate/{20140110051481_create_spud_page_liquid_tags.tb_cms.rb → 20141231214478_create_spud_page_liquid_tags.tb_cms.rb} +0 -0
  76. /data/spec/dummy/db/migrate/{20140110051482_create_spud_snippets.tb_cms.rb → 20141231214479_create_spud_snippets.tb_cms.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d493436489707a83b24c42f45f4c28da810f6eb
4
- data.tar.gz: 0b85e51660ae264c80f50e063fa2ebca8538cf02
3
+ metadata.gz: 603c1fdda41198a90994c4437b1ef98b77c2d53e
4
+ data.tar.gz: 6b7756d1a544e4d0cd23435bb471085d1b5a7020
5
5
  SHA512:
6
- metadata.gz: 9106c75d5cd3f91334426eb8dd51e4006bb9cfbe04d6b8c5d1a8569e76537e2302361bc9dcf396ce0976045712ca4b58ac0f01f50604b4d9d22c44eda5295d64
7
- data.tar.gz: 89588fb1c7d5ccf19e299ea1b6c076e41564a45a0268781df4b124d3d1085f89459100dab67752cba18f5dd55e24cf7011b68b59480c81a540f122dc2840dd84
6
+ metadata.gz: 0b6bf5a0086d59e8d294a82172f556658f38de6bd0bd20ed850cb3cf04257dc56ca8f5816abdb7f885877e107cd4d02c8f79427e67fb2f5dea550cd7f3b4b8b4
7
+ data.tar.gz: 42fbc6c40d02f55d97b4acd74a9c0bd707c2f521fedfbc8fe00933e2764c5c875fc439d329f2891fbf529ee45e41d134df9e8c8cebb7673eca51d58846a8254e
@@ -92,9 +92,6 @@ private
92
92
  if @menu.blank?
93
93
  flash[:error] = "Menu not found!"
94
94
  redirect_to admin_menus_url() and return false
95
- elsif Spud::Core.multisite_mode_enabled && @menu.site_id != session[:admin_site]
96
- flash[:warning] = "Site Context Changed. The menu you were viewing is not associated with the current site. Redirected back to menu selections."
97
- redirect_to admin_menus_url() and return false
98
95
  end
99
96
  add_breadcrumb "#{@menu.name}", :admin_menu_menu_items_path
100
97
  end
@@ -4,11 +4,10 @@ class Admin::MenusController < Admin::ApplicationController
4
4
  before_filter :load_menu,:only => [:edit,:update,:show,:destroy]
5
5
 
6
6
  def index
7
- @menus = SpudMenu.site(session[:admin_site]).order(:name).paginate :page => params[:page]
7
+ @menus = SpudMenu.all.paginate(:page => params[:page])
8
8
  respond_with @menus
9
9
  end
10
10
 
11
-
12
11
  def new
13
12
  add_breadcrumb "New", :new_admin_menu_path
14
13
  @menu = SpudMenu.new
@@ -18,7 +17,6 @@ class Admin::MenusController < Admin::ApplicationController
18
17
  def create
19
18
  add_breadcrumb "New", :new_admin_menu_path
20
19
  @menu = SpudMenu.new(menu_params)
21
- @menu.site_id = session[:admin_site]
22
20
  flash[:notice] = "New menu created" if @menu.save
23
21
  respond_with @menu,:location => @menu.id != nil ? admin_menu_menu_items_url(:menu_id => @menu.id) : admin_menus_url
24
22
  end
@@ -47,9 +45,6 @@ private
47
45
  if @menu.blank?
48
46
  flash[:error] = "Menu not found!"
49
47
  redirect_to admin_menus_url() and return false
50
- elsif Spud::Core.multisite_mode_enabled && @menu.site_id != session[:admin_site]
51
- flash[:warning] = "Site Context Changed. The menu you were viewing is not associated with the current site. Redirected back to menu selections."
52
- redirect_to admin_menus_url() and return false
53
48
  end
54
49
  end
55
50
 
@@ -22,7 +22,7 @@ class Admin::PagesController < Admin::ApplicationController
22
22
  def new
23
23
  add_breadcrumb "New", :new_admin_page_path
24
24
 
25
- layouts = Spud::Cms::Engine.template_parser.layouts(Spud::Core.site_config_for_id(session[:admin_site] || 0)[:short_name])
25
+ layouts = Spud::Cms::Engine.template_parser.layouts
26
26
  layout, layout_info = layouts.select{|k,v| v[:default]}.flatten
27
27
  @page = SpudPage.new(:layout => layout)
28
28
  parts = layout_info[:partials]
@@ -35,7 +35,6 @@ class Admin::PagesController < Admin::ApplicationController
35
35
 
36
36
  def create
37
37
  @page = SpudPage.new(page_params)
38
- @page.site_id = session[:admin_site]
39
38
  if params[:preview] && params[:preview].to_i == 1
40
39
  preview
41
40
  return
@@ -47,7 +46,7 @@ class Admin::PagesController < Admin::ApplicationController
47
46
  def edit
48
47
  add_breadcrumb @page.name, :edit_admin_page_path
49
48
 
50
- layouts = Spud::Cms::Engine.template_parser.layouts(Spud::Core.site_config_for_id(session[:admin_site] || 0)[:short_name])
49
+ layouts = Spud::Cms::Engine.template_parser.layouts
51
50
  layout, layout_info = layouts.select{|k,v| k == @page.layout}.flatten if @page.layout.blank? == false
52
51
  if layout.blank?
53
52
  layout, layout_info = layouts.select{|k,v| v[:default]}.flatten
@@ -100,7 +99,7 @@ class Admin::PagesController < Admin::ApplicationController
100
99
  end
101
100
 
102
101
  def page_parts
103
- layouts = Spud::Cms::Engine.template_parser.layouts(Spud::Core.site_config_for_id(session[:admin_site] || 0)[:short_name])
102
+ layouts = Spud::Cms::Engine.template_parser.layouts
104
103
  template = params[:template] && !params[:template].blank? ? layouts[params[:template]] : nil
105
104
  page = SpudPage.where(:id => params[:page]).includes(:spud_page_partials).first
106
105
  page = SpudPage.new if page.blank?
@@ -152,9 +151,6 @@ private
152
151
  if @page.blank?
153
152
  flash[:error] = "Page not found!"
154
153
  redirect_to admin_pages_url() and return false
155
- elsif Spud::Core.multisite_mode_enabled && @page.site_id != session[:admin_site]
156
- flash[:warning] = "Site Context Changed. The page you were viewing is not associated with the current site. Redirected back to page selections."
157
- redirect_to admin_pages_url() and return false
158
154
  end
159
155
  return true
160
156
  end
@@ -18,7 +18,6 @@ class Admin::SnippetsController < Admin::ApplicationController
18
18
  def create
19
19
  add_breadcrumb "New", :new_admin_snippet_url
20
20
  @snippet = SpudSnippet.new(snippet_params)
21
- @snippet.site_id = session[:admin_site]
22
21
 
23
22
  @snippet.save
24
23
 
@@ -49,9 +48,6 @@ private
49
48
  if @snippet.blank?
50
49
  flash[:error] = "Snippet does not exist!"
51
50
  redirect_to admin_snippets_url and return false
52
- elsif Spud::Core.multisite_mode_enabled && @snippet.site_id != session[:admin_site]
53
- flash[:warning] = "This snippet is for a different site"
54
- redirect_to admin_snippets_url and return false
55
51
  end
56
52
  end
57
53
 
@@ -2,10 +2,6 @@ class Cms::SitemapsController < Spud::ApplicationController
2
2
  respond_to :xml
3
3
  def show
4
4
  @pages = SpudPage.published_pages.viewable.order(:spud_page_id)
5
- if Spud::Core.multisite_mode_enabled
6
- site_config = Spud::Core.site_config_for_host(request.host_with_port)
7
- @pages = @pages.site(!site_config.blank? ? site_config[:site_id] : 0)
8
- end
9
5
  respond_with @pages
10
6
  end
11
7
  end
@@ -12,33 +12,10 @@ class PagesController < ApplicationController
12
12
  end
13
13
 
14
14
  url_name = !params[:id].blank? ? params[:id] : Spud::Cms.root_page_name
15
+ @page = SpudPage.published_pages.find_by(:url_name => url_name)
15
16
 
16
- # MultiSite Code Block
17
- if params[:id].blank? && Spud::Core.multisite_mode_enabled
18
- site_config = Spud::Core.site_config_for_host(request.host_with_port)
19
- if !site_config.blank?
20
- cms_config = Spud::Cms.site_config_for_short_name(site_config[:short_name])
21
- url_name = cms_config[:root_page_name] if !cms_config.blank? && !cms_config[:root_page_name].blank?
22
- end
23
- end
24
-
25
- @page = SpudPage.published_pages.where(:url_name => url_name)
26
-
27
- # MultiSite Code Block
28
- if Spud::Core.multisite_mode_enabled
29
- site_config = Spud::Core.site_config_for_host(request.host_with_port)
30
- @page = @page.site(!site_config.blank? ? site_config[:site_id] : nil)
31
- end
32
-
33
- @page = @page.first
34
17
  if @page.blank?
35
- @permalink = SpudPermalink.where(:url_name => url_name)
36
-
37
- # MultiSite Code Block
38
- if Spud::Core.multisite_mode_enabled
39
- @permalink = @permalink.site(!site_config.blank? ? site_config[:site_id] : nil)
40
- end
41
- @permalink = @permalink.first
18
+ @permalink = SpudPermalink.find_by(:url_name => url_name)
42
19
 
43
20
  if !@permalink.blank? && @permalink.attachment_type == 'SpudPage'
44
21
  redirect_to @permalink.attachment.url_name == Spud::Cms.root_page_name ? root_url() : page_url(:id => @permalink.attachment.url_name) , :status => :moved_permanently and return
@@ -52,15 +29,7 @@ class PagesController < ApplicationController
52
29
  return if defined?(require_user) && require_user == false
53
30
  end
54
31
 
55
- layout = Spud::Cms.default_page_layout
56
-
57
- # MultiSite Code Block
58
- if Spud::Core.multisite_mode_enabled && !site_config.blank?
59
- cms_config = Spud::Cms.site_config_for_short_name(site_config[:short_name])
60
- layout = cms_config[:default_page_layout] if !cms_config.blank? && !cms_config[:default_page_layout].blank?
61
- end
62
-
63
- layout = @page.layout || layout
32
+ layout = @page.layout || Spud::Cms.default_page_layout
64
33
 
65
34
  action_name = "#{layout}_action"
66
35
  if respond_to?(action_name)
@@ -24,10 +24,6 @@ module Cms::ApplicationHelper
24
24
 
25
25
  pages = SpudPage.viewable.published_pages
26
26
 
27
- if Spud::Core.multisite_mode_enabled
28
- site_config = Spud::Core.site_config_for_host(request.host_with_port)
29
- pages = pages.site(site_config[:site_id]) if !site_config.blank?
30
- end
31
27
  start_page = nil
32
28
  max_depth = 0
33
29
  active_class = "menu-active"
@@ -93,12 +89,7 @@ module Cms::ApplicationHelper
93
89
  menu_id = nil
94
90
  link_options = {}
95
91
  start_menu_item = nil
96
-
97
- if Spud::Core.multisite_mode_enabled
98
- menu = SpudMenu.where(:name => options[:name], :site_id => current_site_id).first
99
- else
100
- menu = SpudMenu.where(:name => options[:name]).first
101
- end
92
+ menu = SpudMenu.where(:name => options[:name]).first
102
93
 
103
94
  if menu.blank?
104
95
  return ''
@@ -172,12 +163,7 @@ module Cms::ApplicationHelper
172
163
  seperator = options[:seperator]
173
164
  end
174
165
 
175
- menu = SpudMenu.where(:name => options[:name])
176
- if Spud::Core.multisite_mode_enabled
177
- site_config = Spud::Core.site_config_for_host(request.host_with_port)
178
- menu = menu.site(site_config[:site_id]) if !site_config.blank?
179
- end
180
- menu = menu.first
166
+ menu = SpudMenu.find_by(:name => options[:name])
181
167
  if(menu.blank?)
182
168
  return ""
183
169
  end
@@ -294,8 +280,6 @@ private
294
280
  end
295
281
 
296
282
  def layout_options
297
- layouts = Spud::Cms::Engine.template_parser.layouts(Spud::Core.site_config_for_id(session[:admin_site] || 0)[:short_name])
298
-
299
283
  layouts = Spud::Cms::Engine.template_parser.layouts
300
284
  layout_options = []
301
285
  layouts.each_pair do |key,value|
@@ -0,0 +1,21 @@
1
+ module CmsDeprecatedMultisite
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ scope :site, ->(sid){
6
+ ActiveSupport::Deprecation.warn 'Model.site scope is deprecated and will be removed in the future'
7
+ self.all()
8
+ }
9
+ end
10
+
11
+ def site_id
12
+ ActiveSupport::Deprecation.warn '#site_id is deprecated and will be removed in the future'
13
+ return 0
14
+ end
15
+
16
+ def site_id=(id)
17
+ ActiveSupport::Deprecation.warn '#site_id is deprecated and will be removed in the future'
18
+ return nil
19
+ end
20
+
21
+ end
@@ -1,9 +1,9 @@
1
1
  class SpudMenu < ActiveRecord::Base
2
+ include CmsDeprecatedMultisite
3
+
2
4
  validates :name,:presence => true
3
- validates_uniqueness_of :name, :scope => [:site_id]
5
+ validates_uniqueness_of :name
4
6
 
5
7
  has_many :spud_menu_items, :as => :parent, :dependent => :destroy
6
8
  has_many :spud_menu_items_combined, :class_name => "SpudMenuItem", :foreign_key => :spud_menu_id, :dependent => :destroy
7
-
8
- scope :site, lambda {|sid| where(:site_id => sid)}
9
9
  end
@@ -1,4 +1,6 @@
1
1
  class SpudPage < ActiveRecord::Base
2
+ include CmsDeprecatedMultisite
3
+
2
4
  spud_searchable
3
5
  belongs_to :spud_page
4
6
  has_many :spud_page_partial_revisions
@@ -10,14 +12,13 @@ class SpudPage < ActiveRecord::Base
10
12
 
11
13
  before_validation :generate_url_name
12
14
  validates :name,:presence => true
13
- validates_uniqueness_of :name, :scope => [:site_id,:spud_page_id]
15
+ validates_uniqueness_of :name, :scope => [:spud_page_id]
14
16
  validates :url_name,:presence => true
15
- validates_uniqueness_of :url_name, :scope => :site_id
17
+ validates_uniqueness_of :url_name
16
18
 
17
19
  accepts_nested_attributes_for :spud_page_partials, :allow_destroy => true
18
20
 
19
21
  scope :parent_pages, ->{ where(:spud_page_id => nil)}
20
- scope :site, lambda {|sid| where(:site_id => sid)}
21
22
  scope :published_pages, ->{ where(:published => true) }
22
23
  scope :viewable, ->{ where(:visibility => 0) }
23
24
 
@@ -25,15 +26,6 @@ class SpudPage < ActiveRecord::Base
25
26
  self.spud_page_partials.collect{|partial| partial.content_processed }.join(' ')
26
27
  end
27
28
 
28
- def self.grouped(site_id=0)
29
-
30
- if(Spud::Core.multisite_mode_enabled)
31
- return site(site_id).to_a.group_by(&:spud_page_id)
32
- else
33
- return all.group_by(&:spud_page_id)
34
- end
35
- end
36
-
37
29
  def to_liquid
38
30
  return {'name' => self.name, 'url_name' => self.url_name}
39
31
  end
@@ -42,7 +34,7 @@ class SpudPage < ActiveRecord::Base
42
34
  # :fitler Filters out a page by ID, and all of its children
43
35
  # :value Pick an attribute to be used in the value field, defaults to ID
44
36
  def self.options_tree_for_page(config={})
45
- collection = config[:collection] || self.grouped(config[:site_id])
37
+ collection = config[:collection] || self.all.group_by(&:spud_page_id)
46
38
  level = config[:level] || 0
47
39
  parent_id = config[:parent_id] || nil
48
40
  filter = config[:filter] || nil
@@ -69,12 +61,12 @@ class SpudPage < ActiveRecord::Base
69
61
  end
70
62
  url_name += self.name.parameterize.downcase
71
63
  if !self.use_custom_url_name
72
- pages = SpudPage
64
+ pages = SpudPage.all
73
65
 
74
66
  if !self.id.blank?
75
67
  pages = pages.where("id != #{self.id}")
76
68
  end
77
- url_names = pages.site(self.site_id).load.collect{|p| p.url_name}
69
+ url_names = pages.to_a.collect{|p| p.url_name}
78
70
 
79
71
  counter = 1
80
72
  url_name_new = url_name
@@ -85,7 +77,7 @@ class SpudPage < ActiveRecord::Base
85
77
  # url_name = url_name_new
86
78
  # Check Permalinks List
87
79
 
88
- permalink = SpudPermalink.site(self.site_id).where(:url_name => url_name_new).first
80
+ permalink = SpudPermalink.where(:url_name => url_name_new).first
89
81
  counter = 1
90
82
  while permalink.blank? == false
91
83
 
@@ -95,20 +87,20 @@ class SpudPage < ActiveRecord::Base
95
87
  else
96
88
  url_name_new = url_name + "-#{counter}"
97
89
  counter += 1
98
- permalink = SpudPermalink.site(self.site_id).where(:url_name => url_name_new).first
90
+ permalink = SpudPermalink.where(:url_name => url_name_new).first
99
91
  end
100
92
  end
101
93
  url_name = url_name_new
102
94
  end
103
95
  if self.url_name.blank? == false && url_name != self.url_name
104
- self.spud_permalinks.create(:url_name => self.url_name,:site_id => self.site_id)
96
+ self.spud_permalinks.create(:url_name => self.url_name)
105
97
  end
106
98
  self.url_name = url_name
107
99
  self.use_custom_url_name = false
108
100
  elsif self.id.to_i > 0
109
101
  page = SpudPage.where(:id => self.id).first
110
102
  if page.url_name.blank? == false && page.url_name != self.url_name
111
- permalink = SpudPermalink.site(self.site_id).where(:url_name => self.url_name).first
103
+ permalink = SpudPermalink.where(:url_name => self.url_name).first
112
104
  if permalink.blank? == false
113
105
  if permalink.attachment == self
114
106
  permalink.destroy
@@ -117,7 +109,7 @@ class SpudPage < ActiveRecord::Base
117
109
  return false
118
110
  end
119
111
  end
120
- self.spud_permalinks.create(:url_name => page.url_name,:site_id => self.site_id)
112
+ self.spud_permalinks.create(:url_name => page.url_name)
121
113
  end
122
114
  end
123
115
  return true
@@ -1,9 +1,8 @@
1
1
  class SpudSnippet < ActiveRecord::Base
2
+ include CmsDeprecatedMultisite
2
3
 
3
4
  validates :name, :presence => true
4
- validates_uniqueness_of :name, :scope => :site_id
5
-
6
- scope :site, lambda {|sid| where(:site_id => sid)}
5
+ validates_uniqueness_of :name
7
6
 
8
7
  acts_as_tb_liquid_content
9
8
 
@@ -17,7 +17,7 @@
17
17
  <div class="form-group">
18
18
  <%=f.label :spud_page_id, "Page", :class=>"col-sm-2 control-label"%>
19
19
  <div class="col-sm-10">
20
- <%= f.select :spud_page_id, options_for_select(SpudPage.options_tree_for_page(:site_id => session[:admin_site]), @menu_item.spud_page_id), {:include_blank => 'Use URL instead'}, {:class=>'form-control',:title => "", :onchange => "if($(this).val() != '') {$('#spud_menu_item_url').val('');}"}%>
20
+ <%= f.select :spud_page_id, options_for_select(SpudPage.options_tree_for_page(), @menu_item.spud_page_id), {:include_blank => 'Use URL instead'}, {:class=>'form-control',:title => "", :onchange => "if($(this).val() != '') {$('#spud_menu_item_url').val('');}"}%>
21
21
  </div>
22
22
  </div>
23
23
 
@@ -35,7 +35,7 @@
35
35
  <div class="form-group">
36
36
  <%= f.label :spud_page_id, "Parent Page", :class=>"col-lg-2 control-label"%>
37
37
  <div class="col-lg-10">
38
- <%= f.select :spud_page_id,options_for_select(SpudPage.options_tree_for_page(:filter => @page,:site_id => session[:admin_site]),@page.spud_page_id),{:include_blank => 'None'},{:title => "", :class=>'form-control' }%>
38
+ <%= f.select :spud_page_id,options_for_select(SpudPage.options_tree_for_page(:filter => @page), @page.spud_page_id),{:include_blank => 'None'},{:title => "", :class=>'form-control' }%>
39
39
  </div>
40
40
  </div>
41
41
 
@@ -2,9 +2,7 @@ class ChangeLiquidTagsToPolymorphic < ActiveRecord::Migration
2
2
  def up
3
3
  rename_column :spud_page_liquid_tags, :spud_page_partial_id, :attachment_id
4
4
  add_column :spud_page_liquid_tags, :attachment_type, :string
5
-
6
- add_index :spud_page_liquid_tags, [:attachment_type,:attachment_id]
7
-
5
+ add_index :spud_page_liquid_tags, [:attachment_type, :attachment_id], :name => 'inde_spud_page_liquid_tags_on_attachment'
8
6
  if defined?(SpudPageLiquidTag)
9
7
  SpudPageLiquidTag.all.each do |f|
10
8
  f.update_attributes(:attachment_type => "SpudPagePartial")
@@ -0,0 +1,12 @@
1
+ class RemoveSiteIdFromCmsTables < ActiveRecord::Migration
2
+ def up
3
+ remove_column :spud_menus, :site_id
4
+ remove_column :spud_pages, :site_id
5
+ remove_column :spud_snippets, :site_id
6
+ end
7
+ def down
8
+ add_column :spud_menus, :site_id, :integer
9
+ add_column :spud_pages, :site_id, :integer
10
+ add_column :spud_snippets, :site_id, :integer
11
+ end
12
+ end
@@ -21,10 +21,6 @@ module Spud
21
21
  if Spud::Cms.snippets_enabled
22
22
  config.admin_applications += [{:name => "Snippets",:thumbnail => "spud/admin/snippets_thumb.png",:url => "/admin/snippets",:order => 3}]
23
23
  end
24
-
25
- if Spud::Cms.enable_sitemap == true
26
- config.sitemap_urls += [:cms_sitemap_url]
27
- end
28
24
  end
29
25
  end
30
26
 
@@ -3,21 +3,7 @@ module Spud
3
3
  class TemplateParser
4
4
 
5
5
 
6
- def layouts(site_short_name=nil)
7
- if(site_short_name != nil)
8
- filtered_layouts = {}
9
- all_layouts.each do |key,value|
10
- if value[:sites].include?(site_short_name.to_s.downcase)
11
- filtered_layouts[key] = value
12
- end
13
- end
14
- return filtered_layouts
15
- else
16
- return all_layouts
17
- end
18
- end
19
-
20
- def all_layouts
6
+ def layouts
21
7
  if @layouts && Rails.env != 'development'
22
8
  return @layouts
23
9
  end
@@ -32,8 +18,8 @@ module Spud
32
18
  return @layouts
33
19
  end
34
20
 
35
-
36
21
  private
22
+
37
23
  def process_layouts(filepath)
38
24
  layouts = {}
39
25
  Dir.glob(filepath.join("**","*.html.*")) do |template|
@@ -79,20 +65,6 @@ module Spud
79
65
  else
80
66
  layouts[default_layout_path][:default] = true
81
67
  end
82
-
83
- Spud::Core.multisite_config.each do |config|
84
- cms_config = Spud::Cms.site_config_for_short_name(config[:short_name])
85
- layout_path = cms_config.blank? == false && cms_config[:default_page_layout].blank? == false ? layout_path(Rails.application.root.join('app','views','layouts',cms_config[:default_page_layout])) : default_layout_path
86
-
87
- layout = layouts[layout_path]
88
- if layout.blank?
89
- layouts[layout_path] = {:template_name => "Default", :partials => ["Body"], :sites => [config[:short_name].to_s.downcase], :default => true}
90
- else
91
- layouts[layout_path][:sites] << config[:short_name].to_s.downcase
92
- layouts[layout_path][:default] = true
93
- end
94
- end
95
-
96
68
  end
97
69
 
98
70
  def layout_path(template)
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Cms
3
- VERSION = "1.2.0.beta1"
3
+ VERSION = "1.2.0.beta3"
4
4
  end
5
5
  end
@@ -1,2 +1,2 @@
1
1
  require 'authlogic/test_case'
2
- include Authlogic::TestCase
2
+ include Authlogic::TestCase