diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
new file mode 100644
index 0000000..fa21b58
--- /dev/null
+++ b/app/controllers/help_controller.rb
@@ -0,0 +1,104 @@
+class HelpController < ApplicationController
+ append_before_filter :fetch_page, :only => [ :show, :edit, :update, :destroy ]
+
+ # GET /helps
+ # GET /helps.xml
+ def index
+ @page = Page.find_by_title_and_owner_type 'HomePage', 'Help'
+ @content_title = 'BarleySodas Help'
+ @secondary_title = ''
+ @tags = Page.tags(:limit => 25, :order => 'name DESC',
+ :owner_type => 'Help')
+ end
+
+ # GET /helps/1
+ # GET /helps/1.xml
+ def show
+ @secondary_title = ''
+ respond_to do |format|
+ format.html # show.rhtml
+ format.xml { render :xml => @page.to_xml }
+ end
+ end
+
+ # GET /helps/new
+ def new
+ @page = Page.new
+ @secondary_title = 'Creating help page'
+ end
+
+ # GET /helps/1;edit
+ def edit
+ @secondary_title = 'Updating help page'
+ end
+
+ # POST /helps
+ # POST /helps.xml
+ def create
+ @page = Page.new(params[:page])
+ @page.owner_type = 'Help'
+ respond_to do |format|
+ if @page.save
+ flash[:notice] = 'Help was successfully created.'
+ format.html {
+ if @page.title == 'HomePage'
+ redirect_to :controller => 'help', :action => 'index'
+ else
+ redirect_to help_url({ :id => @page.title_for_url })
+ end
+ }
+ format.xml { head :created,
+ :location => help_url({ :id => @page.title_for_url }) }
+ else
+ format.html {
+ @secondary_title = 'Creating help page'
+ render :action => "new"
+ }
+ format.xml { render :xml => @page.errors.to_xml }
+ end
+ end
+ end
+
+ # PUT /helps/1
+ # PUT /helps/1.xml
+ def update
+ @page.attributes = params[:page]
+ respond_to do |format|
+ if @page.save
+ flash[:notice] = 'Help was successfully updated.'
+ format.html {
+ if @page.title == 'HomePage'
+ redirect_to :controller => 'help', :action => 'index'
+ else
+ redirect_to help_url({ :id => @page.title_for_url })
+ end
+ }
+ format.xml { head :ok }
+ else
+ format.html {
+ @secondary_title = 'Updating help page'
+ render :action => "edit"
+ }
+ format.xml { render :xml => @page.errors.to_xml, :status => 400 }
+ end
+ end
+ end
+
+ # DELETE /helps/1
+ # DELETE /helps/1.xml
+ def destroy
+ @page.destroy
+ respond_to do |format|
+ format.html { redirect_to :controller => 'help', :action => 'index' }
+ format.xml { head :ok }
+ end
+ end
+
+ protected
+
+ def fetch_page
+ @page = Page.find_by_title_and_owner_type(Page.title_from_url(params[:id]),
+ 'Help')
+ raise ActiveRecord::RecordNotFound.new if @page.nil?
+ end
+end
diff --git a/app/helpers/help_helper.rb b/app/helpers/help_helper.rb
new file mode 100644
index 0000000..ba75291
--- /dev/null
+++ b/app/helpers/help_helper.rb
@@ -0,0 +1,11 @@
+module HelpHelper
+ def show_help_link(page, better_title = 'Show')
+ link_to better_title, help_path({ :id => page.title_for_url }),
+ { :title => page.title }
+ end
+
+ def edit_help_link(page)
+ link_to 'Edit Help Page', edit_help_path({ :id => page.title_for_url }),
+ { :title => "Edit Help Page #{page.title}" }
+ end
+end
diff --git a/app/views/help/edit.rhtml b/app/views/help/edit.rhtml
new file mode 100644
index 0000000..c02a020
--- /dev/null
+++ b/app/views/help/edit.rhtml
@@ -0,0 +1,12 @@
+<%= error_messages_for :page %>
+
+<% form_for(:help, :url => help_path({ :id => @page.title_for_url }), :html => { :method => :put }) do |f| %>
+ <%= render :partial => 'pages/page_form' %>
+
+ <%= submit_tag "Update" %>
+
+<% end %>
+
+<% content_for :sidebar do -%>
+ <%= show_help_link(@page) unless @page.title == 'HomePage' -%>
+<% end -%>
\ No newline at end of file
diff --git a/app/views/help/index.rhtml b/app/views/help/index.rhtml
new file mode 100644
index 0000000..dba66f8
--- /dev/null
+++ b/app/views/help/index.rhtml
@@ -0,0 +1,6 @@
+<%= render :partial => 'pages/page' -%>
+
+<% content_for :sidebar do -%>
+ <%= edit_help_link(@page) -%>
+ <%= render :partial => 'shared/tag_cloud' %>
+<% end -%>
\ No newline at end of file
diff --git a/app/views/help/new.rhtml b/app/views/help/new.rhtml
new file mode 100644
index 0000000..2dcba1d
--- /dev/null
+++ b/app/views/help/new.rhtml
@@ -0,0 +1,11 @@
+<%= error_messages_for :page %>
+
+<% form_for(:help, :url => { :controller => 'help', :action => 'index' }, :html => { :method => :post }) do |f| %>
+
+ <%= text_field 'page', 'title' %>
+
+ <%= render :partial => 'pages/page_form' %>
+
+ <%= submit_tag "Create" %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/help/show.rhtml b/app/views/help/show.rhtml
new file mode 100644
index 0000000..7064640
--- /dev/null
+++ b/app/views/help/show.rhtml
@@ -0,0 +1,6 @@
+<%= render :partial => 'pages/page' %>
+
+<% content_for :sidebar do -%>
+ <%= edit_help_link(@page) -%>
+ <%= link_to 'Destroy', help_path(@page.title_for_url), :confirm => 'Are you sure?', :method => :delete unless @page.title == 'HomePage' -%>
+<% end -%>
\ No newline at end of file
diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml
index f591c84..134dc70 100644
--- a/app/views/layouts/application.rhtml
+++ b/app/views/layouts/application.rhtml
@@ -38,6 +38,7 @@
<%= link_to_unless_current 'Discussions', discussions_path -%>
<%= link_to_unless_current 'Peoples', peoples_path -%>
<%= link_to_unless_current 'Roles', roles_path -%>
+ <%= link_to_unless_current 'Help', :controller => 'help', :action => 'index' -%>
<% unless logged_in? -%><%= link_to_unless_current 'Login', new_session_path -%><% else -%><%= link_to 'Logout', session_path(:id => session[:people_title]), :method => :delete -%><% end %>
<%= yield :sidebar %>
diff --git a/config/routes.rb b/config/routes.rb
index 79db361..28d35e9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,6 +1,6 @@
ActionController::Routing::Routes.draw do |map|
map.resources :beers, :breweries, :pages, :discussions, :peoples, :roles,
- :sessions
+ :sessions, :help
map.connect ':controller/:action/:id.:format'
map.connect ':controller/:action/:id'
diff --git a/db/migrate/011_help_start_page.rb b/db/migrate/011_help_start_page.rb
new file mode 100644
index 0000000..acae868
--- /dev/null
+++ b/db/migrate/011_help_start_page.rb
@@ -0,0 +1,21 @@
+class HelpStartPage < ActiveRecord::Migration
+ def self.up
+redcloths = "
+h1. Thanks for using BarleySodas
+
+Please check out these topics for more specialized information.
+
+* [[Peoples]]
+* [[Beers]]
+* [[Breweries]]
+* [[Discussions]]
+* [[Pages]]
+* [[Sessions]]
+"
+ Page.create :title => 'HomePage', :owner_type => 'Help', :redcloth => redcloths
+ end
+
+ def self.down
+ Page.destroy_all("owner_type = 'Help'")
+ end
+end
diff --git a/generate_permissions b/generate_permissions
index 9471bf2..a0a9335 100644
--- a/generate_permissions
+++ b/generate_permissions
@@ -5,7 +5,7 @@ base_actions = ApplicationController.action_methods
# rather than defining them here.
controllers = [ AutocompleteController, SessionsController, PagesController,
PeoplesController, BeersController, BreweriesController, RolesController,
- DiscussionsController ]
+ DiscussionsController, HelpController ]
controllers.each do |c|
actions = c.action_methods - base_actions
cname = c.controller_name
diff --git a/test/functional/help_controller_test.rb b/test/functional/help_controller_test.rb
new file mode 100644
index 0000000..3081c2e
--- /dev/null
+++ b/test/functional/help_controller_test.rb
@@ -0,0 +1,57 @@
+require File.dirname(__FILE__) + '/../test_helper'
+require 'helps_controller'
+
+# Re-raise errors caught by the controller.
+class HelpController; def rescue_action(e) raise e end; end
+
+class HelpControllerTest < Test::Unit::TestCase
+ fixtures :helps
+
+ def setup
+ @controller = HelpController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_should_get_index
+ get :index
+ assert_response :success
+ assert assigns(:helps)
+ end
+
+ def test_should_get_new
+ get :new
+ assert_response :success
+ end
+
+ def test_should_create_help
+ old_count = Help.count
+ post :create, :help => { }
+ assert_equal old_count+1, Help.count
+
+ assert_redirected_to help_path(assigns(:help))
+ end
+
+ def test_should_show_help
+ get :show, :id => 1
+ assert_response :success
+ end
+
+ def test_should_get_edit
+ get :edit, :id => 1
+ assert_response :success
+ end
+
+ def test_should_update_help
+ put :update, :id => 1, :help => { }
+ assert_redirected_to help_path(assigns(:help))
+ end
+
+ def test_should_destroy_help
+ old_count = Help.count
+ delete :destroy, :id => 1
+ assert_equal old_count-1, Help.count
+
+ assert_redirected_to helps_path
+ end
+end