kommandant 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +230 -12
  3. data/app/assets/builds/kommandant.css +413 -145
  4. data/app/assets/config/kommandant_manifest.js +2 -0
  5. data/app/assets/images/kommandant/logo.svg +13 -0
  6. data/app/controllers/kommandant/commands_controller.rb +69 -11
  7. data/app/controllers/kommandant/searches_controller.rb +8 -9
  8. data/app/models/kommandant/command.rb +12 -69
  9. data/app/models/kommandant/commands/search_result.rb +4 -11
  10. data/app/views/kommandant/commands/_command.html.erb +23 -0
  11. data/app/views/kommandant/commands/_form.html.erb +58 -0
  12. data/app/views/kommandant/commands/edit.html.erb +1 -0
  13. data/app/views/kommandant/commands/index.html.erb +29 -0
  14. data/app/views/kommandant/commands/new.html.erb +1 -0
  15. data/app/views/kommandant/commands/searches/show.html.erb +4 -4
  16. data/app/views/kommandant/commands/show.html.erb +2 -2
  17. data/app/views/kommandant/shared/_command_palette.html.erb +2 -3
  18. data/app/views/kommandant/shared/command_palette/_command.html.erb +11 -4
  19. data/app/views/kommandant/shared/command_palette/_result.html.erb +5 -1
  20. data/app/views/kommandant/shared/icons/_kommandant.html.erb +5 -0
  21. data/app/views/layouts/kommandant/application.html.erb +24 -9
  22. data/config/locales/en.yml +11 -0
  23. data/config/routes.rb +1 -1
  24. data/lib/generators/kommandant/USAGE +9 -0
  25. data/lib/generators/kommandant/install_generator.rb +9 -0
  26. data/lib/generators/kommandant/templates/initializer.rb +31 -0
  27. data/lib/kommandant/engine.rb +2 -2
  28. data/lib/kommandant/version.rb +1 -1
  29. data/lib/kommandant.rb +4 -0
  30. data/lib/tasks/kommandant_tasks.rake +31 -4
  31. metadata +32 -22
  32. /data/app/views/kommandant/shared/icons/{_command.erb → _command.html.erb} +0 -0
  33. /data/app/views/kommandant/shared/icons/{_search.erb → _search.html.erb} +0 -0
  34. /data/app/views/kommandant/shared/icons/{_spinner.erb → _spinner.html.erb} +0 -0
@@ -1 +1,3 @@
1
1
  //= link_directory ../stylesheets/kommandant .css
