From bb2697f63ef467b7b8398f41b01388f61a83ed3b Mon Sep 17 00:00:00 2001 From: f Date: Sun, 1 Aug 2021 22:05:59 -0300 Subject: [PATCH] Arreglar vistas --- app/jobs/deploy_job.rb | 14 ++++---------- app/mailers/deploy_mailer.rb | 2 +- app/views/deploy_mailer/deployed.html.haml | 2 +- app/views/deploy_mailer/deployed.text.haml | 2 +- app/views/deploys/_deploy_hidden_service.haml | 7 +++---- app/views/deploys/_deploy_local.haml | 2 +- app/views/deploys/_deploy_www.haml | 2 +- app/views/deploys/_deploy_zip.haml | 7 +------ config/locales/en.yml | 8 ++++---- config/locales/es.yml | 8 ++++---- 10 files changed, 21 insertions(+), 33 deletions(-) diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index f1ceca9..bb8c301 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -4,6 +4,8 @@ class DeployJob < ApplicationJob class DeployException < StandardError; end + attr_reader :site + # rubocop:disable Metrics/MethodLength def perform(site, notify = true) ActiveRecord::Base.connection_pool.with_connection do @@ -17,9 +19,9 @@ class DeployJob < ApplicationJob @site.update status: 'building' # 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] @site.update status: 'waiting' notify_usuaries if notify @@ -37,14 +39,6 @@ class DeployJob < ApplicationJob private - def deploy_local - @deploy_local ||= @site.deploys.find_by(type: 'DeployLocal') - end - - def deploy_locally - deploy_local.deploy - end - def deploy_others @site.deploys.where.not(type: 'DeployLocal').find_each do |d| @deployed[d.type.underscore.to_sym] = d.deploy diff --git a/app/mailers/deploy_mailer.rb b/app/mailers/deploy_mailer.rb index 1d0c730..03d72d4 100644 --- a/app/mailers/deploy_mailer.rb +++ b/app/mailers/deploy_mailer.rb @@ -13,7 +13,7 @@ class DeployMailer < ApplicationMailer @usuarie = Usuarie.find(params[:usuarie]) @site = @usuarie.sites.find(params[:site]) @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 # respuesta porque a veces les usuaries nos escriben diff --git a/app/views/deploy_mailer/deployed.html.haml b/app/views/deploy_mailer/deployed.html.haml index e8b2e7a..40c6a98 100644 --- a/app/views/deploy_mailer/deployed.html.haml +++ b/app/views/deploy_mailer/deployed.html.haml @@ -1,6 +1,6 @@ %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] %table diff --git a/app/views/deploy_mailer/deployed.text.haml b/app/views/deploy_mailer/deployed.text.haml index 53a9b00..83696b0 100644 --- a/app/views/deploy_mailer/deployed.text.haml +++ b/app/views/deploy_mailer/deployed.text.haml @@ -1,6 +1,6 @@ = '# ' + t('.hi') \ -= t('.explanation', fqdn: @deploy_local.site.hostname) += t('.explanation', url: @site.deploy_local.url) \ = Terminal::Table.new do |table| - table << [t('.th.type'), t('.th.status')] diff --git a/app/views/deploys/_deploy_hidden_service.haml b/app/views/deploys/_deploy_hidden_service.haml index d638812..38b33b5 100644 --- a/app/views/deploys/_deploy_hidden_service.haml +++ b/app/views/deploys/_deploy_hidden_service.haml @@ -14,10 +14,9 @@ '0', '1' = deploy.label :_destroy, class: 'custom-control-label' do %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] - - if deploy.object.fqdn - = sanitize_markdown t('.help_2', url: deploy.object.url), - tags: %w[p strong em a] + = sanitize_markdown t('.help_2', url: deploy.object.url), + tags: %w[p strong em a] %hr/ diff --git a/app/views/deploys/_deploy_local.haml b/app/views/deploys/_deploy_local.haml index 69a6a52..c60165f 100644 --- a/app/views/deploys/_deploy_local.haml +++ b/app/views/deploys/_deploy_local.haml @@ -6,7 +6,7 @@ .row .col %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] = deploy.hidden_field :type diff --git a/app/views/deploys/_deploy_www.haml b/app/views/deploys/_deploy_www.haml index 9cf186a..5e4a08e 100644 --- a/app/views/deploys/_deploy_www.haml +++ b/app/views/deploys/_deploy_www.haml @@ -15,6 +15,6 @@ '0', '1' = deploy.label :_destroy, class: 'custom-control-label' do %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] %hr/ diff --git a/app/views/deploys/_deploy_zip.haml b/app/views/deploys/_deploy_zip.haml index c158892..5071e3a 100644 --- a/app/views/deploys/_deploy_zip.haml +++ b/app/views/deploys/_deploy_zip.haml @@ -15,10 +15,5 @@ '0', '1' = deploy.label :_destroy, class: 'custom-control-label' do %h3= t('.title') - -# TODO: secar la generación de URLs - - 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] + = sanitize_markdown t('.help', url: deploy.object.url), tags: %w[p strong em a] %hr/ diff --git a/config/locales/en.yml b/config/locales/en.yml index fc194ea..25b662b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -70,7 +70,7 @@ en: hi: "Hi!" explanation: | This e-mail is to notify you that Sutty has built your site, which is - available at . + available at <%{url}/>. You'll find details below. th: @@ -195,7 +195,7 @@ en: deploy_local: title: 'Host at Sutty' help: | - The site will be available at . + The site will be available at <%{url}/>. 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)! @@ -211,7 +211,7 @@ en: title: 'Add www to the address' help: | When you enable this option, your site will also be available - under . + under <%{url}/>. The www prefix has been a way of referring to computers that are available on the World Wide Web. Since @@ -222,7 +222,7 @@ en: help: | ZIP files contain and compress all your site's files. With this option you can download and also share your entire site - through the address, keep it as backup + through the <%{url}> address, keep it as backup or have a strategy of solidary hosting, where many people share a copy of your site. diff --git a/config/locales/es.yml b/config/locales/es.yml index e818539..eac8a49 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -70,7 +70,7 @@ es: hi: "¡Hola!" explanation: | Este correo es para notificarte que Sutty ha generado tu sitio y - ya está disponible en la dirección . + ya está disponible en la dirección <%{url}>. A continuación encontrarás el detalle de lo que hicimos. th: @@ -197,7 +197,7 @@ es: deploy_local: title: 'Alojar en Sutty' help: | - El sitio estará disponible en . + El sitio estará disponible en <%{url}/>. Estamos desarrollando la posibilidad de agregar tus propios dominios, ¡ayudanos! @@ -213,7 +213,7 @@ es: title: 'Agregar www a la dirección' help: | Cuando habilitas esta opción, tu sitio también estará disponible - como . + como <%{url}/>. El prefijo www para las direcciones web ha sido una forma de referirse a las computadoras que están disponibles en la _World @@ -226,7 +226,7 @@ es: help: | Los archivos ZIP contienen y comprimen todos los archivos de tu sitio. Con esta opción podrás descargar y compartir tu sitio - entero a través de la dirección y + entero a través de la dirección <%{url}> y guardarla como copia de seguridad o una estrategia de alojamiento solidario, donde muchas personas comparten una copia de tu sitio.