From de59cd9f34b8e346df111643f11482df9647bd15 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 25 Sep 2023 14:08:37 -0300 Subject: [PATCH 1/3] fix: informar cuando la plantilla no tiene gema #14309 --- config/initializers/core_extensions.rb | 14 ++++++++++++++ config/locales/en.yml | 1 + config/locales/es.yml | 1 + 3 files changed, 16 insertions(+) diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index 1516a43a..837fbd18 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -91,6 +91,15 @@ module Jekyll spec.name == name end + unless spec + I18n.with_locale(locale) do + raise ArgumentError, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) + rescue ArgumentError => e + ExceptionNotifier.notify_exception(e, data: { theme: name, site: site.path }) + raise + end + end + ruby_version = Gem::Version.new(RUBY_VERSION) ruby_version.canonical_segments[2] = 0 base_path = Rails.root.join('_storage', 'gems', File.basename(site.source), 'ruby', @@ -114,6 +123,11 @@ module Jekyll private def gemspec; end + + # @return [Symbol] + def locale + @locale ||= (site.config['locale'] || site.config['lang'] || I18n.locale).to_sym + end end # No necesitamos los archivos de la plantilla diff --git a/config/locales/en.yml b/config/locales/en.yml index 5f97a8b9..56b8c213 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -191,6 +191,7 @@ en: deploys: deploy_local_presence: 'We need to be build the site!' design_id: + missing_gem: "Site is configured to use %{theme} theme, but the corresponding gem is missing from Gemfile" layout_incompatible: error: "Design can't be changed because there are posts with incompatible layouts" help: "Your site has posts with layouts only compatible with the current design. If you change it, the site won't work as you expect. If you're trying out designs, you can delete posts in the following incompatible layouts:: %{layouts}." diff --git a/config/locales/es.yml b/config/locales/es.yml index 9e0b8945..b4fde8a3 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -191,6 +191,7 @@ es: deploys: deploy_local_presence: '¡Necesitamos poder generar el sitio!' design_id: + missing_gem: "El sitio usa la plantilla %{theme} pero la gema correspondiente no se encuentra en el Gemfile" layout_incompatible: error: 'No se puede cambiar la plantilla porque hay artículos con formatos incompatibles' help: 'En tu sitio hay artículos que solo son compatibles con el diseño actual, si cambias la plantilla el sitio no funcionará como esperas. Si estás probando plantillas, puedes eliminar los artículos en los formatos incompatibles: %{layouts}.' From 01e7436576c1060d38dd47a0ef0e4aca656c02f8 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 25 Sep 2023 14:10:34 -0300 Subject: [PATCH 2/3] fix: obtener el nombre del sitio --- config/initializers/core_extensions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index 837fbd18..2e9ed7e1 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -95,7 +95,7 @@ module Jekyll I18n.with_locale(locale) do raise ArgumentError, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) rescue ArgumentError => e - ExceptionNotifier.notify_exception(e, data: { theme: name, site: site.path }) + ExceptionNotifier.notify_exception(e, data: { theme: name, site: File.basename(site.source) }) raise end end From bfd31d051fb002e303ddcd0f253b1e2a7aa50f49 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 25 Sep 2023 14:15:32 -0300 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20lanzar=20una=20excepci=C3=B3n=20cont?= =?UTF-8?q?undente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/initializers/core_extensions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/core_extensions.rb b/config/initializers/core_extensions.rb index 2e9ed7e1..d6039e16 100644 --- a/config/initializers/core_extensions.rb +++ b/config/initializers/core_extensions.rb @@ -93,8 +93,8 @@ module Jekyll unless spec I18n.with_locale(locale) do - raise ArgumentError, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) - rescue ArgumentError => e + raise Jekyll::Errors::InvalidThemeName, I18n.t('activerecord.errors.models.site.attributes.design_id.missing_gem', theme: name) + rescue Jekyll::Errors::InvalidThemeName => e ExceptionNotifier.notify_exception(e, data: { theme: name, site: File.basename(site.source) }) raise end