2010-05-10 22:39:52 +00:00
|
|
|
module Admin
|
|
|
|
class CurrentSitesController < 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
|
|
|
|
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|
|
|
|
|
success.html { redirect_to edit_admin_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
|