2011-03-27 23:49:12 +00:00
|
|
|
require 'bushido'
|
2011-04-01 00:34:19 +00:00
|
|
|
require 'locomotive/hosting/bushido/custom_domain'
|
2011-04-05 00:18:17 +00:00
|
|
|
require 'locomotive/hosting/bushido/first_installation'
|
2011-03-27 23:49:12 +00:00
|
|
|
|
|
|
|
module Locomotive
|
2011-04-01 00:34:19 +00:00
|
|
|
module Hosting
|
2011-03-27 23:49:12 +00:00
|
|
|
module Bushido
|
|
|
|
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
class << self
|
|
|
|
attr_accessor :bushido_domains
|
|
|
|
attr_accessor :bushido_subdomain
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module ClassMethods
|
|
|
|
|
|
|
|
def bushido?
|
2011-04-01 00:34:19 +00:00
|
|
|
self.config.hosting == :bushido ||
|
2011-04-06 09:44:52 +00:00
|
|
|
(self.config.hosting == :auto && ENV['APP_TLD'] == 'bushi.do')
|
2011-03-27 23:49:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def enable_bushido
|
2011-04-05 00:18:17 +00:00
|
|
|
self.config.domain = ENV['APP_TLD'] unless self.config.multi_sites?
|
2011-04-01 00:34:19 +00:00
|
|
|
|
2011-04-03 23:59:41 +00:00
|
|
|
self.enhance_site_model_with_bushido
|
2011-03-27 23:49:12 +00:00
|
|
|
|
|
|
|
self.bushido_domains = ::Bushido::App.domains
|
|
|
|
self.bushido_subdomain = ::Bushido::App.subdomain
|
|
|
|
end
|
|
|
|
|
2011-04-03 23:59:41 +00:00
|
|
|
def enhance_site_model_with_bushido
|
2011-04-01 00:34:19 +00:00
|
|
|
Site.send :include, Locomotive::Hosting::Bushido::CustomDomain
|
2011-04-05 00:18:17 +00:00
|
|
|
Site.send :include, Locomotive::Hosting::Bushido::FirstInstallation
|
2011-03-27 23:49:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# manage domains
|
|
|
|
|
|
|
|
def add_bushido_domain(name)
|
|
|
|
Locomotive.logger "[add bushido domain] #{name}"
|
|
|
|
::Bushido::App.add_domain(name)
|
2011-04-24 23:21:38 +00:00
|
|
|
|
2011-03-27 23:49:12 +00:00
|
|
|
if ::Bushido::Command.last_command_successful?
|
|
|
|
self.bushido_domains << name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_bushido_domain(name)
|
|
|
|
Locomotive.logger "[remove bushido domain] #{name}"
|
|
|
|
::Bushido::App.remove_domain(name)
|
2011-04-24 23:21:38 +00:00
|
|
|
|
2011-03-27 23:49:12 +00:00
|
|
|
if ::Bushido::Command.last_command_successful?
|
|
|
|
self.bushido_domains.delete(name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_bushido_subdomain(name)
|
|
|
|
Locomotive.logger "[set bushido subdomain] #{name}.bushi.do"
|
|
|
|
::Bushido::App.set_subdomain(name)
|
|
|
|
|
|
|
|
if ::Bushido::Command.last_command_successful?
|
|
|
|
self.bushido_subdomain = name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|