2
+ //= link kommandant.css
3
+ //= link kommandant/logo.svg
@@ -0,0 +1,13 @@
1
+ <svg width="152" height="38" viewBox="0 0 152 38" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path
3
+ d="M16 3C8.16697 3 1.81641 7.28519 1.81641 11.1524C1.81641 13.0215 3.30272 14.2793 5.72266 15.2979V16.8721H26.2783V15.2403C28.6953 14.2013 30.1836 13.0216 30.1836 11.1524C30.1836 7.28519 23.834 3 16 3ZM16 14.9053C14.1269 14.9053 12.6083 13.3867 12.6083 11.5136C12.6083 9.64056 14.1269 8.12113 16 8.12113C17.873 8.12113 19.3925 9.64069 19.3925 11.5137C19.3925 13.3867 17.873 14.9053 16 14.9053Z"
4
+ fill="currentColor" />
5
+ <path d="M14.1094 11.0888L14.8321 13.3115H17.1689L17.8906 11.0888L16 9.71484L14.1094 11.0888Z"
6
+ fill="currentColor" />
7
+ <path
8
+ d="M26.3897 22.418C26.3711 22.4014 26.3506 22.3897 26.331 22.375L26.2343 18.4473C26.2617 18.334 26.2783 18.2207 26.2783 18.1055H25.4726V18.0449H6.42384V18.1055H5.72272C5.72272 18.1309 5.72666 18.1563 5.72759 18.1817L5.66803 18.1582L5.56447 22.375C5.41897 22.4854 5.28128 22.625 5.17578 22.8009C5.00978 23.0733 4.92772 23.4083 4.92872 23.7677C4.92972 24.0645 4.98047 24.3829 5.08397 24.7384C5.2656 25.3585 5.56541 26.084 6.00197 26.709C6.22172 27.0205 6.47659 27.3087 6.79297 27.5372C7.00291 27.6895 7.24903 27.8125 7.52147 27.879C7.54103 27.9903 7.56541 28.1114 7.59178 28.2394C7.6416 28.4835 7.70116 28.7472 7.76759 28.9962C7.83597 29.2472 7.90434 29.4767 8.00391 29.6905C8.57034 30.8926 9.28616 31.836 10.0567 32.5645C11.2139 33.6582 12.4863 34.2676 13.5615 34.6016C14.6407 34.9356 15.5176 35 15.9473 35C16.2363 35 16.7178 34.9707 17.3311 34.8535C18.2481 34.6758 19.4542 34.2989 20.6543 33.5039C21.8545 32.7109 23.043 31.4942 23.8907 29.6895C23.9903 29.4766 24.0596 29.2471 24.128 28.9961C24.2276 28.623 24.3116 28.2149 24.3721 27.8935C24.3731 27.8887 24.3731 27.8838 24.375 27.8789C24.6465 27.8125 24.8926 27.6895 25.1016 27.5371C25.5752 27.1934 25.916 26.7197 26.1953 26.2246C26.4707 25.7275 26.6758 25.2031 26.8115 24.7383C26.9141 24.3828 26.9658 24.0645 26.9668 23.7676C26.9668 23.4473 26.9023 23.1485 26.7705 22.8926C26.6729 22.7022 26.5381 22.5401 26.3897 22.418ZM25.4893 24.3535C25.3467 24.8497 25.0811 25.4727 24.7657 25.918C24.6104 26.1407 24.4434 26.3164 24.2988 26.4199C24.1514 26.5234 24.0449 26.5537 23.9532 26.5547L23.8917 26.5498L23.2168 26.4482L23.1094 27.123L23.1075 27.1387C23.0938 27.2207 23.0283 27.6162 22.9375 28.0469C22.8926 28.2617 22.8398 28.4863 22.7872 28.6797C22.7363 28.8711 22.6778 29.0371 22.6455 29.1035C22.1504 30.1523 21.542 30.9492 20.8926 31.5644C19.918 32.4854 18.8438 33 17.9248 33.2862C17.0088 33.5723 16.2422 33.624 15.9473 33.6231C15.753 33.6231 15.3438 33.6016 14.8242 33.501C14.044 33.3507 13.0117 33.0264 12.001 32.3565C10.9892 31.6846 9.99216 30.6758 9.24997 29.1035C9.21478 29.0332 9.15228 28.8487 9.0976 28.6407C9.01266 28.3242 8.93253 27.9395 8.87691 27.6387C8.84759 27.4884 8.82516 27.3575 8.80953 27.2657C8.80172 27.2207 8.79491 27.1836 8.79097 27.1592L8.7851 27.1231L8.67866 26.4493L8.00385 26.5499L7.94235 26.5547C7.8496 26.5537 7.74409 26.5235 7.59566 26.42C7.37691 26.2667 7.11516 25.9424 6.90328 25.5547C6.68747 25.169 6.51366 24.7247 6.40622 24.3535C6.33003 24.0938 6.30566 23.8994 6.30566 23.7676C6.30666 23.623 6.33203 23.5557 6.34766 23.5235L6.38572 23.4766C6.40816 23.457 6.45503 23.4307 6.52828 23.4122C6.5996 23.3946 6.69234 23.3848 6.77441 23.3848C6.83984 23.3848 6.89841 23.3907 6.93553 23.3945L6.97653 23.4004L7.56641 23.5176C7.63672 23.6348 7.70997 23.7637 7.78416 23.9102C7.86522 23.1387 8.04097 21.6592 8.17184 20.5684C10.0566 21.3877 12.8633 21.9082 16 21.9082C19.082 21.9082 21.8447 21.4063 23.7285 20.6114C23.8593 21.6973 24.0312 23.1485 24.1113 23.9102C24.1855 23.7637 24.2578 23.6348 24.329 23.5176L24.9189 23.4004H24.9199C24.9414 23.3965 25.0234 23.3848 25.1201 23.3848C25.1933 23.3848 25.2744 23.3916 25.3418 23.4063C25.3926 23.418 25.4355 23.4327 25.4648 23.4473C25.5098 23.4717 25.5225 23.4854 25.541 23.5127C25.5567 23.541 25.5879 23.6035 25.5898 23.7676C25.5899 23.8995 25.5645 24.0938 25.4893 24.3535Z"
9
+ fill="currentColor" />
10
+ <path
11
+ d="M39.7617 29H37.043C36.9805 29 36.9492 28.9609 36.9492 28.8828L36.9961 12.418C36.9961 12.3398 37.0273 12.3008 37.0898 12.3008H39.7852C39.8477 12.3008 39.8789 12.3398 39.8789 12.418V18.1016L43.6406 12.3945C43.7031 12.332 43.7617 12.3008 43.8164 12.3008H46.5703C46.6406 12.3008 46.6562 12.332 46.6172 12.3945L42.4688 19.0156L47.1211 28.9062C47.1602 28.9688 47.1211 29 47.0039 29H44.0742C43.9961 29 43.9492 28.9688 43.9336 28.9062L40.6875 21.8516L39.8555 23.1641V28.8828C39.8555 28.9609 39.8242 29 39.7617 29ZM52.1484 29.2344C51.2969 29.2344 50.5117 29.0156 49.793 28.5781C49.082 28.1406 48.5078 27.5586 48.0703 26.832C47.6406 26.0977 47.4258 25.293 47.4258 24.418L47.4492 16.8125C47.4492 15.9219 47.6641 15.1211 48.0938 14.4102C48.5156 13.6914 49.0859 13.1172 49.8047 12.6875C50.5234 12.25 51.3047 12.0312 52.1484 12.0312C53.0234 12.0312 53.8086 12.2461 54.5039 12.6758C55.207 13.1055 55.7695 13.6836 56.1914 14.4102C56.6211 15.1289 56.8359 15.9297 56.8359 16.8125L56.8594 24.418C56.8594 25.293 56.6484 26.0938 56.2266 26.8203C55.7969 27.5547 55.2266 28.1406 54.5156 28.5781C53.8047 29.0156 53.0156 29.2344 52.1484 29.2344ZM52.1484 26.3398C52.6328 26.3398 53.0547 26.1445 53.4141 25.7539C53.7734 25.3555 53.9531 24.9102 53.9531 24.418L53.9297 16.8125C53.9297 16.2812 53.7617 15.832 53.4258 15.4648C53.0898 15.0977 52.6641 14.9141 52.1484 14.9141C51.6562 14.9141 51.2344 15.0938 50.8828 15.4531C50.5312 15.8125 50.3555 16.2656 50.3555 16.8125V24.418C50.3555 24.9414 50.5312 25.3945 50.8828 25.7773C51.2344 26.1523 51.6562 26.3398 52.1484 26.3398ZM61.4883 29H58.7695C58.707 29 58.6758 28.9609 58.6758 28.8828L58.7227 12.3945C58.7227 12.332 58.7539 12.3008 58.8164 12.3008H61.7461C61.8086 12.3008 61.8633 12.332 61.9102 12.3945L64.1016 15.5586L66.2812 12.3945C66.3281 12.332 66.3867 12.3008 66.457 12.3008H69.3984C69.4688 12.3008 69.5039 12.332 69.5039 12.3945L69.5508 28.8828C69.5508 28.9609 69.5195 29 69.457 29H66.7383C66.6758 29 66.6445 28.9609 66.6445 28.8828L66.6211 16.6367L64.1016 20.293L61.6055 16.6367L61.582 28.8828C61.582 28.9609 61.5508 29 61.4883 29ZM74.3789 29H71.6602C71.5977 29 71.5664 28.9609 71.5664 28.8828L71.6133 12.3945C71.6133 12.332 71.6445 12.3008 71.707 12.3008H74.6367C74.6992 12.3008 74.7539 12.332 74.8008 12.3945L76.9922 15.5586L79.1719 12.3945C79.2188 12.332 79.2773 12.3008 79.3477 12.3008H82.2891C82.3594 12.3008 82.3945 12.332 82.3945 12.3945L82.4414 28.8828C82.4414 28.9609 82.4102 29 82.3477 29H79.6289C79.5664 29 79.5352 28.9609 79.5352 28.8828L79.5117 16.6367L76.9922 20.293L74.4961 16.6367L74.4727 28.8828C74.4727 28.9609 74.4414 29 74.3789 29ZM83.6484 28.8828L86.625 12.3945C86.6406 12.332 86.6797 12.3008 86.7422 12.3008H90.2227C90.2852 12.3008 90.3242 12.332 90.3398 12.3945L93.1992 28.8828C93.207 28.9609 93.1758 29 93.1055 29H90.4453C90.3672 29 90.3242 28.9609 90.3164 28.8828L90.0586 27.125H86.7891L86.5312 28.8828C86.5234 28.9609 86.4844 29 86.4141 29H83.7422C83.6797 29 83.6484 28.9609 83.6484 28.8828ZM88.3477 17.8203L87.2695 24.5586H89.5781L88.5938 17.8203L88.4531 16.9297L88.3477 17.8203ZM97.3125 29H94.9102C94.7852 29 94.7227 28.9453 94.7227 28.8359L94.6992 12.4883C94.6992 12.3633 94.7617 12.3008 94.8867 12.3008H97.0547L101.109 21.7578L100.992 12.4883C100.992 12.3633 101.062 12.3008 101.203 12.3008H103.582C103.676 12.3008 103.723 12.3633 103.723 12.4883L103.746 28.8594C103.746 28.9531 103.707 29 103.629 29H101.52L97.3594 20.1641L97.5352 28.8125C97.5352 28.9375 97.4609 29 97.3125 29ZM110.25 28.9766L105.949 29C105.871 29 105.832 28.9609 105.832 28.8828L105.879 12.3945C105.879 12.332 105.91 12.3008 105.973 12.3008L110.461 12.2773C111.352 12.2539 112.156 12.457 112.875 12.8867C113.602 13.3164 114.18 13.8984 114.609 14.6328C115.047 15.3594 115.266 16.1641 115.266 17.0469V23.9375C115.266 24.8594 115.043 25.7031 114.598 26.4688C114.145 27.2266 113.543 27.832 112.793 28.2852C112.043 28.7305 111.195 28.9609 110.25 28.9766ZM110.461 15.1484L108.785 15.1719L108.762 26.0469H110.25C110.844 26.0469 111.344 25.8398 111.75 25.4258C112.156 25.0117 112.359 24.5156 112.359 23.9375V17.0234C112.359 16.5156 112.172 16.0742 111.797 15.6992C111.422 15.3164 110.977 15.1328 110.461 15.1484ZM116.344 28.8828L119.32 12.3945C119.336 12.332 119.375 12.3008 119.438 12.3008H122.918C122.98 12.3008 123.02 12.332 123.035 12.3945L125.895 28.8828C125.902 28.9609 125.871 29 125.801 29H123.141C123.062 29 123.02 28.9609 123.012 28.8828L122.754 27.125H119.484L119.227 28.8828C119.219 28.9609 119.18 29 119.109 29H116.438C116.375 29 116.344 28.9609 116.344 28.8828ZM121.043 17.8203L119.965 24.5586H122.273L121.289 17.8203L121.148 16.9297L121.043 17.8203ZM130.008 29H127.605C127.48 29 127.418 28.9453 127.418 28.8359L127.395 12.4883C127.395 12.3633 127.457 12.3008 127.582 12.3008H129.75L133.805 21.7578L133.688 12.4883C133.688 12.3633 133.758 12.3008 133.898 12.3008H136.277C136.371 12.3008 136.418 12.3633 136.418 12.4883L136.441 28.8594C136.441 28.9531 136.402 29 136.324 29H134.215L130.055 20.1641L130.23 28.8125C130.23 28.9375 130.156 29 130.008 29ZM143.648 29H140.941C140.871 29 140.836 28.9609 140.836 28.8828V15.1953H137.719C137.641 15.1953 137.602 15.1562 137.602 15.0781L137.625 12.3945C137.625 12.332 137.656 12.3008 137.719 12.3008H146.836C146.922 12.3008 146.965 12.332 146.965 12.3945V15.0781C146.965 15.1562 146.934 15.1953 146.871 15.1953H143.719L143.742 28.8828C143.742 28.9609 143.711 29 143.648 29Z"
12
+ fill="currentColor" />
13
+ </svg>
@@ -1,17 +1,75 @@
1
- module Kommandant
2
- class CommandsController < ApplicationController
3
- before_action :set_command
4
-
5
- def show
6
- if Kommandant.config.recent_commands.enabled
7
- current_user.recent_commands.prepend(@command.id)
8
- end
1
+ class Kommandant::CommandsController < ApplicationController
2
+ before_action :set_command, except: [:index, :new, :create]
3
+ before_action :set_resource_classes, only: [:new, :edit]
4
+
5
+ layout "kommandant/application"
6
+
7
+ def index
8
+ @commands = Kommandant::Command.all
9
+ end
10
+
11
+ def new
12
+ @command = Kommandant::Command.new
13
+ end
14
+
15
+ def create
16
+ @command = Kommandant::Command.new(command_params_with_translations)
17
+
18
+ if @command.save
19
+ redirect_to commands_path, notice: "Command was successfully created."
20
+ else
21
+ render :new
22
+ end
23
+ end
24
+
25
+ def show
26
+ if Kommandant.config.recent_commands.enabled
27
+ current_user.recent_commands.prepend(@command.id)
9
28
  end
