iron-cms 0.19.1 → 0.20.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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -8
  3. data/app/assets/builds/iron.css +2125 -2101
  4. data/app/assets/tailwind/iron/application.css +2 -0
  5. data/app/assets/tailwind/iron/components/field-list.css +35 -0
  6. data/app/assets/tailwind/iron/components/translation-notice.css +39 -0
  7. data/app/assets/tailwind/iron/lexxy.css +154 -47
  8. data/app/controllers/iron/blocks_controller.rb +8 -1
  9. data/app/controllers/iron/entries/content_copies_controller.rb +36 -0
  10. data/app/controllers/iron/entries_controller.rb +2 -1
  11. data/app/controllers/iron/references_controller.rb +7 -0
  12. data/app/helpers/iron/entries_helper.rb +24 -0
  13. data/app/helpers/iron/fields_helper.rb +21 -0
  14. data/app/mcp/iron/mcp/tool_context.rb +27 -12
  15. data/app/mcp/iron/mcp/tools/create_entry.rb +4 -3
  16. data/app/mcp/iron/mcp/tools/get_entry.rb +4 -3
  17. data/app/mcp/iron/mcp/tools/list_content_types.rb +1 -1
  18. data/app/mcp/iron/mcp/tools/list_entries.rb +4 -3
  19. data/app/mcp/iron/mcp/tools/search.rb +4 -3
  20. data/app/mcp/iron/mcp/tools/update_entry.rb +4 -3
  21. data/app/models/iron/entry/titlable.rb +29 -11
  22. data/app/models/iron/entry/translatable.rb +53 -0
  23. data/app/models/iron/entry.rb +1 -1
  24. data/app/models/iron/field.rb +14 -0
  25. data/app/models/iron/fields/block.rb +8 -0
  26. data/app/models/iron/fields/block_list.rb +14 -0
  27. data/app/models/iron/fields/boolean.rb +4 -0
  28. data/app/models/iron/fields/file.rb +4 -0
  29. data/app/models/iron/fields/reference_list.rb +8 -0
  30. data/app/models/iron/fields/rich_text_area.rb +10 -0
  31. data/app/views/iron/entries/_entry.html.erb +1 -1
  32. data/app/views/iron/entries/_entry_option.html.erb +4 -3
  33. data/app/views/iron/entries/_translation_notice.html.erb +32 -0
  34. data/app/views/iron/entries/edit.html.erb +14 -4
  35. data/app/views/iron/entries/entry.html.erb +8 -4
  36. data/app/views/iron/entries/fields/_block_list.html.erb +6 -22
  37. data/app/views/iron/entries/fields/_reference.html.erb +1 -1
  38. data/app/views/iron/entries/fields/_reference_item.html.erb +2 -2
  39. data/app/views/iron/entries/fields/_reference_list.html.erb +12 -3
  40. data/app/views/iron/entries/fields/block_list/_empty_state.html.erb +49 -0
  41. data/app/views/iron/entries/fields/block_list/_menu.html.erb +14 -0
  42. data/app/views/iron/entries/search.html.erb +3 -1
  43. data/app/views/iron/home/_recent_activity.html.erb +1 -1
  44. data/config/locales/en.yml +32 -0
  45. data/config/locales/it.yml +32 -0
  46. data/config/routes.rb +10 -0
  47. data/lib/iron/version.rb +1 -1
  48. metadata +18 -5
