tiny_admin 0.10.0 → 0.11.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/tiny_admin/actions/index.rb +4 -4
  4. data/lib/tiny_admin/authentication.rb +8 -8
  5. data/lib/tiny_admin/basic_app.rb +5 -3
  6. data/lib/tiny_admin/field.rb +5 -4
  7. data/lib/tiny_admin/plugins/active_record_repository.rb +1 -1
  8. data/lib/tiny_admin/plugins/base_repository.rb +2 -1
  9. data/lib/tiny_admin/plugins/no_auth.rb +2 -2
  10. data/lib/tiny_admin/plugins/simple_auth.rb +10 -10
  11. data/lib/tiny_admin/raw_html.rb +11 -0
  12. data/lib/tiny_admin/router.rb +36 -29
  13. data/lib/tiny_admin/settings.rb +22 -8
  14. data/lib/tiny_admin/store.rb +9 -12
  15. data/lib/tiny_admin/support.rb +14 -2
  16. data/lib/tiny_admin/utils.rb +7 -5
  17. data/lib/tiny_admin/version.rb +1 -1
  18. data/lib/tiny_admin/views/actions/index.rb +23 -27
  19. data/lib/tiny_admin/views/actions/show.rb +15 -21
  20. data/lib/tiny_admin/views/attributes.rb +18 -0
  21. data/lib/tiny_admin/views/basic_layout.rb +1 -6
  22. data/lib/tiny_admin/views/components/actions_buttons.rb +24 -0
  23. data/lib/tiny_admin/views/components/basic_component.rb +1 -5
  24. data/lib/tiny_admin/views/components/field_value.rb +15 -4
  25. data/lib/tiny_admin/views/components/filters_form.rb +21 -21
  26. data/lib/tiny_admin/views/components/flash.rb +5 -5
  27. data/lib/tiny_admin/views/components/head.rb +4 -4
  28. data/lib/tiny_admin/views/components/navbar.rb +17 -17
  29. data/lib/tiny_admin/views/components/pagination.rb +15 -15
  30. data/lib/tiny_admin/views/components/widgets.rb +23 -8
  31. data/lib/tiny_admin/views/default_layout.rb +8 -8
  32. data/lib/tiny_admin/views/pages/content.rb +4 -4
  33. data/lib/tiny_admin/views/pages/error_page.rb +26 -0
  34. data/lib/tiny_admin/views/pages/page_not_allowed.rb +2 -10
  35. data/lib/tiny_admin/views/pages/page_not_found.rb +2 -10
  36. data/lib/tiny_admin/views/pages/record_not_found.rb +2 -10
  37. data/lib/tiny_admin/views/pages/root.rb +3 -3
  38. data/lib/tiny_admin/views/pages/simple_auth_login.rb +12 -12
  39. data/lib/tiny_admin.rb +8 -8
  40. metadata +13 -6
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinyAdmin
4
+ module Views
5
+ module Pages
6
+ class ErrorPage < DefaultLayout
7
+ def view_template
8
+ super do
9
+ div(class: css_class) {
10
+ h1(class: "title") { title }
11
+ }
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def css_class
18
+ self.class.name.split("::").last
19
+ .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
20
+ .gsub(/([a-z\d])([A-Z])/, '\1_\2')
21
+ .downcase
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -3,17 +3,9 @@
3
3
  module TinyAdmin
4
4
  module Views
5
5
  module Pages
6
- class PageNotAllowed < DefaultLayout
7
- def template
8
- super do
9
- div(class: 'page_not_allowed') {
10
- h1(class: 'title') { title }
11
- }
12
- end
13
- end
14
-
6
+ class PageNotAllowed < ErrorPage
15
7
  def title
16
- 'Page not allowed'
8
+ "Page not allowed"
17
9
  end
18
10
  end
19
11
  end
@@ -3,17 +3,9 @@
3
3
  module TinyAdmin
4
4
  module Views
5
5
  module Pages
6
- class PageNotFound < DefaultLayout
7
- def template
8
- super do
9
- div(class: 'page_not_found') {
10
- h1(class: 'title') { title }
11
- }
12
- end
13
- end
14
-
6
+ class PageNotFound < ErrorPage
15
7
  def title
16
- 'Page not found'
8
+ "Page not found"
17
9
  end
18
10
  end
19
11
  end
@@ -3,17 +3,9 @@
3
3
  module TinyAdmin
4
4
  module Views
5
5
  module Pages
6
- class RecordNotFound < DefaultLayout
7
- def template
8
- super do
9
- div(class: 'record_not_found') {
10
- h1(class: 'title') { title }
11
- }
12
- end
13
- end
14
-
6
+ class RecordNotFound < ErrorPage
15
7
  def title
16
- 'Record not found'
8
+ "Record not found"
17
9
  end
18
10
  end
19
11
  end
@@ -4,10 +4,10 @@ module TinyAdmin
4
4
  module Views
5
5
  module Pages
6
6
  class Root < DefaultLayout
7
- def template
7
+ def view_template
8
8
  super do
