permitir dominios alternativos #122

This commit is contained in:
f 2020-02-19 19:29:06 -03:00
parent 6e17a92711
commit 5392f9a942
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
2 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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