diff --git a/app/controllers/beers_controller.rb b/app/controllers/beers_controller.rb
index bd7313d..a97869b 100644
--- a/app/controllers/beers_controller.rb
+++ b/app/controllers/beers_controller.rb
@@ -5,6 +5,8 @@ class BeersController < ApplicationController
# GET /beers
# GET /beers.xml
def index
+ @content_title = 'The Beers'
+ @secondary_title = 'Browsing all beers'
@pages, @beers = paginate :beers, :include => 'page', :per_page => 50,
:order => 'beers.title ASC'
respond_to do |format|
@@ -24,12 +26,14 @@ class BeersController < ApplicationController
# GET /beers/new
def new
+ @secondary_title = 'Create a new beer'
@beer = Beer.new
@page = Page.new
end
# GET /beers/1;edit
def edit
+ @secondary_title = 'Update existing beer'
end
# POST /beers
diff --git a/app/controllers/breweries_controller.rb b/app/controllers/breweries_controller.rb
index 4b04cdd..c7a7b6d 100644
--- a/app/controllers/breweries_controller.rb
+++ b/app/controllers/breweries_controller.rb
@@ -5,6 +5,8 @@ class BreweriesController < ApplicationController
# GET /breweries
# GET /breweries.xml
def index
+ @content_title = 'The Breweries'
+ @secondary_title = 'Browsing all breweries'
@pages, @breweries = paginate :breweries, :include => 'page',
:order => 'breweries.title ASC', :per_page => 50
respond_to do |format|
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d078b5e..f54e35a 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3,16 +3,15 @@ module ApplicationHelper
# Returns the title for a page. This could be a Page title or something else.
#
def page_title
- "BarleySodas :: #{controller.class.to_s.gsub(/Controller/, '')}"
+ "BarleySodas :: #{content_title} :: #{secondary_title}"
end
##
# Returns a pretty name for the current chunk.
#
def content_title
- return @page_title if @page_title
- return @page.title if @page
- "BarleySodas"
+ return @content_title if @content_title
+ controller.class.to_s.gsub(/Controller/, '')
end
##
@@ -21,7 +20,7 @@ module ApplicationHelper
#
def secondary_title
return @secondary_title if @secondary_title
- return params[:action].to_s.capitalize.gsub(/_/) do |x|
+ params[:action].to_s.capitalize.gsub(/_/) do |x|
$1.capitalize
end
end
diff --git a/app/helpers/beers_helper.rb b/app/helpers/beers_helper.rb
index 486ba97..d713278 100644
--- a/app/helpers/beers_helper.rb
+++ b/app/helpers/beers_helper.rb
@@ -1,8 +1,4 @@
module BeersHelper
- def new_beer_link
- link_to "Beer Me!", new_beer_path, { :title => 'Create a new beer' }
- end
-
def abv(beer)
number_to_percentage(beer.abv, { :precision => 1 })
end
diff --git a/app/views/beers/_beer_form.rhtml b/app/views/beers/_beer_form.rhtml
index 675b1c4..a54cfc6 100644
--- a/app/views/beers/_beer_form.rhtml
+++ b/app/views/beers/_beer_form.rhtml
@@ -10,6 +10,4 @@
Final Gravity <%= text_field 'beer', 'final_gravity' %>
-
- Description <%= text_area 'page', 'redcloth' %>
-
\ No newline at end of file
+<%= render :partial => 'pages/page_form' %>
diff --git a/app/views/beers/edit.rhtml b/app/views/beers/edit.rhtml
index 1d6f91a..28136e5 100644
--- a/app/views/beers/edit.rhtml
+++ b/app/views/beers/edit.rhtml
@@ -1,5 +1,3 @@
-Editing beer
-
<%= error_messages_for :beer %>
<% form_for(:beer, :url => beer_path(@beer.page.title_for_url), :html => { :method => :put }) do |f| %>
@@ -9,7 +7,7 @@
<% end -%>
-
- <%= link_to 'Show', beer_path(@beer.page.title_for_url) %> |
- <%= link_to 'Beers', beers_path %>
-
\ No newline at end of file
+<% content_for :sidebar do -%>
+ <%= link_to 'New Beer', new_beer_path -%>
+ <%= link_to 'Show', beer_path(@beer.page.title_for_url) -%>
+<% end -%>
diff --git a/app/views/beers/index.rhtml b/app/views/beers/index.rhtml
index 1dacf5c..930a156 100644
--- a/app/views/beers/index.rhtml
+++ b/app/views/beers/index.rhtml
@@ -1,5 +1,3 @@
-The Beers
-
<% unless @beers.empty? -%>
@@ -16,10 +14,10 @@
<% end %>
+<% else -%>
+No beers, yet
<% end -%>
-
-
-
- <%= new_beer_link %>
-
\ No newline at end of file
+<% content_for :sidebar do -%>
+ <%= link_to "New Beer", new_beer_path, { :title => 'Create a new beer' } -%>
+<% end -%>
diff --git a/app/views/beers/new.rhtml b/app/views/beers/new.rhtml
index 861bedb..035c84e 100644
--- a/app/views/beers/new.rhtml
+++ b/app/views/beers/new.rhtml
@@ -1,5 +1,3 @@
-Create a new beer
-
<%= error_messages_for :beer %>
<% form_for(:beer, :url => beers_path, :html => { :method => :post }) do |f| %>
@@ -8,7 +6,3 @@
<%= submit_tag "Create" %>
<% end -%>
-
-
- <%= link_to 'Beers', beers_path %>
-
\ No newline at end of file
diff --git a/app/views/beers/show.rhtml b/app/views/beers/show.rhtml
index 8e2889f..8b0de59 100644
--- a/app/views/beers/show.rhtml
+++ b/app/views/beers/show.rhtml
@@ -1,4 +1,4 @@
-<%= @beer.title -%>
+<%= render :partial => 'pages/page' %>
<%
attributes = []
@@ -13,9 +13,7 @@
<% end -%>
-<%= @page.html %>
-
-
- <%= link_to 'Edit', edit_beer_path(@beer) %> |
- <%= link_to 'Beers', beers_path %>
-
\ No newline at end of file
+<% content_for :sidebar do -%>
+ <%= link_to 'New Beer', new_beer_path -%>
+ <%= link_to 'Edit Beer', edit_beer_path(@beer.page.title_for_url) -%>
+<% end -%>
diff --git a/app/views/breweries/_brewery_form.rhtml b/app/views/breweries/_brewery_form.rhtml
index 192cc50..bc35f81 100644
--- a/app/views/breweries/_brewery_form.rhtml
+++ b/app/views/breweries/_brewery_form.rhtml
@@ -16,6 +16,4 @@
Country <%= country_select 'brewery', 'country', [ 'United States', 'United Kingdom', 'Germany' ] %>
-
- Description <%= text_area 'page', 'redcloth' %>
-
\ No newline at end of file
+<%= render :partial => 'pages/page_form' %>
diff --git a/app/views/breweries/edit.rhtml b/app/views/breweries/edit.rhtml
index 466d212..8b01cea 100644
--- a/app/views/breweries/edit.rhtml
+++ b/app/views/breweries/edit.rhtml
@@ -1,5 +1,3 @@
-Editing brewery
-
<%= error_messages_for :brewery %>
<% form_for(:brewery, :url => brewery_path(@brewery.page.title_for_url), :html => { :method => :put }) do |f| %>
@@ -9,7 +7,7 @@
<% end %>
-
- <%= link_to 'Show', brewery_path(@brewery.page.title_for_url) %> |
- <%= link_to 'Breweries', breweries_path %>
-
\ No newline at end of file
+<% content_for :sidebar do -%>
+ <%= link_to 'New Brewery', new_brewery_path -%>
+ <%= link_to 'Show', brewery_path(@brewery.page.title_for_url) -%>
+<% end -%>
diff --git a/app/views/breweries/index.rhtml b/app/views/breweries/index.rhtml
index c235423..1f5897d 100644
--- a/app/views/breweries/index.rhtml
+++ b/app/views/breweries/index.rhtml
@@ -1,5 +1,4 @@
-Breweries
-
+<% unless @breweries.empty? -%>
Title
@@ -16,9 +15,10 @@
<% end %>
+<% else -%>
+No breweries, yet.
+<% end -%>
-
-
-
- <%= link_to 'New brewery', new_brewery_path %>
-
\ No newline at end of file
+<% content_for :sidebar do -%>
+ <%= link_to 'New brewery', new_brewery_path -%>
+<% end -%>
diff --git a/app/views/breweries/new.rhtml b/app/views/breweries/new.rhtml
index 89ea2bc..a4e609b 100644
--- a/app/views/breweries/new.rhtml
+++ b/app/views/breweries/new.rhtml
@@ -1,5 +1,3 @@
-New brewery
-
<%= error_messages_for :brewery %>
<% form_for(:brewery, :url => breweries_path, :html => { :method => :post }) do |f| %>
@@ -8,7 +6,3 @@
<%= submit_tag "Create" %>
<% end %>
-
-
- <%= link_to 'Breweries', breweries_path %>
-
\ No newline at end of file
diff --git a/app/views/breweries/show.rhtml b/app/views/breweries/show.rhtml
index 3f38afe..4021e60 100644
--- a/app/views/breweries/show.rhtml
+++ b/app/views/breweries/show.rhtml
@@ -1,4 +1,4 @@
-<%= @brewery.title -%>
+<%= render :partial => 'pages/page' %>
-<%= @page.html %>
-
-
- <%= link_to 'Edit', edit_brewery_path(@brewery.page.title_for_url) %> |
- <%= link_to 'Breweries', breweries_path %>
-
+<% content_for :sidebar do -%>
+ <%= link_to 'New Brewery', new_brewery_path -%>
+ <%= link_to 'Edit', edit_brewery_path(@brewery.page.title_for_url) -%>
+<% end -%>
diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml
index e6c7c0d..f490f19 100644
--- a/app/views/layouts/application.rhtml
+++ b/app/views/layouts/application.rhtml
@@ -28,7 +28,11 @@
<%= yield %>
diff --git a/app/views/pages/_page.rhtml b/app/views/pages/_page.rhtml
index 7794125..1175ba5 100644
--- a/app/views/pages/_page.rhtml
+++ b/app/views/pages/_page.rhtml
@@ -1,9 +1,19 @@
-
-
<%= link_to_page(@page) -%>
-
-<%= @page.html %>
-
-
-Current Version: <%= @page.version %>
-
-
+
+
+ <%= @page.title %>
+
+
+
+ Posted by Author Name Here
+
+
+
+ <%= @page.html %>
+
+
+
\ No newline at end of file
diff --git a/app/views/pages/_page_form.rhtml b/app/views/pages/_page_form.rhtml
new file mode 100644
index 0000000..b476445
--- /dev/null
+++ b/app/views/pages/_page_form.rhtml
@@ -0,0 +1,3 @@
+
+ Description <%= text_area 'page', 'redcloth' %>
+
\ No newline at end of file
diff --git a/app/views/pages/edit.rhtml b/app/views/pages/edit.rhtml
index 32db15e..230ea06 100644
--- a/app/views/pages/edit.rhtml
+++ b/app/views/pages/edit.rhtml
@@ -3,16 +3,13 @@
<%= error_messages_for :page %>
<% form_for(:page, :url => page_path({ :id => @page.title_for_url }), :html => { :method => :put }) do |f| %>
-
- Title <%= text_field 'page', 'title' %>
-
-
- Description <%= text_area 'page', 'redcloth' %>
-
-
- <%= submit_tag "Update" %>
-
+<%= render :partial => 'page_form' %>
+
+ <%= submit_tag "Update" %>
+
<% end %>
-<%= link_to 'Show', page_path({ :id => @page.title_for_url }) %> |
-<%= link_to 'Back', pages_path %>
+<% content_for :sidebar do -%>
+ <%= link_to 'Show', page_path({ :id => @page.title_for_url }) %>
+ <%= link_to 'Browse Pages', pages_path %>
+<% end -%>
diff --git a/app/views/pages/index.rhtml b/app/views/pages/index.rhtml
index de5f585..1da608e 100644
--- a/app/views/pages/index.rhtml
+++ b/app/views/pages/index.rhtml
@@ -1 +1,5 @@
<%= render :partial => 'page' -%>
+
+<% content_for :sidebar do -%>
+ <%= link_to 'New Page', new_page_path -%>
+<% end -%>
diff --git a/app/views/pages/new.rhtml b/app/views/pages/new.rhtml
index fb82989..3df8b2c 100644
--- a/app/views/pages/new.rhtml
+++ b/app/views/pages/new.rhtml
@@ -3,9 +3,15 @@
<%= error_messages_for :page %>
<% form_for(:page, :url => pages_path) do |f| %>
-
- <%= submit_tag "Create" %>
-
+
+ Title <%= text_field 'page', 'title' %>
+
+<%= render :partial => 'page_form' %>
+
+ <%= submit_tag "Create" %>
+
<% end %>
-<%= link_to 'Back', pages_path %>
\ No newline at end of file
+<% content_for :sidebar do -%>
+ <%= link_to 'Browse Pages', pages_path %>
+<% end -%>
\ No newline at end of file
diff --git a/app/views/pages/show.rhtml b/app/views/pages/show.rhtml
index a38b777..c6b21e1 100644
--- a/app/views/pages/show.rhtml
+++ b/app/views/pages/show.rhtml
@@ -1,4 +1,6 @@
<%= render :partial => 'page' %>
-<%= link_to 'Edit', edit_page_path({ :id => @page.title_for_url }) %> |
-<%= link_to 'Back', pages_path %>
+<% content_for :sidebar do -%>
+ <%= link_to 'Edit Page', edit_page_path({ :id => @page.title_for_url }) %>
+ <%= link_to 'Browse Pages', pages_path %>
+<% end -%>