iron-cms 0.9.0 → 0.10.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: 687916dc93a240e583f38cbad26dc23e306bf8bd13ff3c8f7dd51e6b15643672
4
- data.tar.gz: d8d6d1ebf7feac09405a53363e775ca004c3f95d246f7f3a7fa520c1766e360d
3
+ metadata.gz: 7cf5dcee3aab1c40252f69f9314a3f3db2c43b359bd7045264c837856406e260
4
+ data.tar.gz: 5e0e7f58dfa1630254637185f8e9adce63800fc83b4633a805aae36ac130e742
5
5
  SHA512:
6
- metadata.gz: 952c317f76c2f810f7f188c5d546e745cbc920738a273479f5fb2381c8bd7d1a9cc264b6e76e1d8431fbee5c000e4b82707d3b60fd0c5603549738afa4c30f6c
7
- data.tar.gz: 1cfef442f2eeea1e3df722398424e113efc92c9452640dc0d6db2b882f064d59d9f2e4c92296137c93b67ff33876ac8d21c659e0e963ec0eb5aaf1d68450fe6a
6
+ metadata.gz: ff9f0219866d562528218a0aa7156947e6c5b813ed1c2faf2142122ff430e23b2bf6e5d1c267c1d3db0ef4d566444ea253c43a0792f4422f944064554112971c
7
+ data.tar.gz: 186733969e7fdd9f69b1f7ef38391b7985165d29ede268eac7288a4b3f20c0277c39500cbdce85a860fa9a1c7d2c7ddca4cbbe11c42cae0f5de621ad62799139
@@ -4173,6 +4173,14 @@
4173
4173
  }
4174
4174
  }
4175
4175
  }
