beef-pages 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
@@ -86,17 +86,22 @@ class Admin::PagesController < Admin::BaseController
86
86
 
87
87
  def destroy
88
88
  @page = Page.find(params[:id])
89
- @page.destroy
90
-
91
- respond_to do |format|
92
- format.html {
93
- if params[:page].nil?
94
- redirect_to(admin_pages_url)
95
- else
96
- redirect_to(admin_page_pages_url(@page.parent))
97
- end
98
- }
99
- format.xml { head :ok }
89
+ if @page.lock_level >0
90
+ flash[:notice] = 'This Page is locked.'
91
+ redirect_to(:back)
92
+ else
93
+ @page.destroy
94
+
95
+ respond_to do |format|
96
+ format.html {
97
+ if params[:page].nil?
98
+ redirect_to(admin_pages_url)
99
+ else
100
+ redirect_to(admin_page_pages_url(@page.parent))
101
+ end
102
+ }
103
+ format.xml { head :ok }
104
+ end
100
105
  end
101
106
  end
102
107
 
data/app/models/page.rb CHANGED
@@ -38,6 +38,10 @@ class Page < ActiveRecord::Base
38
38
  def featured?
39
39
  !features.empty?
40
40
  end
41
+
42
+ def lock_level
43
+ read_attribute(:lock_level) || 0
44
+ end
41
45
 
42
46
  private
43
47
 
@@ -1,5 +1,5 @@
1
1
  <tr id="pages-<%= page.id %>">
2
- <td class="title"><%= link_to page.title, admin_page_pages_path(page) %></td>
2
+ <td class="title"><%= link_to page.title, admin_page_path(page) %></td>
3
3
  <td><%= link_to pluralize(page.children.count, "sub page"), admin_page_pages_path(page) %></td>
4
4
  <td><%= content_status(page) %></td>
5
5
  <td><%= page.author %><br />(<%= page.created_at.to_formatted_s(:short) %>)</td>
@@ -9,7 +9,7 @@
9
9
  <td><%= link_to 'Show', page_path(page.permalink), :class => 'show' if page.published? %></td>
10
10
  <td><%= link_to 'Add page', new_admin_page_page_path(page), :class => 'add', :title => "Add a sub-page under #{page.title}" %></td>
11
11
  <td><%= link_to 'Edit', [:admin, page], :class => 'edit' %></td>
12
- <td><%= link_to('Destroy', admin_page_path(page), :confirm => 'Are you sure?', :method => :delete, :class => 'delete') unless page.parent_id.nil? || !current_user.admin? %></td>
12
+ <td><%= link_to('Destroy', admin_page_path(page), :confirm => 'Are you sure?', :method => :delete, :class => 'delete') unless page.lock_level >=1 || !current_user.admin? %></td>
13
13
  <td>
14
14
  <%= link_to 'up', move_up_admin_page_path(page), { :class => "page_up" } if current_user.admin? && !page.first? %>
15
15
  <%= link_to 'down', move_down_admin_page_path(page), { :class => 'page_down' } if current_user.admin? && !page.last? %>
@@ -2,16 +2,13 @@
2
2
 
3
3
  <ul class="choices">
4
4
  <% unless @parent.nil? %>
5
- <li><%= link_to 'New page', new_admin_page_page_path(@parent), :class => "button", :title => "Add a sub-page under #{@parent.title}" %></li>
6
-
5
+ <li><%= link_to 'New page', new_admin_page_page_path(@parent), :class => "button", :title => "Add a sub-page under #{@parent.title}" %></li>
7
6
  <% if @parent.parent.nil? %>
8
- <li><%= link_to "All top pages", admin_pages_path(), :class => "up button" %></li>
7
+ <li><%= link_to "All top pages", admin_pages_path(), :class => "up button" %></li>
9
8
  <% else %>
10
- <li><%= link_to "Up to #{@parent.parent.title}", admin_page_pages_path(@parent.parent), :class => "up button" %></li>
9
+ <li><%= link_to "Up to #{@parent.parent.title}", admin_page_pages_path(@parent.parent), :class => "up button" %></li>
11
10
  <% end %>
12
-
13
11
  <% end %>
14
-
15
12
  </ul>
16
13
 
17
14
  <%= hidden_field_tag 'form_authenticity_token', "#{form_authenticity_token}" %>
@@ -22,7 +19,7 @@
22
19
  <th>Title</th>
23
20
  <th># Sub Pages</th>
24
21
  <th>Status</th>
