5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 14:21:41 +00:00

enviar más información

This commit is contained in:
f 2022-04-06 20:07:14 -03:00
parent d18293bea3
commit 87cdba9bec
12 changed files with 52 additions and 10 deletions

View file

@ -27,7 +27,13 @@ class DeployJob < ApplicationJob
@site.update status: 'building'
# Asegurarse que DeployLocal sea el primero!
@deployed = { deploy_local: deploy_locally }
@deployed = {
deploy_local: {
status: deploy_locally,
seconds: deploy_local.build_stats.last.seconds,
url: site.url
}
}
# No es opcional
unless @deployed[:deploy_local]
@ -60,7 +66,11 @@ class DeployJob < ApplicationJob
def deploy_others
@site.deploys.where.not(type: 'DeployLocal').find_each do |d|
@deployed[d.type.underscore.to_sym] = d.deploy
@deployed[d.type.underscore.to_sym] = {
status: d.deploy,
seconds: d.build_stats.last.seconds,
url: d.url
}
end
end

View file

@ -15,6 +15,10 @@ class Deploy < ApplicationRecord
raise NotImplementedError
end
def url
raise NotImplementedError
end
def limit
raise NotImplementedError
end

View file

@ -18,6 +18,10 @@ class DeployAlternativeDomain < Deploy
end
def destination
File.join(Rails.root, '_deploy', hostname.gsub(/\.\z/, ''))
@destination ||= File.join(Rails.root, '_deploy', hostname.gsub(/\.\z/, ''))
end
def url
"https://#{File.basename destination}"
end
end

View file

@ -13,6 +13,6 @@ class DeployHiddenService < DeployWww
end
def url
'http://' + fqdn
"http://#{fqdn}"
end
end

View file

@ -25,6 +25,10 @@ class DeployLocal < Deploy
1
end
def url
site.url
end
# Obtener el tamaño de todos los archivos y directorios (los
# directorios son archivos :)
def size

View file

@ -16,6 +16,10 @@ class DeployPrivate < DeployLocal
File.join(Rails.root, '_private', site.name)
end
def url
"#{ENV['PANEL_URL']}/sites/private/#{site.name}"
end
# No usar recursos en compresión y habilitar los datos privados
def env
@env ||= super.merge({

View file

@ -27,6 +27,10 @@ class DeployWww < Deploy
"www.#{site.hostname}"
end
def url
"https://www.#{site.hostname}/"
end
private
def remove_destination!

View file

@ -49,6 +49,10 @@ class DeployZip < Deploy
"#{site.hostname}.zip"
end
def url
"#{site.url}#{file}"
end
def path
File.join(destination, file)
end

View file

@ -8,10 +8,15 @@
%tr
%th= t('.th.type')
%th= t('.th.status')
%th= t('.th.url')
%th= t('.th.seconds')
%tbody
- @deploys.each do |deploy, value|
- @deploys.each_pair do |deploy, value|
%tr
%td= t(".#{deploy}.title")
%td= value ? t(".#{deploy}.success") : t(".#{deploy}.error")
%td= value[:status] ? t(".#{deploy}.success") : t(".#{deploy}.error")
%td= link_to value[:url], value[:url]
%td
%time{ datetime: "PT#{value[:seconds]}S" }= distance_of_time_in_words value[:seconds].seconds
= sanitize_markdown t('.help'), tags: %w[p a strong em]

View file

@ -3,10 +3,9 @@
= t('.explanation', fqdn: @deploy_local.site.hostname)
\
= Terminal::Table.new do |table|
- table << [t('.th.type'), t('.th.status')]
- table << [t('.th.type'), t('.th.status'), t('.th.url'), t('.th.seconds')]
- table.add_separator
- @deploys.each do |deploy, value|
- table << [t(".#{deploy}.title"),
value ? t(".#{deploy}.success") : t(".#{deploy}.error")]
- @deploys.each_pair do |deploy, value|
- table << [ t(".#{deploy}.title"), value[:status] ? t(".#{deploy}.success") : t(".#{deploy}.error"), value[:url], distance_of_time_in_words(value[:seconds].seconds) ]
\
= t('.help')

View file

@ -76,6 +76,8 @@ en:
th:
type: Type
status: Status
seconds: Duration
url: Address
deploy_local:
title: Build the site
success: Success!

View file

@ -76,6 +76,8 @@ es:
th:
type: Tipo
status: Estado
seconds: Duración
url: Dirección
deploy_local:
title: Generar el sitio
success: ¡Éxito!