diff --git a/app/controllers/api/v1/sites_controller.rb b/app/controllers/api/v1/sites_controller.rb index 18550fe..fcf694e 100644 --- a/app/controllers/api/v1/sites_controller.rb +++ b/app/controllers/api/v1/sites_controller.rb @@ -8,7 +8,8 @@ module Api password: ENV['HTTP_BASIC_PASSWORD'] def index - render json: Site.all.order(:name).pluck(:name) + render json: Site.all.order(:name).pluck(:name) + + DeployAlternativeDomain.all.map(&:hostname) end # Detecta si se puede generar un certificado diff --git a/app/models/deploy_alternative_domain.rb b/app/models/deploy_alternative_domain.rb new file mode 100644 index 0000000..e4960e6 --- /dev/null +++ b/app/models/deploy_alternative_domain.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +# Soportar dominios alternativos +class DeployAlternativeDomain < Deploy + store :values, accessors: %i[hostname], coder: JSON + + # Generar un link simbólico del sitio principal al alternativo + def deploy + File.symlink?(destination) || + File.symlink(site.hostname, destination).zero? + end + + # No hay límite para los dominios alternativos + def limit; end + + def size + File.size destination + end + + def destination + File.join(Rails.root, '_deploy', hostname.gsub(/\.\z/, '')) + end +end