10
29
 
11
- private
30
+ render :show, layout: false
31
+ end
12
32
 
13
- def set_command
14
- @command = Kommandant::Command.find(params[:id])
33
+ def edit
34
+ end
35
+
36
+ def update
37
+ if @command.update(command_params_with_translations)
38
+ redirect_to commands_path, notice: "Command was successfully updated."
39
+ else
40
+ render :edit
15
41
  end
16
42
  end
43
+
44
+ def destroy
45
+ @command.destroy
46
+
47
+ redirect_to commands_path, notice: "Command was successfully destroyed."
48
+ end
49
+
50
+ private
51
+
52
+ def set_command
53
+ @command = Kommandant::Command.find(params[:id])
54
+ end
55
+
56
+ def set_resource_classes
57
+ Rails.application.eager_load!
58
+ @resource_classes = ::ApplicationRecord.descendants.sort_by(&:name)
59
+ end
60
+
61
+ def command_params_with_translations
62
+ return command_params if command_params[:translations].nil?
63
+
64
+ command_params.merge(translations: command_params[:translations].each_pair { |key, value| value.compact_blank! })
65
+ end
66
+
67
+ def command_params
68
+ params.require(:command).permit(:icon, :path, :http_method, :resource_class, :redirect_path,
69
+ :search_result_text_method, :admin_only, translations: permitted_translation_params)
70
+ end
71
+
72
+ def permitted_translation_params
73
+ I18n.available_locales.map { |locale| {locale => [:name, :placeholder, :result_text]} }
74
+ end
17
75
  end
