5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 04:31:41 +00:00
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 # Queremos que los artículos nuevos siempre cacheen, si usamos el UUID
# siempre vamos a obtener un item nuevo. # siempre vamos a obtener un item nuevo.
def cache_key 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 end
def cache_version def cache_version
@ -24,7 +24,7 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
end end
def cache_key_with_version def cache_key_with_version
cache_key + '-' + cache_version "#{cache_key}-#{cache_version}"
end end
# XXX: Deberíamos sanitizar durante la asignación? # 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 # @param slash Boolean Agregar / al final o no
# @return String La URL con o sin / al final # @return String La URL con o sin / al final
def url(slash: true) def url(slash: true)
'https://' + hostname + (slash ? '/' : '') "https://#{hostname}#{slash ? '/' : ''}"
end end
# Obtiene los dominios alternativos # Obtiene los dominios alternativos
@ -105,7 +105,7 @@ class Site < ApplicationRecord
# @return Array # @return Array
def alternative_hostnames def alternative_hostnames
deploys.where(type: 'DeployAlternativeDomain').map(&:hostname).map do |h| 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
end end
@ -114,7 +114,7 @@ class Site < ApplicationRecord
# @return Array # @return Array
def alternative_urls(slash: true) def alternative_urls(slash: true)
alternative_hostnames.map do |h| alternative_hostnames.map do |h|
'https://' + h + (slash ? '/' : '') "https://#{h}#{slash ? '/' : ''}"
end end
end end
@ -275,7 +275,9 @@ class Site < ApplicationRecord
# NoMethodError # NoMethodError
@layouts_struct ||= Struct.new(*layout_keys, keyword_init: true) @layouts_struct ||= Struct.new(*layout_keys, keyword_init: true)
@layouts ||= @layouts_struct.new(**data['layouts'].map do |name, metadata| @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.to_h)
end end
@ -404,7 +406,7 @@ class Site < ApplicationRecord
end end
def self.default def self.default
find_by(name: Site.domain + '.') find_by(name: "#{Site.domain}.")
end end
def reset def reset

View file

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