From d896a111b8128ff24be33b6233f8c85bd5ffdd0a Mon Sep 17 00:00:00 2001 From: f Date: Fri, 30 Dec 2022 10:55:10 -0300 Subject: [PATCH 1/2] fix: no cargar el sitio hasta que no se usen los posts --- app/models/site.rb | 6 +++++- app/views/sites/index.haml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index dfc4f034..ac290403 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -333,6 +333,10 @@ class Site < ApplicationRecord status == 'building' end + def jekyll? + File.directory? path + end + def jekyll run_in_path do @jekyll ||= @@ -432,7 +436,7 @@ class Site < ApplicationRecord # Clona el esqueleto de Sutty para crear el sitio nuevo, no pasa nada # si el sitio ya existe def clone_skel! - return if File.directory? path + return if jekyll? Rugged::Repository.clone_at ENV['SKEL_SUTTY'], path end diff --git a/app/views/sites/index.haml b/app/views/sites/index.haml index d69dbeac..56178775 100644 --- a/app/views/sites/index.haml +++ b/app/views/sites/index.haml @@ -14,7 +14,7 @@ %table.table.table-condensed %tbody - @sites.each do |site| - - next unless site.jekyll + - next unless site.jekyll? - rol = current_usuarie.rol_for_site(site) -# TODO: Solo les usuaries cachean porque tenemos que separar From f35f4c0f065196efe273ab2be70636545e9d4bea Mon Sep 17 00:00:00 2001 From: f Date: Fri, 30 Dec 2022 10:56:00 -0300 Subject: [PATCH 2/2] fix: cargar jekyll cuando realmente se lo usa --- app/models/site.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/site.rb b/app/models/site.rb index ac290403..f38500eb 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -54,10 +54,6 @@ class Site < ApplicationRecord before_create :clone_skel! # Elimina el directorio al destruir un sitio before_destroy :remove_directories! - # Carga el sitio Jekyll una vez que se inicializa el modelo o después - # de crearlo - after_initialize :install_gems, :load_jekyll - after_create :install_gems, :load_jekyll # Cambiar el nombre del directorio before_update :update_name! before_save :add_private_key_if_missing! @@ -338,12 +334,14 @@ class Site < ApplicationRecord end def jekyll - run_in_path do - @jekyll ||= + @jekyll ||= + begin + install_gems + Jekyll::Site.new(configuration).tap do |site| site.reader = JekyllData::Reader.new(site) if site.theme end - end + end end # Cargar el sitio Jekyll