5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 09:16:22 +00:00

Merge branch 'informative-deploys' into panel.sutty.nl

This commit is contained in:
f 2022-04-06 20:08:28 -03:00
commit 4c3e56ac60
12 changed files with 52 additions and 10 deletions

View file

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

View file

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

View file

@ -18,6 +18,10 @@ class DeployAlternativeDomain < Deploy
end end
def destination 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
end end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,10 +8,15 @@
%tr %tr
%th= t('.th.type') %th= t('.th.type')
%th= t('.th.status') %th= t('.th.status')
%th= t('.th.url')
%th= t('.th.seconds')
%tbody %tbody
- @deploys.each do |deploy, value| - @deploys.each_pair do |deploy, value|
%tr %tr
%td= t(".#{deploy}.title") %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] = sanitize_markdown t('.help'), tags: %w[p a strong em]

View file

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

View file

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

View file

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