beef-pages 0.2.3 → 0.2.4

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 CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -26,9 +26,14 @@ class Admin::PagesController < Admin::BaseController
26
26
  end
27
27
 
28
28
  def new
29
- @page = Page.new( :parent_id => params[:page_id] )
30
-
31
- render :action => 'show'
29
+
30
+ if params[:page_id].nil?
31
+ flash[:notice] = 'Unspecified parent page.'
32
+ redirect_to(admin_pages_url)
33
+ else
34
+ @page = Page.new( :parent_id => params[:page_id] )
35
+ render :action => 'show'
36
+ end
32
37
  end
33
38
 
34
39
  def edit
@@ -98,19 +103,6 @@ class Admin::PagesController < Admin::BaseController
98
103
  def preview
99
104
  session[:page_preview] = params[:page]
100
105
  end
101
-
102
- def feature
103
- @page = Page.find(params[:id])
104
- if request.put?
105
- if params[:spot] == 'remove'
106
- @page.features.delete_all
107
- else
108
- @page.feature_at! params[:spot]
109
- end
110
- flash[:notice] = 'Page has been featured'
111
- redirect_to admin_pages_path
112
- end
113
- end
114
106
 
115
107
  def move_up
116
108
  Page.find(params[:id]).move_higher
@@ -13,6 +13,7 @@ class PagesController < ApplicationController
13
13
 
14
14
  def preview
15
15
  @page = Page.new(session[:page_preview])
16
+ @page.id = 0
16
17
  session[:page_preview] = nil
17
18
  render :template => "pages/templates/#{(@page.template || get_template_names.first)}"
18
19
  end
@@ -4,4 +4,15 @@ module PagesHelper
4
4
  return if pages.empty?
5
5
  yield(pages)
6
6
  end
7
+
8
+
9
+ def sub_pages_list(permalink)
10
+ page = Page.find_by_permalink(permalink)
11
+ return if page.nil?
12
+ page_items = page.children.published.collect do |sub_page|
13
+ content_tag( :li, link_to( h(sub_page.title), page_path(sub_page.permalink)))
14
+ end
15
+ content_tag :ul, page_items.join unless page_items.empty?
16
+ end
17
+
7
18
  end
@@ -1,9 +1,10 @@
1
1
  <tr id="pages-<%= page.id %>">
2
2
  <td class="title"><%= link_to page.title, admin_page_pages_path(page) %></td>
3
+ <td><%= link_to pluralize(page.children.count, "sub page"), admin_page_pages_path(page) %></td>
3
4
  <td><%= content_status(page) %></td>
4
5
  <td><%= page.author %><br />(<%= page.created_at.to_formatted_s(:short) %>)</td>
5
6
  <td><%= page.editor %><%= "<br />(#{page.updated_at.to_formatted_s(:short)})" unless page.updated_at.nil? %></td>
6
- <td class="date"><%= page.published_at.to_formatted_s(:short) %></td>
7
+ <td class="date"><%= page.published_at.to_formatted_s(:short) unless page.published_at.nil? %></td>
7
8
  <td class="date"><%= page.published_to.to_formatted_s(:short) unless page.published_to.nil? %></td>
8
9
  <td><%= link_to 'Show', page_path(page.permalink), :class => 'show' if page.published? %></td>
9
10
  <td><%= link_to 'Add page', new_admin_page_page_path(page), :class => 'add', :title => "Add a sub-page under #{page.title}" %></td>
@@ -1,9 +1,7 @@
1
1
  <h1>Listing pages<%= " under #{@parent.title}" unless @parent.nil? %></h1>
2
2
 
3
3
  <ul class="choices">
4
- <% if @parent.nil? %>
5
- <li><%= link_to 'New page', new_admin_page_path(), :class => "button", :title => "Add a new root page" %></li>
6
- <% else %>
4
+ <% unless @parent.nil? %>
7
5
  <li><%= link_to 'New page', new_admin_page_page_path(@parent), :class => "button", :title => "Add a sub-page under #{@parent.title}" %></li>
8
6
 
9
7
  <% if @parent.parent.nil? %>
@@ -22,8 +20,9 @@
22
20
  <thead>
23
21
  <tr>
24
22
  <th>Title</th>
23
+ <th># Sub Pages</th>
25
24
  <th>Status</th>
