2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive
|
2011-07-06 18:48:04 +00:00
|
|
|
class CurrentSiteController < BaseController
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-12-14 17:00:12 +00:00
|
|
|
defaults :instance_name => 'site'
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
sections 'settings', 'site'
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
actions :edit, :update
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-06-26 23:02:48 +00:00
|
|
|
skip_load_and_authorize_resource
|
|
|
|
|
|
|
|
load_and_authorize_resource :class => 'Site'
|
|
|
|
|
2010-07-13 20:01:40 +00:00
|
|
|
respond_to :json, :only => :update
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def update
|
2010-07-13 00:46:17 +00:00
|
|
|
update! do |success, failure|
|
2011-10-31 23:44:23 +00:00
|
|
|
success.html { redirect_to edit_current_site_url(new_host_if_subdomain_changed) }
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
protected
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
def resource
|
|
|
|
@site = current_site
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def new_host_if_subdomain_changed
|
2011-04-24 23:21:38 +00:00
|
|
|
if !Locomotive.config.manage_subdomain? || @site.domains.include?(request.host)
|
2010-05-10 22:39:52 +00:00
|
|
|
{}
|
|
|
|
else
|
2011-04-24 23:21:38 +00:00
|
|
|
{ :host => site_url(@site, { :fullpath => false, :protocol => false }) }
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|