@@ -1,14 +1,13 @@
1
- module Kommandant
2
- class SearchesController < ApplicationController
3
- def index
4
- @results = Kommandant::Command.search(params[:query])
1
+ class Kommandant::SearchesController < ApplicationController
2
+ def index
3
+ @results = Kommandant::Command.search(params[:query])
5
4
 
6
- unless Kommandant.config.admin_only_filter_lambda.present? && Kommandant.config.admin_only_filter_lambda.call(current_user, current_admin)
7
- @results.reject!(&:admin_only?)
8
- end
5
+ unless Kommandant.config.admin_only_filter_lambda.present? && Kommandant.config.admin_only_filter_lambda.call(current_user, current_admin)
6
+ @results.reject!(&:admin_only?)
9
7
  end
8
+ end
10
9
 
11
- def new
12
- end
10
+ def new
13
11
  end
14
12
  end
13
+
@@ -1,62 +1,11 @@
1
1
  module Kommandant
2
- class Command
3
- class << self
4
- def reindex!
5
- index.add_documents(
6
- JSON.parse(File.read(Kommandant.config.commands_path))
7
- )
8
- end
9
-
10
- def search(query)
11
- result = index.search(query)["hits"]
12
-
13
- result.map do |command|
14
- new(**command.symbolize_keys)
15
- end
16
- end
17
-
18
- def find(id)
19
- search(id).find { |command| command.id == id }
20
- end
21
-
22
- def all
23
- JSON.parse(File.read(Kommandant.config.commands_path)).map do |hash|
24
- Kommandant::Command.new(**hash.symbolize_keys)
25
- end
26
- end
27
-
28
- def index
29
- client.index("commands")
30
- end
31
-
32
- def client
33
- MeiliSearch::Rails.client
34
- end
35
- end
2
+ class Command < ApplicationRecord
3
+ include MeiliSearch::Rails
36
4
 
37
- def initialize(id:, icon:, path:, http_method:, resource_class: nil, redirect_path: nil, text_keys: [], admin_only: false, translations: {})
38
- @id = id
39
- @icon = icon
40
- @path = path
41
- @http_method = http_method
42
- @resource_class = resource_class
43
- @redirect_path = redirect_path
44
- @text_keys = text_keys
45
- @admin_only = admin_only
46
- @translator = I18n::Backend::KeyValue.new({})
47
- translations.each_pair do |locale, data|
48
- @translator.store_translations(locale, data)
49
- end
5
+ meilisearch do
6
+ attribute :translations
50
7
  end
51
8
 
52
- def ==(other)
53
- instance_variables.all? do |ivar|
54
- instance_variable_get(ivar) == other.instance_variable_get(ivar)
55
- end
56
- end
57
-
58
- attr_reader :id, :path, :http_method, :resource_class, :redirect_path, :text_keys, :translator
59
-
60
9
  def name
61
10
  return "no translation for #{I18n.locale}.name in Meilisearch" unless translator.exists?(I18n.locale, "name")
62
11
 
@@ -69,20 +18,14 @@ module Kommandant
69
18
  translator.translate(I18n.locale, "placeholder")
70
19
  end
71
20
 
72
- def admin_only?
73
- admin_only
74
- end
75
-
76
- def icon?
77
- icon.present?
78
- end
79
-
80
- def icon
81
- @icon.to_s.dasherize
21
+ def translator
22
+ @translator ||= begin
23
+ translator = I18n::Backend::KeyValue.new({})
24
+ translations&.each_pair do |locale, data|
25
+ translator.store_translations(locale, data)
26
+ end
27
+ translator
28
+ end
82
29
  end
83
-
84
- private
85
-
86
- attr_reader :admin_only
87
30
  end
88
31
  end
@@ -3,23 +3,16 @@ module Kommandant
3
3
  def initialize(command:, resource:)
4
4
  @command = command
5
5
  @resource = resource
6
- @translator = command.translator
7
6
  end
8
7
 
9
8
  attr_reader :resource
10
9
  delegate :icon, to: :command
11
10
 
12
11
  def name
13
- if translator.exists?(I18n.locale, "result_text")
14
- translation_attributes = {}
15
- command.text_keys.each do |key|
16
- translation_attributes[key.to_sym] = indexed_attribute_for(resource, key)
17
- end
18
- translator.translate(I18n.locale, "result_text", **translation_attributes)
12
+ if command.translator.exists?(I18n.locale, "result_text")
13
+ command.translator.translate(I18n.locale, "result_text")
19
14
  else
20
- command.text_keys.map do |text_key|
21
- indexed_attribute_for(resource, text_key)
22
- end.join(", ")
15
+ indexed_attribute_for(resource, command.search_result_text_method)
23
16
  end
24
17
  end
25
18
 
@@ -35,7 +28,7 @@ module Kommandant
35
28
 
36
29
  private
37
30
 
38
- attr_reader :command, :translator
31
+ attr_reader :command
39
32
 
40
33
  def indexed_attribute_for(resource, text_key)
41
34
  resource.meilisearch_settings.get_attributes(resource)[text_key]
