mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 01:36:22 +00:00
Merge branch 'issue-10022' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
commit
c61ad24f37
3 changed files with 23 additions and 5 deletions
|
@ -179,10 +179,20 @@ class Site < ApplicationRecord
|
|||
# Siempre tiene que tener algo porque las traducciones están
|
||||
# incorporadas a los sitios de Sutty, aunque les usuaries no traduzcan
|
||||
# sus sitios.
|
||||
#
|
||||
# @return [Array]
|
||||
def locales
|
||||
@locales ||= config.fetch('locales', I18n.available_locales).map(&:to_sym)
|
||||
end
|
||||
|
||||
# Modificar los locales disponibles
|
||||
#
|
||||
# @param :new_locales [Array]
|
||||
# @return [Array]
|
||||
def locales=(new_locales)
|
||||
@locales = new_locales.map(&:to_sym).uniq
|
||||
end
|
||||
|
||||
# Similar a site.i18n en jekyll-locales
|
||||
#
|
||||
# @return [Hash]
|
||||
|
@ -486,6 +496,7 @@ class Site < ApplicationRecord
|
|||
config.title = title
|
||||
config.url = url(slash: false)
|
||||
config.hostname = hostname
|
||||
config.locales = locales.map(&:to_s)
|
||||
end
|
||||
|
||||
# Valida si el sitio tiene al menos una forma de alojamiento asociada
|
||||
|
|
|
@ -33,10 +33,10 @@ class Site
|
|||
def write
|
||||
return if persisted?
|
||||
|
||||
@saved = Site::Writer.new(site: site, file: path,
|
||||
content: content.to_yaml).save
|
||||
# Actualizar el hash para no escribir dos veces
|
||||
@hash = content.hash
|
||||
@saved = Site::Writer.new(site: site, file: path, content: content.to_yaml).save.tap do |result|
|
||||
# Actualizar el hash para no escribir dos veces
|
||||
@hash = content.hash
|
||||
end
|
||||
end
|
||||
alias save write
|
||||
|
||||
|
|
|
@ -11,7 +11,14 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
|
|||
add_role temporal: false, rol: 'usuarie'
|
||||
sync_nodes
|
||||
|
||||
I18n.with_locale(usuarie&.lang&.to_sym || I18n.default_locale) do
|
||||
I18n.with_locale(usuarie.lang.to_sym || I18n.default_locale) do
|
||||
# No se puede llamar a site.config antes de save porque el sitio
|
||||
# todavía no existe.
|
||||
#
|
||||
# TODO: hacer que el repositorio se cree cuando es necesario, para
|
||||
# que no haya estados intermedios.
|
||||
site.locales = [usuarie.lang] + I18n.available_locales
|
||||
|
||||
site.save &&
|
||||
site.config.write &&
|
||||
commit_config(action: :create)
|
||||
|
|
Loading…
Reference in a new issue