beef-pages 0.3.10 → 0.3.11
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/VERSION +1 -1
- data/app/controllers/admin/pages_controller.rb +13 -13
- data/app/models/page.rb +19 -13
- data/app/views/admin/pages/index.html.erb +8 -6
- data/app/views/admin/pages/show.html.erb +2 -1
- data/beef-pages.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.11
|
@@ -27,7 +27,7 @@ class Admin::PagesController < Admin::BaseController
|
|
27
27
|
|
28
28
|
def new
|
29
29
|
|
30
|
-
if params[:page_id].nil?
|
30
|
+
if params[:page_id].nil? and not Page.allow_new_roots?
|
31
31
|
flash[:notice] = 'Unspecified parent page.'
|
32
32
|
redirect_to(admin_pages_url)
|
33
33
|
else
|
@@ -47,13 +47,13 @@ class Admin::PagesController < Admin::BaseController
|
|
47
47
|
respond_to do |format|
|
48
48
|
if @page.save
|
49
49
|
flash[:notice] = 'Page was successfully created.'
|
50
|
-
format.html
|
50
|
+
format.html do
|
51
51
|
if @page.parent.nil?
|
52
52
|
redirect_to(admin_pages_url)
|
53
53
|
else
|
54
54
|
redirect_to(admin_page_pages_url(@page.parent))
|
55
55
|
end
|
56
|
-
|
56
|
+
end
|
57
57
|
format.xml { render :xml => @page, :status => :created, :location => @page }
|
58
58
|
else
|
59
59
|
format.html { render :action => "show" }
|
@@ -69,13 +69,13 @@ class Admin::PagesController < Admin::BaseController
|
|
69
69
|
respond_to do |format|
|
70
70
|
if @page.update_attributes(params[:page])
|
71
71
|
flash[:notice] = 'Page was successfully updated.'
|
72
|
-
format.html
|
72
|
+
format.html do
|
73
73
|
if @page.parent.nil?
|
74
74
|
redirect_to(admin_pages_url)
|
75
75
|
else
|
76
76
|
redirect_to(admin_page_pages_url(@page.parent))
|
77
77
|
end
|
78
|
-
|
78
|
+
end
|
79
79
|
format.xml { head :ok }
|
80
80
|
else
|
81
81
|
format.html { render :action => "show" }
|
@@ -93,14 +93,14 @@ class Admin::PagesController < Admin::BaseController
|
|
93
93
|
@page.destroy
|
94
94
|
|
95
95
|
respond_to do |format|
|
96
|
-
format.html
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
96
|
+
format.html do
|
97
|
+
flash[:notice] = 'Page was successfully deleted.'
|
98
|
+
if params[:page].nil?
|
99
|
+
redirect_to(admin_pages_url)
|
100
|
+
else
|
101
|
+
redirect_to(admin_page_pages_url(@page.parent))
|
102
|
+
end
|
103
|
+
end
|
104
104
|
format.xml { head :ok }
|
105
105
|
end
|
106
106
|
end
|
data/app/models/page.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
class Page < ActiveRecord::Base
|
2
|
-
default_scope :order => 'position ASC'
|
2
|
+
default_scope :order => 'position ASC'
|
3
3
|
named_scope :top, :conditions => {:parent_id => nil}, :order => :position
|
4
4
|
# http://ramblings.gibberishcode.net/archives/one-activerecord-model-acting-as-a-list-and-tree
|
5
|
-
|
5
|
+
|
6
6
|
has_assets
|
7
7
|
acts_as_content_node
|
8
8
|
acts_as_tree
|
@@ -14,17 +14,17 @@ class Page < ActiveRecord::Base
|
|
14
14
|
|
15
15
|
validates_presence_of :title
|
16
16
|
validates_presence_of :body, :tag_list, :description, :if => :publish
|
17
|
-
|
17
|
+
|
18
18
|
LOCK_LEVEL_DELETE = 1
|
19
19
|
LOCK_LEVEL_PERMALINK = 2
|
20
20
|
LOCK_LEVEL_TEMPLATE = 3
|
21
21
|
LOCK_LEVEL_SUBPAGE = 4
|
22
|
-
LOCK_LEVEL_TITLE = 5
|
23
|
-
|
22
|
+
LOCK_LEVEL_TITLE = 5
|
23
|
+
|
24
24
|
def first_child?
|
25
25
|
self == self.self_and_siblings.first
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def last_child?
|
29
29
|
self == self.self_and_siblings.last
|
30
30
|
end
|
@@ -36,15 +36,15 @@ class Page < ActiveRecord::Base
|
|
36
36
|
def reindex_children(recurse = true, departing_child = nil)
|
37
37
|
Page.reindex_pages(children, recurse, departing_child)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def root?
|
41
41
|
parent_id.nil?
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def featured?
|
45
45
|
!features.empty?
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def lock_level
|
49
49
|
read_attribute(:lock_level) || 0
|
50
50
|
end
|
@@ -56,6 +56,12 @@ class Page < ActiveRecord::Base
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
# Flag if creation of new root pages id allowed
|
60
|
+
cattr_accessor :allow_new_roots
|
61
|
+
def self.allow_new_roots?
|
62
|
+
allow_new_roots == true
|
63
|
+
end
|
64
|
+
|
59
65
|
private
|
60
66
|
|
61
67
|
def set_url
|
@@ -63,8 +69,8 @@ class Page < ActiveRecord::Base
|
|
63
69
|
end
|
64
70
|
|
65
71
|
# takes a given array of pages and recursively (or not) reindexes
|
66
|
-
# if departing_child is supplied, it is removed from the array so
|
67
|
-
# that former siblings are reindexed as though it was already
|
72
|
+
# if departing_child is supplied, it is removed from the array so
|
73
|
+
# that former siblings are reindexed as though it was already
|
68
74
|
# removed from the collection.
|
69
75
|
def self.reindex_pages(pages, recurse, departing_child)
|
70
76
|
pages.select{|r| r != departing_child}.each_with_index do |page, index|
|
@@ -74,7 +80,7 @@ class Page < ActiveRecord::Base
|
|
74
80
|
true
|
75
81
|
end
|
76
82
|
|
77
|
-
# When the parent id of a node changes, the acts_as_list gets lost, so
|
83
|
+
# When the parent id of a node changes, the acts_as_list gets lost, so
|
78
84
|
# we need to reindex the affected nodes to keep things sane
|
79
85
|
def keep_position_sane
|
80
86
|
return unless self.parent_id_changed?
|
@@ -90,5 +96,5 @@ class Page < ActiveRecord::Base
|
|
90
96
|
last_page = (self.parent_id.nil? ? Page.top.last : Page.find(self.parent_id).children.last)
|
91
97
|
self.position = (last_page.nil? ? 1 : last_page.position + 1)
|
92
98
|
true
|
93
|
-
end
|
99
|
+
end
|
94
100
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
<h1>Listing pages<%= " under #{@parent.title}" unless @parent.nil? %></h1>
|
2
2
|
|
3
3
|
<ul class="choices">
|
4
|
-
<%
|
5
|
-
|
6
|
-
<%
|
4
|
+
<% if !@parent.nil? and @parent.lock_level < Page::LOCK_LEVEL_SUBPAGE -%>
|
5
|
+
<li><%= link_to 'New page', new_admin_page_page_path(@parent), :class => 'button', :title => "Add a sub-page under #{@parent.title}" %></li>
|
6
|
+
<% elsif @parent.nil? and Page.allow_new_roots? %>
|
7
|
+
<li><%= link_to 'New page', new_admin_page_path, :class => 'button', :title => "Add new page" %></li>
|
8
|
+
<% end -%>
|
9
|
+
<% if !@parent.nil? and @parent.parent.nil? %>
|
7
10
|
<li><%= link_to "All top pages", admin_pages_path(), :class => "up button" %></li>
|
8
|
-
<%
|
11
|
+
<% elsif !@parent.nil? %>
|
9
12
|
<li><%= link_to "Up to #{@parent.parent.title}", admin_page_pages_path(@parent.parent), :class => "up button" %></li>
|
10
|
-
<% end %>
|
11
13
|
<% end %>
|
12
|
-
</ul>
|
14
|
+
</ul>
|
13
15
|
|
14
16
|
<table class="featurable">
|
15
17
|
<thead>
|
@@ -26,8 +26,9 @@
|
|
26
26
|
<p>
|
27
27
|
<%= f.label :permalink, "URL" %><br/>
|
28
28
|
<%= root_url %><%= f.text_field :permalink %>
|
29
|
-
<p>URLs are most efficient if they closely reflect the title or main subject of this content. Changing the permalink will make search engines think it is a different page resulting in a loss of page rank, only change if very necessary. Leave blank to use the title.</p>
|
30
29
|
</p>
|
30
|
+
<p>URLs are most efficient if they closely reflect the title or main subject of this content. Changing the permalink will make search engines think it is a different page resulting in a loss of page rank, only change if very necessary. Leave blank to use the title.</p>
|
31
|
+
|
31
32
|
<% else %>
|
32
33
|
<p>
|
33
34
|
<%= f.label :permalink, "URL" %><br/>
|
data/beef-pages.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{beef-pages}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steve England"]
|
12
|
-
s.date = %q{2010-01-
|
12
|
+
s.date = %q{2010-01-27}
|
13
13
|
s.email = %q{steve@wearebeef.co.uk}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beef-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve England
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-27 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|