@@ -0,0 +1,23 @@
1
+ <tr class="hover:kommandant-bg-gray-50">
2
+ <th class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900"><%= command.name %></th>
3
+ <td class="kommandant-px-6 kommandant-py-4 kommandant-size-6">
4
+ <div class="kommandant-size-6 kommandant-mx-auto">
5
+ <%= render "kommandant/shared/icons/command", icon: command.icon %>
6
+ </div>
7
+
8
+ <p class="kommandant-text-center">
9
+ <%= command.icon %>
10
+ </p>
11
+ </td>
12
+ <td class="kommandant-px-6 kommandant-py-4"><%= command.path %></td>
13
+ <td class="kommandant-px-6 kommandant-py-4"><%= command.http_method %></td>
14
+ <td class="kommandant-px-6 kommandant-py-4"><%= command.resource_class %></td>
15
+ <td class="kommandant-px-6 kommandant-py-4"><%= command.redirect_path %></td>
16
+ <td class="kommandant-px-6 kommandant-py-4"><%= command.search_result_text_method %></td>
17
+ <td class="kommandant-px-6 kommandant-py-4"><%= command.translations %></td>
18
+ <td class="kommandant-px-6 kommandant-py-4"><%= command.admin_only %></td>
19
+ <td class="kommandant-flex kommandant-justify-end kommandant-gap-4 kommandant-px-6 kommandant-py-4 kommandant-font-medium">
20
+ <%= button_to "Delete", command_path(command), method: :delete, class: "kommandant-underline kommandant-font-medium" %>
21
+ <%= link_to "Edit", edit_command_path(command), class: "kommandant-underline kommandant-font-medium" %>
22
+ </td>
23
+ </tr>
@@ -0,0 +1,58 @@
1
+ <%= form_with model: command, class: "kommandant-flex kommandant-flex-col kommandant-space-y-4" do |form| %>
2
+ <% I18n.available_locales.each do |locale| %>
3
+ <label for="<%= locale %>" class="kommandant-text-lg kommandant-font-medium"><%= t("kommandant.commands.translations", code: locale) %></label>
4
+ <div id="<%= locale %>" class="kommandant-flex kommandant-space-x-4">
5
+ <div>
6
+ <%= form.label t("kommandant.translations.name"), for: "command[translations][#{locale}][name]", class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
7
+ <%= form.text_field :name, name: "command[translations][#{locale}][name]", value: command.translations&.dig(locale.to_s, "name"), class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
8
+ </div>
9
+ <div>
10
+ <%= form.label t("kommandant.translations.placeholder"), for: "[translations][#{locale}][placeholder]", class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
11
+ <%= form.text_field :placeholder, name: "command[translations][#{locale}][placeholder]", value: command.translations&.dig(locale.to_s, "placeholder"), class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
12
+ </div>
13
+ <div>
14
+ <%= form.label t("kommandant.translations.result_text"), for: "[translations][#{locale}][result_text]", class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
15
+ <%= form.text_field :result_text, name: "command[translations][#{locale}][result_text]", value: command.translations&.dig(locale.to_s, "result_text"), class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
16
+ </div>
17
+ </div>
18
+ <% end %>
19
+
20
+ <div>
21
+ <%= form.label :icon, class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
22
+ <%= form.text_field :icon, class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
23
+ </div>
24
+
25
+ <div>
26
+ <%= form.label :path, class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
27
+ <%= form.text_field :path, class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
28
+ </div>
29
+
30
+ <div>
31
+ <%= form.label :http_method, class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
32
+ <%= form.select :http_method, [:get, :post, :patch, :put, :delete], {}, class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
33
+ </div>
34
+
35
+ <div>
36
+ <%= form.label :resource_class, class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
37
+ <%= form.select :resource_class, options_from_collection_for_select(resource_classes, :name, :name, selected: form.object.resource_class), {include_blank: true}, class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
38
+ </div>
39
+
40
+ <div>
41
+ <%= form.label :redirect_path, class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
42
+ <%= form.text_field :redirect_path, class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
43
+ </div>
44
+
45
+ <div>
46
+ <%= form.label :search_result_text_method, class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
47
+ <%= form.text_field :search_result_text_method, class: "kommandant-mt-1 kommandant-border-slate-500 kommandant-rounded-sm" %>
48
+ </div>
49
+
50
+ <div>
51
+ <%= form.label :admin_only, class: "kommandant-block kommandant-text-slate-700 kommandant-font-medium kommandant-text-sm" %>
52
+ <%= form.check_box :admin_only, class: "kommandant-mt-1 kommandant-h-4 kommandant-w-4 kommandant-rounded kommandant-slate-300 kommandant-text-slate-600 kommandant-shadow-sm focus:kommandant-border-slate-300 focus:kommandant-ring focus:kommandant-ring-slate-200 focus:kommandant-ring-opacity-50 focus:kommandant-ring-offset-0 disabled:kommandant-cursor-not-allowed disabled:kommandant-text-slate-400" %>
53
+ </div>
54
+
55
+ <div>
56
+ <%= form.submit class: "kommandant-px-2 kommandant-py-1 kommandant-rounded kommandant-text-sm kommandant-bg-slate-900 kommandant-text-white" %>
57
+ </div>
58
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render "form", command: @command, resource_classes: @resource_classes %>
@@ -0,0 +1,29 @@
1
+ <div class="kommandant-flex kommandant-justify-between">
2
+ <h1 class="kommandant-text-3xl kommandant-font-medium kommandant-leading-6">Commands</h1>
3
+
4
+ <%= link_to t("kommandant.new"), new_command_path, class: "kommandant-px-2 kommandant-py-1 kommandant-rounded kommandant-text-sm kommandant-bg-slate-900 kommandant-text-white" %>
5
+ </div>
6
+
7
+ <div class="kommandant-mt-4 kommandant-overflow-hidden kommandant-rounded kommandant-border kommandant-border-gray-200">
8
+ <table class="kommandant-w-full kommandant-border-collapse kommandant-bg-white kommandant-text-left kommandant-text-sm kommandant-text-gray-500">
9
+ <thead class="kommandant-bg-gray-50">
10
+ <tr>
11
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Name</th>
12
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Icon</th>
13
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Path</th>
14
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">HTTP Method</th>
15
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Resource Class</th>
16
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Redirect Path</th>
17
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Search Result Text Method</th>
18
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Translations</th>
19
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900">Admin only</th>
20
+ <th scope="col" class="kommandant-px-6 kommandant-py-4 kommandant-font-medium kommandant-text-gray-900"></th>
21
+ </tr>
22
+ </thead>
23
+ <tbody class="kommandant-divide-y kommandant-divide-gray-100 kommandant-border-t kommandant-border-gray-100">
24
+ <% @commands.each do |command| %>
25
+ <%= render command %>
26
+ <% end %>
27
+ </tbody>
28
+ </table>
29
+ </div>
@@ -0,0 +1 @@
1
+ <%= render "form", command: @command, resource_classes: @resource_classes %>
@@ -19,9 +19,9 @@
19
19
  <% @results.each do |result| %>
20
20
  <%# TODO: How about a default? %>
21
21
  <% if partial_exists_for_result?(result) %>
22
- <%= render result.resource, result: result %>
22
+ <%= render result.resource, result: result, query: params[:query] %>
23
23
  <% else %>
24
- <%= render "kommandant/shared/command_palette/result", result: result %>
24
+ <%= render "kommandant/shared/command_palette/result", result: result, query: params[:query] %>
25
25
  <% end %>
26
26
  <% end %>
27
27
  </ul>
@@ -47,7 +47,7 @@
47
47
  <div class="kommandant-flex kommandant-justify-end kommandant-items-center kommandant-divide-x kommandant-bg-gray-50 kommandant-py-2.5 kommandant-px-4 kommandant-text-xs kommandant-text-gray-700">
48
48
  <div class="kommandant-pr-2 kommandant-flex kommandant-flex-wrap kommandant-justify-end kommandant-items-center kommandant-space-x-2">
49
49
  <span><%= t("kommandant.pagination.prev").html_safe %>:</span>
50
-
50
+
51
51
  <div class="kommandant-flex kommandant-items-center kommandant-space-x-1">