@@ -0,0 +1,49 @@
1
+ <%# locals: (block_list:, builder:) -%>
2
+
3
+ <% counterpart = block_list.counterpart_with_blocks %>
4
+
5
+ <div class="field-list-empty">
6
+ <div class="field-list-empty-icon">
7
+ <%= icon "rows-3", class: "size-5" %>
8
+ </div>
9
+
10
+ <% if counterpart %>
11
+ <p class="field-list-empty-title"><%= t(".untranslated_title", target: block_list.locale.name) %></p>
12
+ <p class="field-list-empty-description">
13
+ <%= t(".untranslated_description", count: counterpart.blocks.size, source: counterpart.locale.name, target: block_list.locale.name) %>
14
+ </p>
15
+
16
+ <div class="field-list-empty-actions">
17
+ <%= link_to entry_editor_path(block_list.entry, locale: counterpart.locale), class: "button-secondary button-sm" do %>
18
+ <%= t(".view_in", source: counterpart.locale.name) %>
19
+ <%= icon "arrow-right", class: "size-4" %>
20
+ <% end %>
21
+ </div>
22
+ <% else %>
23
+ <p class="field-list-empty-title"><%= t(".title") %></p>
24
+ <p class="field-list-empty-description"><%= t(".description") %></p>
25
+
26
+ <% quick_picks, more = block_quick_picks(block_list) %>
27
+ <div class="field-list-empty-actions">
28
+ <% quick_picks.each do |block_definition| %>
29
+ <%= link_to new_block_in_list_path(block_list, block_definition, builder),
30
+ data: { turbo_stream: true },
31
+ class: "button-secondary button-sm" do %>
32
+ <%= icon "plus", class: "size-4 text-stone-400" %>
33
+ <%= block_definition.name %>
34
+ <% end %>
35
+ <% end %>
36
+
37
+ <% if more.any? %>
38
+ <el-dropdown class="inline-block">
39
+ <button type="button" class="button-ghost button-sm">
40
+ <%= t(".more", count: more.size) %>
41
+ <%= icon "chevron-down", class: "size-4" %>
42
+ </button>
43
+
44
+ <%= render "iron/entries/fields/block_list/menu", block_list:, builder:, block_definitions: more, anchor: "bottom" %>
45
+ </el-dropdown>
46
+ <% end %>
47
+ </div>
48
+ <% end %>
49
+ </div>
@@ -0,0 +1,14 @@
1
+ <%# locals: (block_list:, builder:, block_definitions:, anchor: "bottom end") -%>
2
+
3
+ <el-menu anchor="<%= anchor %>" popover class="w-56 text-left origin-top-right rounded-md bg-white shadow-lg outline-1 outline-black/5 transition transition-discrete [--anchor-gap:--spacing(2)] data-closed:scale-95 data-closed:transform data-closed:opacity-0 data-enter:duration-100 data-enter:ease-out data-leave:duration-75 data-leave:ease-in dark:bg-stone-800 dark:shadow-none dark:-outline-offset-1 dark:outline-white/10">
4
+ <div class="py-1">
5
+ <% block_definitions.each do |block_definition| %>
6
+ <%= link_to new_block_in_list_path(block_list, block_definition, builder),
7
+ data: { turbo_stream: true },
8
+ class: "group/item flex items-center px-4 py-2 text-sm text-stone-700 focus:bg-sky-100 focus:text-stone-900 focus:outline-hidden dark:text-stone-300 dark:focus:bg-sky-500/20 dark:focus:text-white" do %>
9
+ <%= icon "plus", class: "mr-3 size-5 text-stone-400 group-focus/item:text-sky-600 dark:text-stone-500 dark:group-focus/item:text-sky-400" %>
10
+ <%= block_definition.name %>
11
+ <% end %>
12
+ <% end %>
13
+ </div>
14
+ </el-menu>
@@ -14,6 +14,7 @@
14
14
  <%= form.hidden_field :reference_list_field_definition_id, value: @reference_list_field_definition_id %>
15
15
  <%= form.hidden_field :form_field_name, value: @form_field_name %>
16
16
  <%= form.hidden_field :reference_list_dom_id, value: @reference_list_dom_id %>
17
+ <%= form.hidden_field :locale, value: @locale.code %>
17
18
  <% end %>
18
19
  <%= turbo_frame_tag "entries_search_results" do %>
19
20
  <div
@@ -25,7 +26,8 @@
25
26
  as: :entry,
26
27
  locals: {
27
28
  reference_list_dom_id: @reference_list_dom_id,
28
- form_field_name: @form_field_name
29
+ form_field_name: @form_field_name,
30
+ locale: @locale
29
31
  } %>
30
32
  </div>
31
33
  <% end %>
@@ -5,7 +5,7 @@
5
5
 
6
6
  <div class="mt-4 card card-list">
7
7
  <% @recent_entries.each do |entry| %>
8
- <% entry_title = entry.content_type.single? ? entry.content_type.name : entry.title %>
8
+ <% entry_title = entry.content_type.single? ? entry.content_type.name : entry.display_title %>
9
9
  <% entry_path = entry.content_type.single? ? entry_content_type_path(entry.content_type) : edit_entry_path(entry) %>
