diff --git a/app/views/admin/errors/no_page.html.haml b/app/views/admin/errors/no_page.html.haml new file mode 100644 index 00000000..d4948def --- /dev/null +++ b/app/views/admin/errors/no_page.html.haml @@ -0,0 +1 @@ +No Page! \ No newline at end of file diff --git a/app/views/admin/errors/no_site.html.haml b/app/views/admin/errors/no_site.html.haml new file mode 100644 index 00000000..5bee4fcc --- /dev/null +++ b/app/views/admin/errors/no_site.html.haml @@ -0,0 +1 @@ +No Site! \ No newline at end of file diff --git a/app/views/admin/layouts/error.html.haml b/app/views/admin/layouts/error.html.haml new file mode 100644 index 00000000..f1d0cc89 --- /dev/null +++ b/app/views/admin/layouts/error.html.haml @@ -0,0 +1 @@ += yield \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7578a6de..17847109 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,9 +1,9 @@ # Locomotive::Application.routes.draw do |map| Rails.application.routes.draw do - constraints(Locomotive::Routing::DefaultConstraint) do - root :to => 'home#show' - end + # constraints(Locomotive::Routing::DefaultConstraint) do + # root :to => 'home#show' + # end # admin authentication devise_for :admin, :class_name => 'Account', :controllers => { :sessions => 'admin/sessions', :passwords => 'admin/passwords' } diff --git a/lib/locomotive/render.rb b/lib/locomotive/render.rb index 5b98aa19..16ffa99a 100644 --- a/lib/locomotive/render.rb +++ b/lib/locomotive/render.rb @@ -13,7 +13,7 @@ module Locomotive else @page = locomotive_page - redirect_to application_root_url and return if @page.nil? + render_no_page_error and return if @page.nil? output = @page.render(locomotive_context) @@ -21,6 +21,10 @@ module Locomotive end end + def render_no_page_error + render :template => "/admin/errors/no_page", :layout => false + end + def locomotive_page path = (params[:path] || request.fullpath).clone path.gsub!(/\.[a-zA-Z][a-zA-Z0-9]{2,}$/, '') diff --git a/lib/locomotive/routing/site_dispatcher.rb b/lib/locomotive/routing/site_dispatcher.rb index 3836898f..9fa988f9 100644 --- a/lib/locomotive/routing/site_dispatcher.rb +++ b/lib/locomotive/routing/site_dispatcher.rb @@ -26,7 +26,11 @@ module Locomotive end def require_site - redirect_to application_root_url and return false if current_site.nil? + render_no_site_error and return false if current_site.nil? + end + + def render_no_site_error + render :template => "/admin/errors/no_site", :layout => false end def validate_site_membership @@ -34,10 +38,6 @@ module Locomotive sign_out_and_redirect(current_admin) end - def application_root_url - root_url(:host => Locomotive.config.default_domain, :port => request.port) - end - end end