4176
+ .dark\:bg-red-500\/5 {
4177
+ @media (prefers-color-scheme: dark) {
4178
+ background-color: color-mix(in srgb, oklch(63.7% 0.237 25.331) 5%, transparent);
4179
+ @supports (color: color-mix(in lab, red, red)) {
4180
+ background-color: color-mix(in oklab, var(--color-red-500) 5%, transparent);
4181
+ }
4182
+ }
4183
+ }
4176
4184
  .dark\:bg-red-500\/10 {
4177
4185
  @media (prefers-color-scheme: dark) {
4178
4186
  background-color: color-mix(in srgb, oklch(63.7% 0.237 25.331) 10%, transparent);
@@ -0,0 +1,14 @@
1
+ module Iron
2
+ module AdminLocale
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ around_action :set_admin_locale
7
+ end
8
+
9
+ private
10
+ def set_admin_locale(&action)
11
+ I18n.with_locale(Current.user&.language || :en, &action)
12
+ end
13
+ end
14
+ end
@@ -1,7 +1,7 @@
1
1
  module Iron
2
2
  class ApplicationController < ActionController::Base
3
3
  include ActiveStorage::SetCurrent
4
- include Authentication, Authorization
4
+ include AdminLocale, Authentication, Authorization
5
5
  default_form_builder FormBuilder
6
6
  end
7
7
  end
@@ -0,0 +1,20 @@
1
+ module Iron
2
+ module Users
3
+ class EmailsController < ApplicationController
4
+ before_action :set_user
5
+
6
+ def update
7
+ if @user.update(params.require(:user).permit(:email_address))
8
+ redirect_to @user, notice: "Email updated."
9
+ else
10
+ render "iron/users/show", status: :unprocessable_entity
11
+ end
12
+ end
13
+
14
+ private
15
+ def set_user
16
+ @user = Current.user
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Iron
2
+ module Users
3
+ class LanguagesController < ApplicationController
4
+ before_action :set_user
5
+
6
+ def update
7
+ if @user.update(params.require(:user).permit(:language))
8
+ redirect_to @user, notice: "Language updated."
9
+ else
10
+ render "iron/users/show", status: :unprocessable_entity
11
+ end
12
+ end
13
+
14
+ private
15
+ def set_user
16
+ @user = Current.user
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Iron
2
+ module Users
3
+ class PasswordsController < ApplicationController
4
+ before_action :set_user
5
+
6
+ def update
7
+ if @user.update(params.require(:user).permit(:password, :password_confirmation))
8
+ redirect_to @user, notice: "Password changed."
9
+ else
10
+ render "iron/users/show", status: :unprocessable_entity
11
+ end
12
+ end
13
+
14
+ private
15
+ def set_user
16
+ @user = Current.user
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ module Iron
2
+ module Users
3
+ class RolesController < ApplicationController
4
+ before_action :set_user
5
+ before_action :ensure_can_administer
6
+
7
+ def update
8
+ if @user.update(params.expect(user: [ :role ]))
9
+ redirect_to @user, notice: "Role updated."
10
+ else
11
+ redirect_to @user, alert: @user.errors.full_messages.to_sentence
12
+ end
13
+ end
14
+
15
+ private
16
+ def set_user
17
+ @user = User.find(params.expect(:user_id))
18
+ end
19
+ end
20
+ end
21
+ end
@@ -3,7 +3,7 @@ module Iron
3
3
  layout "iron/authentication", only: %i[ new create ]
4
4
  require_unauthenticated_access only: %i[ new create ]
5
5
 
6
- before_action :set_user, only: %i[ show update destroy ]
6
+ before_action :set_user, only: %i[ show destroy ]
7
7
  before_action :verify_join_code, only: %i[ new create ]
8
8
  before_action :ensure_can_administer, only: %i[ index destroy ]
9
9
 
@@ -30,14 +30,6 @@ module Iron
30
30
  redirect_to sign_in_url(email_address: join_params[:email_address])
31
31
  end
32
32
 
33
- def update
34
- if @user.current?
35
- update_own_profile
36
- else
37
- update_user_role
38
- end
39
- end
40
-
41
33
  def destroy
42
34
  if @user.destroy
43
35
  redirect_back fallback_location: users_path, notice: "User was successfully removed.", status: :see_other
@@ -55,36 +47,8 @@ module Iron
55
47
  params.expect(user: [ :email_address, :password, :password_confirmation ])
56
48
  end
57
49
 
58
- def profile_params
59
- params.require(:user).permit(:email_address, :password, :password_confirmation)
60
- end
61
-
62
- def role_params
63
- params.expect(user: [ :role ])
64
- end
65
-
66
50
  def verify_join_code
67
51
  head :not_found if Current.account.join_code != params[:join_code]
68
52
  end
69
-
70
- def update_own_profile
71
- notice = profile_params.key?(:password) ? "Password changed." : "Email updated."
72
-
73
- if @user.update(profile_params)
74
- redirect_to @user, notice: notice
75
- else
76
- render :show, status: :unprocessable_entity
77
- end
78
- end
79
-
80
- def update_user_role
81
- head :forbidden and return unless Current.user.can_administer?
82
-
83
- if @user.update(role_params)
84
- redirect_to @user, notice: "Role updated."
85
- else
86
- redirect_to @user, alert: @user.errors.full_messages.to_sentence
87
- end
88
- end
89
53
  end
90
54
  end
@@ -3,6 +3,10 @@ module Iron
3
3
  include Role
4
4
  include Transferable
5
5
 
6
+ ADMIN_LANGUAGES = { "en" => "English", "it" => "Italiano" }.freeze
7
+
8
+ validates :language, inclusion: { in: ADMIN_LANGUAGES.keys }
9
+
6
10
  before_destroy :ensure_not_current_user
7
11
 
8
12
  has_secure_password
@@ -7,7 +7,7 @@
7
7
  <div class="modal-header">
8
8
  <h3 class="modal-title">Change email</h3>
9
9
  </div>
10
- <%= form_with(model: user) do |form| %>
10
+ <%= form_with(model: user, url: user_email_path(user)) do |form| %>
11
11
  <div class="modal-body">
12
12
  <div class="field">
13
13
  <%= form.label :email_address, "Email" %>
@@ -0,0 +1,28 @@
1
+ <%# locals: (user:) -%>
2
+ <div data-controller="modal">
3
+ <button data-action="modal#open" class="button-link button-sm">Edit</button>
4
+
5
+ <dialog class="modal" data-modal-target="dialog" data-action="turbo:submit-end->modal#submitEnd" closedby="any">
6
+ <div class="modal-handle" data-action="touchstart->modal#dragStart touchmove->modal#dragMove touchend->modal#dragEnd"><div></div></div>
7
+ <div class="modal-header">
8
+ <h3 class="modal-title">Change language</h3>
9
+ </div>
10
+ <%= form_with(model: user, url: user_language_path(user)) do |form| %>
11
+ <div class="modal-body">
12
+ <div class="selection-list">
13
+ <% Iron::User::ADMIN_LANGUAGES.each do |code, name| %>
14
+ <label class="selection-list-item">
15
+ <%= form.radio_button :language, code, class: "sr-only" %>
16
+ <span class="selection-list-name"><%= name %></span>
17
+ <%= icon "check", class: "selection-list-check" %>
18
+ </label>
19
+ <% end %>
20
+ </div>
21
+ </div>
22
+ <div class="modal-footer">
23
+ <button type="button" data-action="modal#close" class="button-secondary button-lg sm:button-sm">Cancel</button>
24
+ <%= form.submit "Save", class: "button-primary button-lg sm:button-sm" %>
25
+ </div>
26
+ <% end %>
27
+ </dialog>
28
+ </div>
@@ -7,7 +7,7 @@
7
7
  <div class="modal-header">
8
8
  <h3 class="modal-title">Change password</h3>
9
9
  </div>
10
- <%= form_with(model: user) do |form| %>
10
+ <%= form_with(model: user, url: user_password_path(user)) do |form| %>
11
11
  <div class="modal-body">
12
12
  <div class="field-group">
13
13
  <div class="field">
@@ -7,7 +7,7 @@
7
7
  <div class="modal-header">
8
8
  <h3 class="modal-title">Change role</h3>
9
9
  </div>
10
- <%= form_with(model: user) do |form| %>
10
+ <%= form_with(model: user, url: user_role_path(user)) do |form| %>
11
11
  <div class="modal-body">
12
12
  <div class="selection-list">
13
13
  <% Iron::User.roles.each do |key, _| %>
@@ -51,6 +51,14 @@
51
51
  </div>
52
52
  <%= render "iron/users/change_password_dialog", user: @user %>
53
53
  </div>
54
+
55
+ <div class="px-5 py-2.5 flex items-center justify-between gap-4">
56
+ <div class="min-w-0">
57
+ <div class="text-sm font-medium text-stone-900 dark:text-white">Language</div>
58
+ <div class="text-sm text-stone-500 dark:text-stone-400"><%= Iron::User::ADMIN_LANGUAGES[@user.language] %></div>
59
+ </div>
60
+ <%= render "iron/users/change_language_dialog", user: @user %>
61
+ </div>
54
62
  </div>
55
63
  </section>
56
64
 
@@ -91,7 +99,7 @@
91
99
  <p class="mt-1 text-sm text-stone-500 dark:text-stone-400">Permanent actions that cannot be undone.</p>
92
100
 
93
101
  <div class="mt-4">
94
- <div class="rounded-xl ring-1 ring-red-200 dark:ring-red-500/20 p-5">
102
+ <div class="rounded-xl ring-1 ring-red-200 bg-red-50 dark:ring-red-500/20 dark:bg-red-500/5 p-5">
95
103
  <div class="flex items-center justify-between gap-4">
96
104
  <div>
97
105
  <h3 class="text-sm font-medium text-stone-900 dark:text-white">Remove user</h3>
@@ -0,0 +1,36 @@
1
+ it:
2
+ iron:
3
+ home:
4
+ greetings:
5
+ - "È ora di dare forma ai contenuti."
6
+ - "Le tue parole ti aspettano."
7
+ - "Creiamo qualcosa di grande."
8
+ - "I contenuti freschi partono da qui."
9
+ - "Cosa pubblicherai oggi?"
10
+ - "La pagina bianca ti aspetta."
11
+ - "Crea, pubblica, ripeti."
12
+ - "I tuoi contenuti, la tua storia."
13
+ - "Pronto a raccontare la tua storia?"
14
+ - "Le parole hanno potere. Usale."
15
+ - "Crea qualcosa che valga la pena leggere."
16
+ - "Una bozza in meno verso il traguardo."
17
+ - "Le idee non si pubblicano da sole."
18
+ - "Rendilo chiaro. Rendilo brillante."
19
+ - "I buoni contenuti richiedono pratica."
20
+ - "Pubblica, poi perfeziona."
21
+ - "Pensa, scrivi, pubblica."
22
+ - "Ogni grande pagina inizia qui."
23
+ - "Semplicità e autenticità."
24
+ - "A cosa stai pensando oggi?"
25
+ - "Piccole modifiche, grande impatto."
26
+ - "Il contenuto è un'arte."
27
+ - "Scrivi una volta, ispira molti."
28
+ - "Meno fronzoli, più sostanza."
29
+ - "Pubblica. Sei pronto."
30
+ - "La struttura porta chiarezza."
31
+ - "Il tuo pubblico ti aspetta."
32
+ - "Fai contare ogni parola."
33
+ pagy:
34
+ p11n: 'OneOther'
35
+ previous: "Prec"
36
+ next: "Succ"
data/config/routes.rb CHANGED
@@ -27,7 +27,14 @@ Iron::Engine.routes.draw do
27
27
  resources :locales, except: %i[ show ]
28
28
 
29
29
  resource :settings, only: %i[ show update ]
30
- resources :users, only: %i[ index show update destroy ]
30
+ resources :users, only: %i[ index show destroy ] do
31
+ scope module: :users do
32
+ resource :email, only: :update
33
+ resource :password, only: :update
34
+ resource :language, only: :update
35
+ resource :role, only: :update
36
+ end
37
+ end
31
38
 
32
39
  # Authentication
33
40
  get "join/:join_code", to: "users#new", as: :join
@@ -0,0 +1,5 @@
1
+ class AddLanguageToIronUsers < ActiveRecord::Migration[8.1]
2
+ def change
3
+ add_column :iron_users, :language, :string, null: false, default: "en"
4
+ end
5
+ end
data/lib/iron/engine.rb CHANGED
@@ -43,6 +43,12 @@ module Iron
43
43
  end
44
44
  end
45
45
 
46
+ initializer "iron.admin_locales" do |app|
47
+ app.config.after_initialize do
48
+ I18n.available_locales |= Iron::User::ADMIN_LANGUAGES.keys.map(&:to_sym)
49
+ end
50
+ end
51
+
46
52
  initializer "iron.global_id_locator" do |app|
47
53
  app.config.after_initialize do
48
54
  global_id_app = ::GlobalID.app || ::Rails.application.config.try(:global_id)&.app
data/lib/iron/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iron
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.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.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Massimo De Marchi
@@ -258,6 +258,7 @@ files:
258
258
  - app/assets/tailwind/iron/components/textarea.css
259
259
  - app/assets/tailwind/iron/components/toggle.css
260
260
  - app/assets/tailwind/iron/lexxy.css
261
+ - app/controllers/concerns/iron/admin_locale.rb
261
262
  - app/controllers/concerns/iron/authentication.rb
262
263
  - app/controllers/concerns/iron/authorization.rb
263
264
  - app/controllers/concerns/iron/locale_aware.rb
@@ -282,6 +283,10 @@ files:
282
283
  - app/controllers/iron/sessions/transfers_controller.rb
283
284
  - app/controllers/iron/sessions_controller.rb
284
285
  - app/controllers/iron/settings_controller.rb
286
+ - app/controllers/iron/users/emails_controller.rb
287
+ - app/controllers/iron/users/languages_controller.rb
288
+ - app/controllers/iron/users/passwords_controller.rb
289
+ - app/controllers/iron/users/roles_controller.rb
285
290
  - app/controllers/iron/users_controller.rb
286
291
  - app/helpers/iron/application_helper.rb
287
292
  - app/helpers/iron/avatar_helper.rb
@@ -472,6 +477,7 @@ files:
472
477
  - app/views/iron/shared/_save_bar.html.erb
473
478
  - app/views/iron/shared/_select.html.erb
474
479
  - app/views/iron/users/_change_email_dialog.html.erb
480
+ - app/views/iron/users/_change_language_dialog.html.erb
475
481
  - app/views/iron/users/_change_password_dialog.html.erb
476
482
  - app/views/iron/users/_change_role_dialog.html.erb
477
483
  - app/views/iron/users/_invite.html.erb
@@ -491,6 +497,7 @@ files:
491
497
  - app/views/layouts/iron/authentication.html.erb
492
498
  - config/importmap.rb
493
499
  - config/locales/en.yml
500
+ - config/locales/it.yml
494
501
  - config/routes.rb
495
502
  - db/migrate/20250422131656_initial_iron_schema.rb
496
503
  - db/migrate/20250427100754_create_iron_accounts.rb
@@ -509,6 +516,7 @@ files:
509
516
  - db/migrate/20250908203158_add_instance_token_to_iron_accounts.rb
510
517
  - db/migrate/20251209103109_create_iron_account_exports.rb
511
518
  - db/migrate/20251209103110_create_iron_account_imports.rb
519
+ - db/migrate/20260207103057_add_language_to_iron_users.rb
512
520
  - lib/generators/iron/pages/pages_generator.rb
513
521
  - lib/generators/iron/pages/templates/pages_controller.rb
514
522
  - lib/generators/iron/pages/templates/show.html.erb