10
10
  <div class="card-item flex items-center justify-between gap-4">
11
11
  <div class="min-w-0">
@@ -140,11 +140,17 @@ en:
140
140
  create_failed: "%{content_type} could not be created"
141
141
  update_failed: "%{content_type} could not be updated"
142
142
  validation_errors: "Could not save changes due to validation errors"
143
+ content_copies:
144
+ create:
145
+ copied: "Copied the %{source} content into %{target}. You can now translate it."
146
+ invalid: "Couldn’t copy from %{source}: %{field} %{error}. Fix it in %{source} and try again."
147
+ skipped: "Nothing was copied: %{target} already has content, or %{source} has none."
143
148
  edit:
144
149
  breadcrumb: "%{content_type} entries"
145
150
  delete_action: "Delete entry"
146
151
  delete_confirm: "Delete this entry? This can't be undone."
147
152
  more_actions: "More actions"
153
+ title_from: "Title from %{source}"
148
154
  empty_state:
149
155
  description: "Get started by creating your first entry."
150
156
  new_entry: "New entry"
@@ -154,15 +160,35 @@ en:
154
160
  edit_field_definition: "Edit field definition"
155
161
  missing_definition: "Missing block definition!"
156
162
  untitled: "Untitled"
163
+ block_list:
164
+ add_block: "Add Block"
165
+ empty_state:
166
+ description: "Pick a block to add the first one."
167
+ more:
168
+ one: "1 more"
169
+ other: "%{count} more"
170
+ title: "No blocks yet"
171
+ untranslated_description:
172
+ one: "The %{source} version has 1 block. Add one here to start the %{target} version."
173
+ other: "The %{source} version has %{count} blocks. Add one here to start the %{target} version."
174
+ untranslated_title: "No blocks in %{target} yet"
175
+ view_in: "View in %{source}"
157
176
  file:
158
177
  upload_hint: "PNG, JPG, GIF up to 10MB"
159
178
  upload_prompt: "Upload a file or drag and drop"
179
+ reference_list:
180
+ add: "Add"
181
+ empty_description: "Use Add to link existing entries."
182
+ empty_title: "No entries linked yet"
160
183
  index:
161
184
  count:
162
185
  one: "1 entry"
163
186
  other: "%{count} entries"
164
187
  new_entry: "New entry"
165
188
  title: "%{content_type} Entries"
189
+ locale_status:
190
+ untranslated: "Not translated"
191
+ written: "Has content"
166
192
  new:
167
193
  back: "%{content_type} entries"
168
194
  heading: "New entry"
@@ -173,6 +199,12 @@ en:
173
199
  updated: "%{content_type} was successfully updated."
174
200
  search:
175
201
  search_placeholder: "Search entries"
202
+ translation_notice:
203
+ copy: "Copy from %{source}"
204
+ description: "Its content is in %{source}. The fields below stay empty in %{target} until you fill them in, or start from a copy of the %{source} version and translate it."
205
+ switch: "Switch to %{source}"
206
+ title: "This entry hasn’t been translated into %{target} yet"
207
+ unsaved_changes: "Save or discard your changes to copy from %{source}."
176
208
  web_page_settings:
177
209
  index_home: "Make this the home page at /"
178
210
  index_with_base: "Make this the index page at /%{base_path}/"
@@ -179,11 +179,17 @@ it:
179
179
  create_failed: "Non è stato possibile creare %{content_type}"
180
180
  update_failed: "Non è stato possibile aggiornare %{content_type}"
181
181
  validation_errors: "Impossibile salvare le modifiche a causa di errori di validazione"
182
+ content_copies:
183
+ create:
184
+ copied: "Contenuti copiati da %{source} a %{target}. Ora puoi tradurli."
185
+ invalid: "Impossibile copiare da %{source}: %{field} %{error}. Correggi in %{source} e riprova."
186
+ skipped: "Nessun contenuto copiato: %{target} ha già dei contenuti, oppure %{source} non ne ha."
182
187
  edit:
183
188
  breadcrumb: "Voci di %{content_type}"
184
189
  delete_action: "Elimina voce"
185
190
  delete_confirm: "Eliminare questa voce? Questa operazione non può essere annullata."