26
- <th>Author</th>
25
+ <th>Author</ th>
27
26
  <th>Updater</th>
28
27
  <th>Published At</th>
29
28
  <th>Published To</th>
@@ -36,6 +35,7 @@
36
35
  <tfoot>
37
36
  <tr>
38
37
  <th>Title</th>
38
+ <th># Sub Pages</th>
39
39
  <th>Status</th>
40
40
  <th>Author</th>
41
41
  <th>Updater</th>
@@ -1,12 +1,23 @@
1
1
  <ul id="nav-secondary">
2
- <% for sibling in @page.self_and_siblings %>
2
+
3
+ <li><%= link_to @page.root.title, page_path(@page.root.permalink) %></li><ul>
4
+
5
+
6
+
7
+ <% for sibling in @page.root.children.published %>
3
8
  <li<%= ' class="active"' if sibling == @page %>><%= link_to sibling.title, page_path(sibling.permalink) %>
4
- <% if sibling == @page && sibling.children.count >0 %>
9
+ <% if sibling == @page && sibling.children.published.count > 0 %>
5
10
  <ul>
6
- <% for child in sibling.children %>
11
+ <% for child in sibling.children.published %>
7
12
  <li><%= link_to child.title, page_path(child.permalink) %></li>
8
13
  <% end %>
9
14
  </ul>
10
15
  <% end %></li>
11
16
  <% end %>
17
+
18
+
19
+
20
+ </ul>
21
+
22
+
12
23
  </ul>
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
2
  map.resources :pages, :only => [:show, :index], :collection => {:preview => :get}
3
3
  map.namespace(:admin) do |admin|
4
- admin.resources :pages, :has_many => :pages, :collection => {:preview => :post}, :member => {:preview => :put, :feature => [:get, :put], :move_up => :get, :move_down => :get}
4
+ admin.resources :pages, :has_many => :pages, :collection => {:preview => :post}, :member => {:preview => :put, :move_up => :get, :move_down => :get}
5
5
  end
6
6
  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.3"
5
+ s.version = "0.2.4"
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-01}
9
+ s.date = %q{2009-09-03}
10
10
  s.email = %q{steve@wearebeef.co.uk}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -24,9 +24,7 @@ Gem::Specification.new do |s|
24
24
  "app/helpers/pages_helper.rb",
25
25
  "app/models/page.rb",
26
26
  "app/views/admin/pages/_page.html.erb",
27
- "app/views/admin/pages/feature.html.erb",
28
27
  "app/views/admin/pages/index.html.erb",
29
- "app/views/admin/pages/preview.rjs",
30
28
  "app/views/admin/pages/show.html.erb",
31
29
  "app/views/pages/_naviagtion.html.erb",
32
30
  "config/routes.rb",
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.3
4
+ version: 0.2.4
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-01 00:00:00 -07:00
12
+ date: 2009-09-03 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -34,9 +34,7 @@ files:
34
34
  - app/helpers/pages_helper.rb
35
35
  - app/models/page.rb
36
36
  - app/views/admin/pages/_page.html.erb
37
- - app/views/admin/pages/feature.html.erb
38
37
  - app/views/admin/pages/index.html.erb
39
- - app/views/admin/pages/preview.rjs
40
38
  - app/views/admin/pages/show.html.erb
41
39
  - app/views/pages/_naviagtion.html.erb
42
40
  - config/routes.rb
@@ -1,10 +0,0 @@
1
- <h1>Feature a page</h1>
2
-
3
- <% form_for([:feature, :admin, @page]) do %>
4
- <p>
5
- <%= label_tag :spot, "Please select where to feture the page '#{h(@page.title)}'" %><br/>
6
- <%= select_tag :spot, options_for_select({'Home page left' => :home_page_left, 'Home page centre' => :home_page_centre, 'Home page right' => :home_page_right, "Remove from feature" => :remove }) %></p>
7
- <p>
8
- <%= submit_tag "Feature", :disable_with => 'Featureing...' %> or <%= link_to 'Cancel', admin_pages_path %>
9
- </p>
10
- <% end -%>
@@ -1 +0,0 @@
1
- page << "myLightWindow.activateWindow({href: '#{preview_pages_path}', title: 'This is only a preview'});"