52
52
  <kbd class="kommandant-px-1 kommandant-py-0.5 kommandant-rounded kommandant-border kommandant-border-gray-400 kommandant-bg-white kommandant-font-semibold kommandant-text-gray-900">Ctrl</kbd>
53
53
  <span>+</span>
@@ -57,7 +57,7 @@
57
57
 
58
58
  <div class="kommandant-pl-2 kommandant-flex kommandant-flex-wrap kommandant-justify-end kommandant-items-center kommandant-space-x-2">
59
59
  <span><%= t("kommandant.pagination.next").html_safe %>:</span>
60
-
60
+
61
61
  <div class="kommandant-flex kommandant-items-center kommandant-space-x-1">
62
62
  <kbd class="kommandant-px-1 kommandant-py-0.5 kommandant-rounded kommandant-border kommandant-border-gray-400 kommandant-bg-white kommandant-font-semibold kommandant-text-gray-900">Ctrl</kbd>
63
63
  <span>+</span>
@@ -11,10 +11,10 @@
11
11
  </div>
12
12
 
13
13
  <%= form_with url: Kommandant::Engine.routes.url_helpers.command_searches_path(@command.id), method: :get, class: "kommandant-flex-grow" do |form| %>
14
- <%= form.text_field :query, class: "kommandant-h-12 kommandant-w-full kommandant-border-0 kommandant-bg-transparent kommandant-pl-1 kommandant-pr-4 kommandant-text-gray-800 kommandant-placeholder-gray-400 focus:kommandant-ring-0 sm:kommandant-text-sm", value: @query, placeholder: @command.placeholder, autocomplete: "off", data: {command_palette_target: "input", action: "keyup->command-palette#submit"} %>
14
+ <%= form.text_field :query, class: "kommandant-h-12 kommandant-w-full kommandant-border-0 kommandant-bg-transparent kommandant-pl-1 kommandant-pr-4 kommandant-text-gray-800 kommandant-placeholder-gray-400 focus:kommandant-ring-0 sm:kommandant-text-sm", value: @query, placeholder: @command&.placeholder, autocomplete: "off", data: {command_palette_target: "input", action: "keyup->command-palette#submit"} %>
15
15
  <% end %>
16
16
  </div>
17
17
  </div>
18
-
18
+
19
19
  <%= render "kommandant/shared/command_palette/loading_message" %>
20
20
  <% end %>
@@ -17,7 +17,7 @@
17
17
  data-transition-leave="kommandant-ease-in kommandant-duration-200"
18
18
  data-transition-leave-start="kommandant-opacity-100 kommandant-scale-100"
19
19
  data-transition-leave-end="kommandant-opacity-0 kommandant-scale-95">
20
-
20
+
21
21
  <div class="kommandant-mx-auto kommandant-max-w-2xl kommandant-transform kommandant-divide-y kommandant-divide-gray-100 kommandant-overflow-hidden kommandant-rounded-xl kommandant-bg-white kommandant-shadow-2xl kommandant-ring-1 kommandant-ring-black kommandant-ring-opacity-5 kommandant-transition-all">
22
22
  <%= turbo_frame_tag :command_palette do %>
23
23
  <div data-command-palette-target="content">
@@ -44,10 +44,9 @@
44
44
  <%= render "kommandant/shared/command_palette/default_state", recent_commands: local_assigns[:recent_commands] %>
45
45
  <% end %>
46
46
  </div>
47
-
47
+
48
48
  <%= render "kommandant/shared/command_palette/loading_message" %>
49
49
  <% end %>
50
50
  </div>
51
51
  </div>
52
52
  </div>
53
-
@@ -1,13 +1,20 @@
1
+ <% target = command.path? && command.http_method == "get" ? {target: "_top"} : {} %>
2
+
1
3
  <li>
2
- <%= link_to command.path, class: "kommandant-group kommandant-cursor-default kommandant-select-none kommandant-flex kommandant-items-center kommandant-px-3 kommandant-py-2 kommandant-rounded-md data-[active=true]:kommandant-bg-slate-600 data-[active=true]:kommandant-text-white group-data-[active=true]:kommandant-outline-none", data: {active: false, keyboard_navigation_target: "focusable", action: "mouseenter->keyboard-navigation#focus click->command-palette#showLoadingMessage", turbo_method: command.http_method} do %>
4
+ <%= link_to command.path? ? command.path : kommandant.command_path(command),
5
+ **{data: {
6
+ active: false,
7
+ keyboard_navigation_target: "focusable",
8
+ action: "mouseenter->keyboard-navigation#focus click->command-palette#showLoadingMessage",
9
+ turbo_method: command.http_method
10
+ },
11
+ class: "kommandant-group kommandant-cursor-default kommandant-select-none kommandant-flex kommandant-items-center kommandant-px-3 kommandant-py-2 kommandant-rounded-md data-[active=true]:kommandant-bg-slate-600 data-[active=true]:kommandant-text-white group-data-[active=true]:kommandant-outline-none"}.merge(target) do %>
3
12
  <% if command.icon? %>
4
- <!-- For some reason the line below works, but the uncommented line does not color the icon... I have no idea why... -->
5
- <!-- <div class="kommandant-flex-none kommandant-text-gray-400 group-data-[active=true]:text-white"> -->
6
13
  <div class="kommandant-flex-none kommandant-text-gray-400 group-data-[active=true]:kommandant-text-white">
7
14
  <%= render "kommandant/shared/icons/command", icon: command.icon %>
8
15
  </div>
9
16
  <% end %>
10
-
17
+
11
18
  <span class="kommandant-ml-3 kommandant-flex-auto kommandant-truncate"><%= command.name %></span>
12
19
  <span class="kommandant-ml-3 kommandant-hidden group-data[active=true]:kommandant-inline kommandant-flex-none kommandant-text-indigo-100"><%= t("kommandant.navigation.jump_to") %></span>
13
20
  <% end %>
@@ -1,6 +1,10 @@
1
1
  <li>
2
2
  <%= link_to result.path, data: {active: false, keyboard_navigation_target: "focusable", action: "mouseenter->keyboard-navigation#focus click->command-palette#showLoadingMessage", turbo_method: result.http_method, turbo_frame: "_top"}, class: "kommandant-group kommandant-cursor-default kommandant-select-none kommandant-flex kommandant-items-center kommandant-px-3 kommandant-py-2 kommandant-rounded-md data-[active=true]:kommandant-bg-slate-600 data-[active=true]:kommandant-text-white group-data-[active=true]:kommandant-outline-none" do %>
