5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 08:54:16 +00:00

método genérico para instanciar el servicio

This commit is contained in:
f 2022-03-05 20:09:09 -03:00
parent 15e978c877
commit 7f6063475b
2 changed files with 8 additions and 4 deletions

View file

@ -12,6 +12,13 @@ module ActiveStorage
class JekyllService < Service::DiskService
BLOB_NAME = 'blob'
# Genera un servicio para un sitio determinado
def self.build_for_site(site:)
new(root: File.join(site.path, 'public'), public: true).tap do |js|
js.name = site.name.to_sym
end
end
# Para poder guardar el archivo con el nombre original pero poder
# recuperarlo durante el download, luego de subirlo le cambiamos el
# nombre y creamos un link simbólico a un nombre conocido.

View file

@ -14,10 +14,7 @@ module ActiveStorage
if configurations.include?(key)
services[key] = configurator.build(key)
elsif (site = Site.find_by_name(key))
root = File.join(site.path, 'public')
services[key] = ActiveStorage::Service::JekyllService.new(root: root, public: true).tap do |s|
s.name = key.to_sym
end
services[key] = ActiveStorage::Service::JekyllService.build_for_site(site: site)
elsif block_given?
yield key
else