From 0d0c8c8b073598d9a74114d8ec65923c90ab7e32 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 31 Mar 2023 19:31:22 -0300 Subject: [PATCH 1/9] =?UTF-8?q?fix:=20mostrar=20los=20dise=C3=B1os=20en=20?= =?UTF-8?q?dos=20columnas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/sites/_form.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/sites/_form.haml b/app/views/sites/_form.haml index 757b8b48..2d8ea4fb 100644 --- a/app/views/sites/_form.haml +++ b/app/views/sites/_form.haml @@ -53,10 +53,10 @@ = render 'bootstrap/alert' do = t('activerecord.errors.models.site.attributes.design_id.layout_incompatible.help', layouts: site.incompatible_layouts.to_sentence) - .row.designs + .row.row-cols-1.row-cols-md-2.designs -# Demasiado complejo para un f.collection_radio_buttons - Design.all.find_each do |design| - .design.col-md-4.d-flex.flex-column + .design.col.d-flex.flex-column .custom-control.custom-radio = f.radio_button :design_id, design.id, checked: design.id == site.design_id, From c2fafac7f0556c12015fb0bf8c102cc22c15723f Mon Sep 17 00:00:00 2001 From: f Date: Fri, 31 Mar 2023 19:32:36 -0300 Subject: [PATCH 2/9] feat: informar el estado del sitio #10492 --- app/models/site.rb | 1 + app/models/site/build_stats.rb | 45 ++++++++++++++++++++++++++++++++++ app/views/posts/index.haml | 4 ++- app/views/sites/_status.haml | 19 ++++++++++++++ config/locales/en.yml | 4 +++ config/locales/es.yml | 4 +++ 6 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 app/models/site/build_stats.rb create mode 100644 app/views/sites/_status.haml diff --git a/app/models/site.rb b/app/models/site.rb index 4b2a8eb9..6aa96612 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -7,6 +7,7 @@ class Site < ApplicationRecord include Site::Forms include Site::FindAndReplace include Site::Api + include Site::BuildStats include Tienda # Cifrar la llave privada que cifra y decifra campos ocultos. Sutty diff --git a/app/models/site/build_stats.rb b/app/models/site/build_stats.rb new file mode 100644 index 00000000..8b23942d --- /dev/null +++ b/app/models/site/build_stats.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +class Site + module BuildStats + extend ActiveSupport::Concern + + included do + # Devuelve el tiempo promedio de publicación para este sitio + # + # @return [Integer] + def average_publication_time + build_stats.group(:action).average(:seconds).values.reduce(:+).round + end + + # Devuelve el tiempo promedio de compilación para sitios similares + # a este. + # + # @return [Integer] + def average_publication_time_for_similar_sites + similar_deploys = Deploy.where(type: deploys.pluck(:type)).pluck(:id) + + BuildStat.where(deploy_id: similar_deploys).group(:action).average(:seconds).values.reduce(:+).round + end + + # Define si podemos calcular el tiempo promedio de publicación + # para este sitio + # + # @return [Boolean] + def average_publication_time_calculable? + build_stats.jekyll.where(status: true).count > 0 + end + + def similar_sites? + !design.no_theme? + end + + # Detecta si el sitio todavía no ha sido publicado + # + # @return [Boolean] + def not_published_yet? + build_stats.jekyll.where(status: true).count.zero? + end + end + end +end diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index dbeddaad..f7b884af 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -1,7 +1,9 @@ %main.row %aside.menu.col-md-3 - %h1= link_to @site.title, @site.url + %h1= @site.title %p.lead= @site.description + - cache_if @usuarie, [@site, I18n.locale] do + = render 'sites/status', site: @site %h3= t('posts.new') %table.mb-3 diff --git a/app/views/sites/_status.haml b/app/views/sites/_status.haml new file mode 100644 index 00000000..fb38896a --- /dev/null +++ b/app/views/sites/_status.haml @@ -0,0 +1,19 @@ +- link = nil +- if site.not_published_yet? + - message = t('.not_published_yet') +- if site.building? + - if site.average_publication_time_calculable? + - average_building_time = site.average_building_time + - elsif !site.similar_sites? + - average_building_time = 60 + - else + - average_building_time = site.average_publication_time_for_similar_sites + + - average_publication_time_human = distance_of_time_in_words average_building_time + - message = t('.building', average_time: average_publication_time_human, seconds: average_building_time) +- else + - message = t('.available') + - link = true + += render 'bootstrap/alert' do + = link_to_if link, message.html_safe, site.url diff --git a/config/locales/en.yml b/config/locales/en.yml index 567ab6bb..ee16f506 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -330,6 +330,10 @@ en: designer_url: 'Support the designer' static_file_migration: 'File migration' find_and_replace: 'Search and replace' + status: + building: "Your site is building, please wait ..." + not_published_yet: "Your site is being published for the first time, please wait up to 1 minute..." + available: "Your site is available! Click here to visit it." index: title: 'My Sites' pull: 'Upgrade' diff --git a/config/locales/es.yml b/config/locales/es.yml index 0a829e4a..e3d3f2ef 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -335,6 +335,10 @@ es: designer_url: 'Apoyá a le(s) diseñadore(s)' static_file_migration: 'Migración de archivos' find_and_replace: 'Búsqueda y reemplazo' + status: + building: "Tu sitio se está publicando, por favor espera ..." + not_published_yet: "Tu sitio se está publicando por primera vez, por favor espera hasta un minuto..." + available: "¡Tu sitio está disponible! Cliquea aquí para visitarlo." index: title: 'Mis sitios' pull: 'Actualizar' From 0442aa1e0672167a9502a5c5b7d14440bd7fdf88 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 31 Mar 2023 19:37:47 -0300 Subject: [PATCH 3/9] fixup! feat: informar el estado del sitio #10492 --- app/views/sites/_status.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/sites/_status.haml b/app/views/sites/_status.haml index fb38896a..52afa3ca 100644 --- a/app/views/sites/_status.haml +++ b/app/views/sites/_status.haml @@ -3,7 +3,7 @@ - message = t('.not_published_yet') - if site.building? - if site.average_publication_time_calculable? - - average_building_time = site.average_building_time + - average_building_time = site.average_publication_time - elsif !site.similar_sites? - average_building_time = 60 - else From f62d7fcc800fd5e6c5eeea9306ee60df49ae9943 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 31 Mar 2023 20:51:20 -0300 Subject: [PATCH 4/9] =?UTF-8?q?fix:=20esperar=20a=20que=20la=20primera=20p?= =?UTF-8?q?ublicaci=C3=B3n=20termine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/site/build_stats.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/site/build_stats.rb b/app/models/site/build_stats.rb index 8b23942d..6eebcc84 100644 --- a/app/models/site/build_stats.rb +++ b/app/models/site/build_stats.rb @@ -27,7 +27,7 @@ class Site # # @return [Boolean] def average_publication_time_calculable? - build_stats.jekyll.where(status: true).count > 0 + build_stats.jekyll.where(status: true).count > 1 end def similar_sites? From 5ae3fe0b354a9649c8b079c2f5966b23cd7b7eef Mon Sep 17 00:00:00 2001 From: f Date: Fri, 31 Mar 2023 20:52:35 -0300 Subject: [PATCH 5/9] =?UTF-8?q?fix:=20dar=20una=20acci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/en.yml | 2 +- config/locales/es.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index ee16f506..f3e319ee 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -331,7 +331,7 @@ en: static_file_migration: 'File migration' find_and_replace: 'Search and replace' status: - building: "Your site is building, please wait ..." + building: "Your site is building, please wait to refresh this page..." not_published_yet: "Your site is being published for the first time, please wait up to 1 minute..." available: "Your site is available! Click here to visit it." index: diff --git a/config/locales/es.yml b/config/locales/es.yml index e3d3f2ef..98181fb3 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -336,7 +336,7 @@ es: static_file_migration: 'Migración de archivos' find_and_replace: 'Búsqueda y reemplazo' status: - building: "Tu sitio se está publicando, por favor espera ..." + building: "Tu sitio se está publicando, por favor espera para recargar esta página..." not_published_yet: "Tu sitio se está publicando por primera vez, por favor espera hasta un minuto..." available: "¡Tu sitio está disponible! Cliquea aquí para visitarlo." index: From ad76fed1b19dac253f67b333be25b7cdd7ee01fa Mon Sep 17 00:00:00 2001 From: f Date: Mon, 3 Apr 2023 13:31:32 -0300 Subject: [PATCH 6/9] fix: alert en modo oscuro --- app/assets/stylesheets/application.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 2f52829b..258698d3 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -52,6 +52,12 @@ $sizes: ( --background: #{$black}; --color: #{$cyan}; } + + .alert-primary { + @include alert-variant(theme-color-level($cyan, $alert-bg-level), + theme-color-level($cyan, $alert-border-level), + theme-color-level($cyan, $alert-color-level)); + } } // TODO: Encontrar la forma de generar esto desde los locales de Rails From bd21f3d9b4806b54b63b3ece2efa5a0d4acbbf5e Mon Sep 17 00:00:00 2001 From: f Date: Mon, 3 Apr 2023 13:47:12 -0300 Subject: [PATCH 7/9] fixup! fix: alert en modo oscuro --- app/assets/stylesheets/application.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 258698d3..99b5a296 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -54,9 +54,9 @@ $sizes: ( } .alert-primary { - @include alert-variant(theme-color-level($cyan, $alert-bg-level), - theme-color-level($cyan, $alert-border-level), - theme-color-level($cyan, $alert-color-level)); + @include alert-variant(theme-color-level("cyan", $alert-bg-level), + theme-color-level("cyan", $alert-border-level), + theme-color-level("cyan", $alert-color-level)); } } From 191dbbd82344a8e7545c4c65e9d84838c435e27e Mon Sep 17 00:00:00 2001 From: f Date: Mon, 3 Apr 2023 13:47:59 -0300 Subject: [PATCH 8/9] fix: indicar que hay un link --- app/views/sites/_status.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/sites/_status.haml b/app/views/sites/_status.haml index 52afa3ca..a731aa7d 100644 --- a/app/views/sites/_status.haml +++ b/app/views/sites/_status.haml @@ -16,4 +16,4 @@ - link = true = render 'bootstrap/alert' do - = link_to_if link, message.html_safe, site.url + = link_to_if link, message.html_safe, site.url, class: 'alert-link' From 3dacef76f1cafb9ecb64cb527737ba34452e9536 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 3 Apr 2023 13:55:21 -0300 Subject: [PATCH 9/9] fix: esto no funciona --- app/assets/stylesheets/application.scss | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 99b5a296..2f52829b 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -52,12 +52,6 @@ $sizes: ( --background: #{$black}; --color: #{$cyan}; } - - .alert-primary { - @include alert-variant(theme-color-level("cyan", $alert-bg-level), - theme-color-level("cyan", $alert-border-level), - theme-color-level("cyan", $alert-color-level)); - } } // TODO: Encontrar la forma de generar esto desde los locales de Rails