mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 22:36:21 +00:00
instanciar JekyllService para cada sitio
This commit is contained in:
parent
02b52b23b9
commit
69e7df4c31
1 changed files with 34 additions and 0 deletions
34
app/lib/active_storage/service/registry_decorator.rb
Normal file
34
app/lib/active_storage/service/registry_decorator.rb
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module ActiveStorage
|
||||||
|
module Service
|
||||||
|
# Modificaciones a ActiveStorage::Service::Registry
|
||||||
|
module RegistryDecorator
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
# El mismo comportamiento que #fetch con el agregado de generar
|
||||||
|
# un {JekyllService} para cada sitio.
|
||||||
|
def fetch(name)
|
||||||
|
services.fetch(name.to_sym) do |key|
|
||||||
|
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
|
||||||
|
elsif block_given?
|
||||||
|
yield key
|
||||||
|
else
|
||||||
|
raise KeyError, "Missing configuration for the #{key} Active Storage service. " \
|
||||||
|
"Configurations available for the #{configurations.keys.to_sentence} services."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
ActiveStorage::Service::Registry.include ActiveStorage::Service::RegistryDecorator
|
Loading…
Reference in a new issue