186
191
  more_actions: "Altre azioni"
192
+ title_from: "Titolo da %{source}"
187
193
  empty_state:
188
194
  description: "Inizia creando la tua prima voce."
189
195
  new_entry: "Nuova voce"
@@ -193,15 +199,35 @@ it:
193
199
  edit_field_definition: "Modifica definizione campo"
194
200
  missing_definition: "Definizione blocco mancante!"
195
201
  untitled: "Senza titolo"
202
+ block_list:
203
+ add_block: "Aggiungi blocco"
204
+ empty_state:
205
+ description: "Scegli un blocco per aggiungere il primo."
206
+ more:
207
+ one: "Altro 1"
208
+ other: "Altri %{count}"
209
+ title: "Ancora nessun blocco"
210
+ untranslated_description:
211
+ one: "La versione %{source} ha 1 blocco. Aggiungine uno qui per iniziare la versione %{target}."
212
+ other: "La versione %{source} ha %{count} blocchi. Aggiungine uno qui per iniziare la versione %{target}."
213
+ untranslated_title: "Ancora nessun blocco in %{target}"
214
+ view_in: "Vedi in %{source}"
196
215
  file:
197
216
  upload_hint: "PNG, JPG, GIF fino a 10MB"
198
217
  upload_prompt: "Carica un file o trascina qui"
218
+ reference_list:
219
+ add: "Aggiungi"
220
+ empty_description: "Usa Aggiungi per collegare voci esistenti."
221
+ empty_title: "Ancora nessuna voce collegata"
199
222
  index:
200
223
  count:
201
224
  one: "1 voce"
202
225
  other: "%{count} voci"
203
226
  new_entry: "Nuova voce"
204
227
  title: "Voci di %{content_type}"
228
+ locale_status:
229
+ untranslated: "Non tradotto"
230
+ written: "Con contenuti"
205
231
  new:
206
232
  back: "Voci di %{content_type}"
207
233
  heading: "Nuova voce"
@@ -212,6 +238,12 @@ it:
212
238
  updated: "%{content_type} aggiornato con successo."
213
239
  search:
214
240
  search_placeholder: "Cerca voci"
241
+ translation_notice:
242
+ copy: "Copia da %{source}"
243
+ description: "I contenuti sono in %{source}. I campi qui sotto restano vuoti in %{target} finché non li compili, oppure parti da una copia della versione %{source} e traducila."
244
+ switch: "Passa a %{source}"
245
+ title: "Questa voce non è ancora stata tradotta in %{target}"
246
+ unsaved_changes: "Salva o annulla le modifiche per copiare da %{source}."
215
247
  web_page_settings:
216
248
  index_home: "Imposta questa come pagina iniziale su /"
217
249
  index_with_base: "Imposta questa come pagina indice su /%{base_path}/"
data/config/routes.rb CHANGED
@@ -11,6 +11,9 @@ Iron::Engine.routes.draw do
11
11
  resources :field_definitions, shallow: true, module: :content_types, except: %i[index show]
12
12
  resources :entries, shallow: true, except: %i[ show ]
13
13
  end
14
+ resources :entries, only: [] do
15
+ resource :content_copy, only: :create, module: :entries
16
+ end
14
17
  resources :blocks, only: [ :new ]
15
18
  resources :references, only: [ :new ]
16
19
  get "entries/search", to: "entries#search"
@@ -77,3 +80,10 @@ Iron::Engine.routes.draw do
77
80
  resources :passwords, param: :token
78
81
  resources :qr_codes, only: :show
79
82
  end
83
+
84
+ # Active Storage teaches only the host's routes to build URLs for its records, so
85
+ # url_for(blob) or image_tag(variant) inside the admin defers to them. This is what
86
+ # `resolve` does, which refuses to run inside the scope isolate_namespace adds.
87
+ %w[ ActiveStorage::Blob ActiveStorage::Attachment ActiveStorage::Variant ActiveStorage::VariantWithRecord ActiveStorage::Preview ].each do |model|
88
+ Iron::Engine.routes.add_polymorphic_mapping(model, {}) { |record, options| main_app.polymorphic_url(record, options) }
89
+ end
data/lib/iron/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iron
2
- VERSION = "0.19.1"
2
+ VERSION = "0.20.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Massimo De Marchi
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.9.9.beta
74
+ version: '1.0'
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.9.9.beta
81
+ version: '1.0'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: importmap-rails
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -283,16 +283,22 @@ dependencies:
283
283
  name: mcp
