This commit is contained in:
f 2021-05-06 17:54:49 -03:00
parent a27a0ca7d8
commit 5880c47676
4 changed files with 11 additions and 10 deletions

View file

@ -1 +0,0 @@
system

View file

@ -14,9 +14,9 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
# Queremos que los artículos nuevos siempre cacheen, si usamos el UUID
# siempre vamos a obtener un item nuevo.
def cache_key
return layout.value + '/' + name.to_s if post.new?
return "#{layout.value}/#{name}" if post.new?
@cache_key ||= 'post/' + post.uuid.value + '/' + name.to_s
@cache_key ||= "post/#{post.uuid.value}/#{name}"
end
def cache_version
@ -24,7 +24,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
end
def cache_key_with_version
cache_key + '-' + cache_version
"#{cache_key}-#{cache_version}"
end
# XXX: Deberíamos sanitizar durante la asignación?

View file

@ -97,7 +97,7 @@ class Site < ApplicationRecord
# @param slash Boolean Agregar / al final o no
# @return String La URL con o sin / al final
def url(slash: true)
'https://' + hostname + (slash ? '/' : '')
"https://#{hostname}#{slash ? '/' : ''}"
end
# Obtiene los dominios alternativos
@ -105,7 +105,7 @@ class Site < ApplicationRecord
# @return Array
def alternative_hostnames
deploys.where(type: 'DeployAlternativeDomain').map(&:hostname).map do |h|
h.end_with?('.') ? h[0..-2] : h + '.' + Site.domain
h.end_with?('.') ? h[0..-2] : "#{h}.#{Site.domain}"
end
end
@ -114,7 +114,7 @@ class Site < ApplicationRecord
# @return Array
def alternative_urls(slash: true)
alternative_hostnames.map do |h|
'https://' + h + (slash ? '/' : '')
"https://#{h}#{slash ? '/' : ''}"
end
end
@ -275,7 +275,9 @@ class Site < ApplicationRecord
# NoMethodError
@layouts_struct ||= Struct.new(*layout_keys, keyword_init: true)
@layouts ||= @layouts_struct.new(**data['layouts'].map do |name, metadata|
[name.to_sym, Layout.new(site: self, name: name.to_sym, meta: metadata.delete('meta')&.with_indifferent_access, metadata: metadata.with_indifferent_access)]
[name.to_sym,
Layout.new(site: self, name: name.to_sym, meta: metadata.delete('meta')&.with_indifferent_access,
metadata: metadata.with_indifferent_access)]
end.to_h)
end
@ -404,7 +406,7 @@ class Site < ApplicationRecord
end
def self.default
find_by(name: Site.domain + '.')
find_by(name: "#{Site.domain}.")
end
def reset

View file

@ -100,7 +100,7 @@ Rails.application.configure do
.new(Syslog::Logger.new('sutty'))
if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end