maglevcms 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c3b9ff3b96ced9c9f3942ea0c0f26dfc29f9d82bccdb5e6077eea9cf0538c0a
4
- data.tar.gz: 6973bba556d750a5e8caa6f80be7b57426cf4db7a919177e510c0d356645ee7c
3
+ metadata.gz: 03a2b641a732256c52996191d8b8b5acd6fade31e3da46c7400b4ddd19d572b8
4
+ data.tar.gz: 7707349dac583ee782baf2b5eb6e2b6c4007d0935529c301376a8876a6a985f4
5
5
  SHA512:
6
- metadata.gz: b7f5ba949b5a13eb50b9d3b4fcf042fad60766decb28d8ff16ee076cf4135264eac84ec6348776913d72c3f1bbd72b751576b7445db2f88b0a86e6d5165caf30
7
- data.tar.gz: 783b36620b0733ca8387fefd08274f63a2e6c98b65e370572dc6f49f7d7db3c6ad6219c9d0f25a34027db00ca66a684963921777e0a2553fc55af3f121388468
6
+ metadata.gz: 48519ed7bfc8b5281297b2996d92a11fa0f9114266e577d05953f507006be5a64d0619ee2cce6c56471c0c4776f3d0706822860f1161163a6ab52ec1e17add3a
7
+ data.tar.gz: ef616f5afbf2f8a25ffdf59cbb75cc72b0276f723ed68eca78bcc8c6bc9781fa54833dd7617a322a1f704807a4b06cf6d4c2e90bcc2058dcf1bd6c3f2a522fec
@@ -21,7 +21,7 @@ export default class extends Controller {
21
21
  '[data-maglev-dropzone]',
22
22
  )
23
23
  this.sourceTarget.contentWindow