284
284
  requirement: !ruby/object:Gem::Requirement
285
285
  requirements:
286
- - - "~>"
286
+ - - ">="
287
287
  - !ruby/object:Gem::Version
288
288
  version: '0.20'
289
+ - - "<"
290
+ - !ruby/object:Gem::Version
291
+ version: '2.0'
289
292
  type: :runtime
290
293
  prerelease: false
291
294
  version_requirements: !ruby/object:Gem::Requirement
292
295
  requirements:
293
- - - "~>"
296
+ - - ">="
294
297
  - !ruby/object:Gem::Version
295
298
  version: '0.20'
299
+ - - "<"
300
+ - !ruby/object:Gem::Version
301
+ version: '2.0'
296
302
  description: A Rails engine for managing and publishing content with a flexible schema.
297
303
  email:
298
304
  - massimo@inkofpixel.com
@@ -317,6 +323,7 @@ files:
317
323
  - app/assets/tailwind/iron/components/drawer.css
318
324
  - app/assets/tailwind/iron/components/dropdown.css
319
325
  - app/assets/tailwind/iron/components/field-definition.css
326
+ - app/assets/tailwind/iron/components/field-list.css
320
327
  - app/assets/tailwind/iron/components/fieldset.css
321
328
  - app/assets/tailwind/iron/components/file-scope-picker.css
322
329
  - app/assets/tailwind/iron/components/file-upload.css
@@ -333,6 +340,7 @@ files:
333
340
  - app/assets/tailwind/iron/components/sortable-list.css
334
341
  - app/assets/tailwind/iron/components/textarea.css
335
342
  - app/assets/tailwind/iron/components/toggle.css
343
+ - app/assets/tailwind/iron/components/translation-notice.css
336
344
  - app/assets/tailwind/iron/lexxy.css
337
345
  - app/controllers/concerns/iron/admin_locale.rb
338
346
  - app/controllers/concerns/iron/api/cursor_pagination.rb
@@ -363,6 +371,7 @@ files:
363
371
  - app/controllers/iron/blocks_controller.rb
364
372
  - app/controllers/iron/content_types/field_definitions_controller.rb
365
373
  - app/controllers/iron/content_types_controller.rb
374
+ - app/controllers/iron/entries/content_copies_controller.rb
366
375
  - app/controllers/iron/entries_controller.rb
367
376
  - app/controllers/iron/field_definitions_controller.rb
368
377
  - app/controllers/iron/first_runs_controller.rb
@@ -471,6 +480,7 @@ files:
471
480
  - app/models/iron/entry/schemable.rb
472
481
  - app/models/iron/entry/searchable.rb
473
482
  - app/models/iron/entry/titlable.rb
483
+ - app/models/iron/entry/translatable.rb
474
484
  - app/models/iron/entry/web_publishable.rb
475
485
  - app/models/iron/exporter.rb
476
486
  - app/models/iron/field.rb
@@ -589,6 +599,7 @@ files:
589
599
  - app/views/iron/entries/_entry.html.erb
590
600
  - app/views/iron/entries/_entry_option.html.erb
591
601
  - app/views/iron/entries/_form.html.erb
602
+ - app/views/iron/entries/_translation_notice.html.erb
592
603
  - app/views/iron/entries/_web_page_settings.html.erb
593
604
  - app/views/iron/entries/edit.html.erb
594
605
  - app/views/iron/entries/entry.html.erb
@@ -606,6 +617,8 @@ files:
606
617
  - app/views/iron/entries/fields/_rich_text_area.html.erb
607
618
  - app/views/iron/entries/fields/_text_area.html.erb
608
619
  - app/views/iron/entries/fields/_text_field.html.erb
620
+ - app/views/iron/entries/fields/block_list/_empty_state.html.erb
621
+ - app/views/iron/entries/fields/block_list/_menu.html.erb
609
622
  - app/views/iron/entries/index.html.erb
610
623
  - app/views/iron/entries/new.html.erb
611
624
  - app/views/iron/entries/search.html.erb