katalyst-koi 4.15.0 → 4.16.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 +4 -4
- data/app/assets/builds/koi/admin.css +1 -1
- data/app/controllers/admin/admin_users_controller.rb +1 -1
- data/app/controllers/admin/credentials_controller.rb +1 -1
- data/app/controllers/admin/otps_controller.rb +1 -1
- data/app/controllers/admin/sessions_controller.rb +1 -1
- data/app/controllers/admin/url_rewrites_controller.rb +1 -1
- data/app/controllers/admin/well_knowns_controller.rb +71 -0
- data/app/controllers/well_knowns_controller.rb +15 -0
- data/app/models/well_known.rb +25 -0
- data/app/views/admin/otps/_form.html.erb +2 -1
- data/app/views/admin/well_knowns/_fields.html.erb +6 -0
- data/app/views/admin/well_knowns/edit.html.erb +12 -0
- data/app/views/admin/well_knowns/index.html.erb +15 -0
- data/app/views/admin/well_knowns/new.html.erb +11 -0
- data/app/views/admin/well_knowns/show.html.erb +19 -0
- data/config/locales/koi.en.yml +1 -0
- data/config/routes.rb +4 -1
- data/db/migrate/20250204060748_create_well_knowns.rb +14 -0
- data/lib/generators/koi/admin_controller/templates/controller.rb.tt +2 -2
- data/lib/generators/koi/admin_route/templates/initializer.rb.tt +1 -0
- data/spec/factories/well_knowns.rb +10 -0
- metadata +13 -7
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Admin
|
4
|
+
class WellKnownsController < ApplicationController
|
5
|
+
before_action :set_well_known, only: %i[show edit update destroy]
|
6
|
+
|
7
|
+
def index
|
8
|
+
collection = Collection.new.with_params(params).apply(::WellKnown.strict_loading.all)
|
9
|
+
|
10
|
+
render locals: { collection: }
|
11
|
+
end
|
12
|
+
|
13
|
+
def show
|
14
|
+
render locals: { well_known: @well_known }
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
render locals: { well_known: ::WellKnown.new }
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
render locals: { well_known: @well_known }
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@well_known = ::WellKnown.new(well_known_params)
|
27
|
+
|
28
|
+
if @well_known.save
|
29
|
+
redirect_to [:admin, @well_known], status: :see_other
|
30
|
+
else
|
31
|
+
render :new, locals: { well_known: @well_known }, status: :unprocessable_content
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
if @well_known.update(well_known_params)
|
37
|
+
redirect_to action: :show, status: :see_other
|
38
|
+
else
|
39
|
+
render :edit, locals: { well_known: @well_known }, status: :unprocessable_content
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
@well_known.destroy!
|
45
|
+
|
46
|
+
redirect_to action: :index, status: :see_other
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# Only allow a list of trusted parameters through.
|
52
|
+
def well_known_params
|
53
|
+
params.expect(well_known: %i[name purpose content_type content])
|
54
|
+
end
|
55
|
+
|
56
|
+
# Use callbacks to share common setup or constraints between actions.
|
57
|
+
def set_well_known
|
58
|
+
@well_known = ::WellKnown.find(params[:id])
|
59
|
+
end
|
60
|
+
|
61
|
+
class Collection < Admin::Collection
|
62
|
+
config.sorting = :name
|
63
|
+
config.paginate = true
|
64
|
+
|
65
|
+
attribute :name, :string
|
66
|
+
attribute :purpose, :string
|
67
|
+
attribute :content_type, :string
|
68
|
+
attribute :content, :string
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class WellKnownsController < ApplicationController
|
4
|
+
before_action :set_well_known
|
5
|
+
|
6
|
+
def show
|
7
|
+
render renderable: @well_known
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def set_well_known
|
13
|
+
@well_known = WellKnown.find_by!(name: params[:name])
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class WellKnown < ApplicationRecord
|
4
|
+
CONTENT_TYPES = {
|
5
|
+
text: "text/plain",
|
6
|
+
json: "application/json",
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
enum :content_type, CONTENT_TYPES
|
10
|
+
|
11
|
+
validates :name, :purpose, :content_type, presence: true
|
12
|
+
validates :name, uniqueness: { case_sensitive: true }
|
13
|
+
|
14
|
+
scope :admin_search, ->(query) do
|
15
|
+
where(arel_table[:name].matches("%#{query}%"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def render_in(view_context)
|
19
|
+
view_context.render(plain: content)
|
20
|
+
end
|
21
|
+
|
22
|
+
def format
|
23
|
+
content_type.to_sym
|
24
|
+
end
|
25
|
+
end
|
@@ -15,7 +15,8 @@
|
|
15
15
|
<ol class="flow">
|
16
16
|
<li>Install an MFA app. Most password managers support MFA.</li>
|
17
17
|
<li>Scan this code using your mobile device or password manager:<br>
|
18
|
-
|
18
|
+
<% otp_app_name = t("koi.auth.otp_app_name", host: URI.parse(root_url).host, email: admin.email) %>
|
19
|
+
<%== RQRCode::QRCode.new(admin.otp.provisioning_uri(otp_app_name)).as_svg(
|
19
20
|
color: "000",
|
20
21
|
shape_rendering: "crispEdges",
|
21
22
|
module_size: 3,
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% content_for :header do %>
|
2
|
+
<%= render(Koi::Header::EditComponent.new(resource: well_known)) %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%= form_with(model: well_known, url: admin_well_known_path(well_known)) do |form| %>
|
6
|
+
<%= render "fields", form: %>
|
7
|
+
|
8
|
+
<div class="actions">
|
9
|
+
<%= form.admin_save %>
|
10
|
+
<%= form.admin_delete %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% content_for :header do %>
|
2
|
+
<%= render(Koi::Header::IndexComponent.new(model: WellKnown)) do |component| %>
|
3
|
+
<% component.with_action "New", new_admin_well_known_path %>
|
4
|
+
<% end %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<%= table_query_with(collection:) %>
|
8
|
+
|
9
|
+
<%= table_with(collection:) do |row| %>
|
10
|
+
<% row.select %>
|
11
|
+
<% row.link :name %>
|
12
|
+
<% row.text :purpose %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= table_pagination_with(collection:) %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% content_for :header do %>
|
2
|
+
<%= render(Koi::Header::NewComponent.new(model: WellKnown)) %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%= form_with(model: well_known, url: admin_well_knowns_path) do |form| %>
|
6
|
+
<%= render "fields", form: %>
|
7
|
+
|
8
|
+
<div class="actions">
|
9
|
+
<%= form.admin_save %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% content_for :header do %>
|
2
|
+
<%= render(Koi::Header::ShowComponent.new(resource: well_known)) %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<h2>Summary</h2>
|
6
|
+
|
7
|
+
<%= summary_table_with(model: well_known) do |row| %>
|
8
|
+
<% row.link :name %>
|
9
|
+
<% row.text :purpose %>
|
10
|
+
<% row.text :content_type %>
|
11
|
+
<% row.text :content %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="actions">
|
15
|
+
<%= button_to "Delete", admin_well_known_path(well_known),
|
16
|
+
class: "button button--secondary",
|
17
|
+
method: :delete,
|
18
|
+
form: { data: { turbo_confirm: "Are you sure?" } } %>
|
19
|
+
</div>
|
data/config/locales/koi.en.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -7,7 +7,6 @@ Rails.application.routes.draw do
|
|
7
7
|
resources :tokens, param: :token, only: %i[show update], token: /[^\/]+/
|
8
8
|
end
|
9
9
|
|
10
|
-
resources :url_rewrites
|
11
10
|
resources :admin_users do
|
12
11
|
resources :credentials, only: %i[new create destroy]
|
13
12
|
resource :otp, only: %i[new create destroy]
|
@@ -19,6 +18,8 @@ Rails.application.routes.draw do
|
|
19
18
|
|
20
19
|
resource :cache, only: %i[destroy]
|
21
20
|
resource :dashboard, only: %i[show]
|
21
|
+
resources :well_knowns
|
22
|
+
resources :url_rewrites
|
22
23
|
|
23
24
|
root to: redirect("admin/dashboard")
|
24
25
|
end
|
@@ -28,4 +29,6 @@ Rails.application.routes.draw do
|
|
28
29
|
mount Katalyst::Navigation::Engine, at: "navigation"
|
29
30
|
mount Flipper::UI.app(Flipper) => "flipper" if Object.const_defined?("Flipper::UI")
|
30
31
|
end
|
32
|
+
|
33
|
+
resources :well_knowns, path: ".well-known", param: :name, only: %i[show], name: /[^\/]+/
|
31
34
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateWellKnowns < ActiveRecord::Migration[8.0]
|
4
|
+
def change
|
5
|
+
create_table :well_knowns do |t|
|
6
|
+
t.string :name, index: { unique: true }
|
7
|
+
t.string :purpose
|
8
|
+
t.string :content_type
|
9
|
+
t.string :content
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -50,9 +50,9 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
50
50
|
# Only allow a list of trusted parameters through.
|
51
51
|
def <%= "#{singular_table_name}_params" %>
|
52
52
|
<%- if attributes_names.empty? -%>
|
53
|
-
params.
|
53
|
+
params.expect(<%= singular_table_name %>: [])
|
54
54
|
<%- else -%>
|
55
|
-
params.
|
55
|
+
params.expect(<%= singular_table_name %>: [<%= permitted_params %>])
|
56
56
|
<%- end -%>
|
57
57
|
end
|
58
58
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-koi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katalyst Interactive
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-04 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -234,7 +233,6 @@ dependencies:
|
|
234
233
|
- - ">="
|
235
234
|
- !ruby/object:Gem::Version
|
236
235
|
version: '3.5'
|
237
|
-
description:
|
238
236
|
email:
|
239
237
|
- developers@katalyst.com.au
|
240
238
|
executables: []
|
@@ -375,11 +373,13 @@ files:
|
|
375
373
|
- app/controllers/admin/sessions_controller.rb
|
376
374
|
- app/controllers/admin/tokens_controller.rb
|
377
375
|
- app/controllers/admin/url_rewrites_controller.rb
|
376
|
+
- app/controllers/admin/well_knowns_controller.rb
|
378
377
|
- app/controllers/concerns/koi/controller/has_admin_users.rb
|
379
378
|
- app/controllers/concerns/koi/controller/has_attachments.rb
|
380
379
|
- app/controllers/concerns/koi/controller/has_webauthn.rb
|
381
380
|
- app/controllers/concerns/koi/controller/is_admin_controller.rb
|
382
381
|
- app/controllers/concerns/koi/controller/json_web_token.rb
|
382
|
+
- app/controllers/well_knowns_controller.rb
|
383
383
|
- app/helpers/koi/application_helper.rb
|
384
384
|
- app/helpers/koi/date_helper.rb
|
385
385
|
- app/helpers/koi/definition_list_helper.rb
|
@@ -394,6 +394,7 @@ files:
|
|
394
394
|
- app/models/concerns/koi/model/archivable.rb
|
395
395
|
- app/models/concerns/koi/model/otp.rb
|
396
396
|
- app/models/url_rewrite.rb
|
397
|
+
- app/models/well_known.rb
|
397
398
|
- app/views/admin/admin_users/_fields.html+self.erb
|
398
399
|
- app/views/admin/admin_users/_fields.html.erb
|
399
400
|
- app/views/admin/admin_users/archived.html.erb
|
@@ -425,6 +426,11 @@ files:
|
|
425
426
|
- app/views/admin/url_rewrites/index.html.erb
|
426
427
|
- app/views/admin/url_rewrites/new.html.erb
|
427
428
|
- app/views/admin/url_rewrites/show.html.erb
|
429
|
+
- app/views/admin/well_knowns/_fields.html.erb
|
430
|
+
- app/views/admin/well_knowns/edit.html.erb
|
431
|
+
- app/views/admin/well_knowns/index.html.erb
|
432
|
+
- app/views/admin/well_knowns/new.html.erb
|
433
|
+
- app/views/admin/well_knowns/show.html.erb
|
428
434
|
- app/views/katalyst/content/asides/_aside.html+form.erb
|
429
435
|
- app/views/katalyst/content/columns/_column.html+form.erb
|
430
436
|
- app/views/katalyst/content/contents/_content.html+form.erb
|
@@ -465,6 +471,7 @@ files:
|
|
465
471
|
- db/migrate/20230602033610_add_archived_to_admin_users.rb
|
466
472
|
- db/migrate/20231211005214_add_status_code_to_url_rewrites.rb
|
467
473
|
- db/migrate/20241214060913_add_otp_secret_to_admin_users.rb
|
474
|
+
- db/migrate/20250204060748_create_well_knowns.rb
|
468
475
|
- db/seeds.rb
|
469
476
|
- lib/generators/koi/active_record/active_record_generator.rb
|
470
477
|
- lib/generators/koi/admin/USAGE
|
@@ -504,12 +511,12 @@ files:
|
|
504
511
|
- lib/koi/release.rb
|
505
512
|
- spec/factories/admins.rb
|
506
513
|
- spec/factories/url_rewrites.rb
|
514
|
+
- spec/factories/well_knowns.rb
|
507
515
|
homepage: https://github.com/katalyst/koi
|
508
516
|
licenses:
|
509
517
|
- MIT
|
510
518
|
metadata:
|
511
519
|
rubygems_mfa_required: 'true'
|
512
|
-
post_install_message:
|
513
520
|
rdoc_options: []
|
514
521
|
require_paths:
|
515
522
|
- lib
|
@@ -524,8 +531,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
524
531
|
- !ruby/object:Gem::Version
|
525
532
|
version: '0'
|
526
533
|
requirements: []
|
527
|
-
rubygems_version: 3.
|
528
|
-
signing_key:
|
534
|
+
rubygems_version: 3.6.2
|
529
535
|
specification_version: 4
|
530
536
|
summary: Koi CMS admin framework
|
531
537
|
test_files: []
|