9
- div(class: 'root') {
10
- render TinyAdmin::Views::Components::Widgets.new(widgets)
9
+ div(class: "root") {
10
+ render TinyAdmin::Views::Components::Widgets.new(widgets, context: { params: params })
11
11
  }
12
12
  end
13
13
  end
@@ -4,22 +4,22 @@ module TinyAdmin
4
4
  module Views
5
5
  module Pages
6
6
  class SimpleAuthLogin < DefaultLayout
7
- def template
7
+ def view_template
8
8
  super do
9
- div(class: 'simple_auth_login') {
10
- h1(class: 'title') { title }
9
+ div(class: "simple_auth_login") {
10
+ h1(class: "title") { title }
11
11
 
12
- form(class: 'form_login', method: 'post') {
13
- div(class: 'mt-3') {
14
- label(for: 'secret', class: 'form-label') {
15
- label_for('Password', options: ['pages.simple_auth_login.inputs.password'])
12
+ form(class: "form_login", method: "post") {
13
+ div(class: "mt-3") {
14
+ label(for: "secret", class: "form-label") {
15
+ label_for("Password", options: ["pages.simple_auth_login.inputs.password"])
16
16
  }
17
- input(type: 'password', name: 'secret', class: 'form-control', id: 'secret')
17
+ input(type: "password", name: "secret", class: "form-control", id: "secret")
18
18
  }
19
19
 
20
- div(class: 'mt-3') {
21
- button(type: 'submit', class: 'button_login btn btn-primary') {
22
- label_for('Login', options: ['pages.simple_auth_login.buttons.submit'])
20
+ div(class: "mt-3") {
21
+ button(type: "submit", class: "button_login btn btn-primary") {
22
+ label_for("Login", options: ["pages.simple_auth_login.buttons.submit"])
23
23
  }
24
24
  }
25
25
  }
@@ -28,7 +28,7 @@ module TinyAdmin
28
28
  end
29
29
 
30
30
  def title
31
- 'Login'
31
+ "Login"
32
32
  end
33
33
  end
34
34
  end
data/lib/tiny_admin.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'phlex'
4
- require 'roda'
5
- require 'zeitwerk'
3
+ require "phlex"
4
+ require "roda"
5
+ require "zeitwerk"
6
6
 
7
- require 'forwardable'
8
- require 'singleton'
9
- require 'yaml'
7
+ require "forwardable"
8
+ require "singleton"
9
+ require "yaml"
10
10
 
11
11
  loader = Zeitwerk::Loader.for_gem
12
12
  loader.setup
@@ -25,10 +25,10 @@ module TinyAdmin
25
25
  end
26
26
 
27
27
  def route_for(section, reference: nil, action: nil, query: nil)
28
- root_path = settings.root_path == '/' ? nil : settings.root_path
28
+ root_path = settings.root_path == "/" ? nil : settings.root_path
29
29
  route = [root_path, section, reference, action].compact.join("/")
30
30
  route << "?#{query}" if query
31
- route[0] == '/' ? route : route.prepend('/')
31
+ route[0] == "/" ? route : route.prepend("/")
32
32
  end
33
33
 
34
34
  def settings
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-06-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: phlex
@@ -17,6 +16,9 @@ dependencies:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
18
  version: '1'
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 1.10.0
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +26,9 @@ dependencies:
24
26
  - - "~>"
25
27
  - !ruby/object:Gem::Version
26
28
  version: '1'
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.10.0
27
32
  - !ruby/object:Gem::Dependency
28
33
  name: roda
29
34
  requirement: !ruby/object:Gem::Requirement
@@ -87,6 +92,7 @@ files:
87
92
  - lib/tiny_admin/plugins/base_repository.rb
88
93
  - lib/tiny_admin/plugins/no_auth.rb
89
94
  - lib/tiny_admin/plugins/simple_auth.rb
95
+ - lib/tiny_admin/raw_html.rb
90
96
  - lib/tiny_admin/router.rb
91
97
  - lib/tiny_admin/section.rb
92
98
  - lib/tiny_admin/settings.rb
@@ -96,8 +102,10 @@ files:
96
102
  - lib/tiny_admin/version.rb
97
103
  - lib/tiny_admin/views/actions/index.rb
98
104
  - lib/tiny_admin/views/actions/show.rb
105
+ - lib/tiny_admin/views/attributes.rb
99
106
  - lib/tiny_admin/views/basic_layout.rb
100
107
  - lib/tiny_admin/views/basic_widget.rb
108
+ - lib/tiny_admin/views/components/actions_buttons.rb
101
109
  - lib/tiny_admin/views/components/basic_component.rb
102
110
  - lib/tiny_admin/views/components/field_value.rb
103
111
  - lib/tiny_admin/views/components/filters_form.rb
@@ -108,6 +116,7 @@ files:
108
116
  - lib/tiny_admin/views/components/widgets.rb
109
117
  - lib/tiny_admin/views/default_layout.rb
110
118
  - lib/tiny_admin/views/pages/content.rb
119
+ - lib/tiny_admin/views/pages/error_page.rb
111
120
  - lib/tiny_admin/views/pages/page_not_allowed.rb
112
121
  - lib/tiny_admin/views/pages/page_not_found.rb
113
122
  - lib/tiny_admin/views/pages/record_not_found.rb
@@ -121,7 +130,6 @@ metadata:
121
130
  source_code_uri: https://github.com/blocknotes/tiny_admin
122
131
  changelog_uri: https://github.com/blocknotes/tiny_admin/blob/main/CHANGELOG.md
123
132
  rubygems_mfa_required: 'true'
124
- post_install_message:
125
133
  rdoc_options: []
126
134
  require_paths:
127
135
  - lib
@@ -136,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
144
  - !ruby/object:Gem::Version
137
145
  version: '0'
138
146
  requirements: []
139
- rubygems_version: 3.4.10
140
- signing_key:
147
+ rubygems_version: 3.6.9
141
148
  specification_version: 4
142
149
  summary: Tiny Admin
143
150
  test_files: []