Arreglar vistas

This commit is contained in:
f 2021-08-01 22:05:59 -03:00
parent 2be57ad3af
commit bb2697f63e
10 changed files with 21 additions and 33 deletions

View file

@ -4,6 +4,8 @@
class DeployJob < ApplicationJob class DeployJob < ApplicationJob
class DeployException < StandardError; end class DeployException < StandardError; end
attr_reader :site
# rubocop:disable Metrics/MethodLength # rubocop:disable Metrics/MethodLength
def perform(site, notify = true) def perform(site, notify = true)
ActiveRecord::Base.connection_pool.with_connection do ActiveRecord::Base.connection_pool.with_connection do
@ -17,9 +19,9 @@ 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: site.deploy_local.deploy }
# No es opcional # TODO: No es opcional?
unless @deployed[:deploy_local] unless @deployed[:deploy_local]
@site.update status: 'waiting' @site.update status: 'waiting'
notify_usuaries if notify notify_usuaries if notify
@ -37,14 +39,6 @@ class DeployJob < ApplicationJob
private private
def deploy_local
@deploy_local ||= @site.deploys.find_by(type: 'DeployLocal')
end
def deploy_locally
deploy_local.deploy
end
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 @deployed[d.type.underscore.to_sym] = d.deploy

View file

@ -13,7 +13,7 @@ class DeployMailer < ApplicationMailer
@usuarie = Usuarie.find(params[:usuarie]) @usuarie = Usuarie.find(params[:usuarie])
@site = @usuarie.sites.find(params[:site]) @site = @usuarie.sites.find(params[:site])
@deploys = which_ones @deploys = which_ones
@deploy_local = @site.deploys.find_by(type: 'DeployLocal') @deploy_local = @site.deploy_local
# Informamos a cada quien en su idioma y damos una dirección de # Informamos a cada quien en su idioma y damos una dirección de
# respuesta porque a veces les usuaries nos escriben # respuesta porque a veces les usuaries nos escriben

View file

@ -1,6 +1,6 @@
%h1= t('.hi') %h1= t('.hi')
= sanitize_markdown t('.explanation', fqdn: @deploy_local.site.hostname), = sanitize_markdown t('.explanation', url: @site.deploy_local.url),
tags: %w[p a strong em] tags: %w[p a strong em]
%table %table

View file

@ -1,6 +1,6 @@
= '# ' + t('.hi') = '# ' + t('.hi')
\ \
= t('.explanation', fqdn: @deploy_local.site.hostname) = t('.explanation', url: @site.deploy_local.url)
\ \
= Terminal::Table.new do |table| = Terminal::Table.new do |table|
- table << [t('.th.type'), t('.th.status')] - table << [t('.th.type'), t('.th.status')]

View file

@ -14,10 +14,9 @@
'0', '1' '0', '1'
= deploy.label :_destroy, class: 'custom-control-label' do = deploy.label :_destroy, class: 'custom-control-label' do
%h3= t('.title') %h3= t('.title')
= sanitize_markdown t('.help', public_url: deploy.object.site.url), = sanitize_markdown t('.help', public_url: site.deploy_local.url),
tags: %w[p strong em a] tags: %w[p strong em a]
- if deploy.object.fqdn = sanitize_markdown t('.help_2', url: deploy.object.url),
= sanitize_markdown t('.help_2', url: deploy.object.url), tags: %w[p strong em a]
tags: %w[p strong em a]
%hr/ %hr/

View file

@ -6,7 +6,7 @@
.row .row
.col .col
%h3= t('.title') %h3= t('.title')
= sanitize_markdown t('.help', fqdn: deploy.object.site.hostname), = sanitize_markdown t('.help', url: deploy.object.url),
tags: %w[p strong em a] tags: %w[p strong em a]
= deploy.hidden_field :type = deploy.hidden_field :type

View file

@ -15,6 +15,6 @@
'0', '1' '0', '1'
= deploy.label :_destroy, class: 'custom-control-label' do = deploy.label :_destroy, class: 'custom-control-label' do
%h3= t('.title') %h3= t('.title')
= sanitize_markdown t('.help', fqdn: deploy.object.fqdn), = sanitize_markdown t('.help', url: deploy.object.url),
tags: %w[p strong em a] tags: %w[p strong em a]
%hr/ %hr/

View file

