spud_cms 0.9.21 → 1.0.0.RC1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/app/assets/javascripts/spud/admin/cms/menu_items.js +31 -3
- data/app/assets/stylesheets/spud/admin/cms/application.css +4 -0
- data/app/controllers/pages_controller.rb +5 -8
- data/app/controllers/spud/admin/menu_items_controller.rb +28 -6
- data/app/controllers/spud/admin/menus_controller.rb +6 -2
- data/app/controllers/spud/admin/pages_controller.rb +13 -6
- data/app/controllers/spud/admin/snippets_controller.rb +7 -3
- data/app/controllers/spud/cms/sitemaps_controller.rb +0 -2
- data/app/helpers/spud/cms/application_helper.rb +6 -4
- data/app/models/concerns/spud/liquid_taggable.rb +8 -0
- data/app/models/spud_menu.rb +4 -4
- data/app/models/spud_menu_item.rb +2 -5
- data/app/models/spud_page.rb +9 -12
- data/app/models/spud_page_liquid_tag.rb +1 -2
- data/app/models/spud_page_partial.rb +14 -6
- data/app/models/spud_page_partial_revision.rb +1 -4
- data/app/models/spud_snippet.rb +22 -4
- data/app/observers/page_sweeper.rb +2 -0
- data/app/views/pages/show.html.erb +7 -2
- data/app/views/spud/admin/menu_items/_form.html.erb +3 -10
- data/app/views/spud/admin/menu_items/_menu_item_row.html.erb +2 -2
- data/app/views/spud/admin/menu_items/index.html.erb +3 -1
- data/app/views/spud/admin/pages/_form.html.erb +8 -1
- data/app/views/spud/admin/pages/show.html.erb +13 -11
- data/app/views/spud/admin/snippets/_form.html.erb +8 -1
- data/config/routes.rb +7 -2
- data/lib/spud_cms/engine.rb +11 -8
- data/lib/spud_cms/liquid_taggable.rb +28 -0
- data/lib/spud_cms/page_route.rb +2 -2
- data/lib/spud_cms/version.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +5 -2
- data/spec/controllers/spud/cms/sitemaps_controller_spec.rb +3 -2
- data/spec/dummy/config/environments/development.rb +2 -4
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/environments/test.rb +2 -4
- data/spec/dummy/log/test.log +19992 -4353
- data/spec/models/spud_page_partial_spec.rb +3 -3
- data/spec/models/spud_page_spec.rb +3 -3
- metadata +36 -36
- data/spec/dummy/log/development.log +0 -182
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YWE1NjcwZjNhYzNlZTk4NzdlNDFhNWE1NzAxNTViYzdkZjU5Mjg5OWQ2Yjk3
|
10
|
-
YjA4ZDE2NGRkNWE1Y2Q3YjgwNjVlMTgxM2E5MTE3OWViZjY0MGNmYjg1NTUy
|
11
|
-
Y2NjMTFkYWVlMDRlZjljMTllMjVjNGY1MTE1MmI2M2Q4NmEyMWQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YzE5Zjc3YzhkZWY0MDQyZTg3YmM4YzQ2NzNkZGVhYmYzOWQwZDcwOTEyYWI4
|
14
|
-
MjllZDFhOGU3YTE0ZmNmMjUyZGFlMDRhZTFmNWZhODViOGZmNDE4YTNjN2Ji
|
15
|
-
YTg4NDM2NmU1NTRmNTEwZGU4Y2M5YmQzZjFiMTVjZWQ4MDg5MjU=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54e9c4a61c4797b554e4ddffbf29a1efff29b835
|
4
|
+
data.tar.gz: 397642ca31be38f6ba49303a8cbc0bd622d43780
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6cc9210f9fed2f54a38078f17c740238d256491ee15e5441a93a54186f154af5db22755d3bf1dded796df564a7e8cf1c7d029ef281ceb76d128a80f693529464
|
7
|
+
data.tar.gz: 235e6abbcd19c6e08dc2b9bb1d5b62fe315a73cb6f7a1e7926689561abcc39a0764ababaccc0336262db624d27d82698fff3100f26881bb320f83e29f0dea3b5
|
@@ -2,9 +2,9 @@ spud.admin.cms.menu_items = {};
|
|
2
2
|
|
3
3
|
(function() {
|
4
4
|
var menu_items = spud.admin.cms.menu_items;
|
5
|
-
|
6
|
-
menu_items.init = function() {
|
7
|
-
|
5
|
+
var menuId = 0;
|
6
|
+
menu_items.init = function(id) {
|
7
|
+
menuId = id;
|
8
8
|
$('.sortable').sortable({
|
9
9
|
connectWith:".connectedSortable",
|
10
10
|
start: function(event,ui) {
|
@@ -16,6 +16,7 @@ spud.admin.cms.menu_items = {};
|
|
16
16
|
items:'li',
|
17
17
|
stop: function(event,ui) {
|
18
18
|
$('#root_menu_list').removeClass('menu_edit');
|
19
|
+
menu_items.save.call(menu_items);
|
19
20
|
},
|
20
21
|
over: function(event,ui) {
|
21
22
|
|
@@ -32,4 +33,31 @@ spud.admin.cms.menu_items = {};
|
|
32
33
|
}).disableSelection();
|
33
34
|
};
|
34
35
|
|
36
|
+
menu_items.save = function() {
|
37
|
+
var menuItems = $('#root_menu_list > li > .menu-item-row');
|
38
|
+
|
39
|
+
var orderArray = []
|
40
|
+
menu_items.buildOrderArray(menuItems, orderArray);
|
41
|
+
|
42
|
+
// Post To Menu Items Save method
|
43
|
+
$.ajax({
|
44
|
+
url: "/spud/admin/menus/" + menuId + "/menu_items/sort",
|
45
|
+
type: 'post',
|
46
|
+
data: {menu_order: JSON.stringify(orderArray), _method: 'put'}
|
47
|
+
});
|
48
|
+
|
49
|
+
};
|
50
|
+
|
51
|
+
menu_items.buildOrderArray = function(menuItems,orderArray) {
|
52
|
+
for(var counter=0;counter < menuItems.length; counter++) {
|
53
|
+
var menuItem = $(menuItems[counter]);
|
54
|
+
var menuHash = {id: menuItem.attr('data-menu-item-id'), order: []}
|
55
|
+
var subItems = menuItem.parent().find(' > .menu_list > li > .menu-item-row');
|
56
|
+
if(subItems && subItems.length > 0) {
|
57
|
+
menu_items.buildOrderArray(subItems, menuHash.order)
|
58
|
+
}
|
59
|
+
orderArray.push(menuHash)
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
35
63
|
})();
|
@@ -1,15 +1,13 @@
|
|
1
1
|
class PagesController < ApplicationController
|
2
|
-
caches_action :show, :if => Proc.new { |c| Spud::Cms.cache_mode == :action }
|
3
|
-
|
4
2
|
respond_to :html
|
5
3
|
|
6
4
|
before_filter :set_default_content_type
|
7
5
|
|
8
|
-
after_filter({:only => [:show]}) do |c|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
6
|
+
# after_filter({:only => [:show]}) do |c|
|
7
|
+
# if Spud::Cms.cache_mode == :full_page && @page && @page.is_private? == false
|
8
|
+
# c.cache_page(nil, nil, false)
|
9
|
+
# end
|
10
|
+
# end
|
13
11
|
|
14
12
|
def show
|
15
13
|
# prevents 500 errors if a url like "/home.jpg" is hit
|
@@ -57,7 +55,6 @@ class PagesController < ApplicationController
|
|
57
55
|
end
|
58
56
|
|
59
57
|
if @page.is_private?
|
60
|
-
@rendered_action_cache = true if Spud::Cms.cache_mode == :action
|
61
58
|
return if defined?(require_user) && require_user == false
|
62
59
|
end
|
63
60
|
|
@@ -21,7 +21,7 @@ class Spud::Admin::MenuItemsController < Spud::Admin::CmsController
|
|
21
21
|
def create
|
22
22
|
|
23
23
|
add_breadcrumb "New", :new_spud_admin_page_path
|
24
|
-
@menu_item = SpudMenuItem.new(
|
24
|
+
@menu_item = SpudMenuItem.new(menu_item_params)
|
25
25
|
@menu_item.spud_menu_id = @menu.id
|
26
26
|
if params[:spud_menu_item][:parent_id].blank?
|
27
27
|
@menu_item.parent_id = @menu.id
|
@@ -62,7 +62,7 @@ class Spud::Admin::MenuItemsController < Spud::Admin::CmsController
|
|
62
62
|
else
|
63
63
|
params[:spud_menu_item][:parent_type] = "SpudMenuItem"
|
64
64
|
end
|
65
|
-
@menu_item.attributes =
|
65
|
+
@menu_item.attributes = menu_item_params
|
66
66
|
@menu_item.spud_menu_id = @menu.id
|
67
67
|
flash[:notice] = "Menu saved successfully!" if @menu_item.save
|
68
68
|
|
@@ -76,7 +76,12 @@ class Spud::Admin::MenuItemsController < Spud::Admin::CmsController
|
|
76
76
|
respond_with @menu_item,:location => spud_admin_menu_menu_items_url
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def sort
|
80
|
+
menu_orders = ActiveSupport::JSON.decode(params[:menu_order])
|
81
|
+
sort_menu_items_to_parent(@menu, menu_orders)
|
82
|
+
render :nothing => true, :status => 200
|
83
|
+
|
84
|
+
|
80
85
|
#id param
|
81
86
|
#source position
|
82
87
|
#destination position
|
@@ -86,6 +91,23 @@ class Spud::Admin::MenuItemsController < Spud::Admin::CmsController
|
|
86
91
|
|
87
92
|
end
|
88
93
|
private
|
94
|
+
|
95
|
+
def sort_menu_items_to_parent(parent,menu_orders)
|
96
|
+
sort_position = 0
|
97
|
+
menu_orders.each do |menu_meta|
|
98
|
+
menu_item = SpudMenuItem.find(menu_meta["id"])
|
99
|
+
if menu_item
|
100
|
+
menu_item.menu_order = sort_position
|
101
|
+
menu_item.parent = parent
|
102
|
+
menu_item.save!
|
103
|
+
if menu_meta["order"].nil? == false
|
104
|
+
sort_menu_items_to_parent(menu_item, menu_meta["order"])
|
105
|
+
end
|
106
|
+
sort_position += 1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
89
111
|
def load_menu
|
90
112
|
|
91
113
|
@menu = SpudMenu.where(:id => params[:menu_id]).first
|
@@ -108,8 +130,8 @@ private
|
|
108
130
|
end
|
109
131
|
end
|
110
132
|
|
111
|
-
|
112
|
-
|
113
|
-
|
133
|
+
def menu_item_params
|
134
|
+
params.require(:spud_menu_item).permit(:name,:parent_type,:parent_id,:item_type,:spud_page_id,:menu_order,:url,:classes)
|
135
|
+
end
|
114
136
|
|
115
137
|
end
|
@@ -18,7 +18,7 @@ class Spud::Admin::MenusController < Spud::Admin::CmsController
|
|
18
18
|
|
19
19
|
def create
|
20
20
|
add_breadcrumb "New", :new_spud_admin_menu_path
|
21
|
-
@menu = SpudMenu.new(
|
21
|
+
@menu = SpudMenu.new(menu_params)
|
22
22
|
@menu.site_id = session[:admin_site]
|
23
23
|
flash[:notice] = "New menu created" if @menu.save
|
24
24
|
respond_with @menu,:location => @menu.id != nil ? spud_admin_menu_menu_items_url(:menu_id => @menu.id) : spud_admin_menus_url
|
@@ -32,7 +32,7 @@ class Spud::Admin::MenusController < Spud::Admin::CmsController
|
|
32
32
|
def update
|
33
33
|
add_breadcrumb "Edit #{@menu.name}", :edit_spud_admin_menu_path
|
34
34
|
|
35
|
-
flash[:notice] = "Menu saved successfully" if @menu.update_attributes(
|
35
|
+
flash[:notice] = "Menu saved successfully" if @menu.update_attributes(menu_params)
|
36
36
|
respond_with @menu,:location => spud_admin_menu_menu_items_url(:menu_id => @menu.id)
|
37
37
|
end
|
38
38
|
|
@@ -52,4 +52,8 @@ private
|
|
52
52
|
redirect_to spud_admin_menus_url() and return false
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
def menu_params
|
57
|
+
params.require(:spud_menu).permit(:name, :description)
|
58
|
+
end
|
55
59
|
end
|
@@ -8,10 +8,12 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
|
|
8
8
|
|
9
9
|
@pages = SpudPage.site(session[:admin_site]).where(:spud_page_id => nil).order(:page_order).includes(:spud_pages).paginate :page => params[:page]
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
if Spud::Cms.root_page_name
|
12
|
+
home_page = SpudPage.where(:url_name => Spud::Cms.root_page_name).first
|
13
|
+
if home_page.blank?
|
14
|
+
flash.now[:warning] = "You have not setup your default CMS page. This page will be your homepage. To do so, create a page with the name '#{Spud::Cms.root_page_name.titlecase}'"
|
15
|
+
end
|
16
|
+
end
|
15
17
|
|
16
18
|
respond_with @pages
|
17
19
|
end
|
@@ -39,7 +41,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
|
|
39
41
|
|
40
42
|
def create
|
41
43
|
|
42
|
-
@page = SpudPage.new(
|
44
|
+
@page = SpudPage.new(page_params)
|
43
45
|
@page.site_id = session[:admin_site]
|
44
46
|
if params[:preview] && params[:preview].to_i == 1
|
45
47
|
preview
|
@@ -71,7 +73,7 @@ class Spud::Admin::PagesController < Spud::Admin::CmsController
|
|
71
73
|
|
72
74
|
def update
|
73
75
|
|
74
|
-
@page.attributes =
|
76
|
+
@page.attributes = page_params
|
75
77
|
if params[:preview] && params[:preview].to_i == 1
|
76
78
|
preview
|
77
79
|
return
|
@@ -178,5 +180,10 @@ private
|
|
178
180
|
end
|
179
181
|
|
180
182
|
|
183
|
+
def page_params
|
184
|
+
params.require(:spud_page).permit(: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 => [:id,:name, :content, :format]},:use_custom_url_name,:published,:notes)
|
185
|
+
end
|
186
|
+
|
187
|
+
|
181
188
|
|
182
189
|
end
|
@@ -5,7 +5,7 @@ class Spud::Admin::SnippetsController < Spud::Admin::ApplicationController
|
|
5
5
|
|
6
6
|
before_filter :load_snippet, :only => [:show, :edit, :update, :destroy]
|
7
7
|
|
8
|
-
cache_sweeper :snippet_sweeper, :only => [:update,:destroy,:create]
|
8
|
+
# cache_sweeper :snippet_sweeper, :only => [:update,:destroy,:create]
|
9
9
|
|
10
10
|
def index
|
11
11
|
@snippets = SpudSnippet.site(session[:admin_site]).order(:name).paginate :page => params[:page]
|
@@ -21,7 +21,7 @@ class Spud::Admin::SnippetsController < Spud::Admin::ApplicationController
|
|
21
21
|
|
22
22
|
def create
|
23
23
|
add_breadcrumb "New", :new_spud_admin_snippet_url
|
24
|
-
@snippet = SpudSnippet.new(
|
24
|
+
@snippet = SpudSnippet.new(snippet_params)
|
25
25
|
@snippet.site_id = session[:admin_site]
|
26
26
|
|
27
27
|
@snippet.save
|
@@ -37,7 +37,7 @@ class Spud::Admin::SnippetsController < Spud::Admin::ApplicationController
|
|
37
37
|
|
38
38
|
def update
|
39
39
|
add_breadcrumb "Edit", :edit_spud_admin_snippet_url
|
40
|
-
flash[:notice] = "Snippet saved successfully!" if @snippet.update_attributes(
|
40
|
+
flash[:notice] = "Snippet saved successfully!" if @snippet.update_attributes(snippet_params)
|
41
41
|
respond_with @snippet, :location => spud_admin_snippets_url
|
42
42
|
end
|
43
43
|
|
@@ -58,4 +58,8 @@ private
|
|
58
58
|
redirect_to spud_admin_snippets_url and return false
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
def snippet_params
|
63
|
+
params.require(:spud_snippet).permit(:content, :content_processed, :format, :name)
|
64
|
+
end
|
61
65
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
class Spud::Cms::SitemapsController < Spud::ApplicationController
|
2
2
|
respond_to :xml
|
3
|
-
caches_page :show,:expires_in => 1.day
|
4
3
|
def show
|
5
4
|
@pages = SpudPage.published_pages.public.order(:spud_page_id)
|
6
5
|
if Spud::Core.multisite_mode_enabled
|
7
6
|
site_config = Spud::Core.site_config_for_host(request.host_with_port)
|
8
7
|
@pages = @pages.site(!site_config.blank? ? site_config[:site_id] : 0)
|
9
8
|
end
|
10
|
-
@pages = @pages.all
|
11
9
|
respond_with @pages
|
12
10
|
end
|
13
11
|
end
|
@@ -13,7 +13,9 @@ module Spud::Cms::ApplicationHelper
|
|
13
13
|
end
|
14
14
|
|
15
15
|
if !snippet.blank?
|
16
|
-
|
16
|
+
cache snippet do
|
17
|
+
return snippet.content_processed.html_safe
|
18
|
+
end
|
17
19
|
else
|
18
20
|
return nil
|
19
21
|
end
|
@@ -55,7 +57,7 @@ module Spud::Cms::ApplicationHelper
|
|
55
57
|
content = "<ul>"
|
56
58
|
end
|
57
59
|
|
58
|
-
pages = pages.
|
60
|
+
pages = pages.load.group_by(&:spud_page_id)
|
59
61
|
if pages[start_page].blank?
|
60
62
|
|
61
63
|
return ""
|
@@ -136,7 +138,7 @@ module Spud::Cms::ApplicationHelper
|
|
136
138
|
#{SpudMenuItem.table_name}.menu_order as menu_order,
|
137
139
|
#{SpudMenuItem.table_name}.parent_id as parent_id,
|
138
140
|
#{SpudMenuItem.table_name}.name as name,
|
139
|
-
#{SpudPage.table_name}.url_name as url_name").order(:parent_type,:parent_id).joins("LEFT JOIN #{SpudPage.table_name} ON (#{SpudPage.table_name}.id = #{SpudMenuItem.table_name}.spud_page_id)").
|
141
|
+
#{SpudPage.table_name}.url_name as url_name").order(:parent_type,:parent_id).joins("LEFT JOIN #{SpudPage.table_name} ON (#{SpudPage.table_name}.id = #{SpudMenuItem.table_name}.spud_page_id)").load
|
140
142
|
|
141
143
|
|
142
144
|
grouped_items = menu_items.group_by(&:parent_type)
|
@@ -201,7 +203,7 @@ module Spud::Cms::ApplicationHelper
|
|
201
203
|
#{SpudMenuItem.table_name}.menu_order as menu_order,
|
202
204
|
#{SpudMenuItem.table_name}.parent_id as parent_id,
|
203
205
|
#{SpudMenuItem.table_name}.name as name,
|
204
|
-
#{SpudPage.table_name}.url_name as url_name").order(:parent_type,:parent_id).joins("LEFT JOIN #{SpudPage.table_name} ON (#{SpudPage.table_name}.id = #{SpudMenuItem.table_name}.spud_page_id)").
|
206
|
+
#{SpudPage.table_name}.url_name as url_name").order(:parent_type,:parent_id).joins("LEFT JOIN #{SpudPage.table_name} ON (#{SpudPage.table_name}.id = #{SpudMenuItem.table_name}.spud_page_id)").load
|
205
207
|
|
206
208
|
menu_tags = []
|
207
209
|
menu_items.sort_by{|p| p.menu_order}.each do |item|
|
data/app/models/spud_menu.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class SpudMenu < ActiveRecord::Base
|
2
|
-
validates :name,:presence => true
|
3
|
-
|
2
|
+
validates :name,:presence => true, :uniqueness => [:site_id]
|
3
|
+
|
4
4
|
has_many :spud_menu_items,:as => :parent,:dependent => :destroy
|
5
5
|
has_many :spud_menu_items_combined,:class_name => "SpudMenuItem",:foreign_key => :spud_menu_id,:dependent => :destroy
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
|
8
8
|
scope :site, lambda {|sid| where(:site_id => sid)}
|
9
9
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class SpudMenuItem < ActiveRecord::Base
|
2
|
-
belongs_to :parent, :polymorphic=>true
|
3
|
-
belongs_to :spud_menu
|
2
|
+
belongs_to :parent, :polymorphic=>true, :touch => true
|
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
|
data/app/models/spud_page.rb
CHANGED
@@ -2,6 +2,7 @@ class SpudPage < ActiveRecord::Base
|
|
2
2
|
spud_searchable
|
3
3
|
belongs_to :spud_page
|
4
4
|
has_many :spud_page_partial_revisions
|
5
|
+
has_many :spud_menu_items
|
5
6
|
has_many :spud_pages, :dependent => :nullify
|
6
7
|
has_many :spud_page_partials,:dependent => :destroy
|
7
8
|
has_many :spud_permalinks,:as => :attachment, :dependent => :destroy
|
@@ -9,25 +10,21 @@ class SpudPage < ActiveRecord::Base
|
|
9
10
|
belongs_to :updated_by_user,:class_name => "SpudUser",:foreign_key => :updated_by
|
10
11
|
|
11
12
|
|
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
13
|
before_validation :generate_url_name
|
15
|
-
validates :name,:presence => true
|
16
|
-
|
17
|
-
validates :url_name,:presence => true
|
18
|
-
validates_uniqueness_of :url_name, :scope => :site_id
|
14
|
+
validates :name,:presence => true, :uniqueness => {:scope => [:site_id, :spud_page_id]}
|
15
|
+
validates :url_name,:presence => true, :uniqueness => {: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
|
+
scope :parent_pages, -> {where(:spud_page_id => nil)}
|
22
19
|
scope :site, lambda {|sid| where(:site_id => sid)}
|
23
|
-
scope :published_pages, where(:published => true)
|
24
|
-
scope :public, where(:visibility => 0)
|
20
|
+
scope :published_pages, -> { where(:published => true)}
|
21
|
+
scope :public, -> {where(:visibility => 0)}
|
25
22
|
|
26
23
|
|
27
24
|
def self.grouped(site_id=0)
|
28
25
|
|
29
26
|
if(Spud::Core.multisite_mode_enabled)
|
30
|
-
return site(site_id).
|
27
|
+
return site(site_id).load.group_by(&:spud_page_id)
|
31
28
|
else
|
32
29
|
return all.group_by(&:spud_page_id)
|
33
30
|
end
|
@@ -38,7 +35,7 @@ class SpudPage < ActiveRecord::Base
|
|
38
35
|
end
|
39
36
|
|
40
37
|
# Returns an array of pages in order of heirarchy
|
41
|
-
# :
|
38
|
+
# :filter Filters out a page by ID, and all of its children
|
42
39
|
# :value Pick an attribute to be used in the value field, defaults to ID
|
43
40
|
def self.options_tree_for_page(config={})
|
44
41
|
collection = config[:collection] || self.grouped(config[:site_id])
|
@@ -73,7 +70,7 @@ class SpudPage < ActiveRecord::Base
|
|
73
70
|
if !self.id.blank?
|
74
71
|
pages = pages.where("id != #{self.id}")
|
75
72
|
end
|
76
|
-
url_names = pages.site(self.site_id).
|
73
|
+
url_names = pages.site(self.site_id).collect{|p| p.url_name}
|
77
74
|
|
78
75
|
counter = 1
|
79
76
|
url_name_new = url_name
|