25
- <th>Author</ th>
22
+ <th>Author</th>
26
23
  <th>Updater</th>
27
24
  <th>Published At</th>
28
25
  <th>Published To</th>
@@ -3,30 +3,45 @@
3
3
  <%= stylesheet_link_tag 'lightwindow' %>
4
4
  <% end -%>
5
5
 
6
- <h1><%= @page.new_record? ? 'New' : 'Editing' %> page</h1>
6
+ <h1><%= @page.new_record? ? 'New' : 'Editing a' %> Page</h1>
7
7
 
8
8
  <% form_for([:admin, @page], :html => { :id => 'has-assets-form' }) do |f| %>
9
9
  <%= f.error_messages %>
10
10
 
11
11
  <%= f.hidden_field :parent_id %>
12
+
13
+ <% if @page.lock_level < 3 %>
12
14
  <p>
13
- <%= f.label :title %><br/>
15
+ <%= f.label :title, 'Title*' %><br/>
14
16
  <%= f.text_field :title, :class => 'title' %>
15
17
  </p>
16
-
18
+ <% else %>
19
+ <p>
20
+ <%= f.label :title %><br/>
21
+ <%= @page.title %> (locked)
22
+ </p>
23
+ <% end %>
24
+
25
+ <% if @page.lock_level < 2 %>
17
26
  <p>
18
27
  <%= f.label :permalink, "URL" %><br/>
19
28
  <%= root_url %><%= f.text_field :permalink %>
20
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>
21
30
  </p>
31
+ <% else %>
32
+ <p>
33
+ <%= f.label :permalink, "URL" %><br/>
34
+ <%= root_url %><%= @page.permalink %> (locked)
35
+ </p>
36
+ <% end %>
22
37
 
23
38
  <p>
24
- <%= f.label :description, "Description for search engines" %><br/>
39
+ <%= f.label :description, "Description for search engines*" %><br/>
25
40
  <%= f.text_area :description, "rows" => 4 %>
26
41
  </p>
27
42
 
28
43
  <p>
29
- <%= f.label :tag_list, "Keywords (comma seperated) - used by search engines" %><br/>
44
+ <%= f.label :tag_list, "Keywords (used by search engines) & Tags - comma separated*" %><br/>
30
45
  <%= f.text_field :tag_list, :class => 'long' %>
31
46
  </p>
32
47
 
@@ -37,7 +52,7 @@
37
52
  </p>
38
53
 
39
54
  <p>
40
- <%= f.label :body %><br/>
55
+ <%= f.label :body, 'Body*' %><br/>
41
56
  <%= f.text_area 'body', :class => 'editor' %>
42
57
  </p>
43
58
 
@@ -62,4 +77,5 @@
62
77
  <h2>Asset Upload</h2>
63
78
  <%= asset_upload_form %>
64
79
 
80
+ <%= flickr_select %>
65
81
  <% end %>
@@ -10,6 +10,7 @@ class CreatePages < ActiveRecord::Migration
10
10
  t.string :template, :limit => 20
11
11
  t.integer :position, :default => 0
12
12
  t.references :created_by, :updated_by, :parent
13
+ t.integer :lock_level, :default => 0
13
14
 
14
15
  t.timestamps
15
16
  end
data/lib/pages.rb CHANGED
@@ -3,12 +3,15 @@ module Beef
3
3
  module HelperMethods
4
4
  def get_template_names
5
5
  templates = []
6
- Dir.glob("#{RAILS_ROOT}/app/views/pages/templates/*"){|f| match = /\/([^\/]+)\.html\.erb$/.match(f); templates << match[1] unless match.nil? }
6
+ Dir.glob("#{RAILS_ROOT}/app/views/pages/templates/*") do |f|
7
+ match = /\/([^\/]+)\.html\.erb$/.match(f)
8
+ templates << match[1] unless match.nil?
9
+ end
7
10
  # Move default to top if it exists
8
11
  if default = templates.delete('default')
9
12
  templates.insert(0, default)
10
13
  end
11
- templates.sort
14
+ templates
12
15
  end
13
16
  end
14
17
  end
data/pages.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{pages}
5
- s.version = "0.2.5"
5
+ s.version = "0.2.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Steve England"]
9
- s.date = %q{2009-09-03}
9
+ s.date = %q{2009-09-10}
10
10
  s.email = %q{steve@wearebeef.co.uk}
11
11
  s.extra_rdoc_files = [
12
12
  "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.2.5
4
+ version: 0.2.6
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: 2009-09-03 00:00:00 -07:00
12
+ date: 2009-09-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15