@ -15,10 +15,5 @@
'0', '1' '0', '1'
= deploy.label :_destroy, class: 'custom-control-label' do = deploy.label :_destroy, class: 'custom-control-label' do
%h3= t('.title') %h3= t('.title')
-# TODO: secar la generación de URLs = sanitize_markdown t('.help', url: deploy.object.url), tags: %w[p strong em a]
- name = site.name || t('.ejemplo')
= sanitize_markdown t('.help',
fqdn: deploy.object.site.hostname,
file: deploy.object.file || "#{name}.zip"),
tags: %w[p strong em a]
%hr/ %hr/

View file

@ -70,7 +70,7 @@ en:
hi: "Hi!" hi: "Hi!"
explanation: | explanation: |
This e-mail is to notify you that Sutty has built your site, which is This e-mail is to notify you that Sutty has built your site, which is
available at <https://%{fqdn}>. available at <%{url}/>.
You'll find details below. You'll find details below.
th: th:
@ -195,7 +195,7 @@ en:
deploy_local: deploy_local:
title: 'Host at Sutty' title: 'Host at Sutty'
help: | help: |
The site will be available at <https://%{fqdn}/>. The site will be available at <%{url}/>.
We're working out the details to allow you to use your own site We're working out the details to allow you to use your own site
domains, you can [help us](https://sutty.nl/en/index.html#contact)! domains, you can [help us](https://sutty.nl/en/index.html#contact)!
@ -211,7 +211,7 @@ en:
title: 'Add www to the address' title: 'Add www to the address'
help: | help: |
When you enable this option, your site will also be available When you enable this option, your site will also be available
under <https://%{fqdn}/>. under <%{url}/>.
The www prefix has been a way of referring to The www prefix has been a way of referring to
computers that are available on the World Wide Web. Since computers that are available on the World Wide Web. Since
@ -222,7 +222,7 @@ en:
help: | help: |
ZIP files contain and compress all your site's files. With ZIP files contain and compress all your site's files. With
this option you can download and also share your entire site this option you can download and also share your entire site
through the <https://%{fqdn}/%{file}> address, keep it as backup through the <%{url}> address, keep it as backup
or have a strategy of solidary hosting, where many people or have a strategy of solidary hosting, where many people
share a copy of your site. share a copy of your site.

View file

@ -70,7 +70,7 @@ es:
hi: "¡Hola!" hi: "¡Hola!"
explanation: | explanation: |
Este correo es para notificarte que Sutty ha generado tu sitio y Este correo es para notificarte que Sutty ha generado tu sitio y
ya está disponible en la dirección <https://%{fqdn}>. ya está disponible en la dirección <%{url}>.
A continuación encontrarás el detalle de lo que hicimos. A continuación encontrarás el detalle de lo que hicimos.
th: th:
@ -197,7 +197,7 @@ es:
deploy_local: deploy_local:
title: 'Alojar en Sutty' title: 'Alojar en Sutty'
help: | help: |
El sitio estará disponible en <https://%{fqdn}/>. El sitio estará disponible en <%{url}/>.
Estamos desarrollando la posibilidad de agregar tus propios Estamos desarrollando la posibilidad de agregar tus propios
dominios, ¡ayudanos! dominios, ¡ayudanos!
@ -213,7 +213,7 @@ es:
title: 'Agregar www a la dirección' title: 'Agregar www a la dirección'
help: | help: |
Cuando habilitas esta opción, tu sitio también estará disponible Cuando habilitas esta opción, tu sitio también estará disponible
como <https://%{fqdn}/>. como <%{url}/>.
El prefijo www para las direcciones web ha sido una forma de El prefijo www para las direcciones web ha sido una forma de
referirse a las computadoras que están disponibles en la _World referirse a las computadoras que están disponibles en la _World
@ -226,7 +226,7 @@ es:
help: | help: |
Los archivos ZIP contienen y comprimen todos los archivos de tu Los archivos ZIP contienen y comprimen todos los archivos de tu
sitio. Con esta opción podrás descargar y compartir tu sitio sitio. Con esta opción podrás descargar y compartir tu sitio
entero a través de la dirección <https://%{fqdn}/%{file}> y entero a través de la dirección <%{url}> y
guardarla como copia de seguridad o una estrategia de guardarla como copia de seguridad o una estrategia de
alojamiento solidario, donde muchas personas comparten una copia alojamiento solidario, donde muchas personas comparten una copia
de tu sitio. de tu sitio.