kommandant 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +230 -12
- data/app/assets/builds/kommandant.css +413 -145
- data/app/assets/config/kommandant_manifest.js +2 -0
- data/app/assets/images/kommandant/logo.svg +13 -0
- data/app/controllers/kommandant/commands_controller.rb +69 -11
- data/app/controllers/kommandant/searches_controller.rb +8 -9
- data/app/models/kommandant/command.rb +12 -69
- data/app/models/kommandant/commands/search_result.rb +4 -11
- data/app/views/kommandant/commands/_command.html.erb +23 -0
- data/app/views/kommandant/commands/_form.html.erb +58 -0
- data/app/views/kommandant/commands/edit.html.erb +1 -0
- data/app/views/kommandant/commands/index.html.erb +29 -0
- data/app/views/kommandant/commands/new.html.erb +1 -0
- data/app/views/kommandant/commands/searches/show.html.erb +4 -4
- data/app/views/kommandant/commands/show.html.erb +2 -2
- data/app/views/kommandant/shared/_command_palette.html.erb +2 -3
- data/app/views/kommandant/shared/command_palette/_command.html.erb +11 -4
- data/app/views/kommandant/shared/command_palette/_result.html.erb +5 -1
- data/app/views/kommandant/shared/icons/_kommandant.html.erb +5 -0
- data/app/views/layouts/kommandant/application.html.erb +24 -9
- data/config/locales/en.yml +11 -0
- data/config/routes.rb +1 -1
- data/lib/generators/kommandant/USAGE +9 -0
- data/lib/generators/kommandant/install_generator.rb +9 -0
- data/lib/generators/kommandant/templates/initializer.rb +31 -0
- data/lib/kommandant/engine.rb +2 -2
- data/lib/kommandant/version.rb +1 -1
- data/lib/kommandant.rb +4 -0
- data/lib/tasks/kommandant_tasks.rake +31 -4
- metadata +32 -22
- /data/app/views/kommandant/shared/icons/{_command.erb → _command.html.erb} +0 -0
- /data/app/views/kommandant/shared/icons/{_search.erb → _search.html.erb} +0 -0
- /data/app/views/kommandant/shared/icons/{_spinner.erb → _spinner.html.erb} +0 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
Kommandant.configure do |config|
|
2
|
+
# Commands are loaded from a JSON file. "config/kommandant/commands.json" is the default path. If you want to use a different path, you can set it here.
|
3
|
+
# config.commands_path = "your/custom/path"
|
4
|
+
|
5
|
+
# When meilisearch returns a result, it might include items, that the current user is not allowed to see. You can filter these results with a lamda. This setting has no default, but below is an example that works with cancancan.
|
6
|
+
# config.search_result_filter_lambda = ->(current_ability, resource) { current_ability.can?(:show, resource) }
|
7
|
+
|
8
|
+
# Another search result filter. We use this to allow admins, who are impersonating users, access to all their commands. This setting has no default.
|
9
|
+
# config.admin_only_filter_lambda = ->(current_user, current_admin) { current_user.admin? || current_admin }
|
10
|
+
|
11
|
+
# If you want Kommandant to use a different parent controller, this is the setting for you. Defaults to ApplicationController
|
12
|
+
# config :parent_controller = "YourVerySpecialController"
|
13
|
+
|
14
|
+
# We assume there is a logged in user and therefore a current_user method. The name of this method can be set here. It defaults to current_user.
|
15
|
+
# config.current_user_method = current_account
|
16
|
+
|
17
|
+
# If you use Kredis, Kommandant can display the current user's most recently used commands. It requires your user model to have kredis_unique_list called recent_commands. If you don't use Kredis or do not want this behavior, it can be disabled. It defaults to being enabled.
|
18
|
+
# class User < ApplicationRecord
|
19
|
+
# kredis_unique_list :recent_commands, limit: 5
|
20
|
+
# config.recent_commands.enabled = false
|
21
|
+
|
22
|
+
# When a search returns a lot of results, it can be useful to paginate them. We use Pagy by default to handle this. If you do not use Pagy, this functinality can be turned off or configured to suit your needs. It defaults to being enabled.
|
23
|
+
# config.pagination.enabled = false
|
24
|
+
# config.pagination.items_per_page = 10 # defaults to 10
|
25
|
+
# config.pagination.pagination_lambda = ->(results, items, controller) { controller.send(:pagy_array, results, items: items) }
|
26
|
+
# config.pagination.info_label_lambda = ->(pagination, controller) { controller.send(:pagy_info, pagination).html_safe }
|
27
|
+
# config.pagination.module = "Pagy::Frontend"
|
28
|
+
|
29
|
+
# If you don't want to use icons, you can disable them here. It defaults to being enabled.
|
30
|
+
# config.icons.enabled = false
|
31
|
+
end
|
data/lib/kommandant/engine.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Kommandant
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace Kommandant
|
4
|
-
|
5
|
-
PRECOMPILE_ASSETS = %w
|
4
|
+
|
5
|
+
PRECOMPILE_ASSETS = %w[kommandant.js kommandant.css]
|
6
6
|
initializer "kommandant.assets" do |app|
|
7
7
|
if Rails.application.config.respond_to?(:assets)
|
8
8
|
Rails.application.config.assets.precompile += PRECOMPILE_ASSETS
|
data/lib/kommandant/version.rb
CHANGED
data/lib/kommandant.rb
CHANGED
@@ -11,9 +11,13 @@ module Kommandant
|
|
11
11
|
setting :admin_only_filter_lambda
|
12
12
|
setting :parent_controller, default: "::ApplicationController"
|
13
13
|
setting :current_user_method, default: "current_user"
|
14
|
+
setting :highlight_search_term, default: true
|
14
15
|
setting :recent_commands do
|
15
16
|
setting :enabled, default: true
|
16
17
|
end
|
18
|
+
setting :icons do
|
19
|
+
setting :enabled, default: true
|
20
|
+
end
|
17
21
|
setting :pagination do
|
18
22
|
setting :enabled, default: true
|
19
23
|
setting :items_per_page, default: 10
|
@@ -1,4 +1,31 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
namespace :kommandant do
|
2
|
+
desc "Reindexes all commmands defined in the commands.json file (or whatever you called it)"
|
3
|
+
task reindex_commands: :environment do
|
4
|
+
puts "Reindexing all Kommandant commands"
|
5
|
+
|
6
|
+
Kommandant::Command.reindex!
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Reindexes all models set up with Kommandant"
|
10
|
+
task reindex_models: :environment do
|
11
|
+
Rake::Task["meilisearch:reindex"].invoke
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Reindexes all commands and models. We recommend you run this task every time you deploy your application, to avoid any inconsistencies between what you expect to be indexed and what is actually indexed"
|
15
|
+
task reindex: [:reindex_commands, :reindex_models]
|
16
|
+
|
17
|
+
desc "Clears the Kommandant commands from the search engine"
|
18
|
+
task clear_command_index: :environment do
|
19
|
+
puts "Clearing the Kommandant commands"
|
20
|
+
|
21
|
+
Kommandant::Command.remove_from_index!
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Clears the search engine of all models set up with Kommandant"
|
25
|
+
task clear_model_index: :environment do
|
26
|
+
Rake::Task["meilisearch:clear_indexes"].invoke
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Clears the search engine of all commands and models"
|
30
|
+
task clear_indexes: [:clear_command_index, :clear_model_index]
|
31
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kommandant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolai Bach Woller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dry-configurable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
17
20
|
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
22
|
+
version: 1.0.1
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
24
30
|
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 1.0.1
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: meilisearch-rails
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,39 +45,33 @@ dependencies:
|
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: 0.8.1
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: rails
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
53
|
+
version: 7.0.5
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: 7.0.5
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: turbo-rails
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 1.0.1
|
67
|
+
version: '2.0'
|
65
68
|
type: :runtime
|
66
69
|
prerelease: false
|
67
70
|
version_requirements: !ruby/object:Gem::Requirement
|
68
71
|
requirements:
|
69
72
|
- - "~>"
|
70
73
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: 1.0.1
|
74
|
+
version: '2.0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: tailwindcss-rails
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- Rakefile
|
99
99
|
- app/assets/builds/kommandant.css
|
100
100
|
- app/assets/config/kommandant_manifest.js
|
101
|
+
- app/assets/images/kommandant/logo.svg
|
101
102
|
- app/assets/stylesheets/kommandant/application.css
|
102
103
|
- app/assets/stylesheets/kommandant/application.tailwind.css
|
103
104
|
- app/controllers/concerns/kommandant/recent_commands.rb
|
@@ -111,6 +112,11 @@ files:
|
|
111
112
|
- app/models/kommandant/application_record.rb
|
112
113
|
- app/models/kommandant/command.rb
|
113
114
|
- app/models/kommandant/commands/search_result.rb
|
115
|
+
- app/views/kommandant/commands/_command.html.erb
|
116
|
+
- app/views/kommandant/commands/_form.html.erb
|
117
|
+
- app/views/kommandant/commands/edit.html.erb
|
118
|
+
- app/views/kommandant/commands/index.html.erb
|
119
|
+
- app/views/kommandant/commands/new.html.erb
|
114
120
|
- app/views/kommandant/commands/searches/show.html.erb
|
115
121
|
- app/views/kommandant/commands/show.html.erb
|
116
122
|
- app/views/kommandant/searches/index.html.erb
|
@@ -122,13 +128,17 @@ files:
|
|
122
128
|
- app/views/kommandant/shared/command_palette/_loading_message.html.erb
|
123
129
|
- app/views/kommandant/shared/command_palette/_result.html.erb
|
124
130
|
- app/views/kommandant/shared/icons/_chevron_right.html.erb
|
125
|
-
- app/views/kommandant/shared/icons/_command.erb
|
126
|
-
- app/views/kommandant/shared/icons/
|
127
|
-
- app/views/kommandant/shared/icons/
|
131
|
+
- app/views/kommandant/shared/icons/_command.html.erb
|
132
|
+
- app/views/kommandant/shared/icons/_kommandant.html.erb
|
133
|
+
- app/views/kommandant/shared/icons/_search.html.erb
|
134
|
+
- app/views/kommandant/shared/icons/_spinner.html.erb
|
128
135
|
- app/views/layouts/kommandant/application.html.erb
|
129
136
|
- config/locales/da.yml
|
130
137
|
- config/locales/en.yml
|
131
138
|
- config/routes.rb
|
139
|
+
- lib/generators/kommandant/USAGE
|
140
|
+
- lib/generators/kommandant/install_generator.rb
|
141
|
+
- lib/generators/kommandant/templates/initializer.rb
|
132
142
|
- lib/kommandant.rb
|
133
143
|
- lib/kommandant/engine.rb
|
134
144
|
- lib/kommandant/version.rb
|
File without changes
|
File without changes
|
File without changes
|