3
- <span class="kommandant-ml-3 kommandant-flex-auto kommandant-truncate"><%= result.name %></span>
3
+ <% if Kommandant.config.highlight_search_term %>
4
+ <span class="kommandant-ml-3 kommandant-flex-auto kommandant-truncate"><%= highlight(result.name, query) { |match| tag.b(match, class: "kommandant-bg-amber-200 kommandant-text-gray-900") } %></span>
5
+ <% else %>
6
+ <span class="kommandant-ml-3 kommandant-flex-auto kommandant-truncate"><%= result.name %></span>
7
+ <% end %>
4
8
  <span class="kommandant-ml-3 kommandant-hidden group-data-[active=true]:kommandant-inline kommandant-flex-none kommandant-text-indigo-100"><%= t("kommandant.navigation.jump_to") %></span>
5
9
  <% end %>
6
10
  </li>
@@ -0,0 +1,5 @@
1
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M9.99998 0C5.10436 0 1.13525 2.67824 1.13525 5.09523C1.13525 6.26344 2.0642 7.04957 3.57666 7.68617V8.67008H16.424V7.6502C17.9346 7.00078 18.8647 6.26348 18.8647 5.09527C18.8647 2.67824 14.8962 0 9.99998 0ZM9.99998 7.44078C8.82932 7.44078 7.88021 6.49168 7.88021 5.32102C7.88021 4.15035 8.82932 3.2007 9.99998 3.2007C11.1706 3.2007 12.1203 4.15043 12.1203 5.32105C12.1203 6.49168 11.1706 7.44078 9.99998 7.44078Z" fill="currentColor"/>
3
+ <path d="M8.81836 5.05553L9.27004 6.44467H10.7306L11.1816 5.05553L10 4.19678L8.81836 5.05553Z" fill="currentColor"/>
4
+ <path d="M16.4934 12.1363C16.4818 12.1259 16.469 12.1186 16.4568 12.1094L16.3963 9.65456C16.4135 9.58374 16.4238 9.51296 16.4238 9.44093H15.9202V9.40308H4.01478V9.44093H3.57658C3.57658 9.45679 3.57904 9.47269 3.57962 9.48855L3.5424 9.4739L3.47767 12.1094C3.38673 12.1784 3.30068 12.2657 3.23474 12.3755C3.13099 12.5458 3.0797 12.7552 3.08033 12.9798C3.08095 13.1653 3.11267 13.3643 3.17736 13.5865C3.29087 13.9741 3.47826 14.4275 3.75111 14.8182C3.88845 15.0128 4.04775 15.1929 4.24548 15.3357C4.37669 15.431 4.53052 15.5078 4.7008 15.5494C4.71302 15.6189 4.72826 15.6946 4.74474 15.7746C4.77587 15.9272 4.8131 16.092 4.85462 16.2476C4.89736 16.4045 4.94009 16.5479 5.00232 16.6816C5.35634 17.4329 5.80373 18.0225 6.28529 18.4778C7.00857 19.1614 7.80384 19.5423 8.47584 19.751C9.15029 19.9598 9.69837 20 9.96693 20C10.1476 20 10.4485 19.9817 10.8318 19.9085C11.4049 19.7974 12.1587 19.5618 12.9088 19.065C13.659 18.5693 14.4018 17.8089 14.9315 16.6809C14.9938 16.5479 15.0371 16.4044 15.0799 16.2476C15.1421 16.0144 15.1946 15.7593 15.2324 15.5585C15.2331 15.5554 15.2331 15.5524 15.2343 15.5493C15.404 15.5078 15.5577 15.4309 15.6884 15.3357C15.9844 15.1208 16.1974 14.8248 16.372 14.5154C16.5441 14.2047 16.6723 13.8769 16.7571 13.5864C16.8212 13.3642 16.8535 13.1653 16.8541 12.9798C16.8541 12.7796 16.8138 12.5928 16.7314 12.4329C16.6704 12.3139 16.5862 12.2126 16.4934 12.1363ZM15.9307 13.346C15.8416 13.656 15.6756 14.0454 15.4784 14.3237C15.3814 14.4629 15.277 14.5728 15.1867 14.6375C15.0945 14.7021 15.0279 14.7211 14.9706 14.7217L14.9322 14.7186L14.5104 14.6551L14.4433 15.0769L14.442 15.0867C14.4335 15.138 14.3926 15.3851 14.3358 15.6543C14.3077 15.7886 14.2748 15.9289 14.2419 16.0498C14.2101 16.1694 14.1735 16.2732 14.1533 16.3147C13.8439 16.9702 13.4636 17.4682 13.0577 17.8528C12.4486 18.4284 11.7772 18.75 11.2029 18.9289C10.6304 19.1077 10.1513 19.14 9.96693 19.1394C9.84548 19.1394 9.58974 19.126 9.26502 19.0632C8.77736 18.9692 8.1322 18.7665 7.50048 18.3478C6.86814 17.9279 6.24498 17.2974 5.78111 16.3147C5.75912 16.2708 5.72005 16.1554 5.68587 16.0254C5.63279 15.8276 5.58271 15.5872 5.54795 15.3992C5.52962 15.3052 5.5156 15.2234 5.50584 15.166C5.50095 15.138 5.4967 15.1148 5.49423 15.0995L5.49056 15.0769L5.42404 14.6558L5.00228 14.7187L4.96384 14.7217C4.90587 14.7211 4.83994 14.7022 4.74716 14.6375C4.61045 14.5417 4.44685 14.339 4.31443 14.0967C4.17955 13.8556 4.07091 13.5779 4.00377 13.346C3.95615 13.1836 3.94091 13.0621 3.94091 12.9798C3.94154 12.8894 3.9574 12.8473 3.96716 12.8272L3.99095 12.7979C4.00498 12.7857 4.03427 12.7692 4.08005 12.7576C4.12462 12.7466 4.18259 12.7405 4.23388 12.7405C4.27478 12.7405 4.31138 12.7442 4.33459 12.7466L4.36021 12.7503L4.72888 12.8235C4.77283 12.8967 4.81861 12.9773 4.86498 13.0689C4.91564 12.5867 5.02548 11.662 5.10728 10.9802C6.28525 11.4923 8.03943 11.8176 9.99986 11.8176C11.9261 11.8176 13.6528 11.5039 14.8302 11.0071C14.912 11.6858 15.0194 12.5928 15.0694 13.0689C15.1158 12.9773 15.161 12.8967 15.2055 12.8235L15.5742 12.7503H15.5748C15.5883 12.7478 15.6395 12.7405 15.6999 12.7405C15.7457 12.7405 15.7964 12.7448 15.8385 12.7539C15.8702 12.7613 15.8971 12.7704 15.9154 12.7796C15.9435 12.7948 15.9514 12.8033 15.963 12.8205C15.9728 12.8382 15.9923 12.8772 15.9935 12.9798C15.9936 13.0622 15.9777 13.1836 15.9307 13.346Z" fill="currentColor"/>
5
+ </svg>
@@ -1,15 +1,30 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Kommandant</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
3
+ <head>
4
+ <title>Kommandant</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
7
 