24
- .html2canvas(realSource, { allowTaint: true, logging: true })
24
+ .html2canvas(realSource, { allowTaint: true, logging: true, useCORS: true })
25
25
  .then((canvas) => {
26
26
  this.outputTarget.src = canvas.toDataURL() // for debugging purpose
27
27
  axios
@@ -0,0 +1,257 @@
1
+ {
2
+ "headerNav": {
3
+ "pages": "Páginas:",
4
+ "pageSettings": "Configurações da página",
5
+ "previewSite": "Visualizar site",
6
+ "previewToggler": {
7
+ "button": "Visualizar site",
8
+ "draftLink": "Versão de rascunho",
9
+ "liveLink": "Versão publicada"
10
+ },
11
+ "publishButton": {
12
+ "default": "Publicar site",
13
+ "inProgress": "Publicando...",
14
+ "success": "Publicado!",
15
+ "fail": "Falhou!"
16
+ },
17
+ "saveButton": {
18
+ "default": "Salvar",
19
+ "inProgress": "Salvando...",
20
+ "success": "Salvo!",
21
+ "fail": "Falhou!"
22
+ }
23
+ },
24
+ "sidebarNav": {
25
+ "addNewSectionTooltip": "Adicionar uma nova seção na parte inferior da página",
26
+ "managePageSectionsTooltip": "Reordenar / excluir as seções da página",
27
+ "editStyleTooltip": "Alterar o estilo do seu site",
28
+ "openImageLibraryTooltip": "Abrir a galeria de imagens",
29
+ "leaveEditorTooltip": "Voltar para o aplicativo principal"
30
+ },
31
+ "pagePreview": {
32
+ "loading": "Carregando...",
33
+ "empty": {
34
+ "title": {
35
+ "withoutLocale": "Sua página está em branco",
36
+ "withLocale": "Sua página em %{localeName} está em branco"
37
+ },
38
+ "message": "Por favor, adicione a primeira seção clicando no botão {icon} na barra lateral esquerda."
39
+ }
40
+ },
41
+ "page": {
42
+ "list": {
43
+ "title": "Lista de páginas",
44
+ "subTitle": "Gerenciar as páginas do seu site",
45
+ "newButton": "Nova página",
46
+ "searchPlaceholder": "Digite sua pesquisa aqui...",
47
+ "item": {
48
+ "edit": "Editar configurações da página",
49
+ "clone": "Clonar página",
50
+ "hide": "Ocultar página",
51
+ "show": "Mostrar página",
52
+ "delete": "Excluir página"
53
+ }
54
+ },
55
+ "new": {
56
+ "title": "Criar uma nova página",
57
+ "submitButton": {
58
+ "default": "Criar página",
59
+ "inProgress": "Criando...",
60
+ "success": "Criado!",
61
+ "fail": "Falhou!"
62
+ },
63
+ "cancelButton": "Cancelar"
64
+ },
65
+ "edit": {
66
+ "title": "Editando uma página",
67
+ "currentPage": {
68
+ "title": "Editando a página atual"
69
+ },
70
+ "submitButton": {
71
+ "default": "Atualizar página",
72
+ "inProgress": "Atualizando...",
73
+ "success": "Atualizado!",
74
+ "fail": "Falhou!"
75
+ },
76
+ "cancelButton": "Cancelar"
77
+ },
78
+ "form": {
79
+ "tabs": {
80
+ "main": "Principal",
81
+ "seo": "SEO"
82
+ },
83
+ "title": "Título",
84
+ "path": "Caminho",
85
+ "visible": "Visível",
86
+ "visiblePlaceholder": "Mostrar/Ocultar a página",
87
+ "seoTitle": "Título meta",
88
+ "metaDescription": "Descrição meta",
89
+ "ogTitle": "og:title",
90
+ "ogDescription": "og:description",
91
+ "ogImageUrl": "og:image"
92
+ }
93
+ },
94
+ "sections": {
95
+ "addPane": {
96
+ "title": "Adicionar uma seção"
97
+ },
98
+ "listPane": {
99
+ "title": "Organizar seções",
100
+ "empty": "Não há seções."
101
+ }
102
+ },
103
+ "sectionPane": {
104
+ "tabs": {
105
+ "settings": "Conteúdo",
106
+ "blocks": "Blocos",
107
+ "advanced": "Avançado"
108
+ },
109
+ "blockList": {
110
+ "add": "Adicionar novo item"
111
+ }
112
+ },
113
+ "sectionBlockPane": {
114
+ "tabs": {
115
+ "settings": "Conteúdo",
116
+ "blocks": "Blocos",
117
+ "advanced": "Avançado"
118
+ }
119
+ },
120
+ "themeSectionList": {
121
+ "emptyCategory": "Nenhuma seção"
122
+ },
123
+ "style": {
124
+ "edit": {
125
+ "title": "Estilizar seu site",
126
+ "submitButton": {
127
+ "default": "Atualizar estilo",
128
+ "inProgress": "Atualizando...",
129
+ "success": "Atualizado!",
130
+ "fail": "Falhou!"
131
+ }
132
+ }
133
+ },
134
+ "imageInput": {
135
+ "addButton": "Adicionar imagem",
136
+ "replaceButton": "Substituir imagem",
137
+ "clearButton": "Limpar",
138
+ "altTextPlaceholder": "Texto alternativo para ajudar os mecanismos de busca"
139
+ },
140
+ "imageLibrary": {
141
+ "title": "Lista de imagens",
142
+ "pickerTitle": "Selecionar uma imagem",
143
+ "none": "Nenhuma imagem enviada ainda",
144
+ "searchPlaceholder": "Buscar por um nome de arquivo",
145
+ "pagination": {
146
+ "label": "%{start} - %{end} de %{totalItems} imagens",
147
+ "noItems": "Nenhuma imagem"
148
+ },
149
+ "destroy": {
150
+ "text": "Tem certeza?",
151
+ "ok": "Sim, exclua",
152
+ "cancel": "Cancelar"
153
+ },
154
+ "uploader": {
155
+ "wrongFiles": "Certifique-se de que o tamanho de cada imagem não seja maior que %{limit}.",
156
+ "uploadButton": {
157
+ "default": "Enviar imagens",
158
+ "inProgress": "Enviando...",
159
+ "success": "Enviado!",
160
+ "fail": "Falha!"
161
+ }
162
+ }
163
+ },
164
+ "iconInput": {
165
+ "addButton": "Adicionar ícone",
166
+ "replaceButton": "Substituir ícone",
167
+ "clearButton": "Limpar"
168
+ },
169
+ "iconLibrary": {
170
+ "title": "Ícones",
171
+ "pickerTitle": "Escolher um ícone"
172
+ },
173
+ "linkInput": {
174
+ "placeholder": "Clique aqui para selecionar um link",
175
+ "withNestedTextLabel": "Ativar texto",
176
+ "nestedTextPlaceholder": "Texto"
177
+ },
178
+ "linkPicker": {
179
+ "title": "Selecionar um link",
180
+ "insertTitle": "Inserir um link",
181
+ "page": {
182
+ "name": "Página",
183
+ "input": {
184
+ "label": "Página",
185
+ "placeholder": "Selecione uma página",
186
+ "searchPlaceholder": "Pesquisar...",
187
+ "emptyLabel": "Nenhuma página encontrada"
188
+ },
189
+ "sectionInput": {
190
+ "label": "Seção",
191
+ "placeholder": "Selecione uma seção",
192
+ "emptyLabel": "Nenhuma seção selecionada"
193
+ }
194
+ },
195
+ "url": {
196
+ "name": "URL",
197
+ "input": {
198
+ "label": "URL"
199
+ }
200
+ },
201
+ "email": {
202
+ "name": "Email",
203
+ "input": {
204
+ "label": "Email"
205
+ }
206
+ },
207
+ "shared": {
208
+ "mainButton": {
209
+ "select": "Selecionar",
210
+ "insert": "Adicionar"
211
+ },
212
+ "cancelButton": "Cancelar",
213
+ "newWindowInput": {
214
+ "label": "Abrir em nova janela"
215
+ }
216
+ }
217
+ },
218
+ "collectionItemInput": {
219
+ "select": {
220
+ "placeholder": "Selecione um item",
221
+ "searchPlaceholder": "Pesquisar...",
222
+ "emptyLabel": "Nenhum item encontrado"
223
+ }
224
+ },
225
+ "pagination": {
226
+ "defaultLabel": "%{start} - %{end} de %{totalItems} itens",
227
+ "defaultNoItems": "Nenhum"
228
+ },
229
+ "confirmationButton": {
230
+ "text": "Você tem certeza de que deseja realizar esta ação?",
231
+ "confirmButtonLabel": "Sim",
232
+ "cancelButtonLabel": "Não"
233
+ },
234
+ "errorModals": {
235
+ "staleRecord": {
236
+ "title": "Pedimos desculpas 🙇",
237
+ "message": "Não conseguimos salvar suas alterações porque outra pessoa atualizou o conteúdo no intervalo de tempo.",
238
+ "button": "Por favor, recarregue a página"
239
+ }
240
+ },
241
+ "support": {
242
+ "human": {
243
+ "storageUnits": {
244
+ "format": "%{number} %{unit}",
245
+ "units": {
246
+ "byte": {
247
+ "one": "Byte",
248
+ "other": "Bytes"
249
+ },
250
+ "kb": "KB",
251
+ "mb": "MB",
252
+ "gb": "GB"
253
+ }
254
+ }
255
+ }
256
+ }
257
+ }
@@ -1,14 +1,17 @@
1
1
  import EditorEN from './editor.en.json'
2
2
  import EditorES from './editor.es.json'
3
3
  import EditorFR from './editor.fr.json'
4
+ import EditorPTBR from './editor.pt-BR.json'
4
5
  import { deepMerge } from '@/misc/utils'
5
6
 
6
7
  const overriddenEN = window.customTranslations?.en ?? {}
7
8
  const overriddenES = window.customTranslations?.es ?? {}
8
9
  const overriddenFR = window.customTranslations?.fr ?? {}
10
+ const overriddenPTBR = (window.customTranslations && window.customTranslations['pt-BR']) ? window.customTranslations['pt-BR'] : {}
9
11
 
10
12
  export default {
11
13
  en: deepMerge(EditorEN, overriddenEN),
12
14
  es: deepMerge(EditorES, overriddenES),
13
15
  fr: deepMerge(EditorFR, overriddenFR),
16
+ "pt-BR": deepMerge(EditorPTBR, overriddenPTBR),
14
17
  }
@@ -2,54 +2,58 @@
2
2
 
3
3
  # rubocop:disable Style/ClassAndModuleChildren
4
4
  module Maglev::SectionsConcern
5
- def prepare_sections
5
+ def prepare_sections(theme)
6
6
  # NOTE: pages defined in the theme definition
7
7
  # don't include the ids for sections/blocks
8
8
  self.sections ||= [] # NOTE: the self is mandatory here
9
9
  sections.each do |section|
10
- prepare_section(section)
10
+ prepare_section(theme, section)
11
11
  end
12
12
  end
13
13
 
14
- def prepare_sections_translations
14
+ def prepare_sections_translations(theme)
15
15
  return if sections_translations.blank?
16
16
 
17
17
  sections_translations.each_key do |locale|
18
18
  Maglev::I18n.with_locale(locale) do
19
- prepare_sections
19
+ prepare_sections(theme)
20
20
  end
21
21
  end
22
22
  end
23
23
 
24
24
  private
25
25
 
26
- def prepare_section(section)
26
+ def prepare_section(theme, section)
27
27
  section['id'] ||= SecureRandom.urlsafe_base64(8)
28
- section['settings'] = prepare_settings(section['settings'])
28
+ section['settings'] = prepare_settings(theme, section['type'], nil, section['settings'])
29
29
  section['blocks'] = (section['blocks'] || []).map do |block|
30
- prepare_block(block)
30
+ prepare_block(theme, section['type'], block)
31
31
  end.flatten
32
32
  section
33
33
  end
34
34
 
35
- def prepare_block(block)
35
+ def prepare_block(theme, section_type, block)
36
36
  block['id'] ||= SecureRandom.urlsafe_base64(8)
37
- block['settings'] = prepare_settings(block['settings'])
37
+ block['settings'] = prepare_settings(theme, section_type, block['type'], block['settings'])
38
38
 
39
39
  # the children key is accepted when the sections come from a theme preset
40
40
  children = (block.delete('children') || []).map do |nested_block|
41
41
  nested_block['parent_id'] = block['id']
42
- prepare_block(nested_block)
42
+ prepare_block(theme, section_type, nested_block)
43
43
  end
44
44
  [block, children].flatten
45
45
  end
46
46
 
47
- def prepare_settings(settings)
47
+ def prepare_settings(theme, section_type, block_type, settings)
48
48
  # NOTE: in the theme definition file, we allow developers to declare
49
49
  # default content like this: { <setting_id_1>: <setting_value_1>, ..., <setting_id_n>: <setting_value_n> }
50
- return settings if settings.is_a?(Array)
50
+ settings = settings.map { |key, value| { id: key, value: value } } unless settings.is_a?(Array)
51
51
 
52
- settings.map { |key, value| { id: key, value: value } }
52
+ settings.map do |setting|
53
+ setting = setting.with_indifferent_access
54
+ type = theme.find_setting!(section_type, block_type, setting['id'])
55
+ setting.merge({ value: type.cast_value(setting['value']) })
56
+ end
53
57
  end
54
58
  end
55
59
  # rubocop:enable Style/ClassAndModuleChildren
@@ -5,46 +5,37 @@ class Maglev::Section::Setting
5
5
  ## concerns ##
6
6
  include ActiveModel::Model
7
7
 
8
+ ## constants ##
9
+ REGISTERED_TYPES = %w[text image checkbox link color select collection_item icon divider hint].freeze
10
+
8
11
  ## attributes ##
9
12
  attr_accessor :id, :label, :type, :default, :options
10
13
 
11
14
  ## validations ##
12
15
  validates :id, :label, :type, :default, 'maglev/presence': true
13
- validates :type, inclusion: { in: %w[text image checkbox link color select collection_item icon divider hint] }
16
+ validates :type, inclusion: { in: REGISTERED_TYPES }
14
17
 
15
18
  ## methods ##
16
19
 
17
- # NOTE: any modification to that method must be reflected to the JS editor
18
- def build_default_content(custom_default = nil)
19
- default = custom_default.nil? ? self.default : custom_default
20
- case type.to_sym
21
- when :image then build_default_image_content(default)
22
- when :link then build_default_link_content(default)
23
- when :checkbox then build_default_checkbox_content(default)
24
- when :collection_item then build_default_collection_item_content(default)
25
- else
26
- default || label
20
+ # shortcuts
21
+ REGISTERED_TYPES.each do |type|
22
+ define_method(:"#{type}_type?") do
23
+ self.type.to_s == type
27
24
  end
28
25
  end
29
26
 
30
- def build_default_image_content(default)
31
- default.is_a?(String) ? { url: default } : default || {}
27
+ def cast_value(value)
28
+ self.class.registered_types[type.to_s].cast_value(value)
32
29
  end
33
30
 
34
- def build_default_link_content(default)
35
- if default.is_a?(String)
36
- { text: 'Link', link_type: 'url', href: default }
37
- else
38
- { text: 'Link', link_type: 'url', href: '#' }.merge(default)
39
- end
40
- end
31
+ # NOTE: any modification to that method must be reflected in the JS editor
32
+ def build_default_content(custom_default = nil)
33
+ default = custom_default.nil? ? self.default : custom_default
41
34
 
42
- def build_default_checkbox_content(default)
43
- default.presence || false
44
- end
35
+ # special case: text type
36
+ default ||= label if text_type?
45
37
 
46
- def build_default_collection_item_content(default)
47
- { id: default }
38
+ cast_value(default)
48
39
  end
49
40
 
50
41
  ## class methods ##
@@ -58,5 +49,11 @@ class Maglev::Section::Setting
58
49
  def self.build_many(list)
59
50
  list.map { |hash| build(hash) }
60
51
  end
52
+
53
+ def self.registered_types
54
+ @registered_types ||= REGISTERED_TYPES.index_with do |type|
55
+ "Maglev::SettingTypes::#{type.camelize}".constantize.new
56
+ end
57
+ end
61
58
  end
62
59
  # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Base
5
+ def cast_value(value)
6
+ value
7
+ end
8
+ end
9
+
10
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Checkbox < Maglev::SettingTypes::Base
5
+ def cast_value(value)
6
+ ActiveModel::Type::Boolean.new.cast(value) || false
7
+ end
8
+ end
9
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::CollectionItem < Maglev::SettingTypes::Base
5
+ def cast_value(value)
6
+ if value.is_a?(String)
7
+ { id: default }
8
+ else
9
+ value
10
+ end
11
+ end
12
+ end
13
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Color < Maglev::SettingTypes::Base
5
+ end
6
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Divider < Maglev::SettingTypes::Base
5
+ def cast_value(_value)
6
+ nil
7
+ end
8
+ end
9
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Hint < Maglev::SettingTypes::Base
5
+ def cast_value(_value)
6
+ nil
7
+ end
8
+ end
9
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Icon < Maglev::SettingTypes::Base
5
+ def cast_value(value)
6
+ value
7
+ end
8
+ end
9
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Image < Maglev::SettingTypes::Base
5
+ def cast_value(value)
6
+ if value.is_a?(String)
7
+ { url: value }
8
+ else
9
+ value || {}
10
+ end
11
+ end
12
+ end
13
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Link < Maglev::SettingTypes::Base
5
+ def cast_value(value)
6
+ if value.is_a?(String)
7
+ { text: 'Link', link_type: 'url', href: value }
8
+ else
9
+ { text: 'Link', link_type: 'url', href: '#' }.merge(value)
10
+ end
11
+ end
12
+ end
13
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Select < Maglev::SettingTypes::Base
5
+ end
6
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Style/ClassAndModuleChildren
4
+ class Maglev::SettingTypes::Text < Maglev::SettingTypes::Base
5
+ end
6
+ # rubocop:enable Style/ClassAndModuleChildren
@@ -6,7 +6,11 @@ module Maglev::Site::LocalesConcern
6
6
 
7
7
  included do
8
8
  ## serializers ##
9
- serialize :locales, LocalesSerializer
9
+ if Rails::VERSION::MAJOR > 6
10
+ serialize :locales, coder: LocalesSerializer
11
+ else
12
+ serialize :locales, LocalesSerializer
13
+ end
10
14
 
11
15
  ## validation ##
12
16
  validates :locales, 'maglev/collection': true, length: { minimum: 1 }
@@ -12,5 +12,40 @@ module Maglev
12
12
  validates :id, :name, presence: true
13
13
 
14
14
  ## methods ##
15
+
16
+ def find_setting!(section_id, block_id, setting_id)
17
+ setting = find_setting(section_id, block_id, setting_id)
18
+ raise Maglev::Errors::UnknownSetting.new(section_id, block_id, setting_id) if setting.nil?
19
+
20
+ setting
21
+ end
22
+
23
+ def find_setting(section_id, block_id, setting_id)
24
+ key = [section_id, block_id, setting_id].compact.join('.')
25
+ section_setting_types[key]
26
+ end
27
+
28
+ private
29
+
30
+ def section_setting_types
31
+ @section_setting_types ||= build_section_setting_types
32
+ end
33
+
34
+ def build_section_setting_types
35
+ hash = {}
36
+ sections.each do |section|
37
+ build_section_setting_types_from_settings(hash, section.id, section.settings)
38
+ section.blocks.each do |block|
39
+ build_section_setting_types_from_settings(hash, "#{section.id}.#{block.type}", block.settings)
40
+ end
41
+ end
42
+ hash
43
+ end
44
+
45
+ def build_section_setting_types_from_settings(hash, parent_key, settings)
46
+ settings.each do |setting|
47
+ hash["#{parent_key}.#{setting.id}"] = setting
48
+ end
49
+ end
15
50
  end
16
51
  end
@@ -29,9 +29,9 @@ module Maglev
29
29
  # the sections_translations attribute is put by the SetupPages service
30
30
  # when we generate a brand new site
31
31
  if page_attributes.key?(:sections_translations)
32
- page.prepare_sections_translations
32
+ page.prepare_sections_translations(theme)
33
33
  else
34
- page.prepare_sections
34
+ page.prepare_sections(theme)
35
35
  end
36
36
 
37
37
  page.save!
@@ -40,15 +40,7 @@ module Maglev
40
40
  def persist_site!
41
41
  return unless can_persist_site?
42
42
 
43
- # the sections_translations attribute is put by the SetupPages service
44
- # when we generate a brand new site
45
- if site_attributes.key?(:sections_translations)
46
- site.attributes = site_attributes
47
- site.prepare_sections_translations
48
- else
49
- site.attributes = site_attributes_with_consistent_sections
50
- site.prepare_sections
51
- end
43
+ assign_sections_to_site
52
44
 
53
45
  site.save!
54
46
  end
@@ -89,5 +81,17 @@ module Maglev
89
81
  site_attributes[:sections_translations].present?
90
82
  )
91
83
  end
84
+
85
+ def assign_sections_to_site
86
+ # the sections_translations attribute is put by the SetupPages service
87
+ # when we generate a brand new site
88
+ if site_attributes.key?(:sections_translations)
89
+ site.attributes = site_attributes
90
+ site.prepare_sections_translations(theme)
91
+ else
92
+ site.attributes = site_attributes_with_consistent_sections
93
+ site.prepare_sections(theme)
94
+ end
95
+ end
92
96
  end
93
97
  end
@@ -5,10 +5,10 @@ module Maglev
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- after_commit :save_metadata_now, on: :create
9
-
10
8
  has_one_attached :file
11
9
 
10
+ after_commit :save_metadata_now, on: :create, prepend: true
11
+
12
12
  delegate :url, :download, to: :file
13
13
  end
14
14
 
data/lib/maglev/errors.rb CHANGED
@@ -4,5 +4,12 @@ module Maglev
4
4
  module Errors
5
5
  class NotAuthorized < StandardError; end
6
6
  class UnknownSection < StandardError; end
7
+
8
+ class UnknownSetting < StandardError
9
+ def initialize(section_id, block_id, setting_id)
10
+ key = [section_id, block_id].compact.join('.')
11
+ super("[#{key}] The #{setting_id} setting is undeclared OR its type is unknown.")
12
+ end
13
+ end
7
14
  end
8
15
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Maglev
4
- VERSION = '1.3.0'
4
+ VERSION = '1.4.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maglevcms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-02 00:00:00.000000000 Z
11
+ date: 2023-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder
@@ -56,9 +56,9 @@ dependencies:
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "<="
59
+ - - "<"
60
60
  - !ruby/object:Gem::Version
61
- version: '7.1'
61
+ version: '7.2'
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '6'
@@ -66,9 +66,9 @@ dependencies:
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - "<="
69
+ - - "<"
70
70
  - !ruby/object:Gem::Version
71
- version: '7.1'
71
+ version: '7.2'
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '6'
@@ -628,6 +628,7 @@ files:
628
628
  - app/frontend/editor/locales/editor.en.json
629
629
  - app/frontend/editor/locales/editor.es.json
630
630
  - app/frontend/editor/locales/editor.fr.json
631
+ - app/frontend/editor/locales/editor.pt-BR.json
631
632
  - app/frontend/editor/locales/index.js
632
633
  - app/frontend/editor/main.js
633
634
  - app/frontend/editor/misc/__tests__/utils.spec.js
@@ -722,6 +723,17 @@ files:
722
723
  - app/models/maglev/section/block.rb
723
724
  - app/models/maglev/section/content_concern.rb
724
725
  - app/models/maglev/section/setting.rb
726
+ - app/models/maglev/setting_types/base.rb
727
+ - app/models/maglev/setting_types/checkbox.rb
728
+ - app/models/maglev/setting_types/collection_item.rb
729
+ - app/models/maglev/setting_types/color.rb
730
+ - app/models/maglev/setting_types/divider.rb
731
+ - app/models/maglev/setting_types/hint.rb
732
+ - app/models/maglev/setting_types/icon.rb
733
+ - app/models/maglev/setting_types/image.rb
734
+ - app/models/maglev/setting_types/link.rb
735
+ - app/models/maglev/setting_types/select.rb
736
+ - app/models/maglev/setting_types/text.rb
725
737
  - app/models/maglev/site.rb
726
738
  - app/models/maglev/site/locale.rb
727
739
  - app/models/maglev/site/locales_concern.rb