5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 09:24:17 +00:00

fix: prevención
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2024-01-12 17:36:31 -03:00
parent 4192e8b8f9
commit 5e6cbba28e
No known key found for this signature in database

View file

@ -159,19 +159,19 @@ class Site < ApplicationRecord
# Traer la ruta del sitio # Traer la ruta del sitio
def path def path
File.join(Site.site_path, name) ::File.join(Site.site_path, name)
end end
# La ruta anterior # La ruta anterior
def path_was def path_was
File.join(Site.site_path, name_was) ::File.join(Site.site_path, name_was)
end end
# Limpiar la ruta y unirla con el separador de directorios del # Limpiar la ruta y unirla con el separador de directorios del
# sistema operativo. Como si algún día fuera a cambiar o # sistema operativo. Como si algún día fuera a cambiar o
# soportáramos Windows :P # soportáramos Windows :P
def relative_path(suspicious_path) def relative_path(suspicious_path)
File.join(path, *suspicious_path.gsub('..', '/').gsub('./', '').squeeze('/').split('/')) ::File.join(path, *suspicious_path.gsub('..', '/').gsub('./', '').squeeze('/').split('/'))
end end
# Obtiene la lista de traducciones actuales # Obtiene la lista de traducciones actuales
@ -358,7 +358,7 @@ class Site < ApplicationRecord
end end
def jekyll? def jekyll?
File.directory? path ::File.directory? path
end end
def jekyll def jekyll
@ -376,7 +376,7 @@ class Site < ApplicationRecord
# documentos de Jekyll hacia Sutty para que podamos leer los datos que # documentos de Jekyll hacia Sutty para que podamos leer los datos que
# necesitamos. # necesitamos.
def load_jekyll def load_jekyll
return unless name.present? && File.directory?(path) return unless name.present? && ::File.directory?(path)
reload_jekyll! reload_jekyll!
end end
@ -404,7 +404,7 @@ class Site < ApplicationRecord
# metadatos de Document # metadatos de Document
@configuration = @configuration =
::Jekyll.configuration('source' => path, ::Jekyll.configuration('source' => path,
'destination' => File.join(path, '_site'), 'destination' => ::File.join(path, '_site'),
'safe' => true, 'watch' => false, 'safe' => true, 'watch' => false,
'quiet' => true, 'excerpt_separator' => '') 'quiet' => true, 'excerpt_separator' => '')
@ -429,7 +429,7 @@ class Site < ApplicationRecord
# El directorio donde se almacenan los sitios # El directorio donde se almacenan los sitios
def self.site_path def self.site_path
@site_path ||= File.realpath(ENV.fetch('SITE_PATH', Rails.root.join('_sites'))) @site_path ||= ::File.realpath(ENV.fetch('SITE_PATH', Rails.root.join('_sites')))
end end
def self.default def self.default
@ -460,7 +460,7 @@ class Site < ApplicationRecord
end end
def gemfile_lock_path? def gemfile_lock_path?
File.exist? gemfile_lock_path ::File.exist? gemfile_lock_path
end end
private private
@ -599,16 +599,16 @@ class Site < ApplicationRecord
# Detecta si el Gemfile fue modificado # Detecta si el Gemfile fue modificado
def gemfile_updated? def gemfile_updated?
updated_at < File.mtime(gemfile_path) updated_at < ::File.mtime(gemfile_path)
end end
def gemfile_path def gemfile_path
@gemfile_path ||= File.join(path, 'Gemfile') @gemfile_path ||= ::File.join(path, 'Gemfile')
end end
# @return [String] # @return [String]
def gemfile_lock_path def gemfile_lock_path
@gemfile_lock_path ||= File.join(path, 'Gemfile.lock') @gemfile_lock_path ||= ::File.join(path, 'Gemfile.lock')
end end
# Detecta si el Gemfile.lock fue modificado con respecto al sitio o al # Detecta si el Gemfile.lock fue modificado con respecto al sitio o al
@ -616,8 +616,8 @@ class Site < ApplicationRecord
def gemfile_lock_updated? def gemfile_lock_updated?
return false unless gemfile_lock_path? return false unless gemfile_lock_path?
[updated_at, File.mtime(File.join(path, 'Gemfile'))].any? do |compare| [updated_at, ::File.mtime(::File.join(path, 'Gemfile'))].any? do |compare|
compare < File.mtime(gemfile_lock_path) compare < ::File.mtime(gemfile_lock_path)
end end
end end
end end