8
- <%= stylesheet_link_tag "kommandant/application", media: "all" %>
9
- </head>
10
- <body>
8
+ <%= stylesheet_link_tag "kommandant", "data-turbo-track": "reload" %>
9
+ <style>
10
+ *,::after,::before{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}::after,::before{--tw-content:''}:host,html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type='button']),input:where([type='reset']),input:where([type='submit']){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type='search']{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role="button"],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}[type='text'],[type='email'],[type='url'],[type='password'],[type='number'],[type='date'],[type='datetime-local'],[type='month'],[type='search'],[type='tel'],[type='time'],[type='week'],[multiple],textarea,select{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#6b7280;border-width:1px;border-radius:0;padding:0.5rem 0.75rem;font-size:1rem;line-height:1.5rem;--tw-shadow:0 0 #0000}[type='text']:focus,[type='email']:focus,[type='url']:focus,[type='password']:focus,[type='number']:focus,[type='date']:focus,[type='datetime-local']:focus,[type='month']:focus,[type='search']:focus,[type='tel']:focus,[type='time']:focus,[type='week']:focus,[multiple]:focus,textarea:focus,select:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset:var(--tw-empty,/*!*/ /*!*/);--tw-ring-offset-width:0;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-color:#2563eb}input::-moz-placeholder,textarea::-moz-placeholder{color:#6b7280;opacity:1}input::placeholder,textarea::placeholder{color:#6b7280;opacity:1}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-date-and-time-value{min-height:1.5em}::-webkit-datetime-edit,::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field,::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-second-field,::-webkit-datetime-edit-year-field{padding-top:0;padding-bottom:0}select{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");background-position:right 0.5rem center;background-repeat:no-repeat;background-size:1.5em 1.5em;padding-right:2.5rem;-webkit-print-color-adjust:exact;print-color-adjust:exact}[multiple]{background-image:initial;background-position:initial;background-repeat:unset;background-size:initial;padding-right:0.75rem;-webkit-print-color-adjust:unset;print-color-adjust:unset}[type='checkbox'],[type='radio']{-webkit-appearance:none;-moz-appearance:none;appearance:none;padding:0;-webkit-print-color-adjust:exact;print-color-adjust:exact;display:inline-block;vertical-align:middle;background-origin:border-box;-webkit-user-select:none;-moz-user-select:none;user-select:none;flex-shrink:0;height:1rem;width:1rem;color:#2563eb;background-color:#fff;border-color:#6b7280;border-width:1px;--tw-shadow:0 0 #0000}[type='checkbox']{border-radius:0}[type='radio']{border-radius:100%}[type='checkbox']:focus,[type='radio']:focus{outline:2px solid transparent;outline-offset:2px;--tw-ring-inset:var(--tw-empty,/*!*/ /*!*/);--tw-ring-offset-width:2px;--tw-ring-offset-color:#fff;--tw-ring-color:#2563eb;--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}[type='checkbox']:checked,[type='radio']:checked{border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type='checkbox']:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e")}[type='radio']:checked{background-image:url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e")}[type='checkbox']:checked:hover,[type='checkbox']:checked:focus,[type='radio']:checked:hover,[type='radio']:checked:focus{border-color:transparent;background-color:currentColor}[type='checkbox']:indeterminate{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3e%3cpath stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3e%3c/svg%3e");border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:center;background-repeat:no-repeat}[type='checkbox']:indeterminate:hover,[type='checkbox']:indeterminate:focus{border-color:transparent;background-color:currentColor}[type='file']{background:unset;border-color:inherit;border-width:0;border-radius:0;padding:0;font-size:unset;line-height:inherit}[type='file']:focus{outline:1px solid ButtonText;outline:1px auto -webkit-focus-ring-color}
11
+ </style>
12
+ </head>
13
+ <body class="kommandant-h-full">
14
+ <header class="kommandant-h-16 kommandant-border-b kommandant-border-slate-500">
15
+ <nav class="kommandant-flex kommandant-items-center kommandant-justify-between kommandant-px-12 kommandant-py-4">
16
+ <%= image_tag "kommandant/logo.svg" %>
11
17
 
12
- <%= yield %>
18
+ <% if main_app.respond_to?(:root_url) %>
19
+ <%= link_to main_app.root_url, class: "", data: { turbo: false } do %>
20
+ <%= t("kommandant.navigation.back_to_app") %>
21
+ <% end %>
22
+ <% end %>
23
+ </nav>
24
+ </header>
13
25
 
14
- </body>
26
+ <main class="kommandant-px-12 kommandant-py-8">
27
+ <%= yield %>
28
+ </main>
29
+ </body>
15
30
  </html>
@@ -12,8 +12,19 @@ en:
12
12
  icons:
13
13
  command:
14
14
  icon_missing: Command icon missing with name '%{icon_name}'
15
+
15
16
  navigation:
16
17
  jump_to: Jump to
18
+ back_to_app: ← Back to App
19
+
17
20
  pagination:
18
21
  prev: Previous
19
22
  next: Next
23
+
24
+ commands:
25
+ translations: "%{code} translations"
26
+
27
+ translations:
28
+ name: Name
29
+ placeholder: Placeholder
30
+ result_text: Result text
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  Kommandant::Engine.routes.draw do
2
2
  resources :searches, only: [:index, :new]
3
- resources :commands, only: [:show] do
3
+ resources :commands do
4
4
  resource :searches, module: :commands, only: [:show]
5
5
  end
6
6
  end
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Adds the Kommandant configuration to your application along with a sample command.
3
+
4
+ Example:
5
+ bin/rails generate kommandant:install
6
+
7
+ This will create:
8
+ config/initializers/kommandant.rb
9
+ config/kommandant/commands.json
@@ -0,0 +1,9 @@
1
+ require "rails/generators"
2
+
3
+ class Kommandant::InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("templates", __dir__)
5
+
6
+ def copy_templates
7
+ template "initializer.rb", "config/initializers/kommandant.rb"
8
+ end
9
+ end