You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
12 years ago
|
class Public::PagesController < PublicController
|
||
13 years ago
|
|
||
|
rescue_from ActionView::MissingTemplate do |exception|
|
||
|
if exception.message =~ %r{Missing template pages/}
|
||
|
raise ActionController::RoutingError, "No such page: #{params[:id]}"
|
||
|
else
|
||
|
raise exception
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def show
|
||
13 years ago
|
return redirect_to(domains_path) if user_signed_in? && params[:id] == "home"
|
||
13 years ago
|
|
||
|
options = {template: current_page}
|
||
|
case params[:id]
|
||
|
when "contact"
|
||
13 years ago
|
init = user_signed_in? ? {:name => current_user.name, :email => current_user.email} : {}
|
||
|
@contact_form = ContactForm.new(init)
|
||
13 years ago
|
when "home"
|
||
|
options[:layout] = 'home' unless request.xhr?
|
||
13 years ago
|
when "signed_out"
|
||
|
if user_signed_in?
|
||
|
flash[:warning] = "You are still authenticated"
|
||
|
redirect_to after_sign_in_path_for(current_user) and return
|
||
|
end
|
||
13 years ago
|
end
|
||
13 years ago
|
|
||
|
render options
|
||
13 years ago
|
end
|
||
|
|
||
|
def contact
|
||
|
@contact_form = ContactForm.new(params[:contact_form])
|
||
|
if !@contact_form.deliver
|
||
12 years ago
|
render :template => 'public/pages/contact'
|
||
13 years ago
|
else
|
||
13 years ago
|
redirect_to :back, :notice => 'Your notification has been sent!'
|
||
13 years ago
|
end
|
||
13 years ago
|
end
|
||
|
|
||
|
protected
|
||
13 years ago
|
|
||
|
def current_page
|
||
12 years ago
|
@current_page ||= "public/pages/#{clean_path}"
|
||
13 years ago
|
end
|
||
|
|
||
|
def clean_path
|
||
|
Pathname.new("/#{params[:id]}").cleanpath.to_s[1..-1]
|
||
|
end
|
||
|
|
||
13 years ago
|
end
|