super 0.0.10 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -9
  3. data/README.md +40 -52
  4. data/app/assets/javascripts/super/application.js +5672 -3671
  5. data/app/assets/stylesheets/super/application.css +114681 -71486
  6. data/app/controllers/super/application_controller.rb +31 -21
  7. data/app/helpers/super/form_builder_helper.rb +2 -0
  8. data/app/views/layouts/super/application.html.erb +15 -14
  9. data/app/views/super/application/{_super_schema_display_actions.html.erb → _display_actions.html.erb} +0 -0
  10. data/app/views/super/application/{_super_schema_display_index.html.erb → _display_index.html.erb} +4 -4
  11. data/app/views/super/application/_display_show.html.erb +8 -0
  12. data/app/views/super/application/_filter.html.erb +5 -13
  13. data/app/views/super/application/_filter_type_select.html.erb +5 -2
  14. data/app/views/super/application/_filter_type_text.html.erb +6 -4
  15. data/app/views/super/application/_filter_type_timestamp.html.erb +6 -5
  16. data/app/views/super/application/{_super_schema_form.html.erb → _form.html.erb} +2 -2
  17. data/app/views/super/application/_form_field.html.erb +5 -0
  18. data/app/views/super/application/{_super_layout.html.erb → _layout.html.erb} +8 -8
  19. data/app/views/super/application/{_super_pagination.html.erb → _pagination.html.erb} +1 -1
  20. data/app/views/super/application/{_super_panel.html.erb → _panel.html.erb} +2 -2
  21. data/app/views/super/application/_query.html.erb +18 -0
  22. data/app/views/super/application/_sort.html.erb +18 -0
  23. data/app/views/super/application/_sort_expression.html.erb +25 -0
  24. data/app/views/super/feather/README.md +1 -1
  25. data/app/views/super/feather/_x.html +15 -0
  26. data/config/routes.rb +2 -0
  27. data/frontend/super-frontend/dist/application.css +114681 -71486
  28. data/frontend/super-frontend/dist/application.js +5672 -3671
  29. data/lib/generators/super/action_text/action_text_generator.rb +2 -0
  30. data/lib/generators/super/install/install_generator.rb +18 -23
  31. data/lib/generators/super/install/templates/base_controller.rb.tt +9 -1
  32. data/lib/generators/super/install/templates/initializer.rb.tt +9 -2
  33. data/lib/generators/super/resource/resource_generator.rb +107 -30
  34. data/lib/generators/super/resource/templates/resources_controller.rb.tt +3 -9
  35. data/lib/generators/super/webpacker/webpacker_generator.rb +11 -5
  36. data/lib/super.rb +10 -2
  37. data/lib/super/action_inquirer.rb +13 -3
  38. data/lib/super/assets.rb +46 -23
  39. data/lib/super/badge.rb +61 -0
  40. data/lib/super/cheat.rb +17 -0
  41. data/lib/super/client_error.rb +2 -0
  42. data/lib/super/compatibility.rb +21 -0
  43. data/lib/super/configuration.rb +16 -24
  44. data/lib/super/controls.rb +11 -2
  45. data/lib/super/controls/optional.rb +44 -1
  46. data/lib/super/controls/steps.rb +53 -34
  47. data/lib/super/controls/view.rb +55 -0
  48. data/lib/super/display.rb +29 -13
  49. data/lib/super/display/guesser.rb +4 -0
  50. data/lib/super/display/schema_types.rb +118 -29
  51. data/lib/super/engine.rb +2 -0
  52. data/lib/super/error.rb +12 -0
  53. data/lib/super/filter.rb +2 -0
  54. data/lib/super/filter/form_object.rb +5 -8
  55. data/lib/super/filter/guesser.rb +2 -0
  56. data/lib/super/filter/operator.rb +2 -0
  57. data/lib/super/filter/schema_types.rb +2 -0
  58. data/lib/super/form.rb +3 -1
  59. data/lib/super/form/builder.rb +109 -27
  60. data/lib/super/form/guesser.rb +12 -1
  61. data/lib/super/form/inline_errors.rb +2 -0
  62. data/lib/super/form/schema_types.rb +75 -7
  63. data/lib/super/form/strong_params.rb +2 -0
  64. data/lib/super/layout.rb +3 -1
  65. data/lib/super/link.rb +44 -31
  66. data/lib/super/link_builder.rb +58 -0
  67. data/lib/super/navigation.rb +164 -0
  68. data/lib/super/pagination.rb +3 -43
  69. data/lib/super/panel.rb +3 -1
  70. data/lib/super/partial.rb +2 -0
  71. data/lib/super/partial/resolving.rb +2 -0
  72. data/lib/super/plugin.rb +2 -0
  73. data/lib/super/query/form_object.rb +48 -0
  74. data/lib/super/reset.rb +17 -0
  75. data/lib/super/schema.rb +2 -0
  76. data/lib/super/schema/common.rb +2 -0
  77. data/lib/super/schema/guesser.rb +2 -0
  78. data/lib/super/sort.rb +110 -0
  79. data/lib/super/useful/builder.rb +25 -0
  80. data/lib/super/useful/enum.rb +63 -0
  81. data/lib/super/version.rb +3 -1
  82. data/lib/super/view_helper.rb +2 -0
  83. data/lib/tasks/super/cheat.rake +9 -0
  84. metadata +45 -28
  85. data/CONTRIBUTING.md +0 -56
  86. data/Rakefile +0 -34
  87. data/STABILITY.md +0 -50
  88. data/app/views/super/application/_form_field_checkbox.html.erb +0 -1
  89. data/app/views/super/application/_form_field_rich_text_area.html.erb +0 -1
  90. data/app/views/super/application/_form_field_text.html.erb +0 -1
  91. data/app/views/super/application/_super_schema_display_show.html.erb +0 -8
  92. data/app/views/super/feather/_chevron_down.html +0 -1
  93. data/docs/README.md +0 -8
  94. data/docs/action_text.md +0 -48
  95. data/docs/cheat.md +0 -41
  96. data/docs/faq.md +0 -44
  97. data/docs/installation.md +0 -21
  98. data/docs/quick_start.md +0 -30
  99. data/docs/webpacker.md +0 -25
  100. data/docs/yard_customizations.rb +0 -41
  101. data/lib/super/controls/required.rb +0 -13
  102. data/lib/super/filter/plugin.rb +0 -47
  103. data/lib/super/navigation/automatic.rb +0 -71
data/CONTRIBUTING.md DELETED
@@ -1,56 +0,0 @@
1
- # Contributing
2
-
3
- Thank you for thinking about contributing to Super!
4
-
5
-
6
- ## General guidelines
7
-
8
- There are a few ground rules that to adhere to:
9
-
10
- * be friendly and patient,
11
- * be welcoming,
12
- * be considerate,
13
- * be respectful,
14
- * be careful in the words that you choose and be kind to others,
15
- * when we disagree, try to understand why.
16
-
17
- This isn't an exhaustive list of things that you can't do. Rather, take it in
18
- the spirit in which it's intended - a guide to make it easier to communicate and
19
- participate in the community.
20
-
21
- This applies to all spaces managed by the Super project.
22
-
23
- If you believe someone is violating the code of conduct, we ask that you report
24
- it by emailing: super+conduct at zachahn.com
25
-
26
- Offenders may be banned, asked to apologize, etc.
27
-
28
- (These guidelines are based on the [FreeBSD CoC][FreeBSD CoC], which in turn is
29
- based on [LLVM Project's draft CoC][LLVM CoC], which in turn is based on the
30
- [Django Project Code of Conduct][Django CoC], which is in turn based on wording
31
- from the Speak Up! project.)
32
-
33
-
34
- ## Bug reports / issues
35
-
36
- 1. Please tell us what version of Super, Ruby, and Rails you are using
37
- 1. Please search the issues before posting your problem
38
- 1. Please ask questions in a public place to benefit all Super users
39
- 1. Please email security-related problems to super+security [at] zachahn.com
40
-
41
-
42
- ## Feature requests / pull requests
43
-
44
- Contributors will need to sign a CLA. This isn't set up yet, so I won't be able
45
- to accept contributions.
46
-
47
- 1. Please note that pull requests may be closed/denied for any reason.
48
- Your feature may be better as its own repository. If so, I will link to your
49
- project from the README!
50
- 1. Please allow Super's contributors to modify your PR before merging.
51
- It might make the process a bit smoother, but this isn't a necessity.
52
-
53
-
54
- [FreeBSD CoC]: https://www.freebsd.org/internal/code-of-conduct.html
55
- [LLVM CoC]: https://llvm.org/docs/CodeOfConduct.html
56
- [Django CoC]: https://www.djangoproject.com/conduct/
data/Rakefile DELETED
@@ -1,34 +0,0 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
6
-
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'Super'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.md')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
- require_relative "dummy_path"
18
-
19
- APP_RAKEFILE = File.expand_path("#{SUPER_DUMMY_PATH}/Rakefile", __dir__)
20
- load 'rails/tasks/engine.rake'
21
-
22
- load 'rails/tasks/statistics.rake'
23
-
24
- require 'bundler/gem_tasks'
25
-
26
- require 'rake/testtask'
27
-
28
- Rake::TestTask.new(:test) do |t|
29
- t.libs << 'test'
30
- t.pattern = 'test/**/*_test.rb'
31
- t.verbose = false
32
- end
33
-
34
- task default: :test
data/STABILITY.md DELETED
@@ -1,50 +0,0 @@
1
- # Stability
2
-
3
- The table below shows the current progress towards API stability and the release
4
- of version 1.0.
5
-
6
- Note though that it is neither a comprehensive list nor a guarantee of
7
- stability.
8
-
9
-
10
- <table>
11
- <thead>
12
- <tr><th>Feature</th><th>Status</th></tr>
13
- </thead>
14
- <tbody>
15
- <tr><td>UI</td> <td>❌</td></tr>
16
- <tr><td>Frontend JS</td> <td>❌</td></tr>
17
- <tr><td><code>Super::ActionInquirer</code></td> <td>✅</td></tr>
18
- <tr><td><code>Super::ApplicationController</code></td> <td>✅</td></tr>
19
- <tr><td><code>Super::Assets</code></td> <td>🚧</td></tr>
20
- <tr><td><code>Super::ClientError</code></td> <td>✅</td></tr>
21
- <tr><td><code>Super::Compatability</code></td> <td>🙈</td></tr>
22
- <tr><td><code>Super::Configuration</code></td> <td>🚧</td></tr>
23
- <tr><td><code>Super::Controls::Optional</code></td> <td>✅</td></tr>
24
- <tr><td><code>Super::Controls::Required</code></td> <td>✅</td></tr>
25
- <tr><td><code>Super::Controls::Steps</code></td> <td>🚧</td></tr>
26
- <tr><td><code>Super::Controls</code></td> <td>✅</td></tr>
27
- <tr><td><code>Super::Display</code></td> <td>🤔</td></tr>
28
- <tr><td><code>Super::Engine</code></td> <td>🙈</td></tr>
29
- <tr><td><code>Super::Error</code></td> <td>✅</td></tr>
30
- <tr><td><code>Super::Filter</code></td> <td>❌</td></tr>
31
- <tr><td><code>Super::Form</code></td> <td>🤔</td></tr>
32
- <tr><td><code>Super::Layout</code></td> <td>🤔</td></tr>
33
- <tr><td><code>Super::Link</code></td> <td>✅</td></tr>
34
- <tr><td><code>Super::Navigation</code></td> <td>🤔</td></tr>
35
- <tr><td><code>Super::Pagination</code></td> <td>🤔</td></tr>
36
- <tr><td><code>Super::Panel</code></td> <td>🤔</td></tr>
37
- <tr><td><code>Super::Partial</code></td> <td>🤔</td></tr>
38
- <tr><td><code>Super::Plugin</code></td> <td>✅</td></tr>
39
- <tr><td><code>Super::ViewHelper</code></td> <td>❌</td></tr>
40
- </tbody>
41
- </table>
42
-
43
-
44
- ### Legend
45
-
46
- * ✅ Tentatively stable. Further changes will probably be additive
47
- * 🚧 Likely upcoming breaking changes
48
- * ❌ Planned upcoming breaking changes
49
- * 🤔 Undecided
50
- * 🙈 Private API
@@ -1 +0,0 @@
1
- <%= form.super.check_box!(column) %>
@@ -1 +0,0 @@
1
- <%= form.super.rich_text_area!(column) %>
@@ -1 +0,0 @@
1
- <%= form.super.text_field!(column) %>
@@ -1,8 +0,0 @@
1
- <table class="max-w-full mt-4">
2
- <% super_schema_display_show.each_attribute_name do |attribute_name| %>
3
- <tr>
4
- <th class="py-1 align-baseline text-right px-4"><%= controls.model.human_attribute_name(attribute_name) %></th>
5
- <td class="py-1 align-baseline"><%= super_schema_display_show.render_field(template: self, record: @record, column: attribute_name) %></td>
6
- </tr>
7
- <% end %>
8
- </table>
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
data/docs/README.md DELETED
@@ -1,8 +0,0 @@
1
- # Docs
2
-
3
- * [Quick Start](./quick_start.md)
4
- * [Installation](./installation.md)
5
- * [Webpacker](./webpacker.md)
6
- * [ActionText](./action_text.md)
7
- * [Cheat sheet](./cheat.md)
8
- * [FAQ](./faq.md)
data/docs/action_text.md DELETED
@@ -1,48 +0,0 @@
1
- <!--
2
- # @title ActionText
3
- -->
4
-
5
- # Using ActionText with Super
6
-
7
- Super has some basic support for editing and viewing ActionText. Since
8
- ActionText only works with Webpacker, you'll have to set up Webpacker for your
9
- application. You can optionally set up [Super to use Webpacker](./webpacker.md).
10
-
11
- Once you've set that up, ActionText should be relatively simple. The following
12
- command will copy over the necessary JS and CSS into your application:
13
-
14
- ```bash
15
- bundle exec rails generate super:action_text
16
- ```
17
-
18
- As an example, let's say we're making admin pages for a blog. We'll keep this
19
- example simple and work with a `Post` model with just a `#title` column and
20
- a rich text `#content` field.
21
-
22
- ```ruby
23
- class Post < ApplicationRecord
24
- has_rich_text :content
25
- end
26
- ```
27
-
28
- We'll need to configure the `#form_schema` and `#display_schema` methods.
29
-
30
- ```ruby
31
- class Controls < Super::Controls
32
- # ...
33
-
34
- def form_schema(action:)
35
- Super::Form.new do |fields, type|
36
- fields[:title] = type.text
37
- fields[:content] = type.rich_text_area
38
- end
39
- end
40
-
41
- def display_schema(action:)
42
- Super::Display.new(action: action) do |fields, type|
43
- fields[:title] = type.text
44
- fields[:content] = type.rich_text
45
- end
46
- end
47
- end
48
- ```
data/docs/cheat.md DELETED
@@ -1,41 +0,0 @@
1
- <!--
2
- # @title Cheat sheet
3
- -->
4
-
5
- # Cheat sheet
6
-
7
- ## Controls
8
-
9
- You can configure most of your admin page's behavior by editing Controls.
10
- They only work with ActiveRecord models
11
-
12
- Controls have several required and optional methods. Note that all arguments
13
- must be defined, even if they are ignored.
14
-
15
-
16
- ### Required methods
17
-
18
- The following are the methods that must be defined in the `Controls` class.
19
-
20
- * **`#model()`**
21
- The model that your controller is working with
22
-
23
-
24
- ### Optional methods
25
-
26
- The following are the methods that can be defined in the `Controls` class.
27
-
28
- * **`#title()`**
29
- The title to show on the main panel
30
- * **`#collection_actions(action:)`**
31
- The list of collection-level links
32
- * **`#member_actions(action:)`**
33
- The list of member-level links and `#show` pages
34
- * **`#scope(action:)`**
35
- The starting point of the query/relation. Defaults to `#all`
36
- * **`#display_schema(action:)`**
37
- The display schema definition for the `#index` and `#show` pages
38
- * **`#form_schema(action:)`**
39
- The form schema definition for the `#new` and `#edit` pages
40
- * **`#permitted_params(params, action:)`**
41
- The strong parameters definition
data/docs/faq.md DELETED
@@ -1,44 +0,0 @@
1
- <!--
2
- # @title FAQ
3
- -->
4
-
5
- # FAQ
6
-
7
- ## How do I handle authorization?
8
-
9
- Assuming you already have authentication set up, it should only require defining
10
- a `Controls#initialize` that accepts an authenticated user. From there, you can
11
- customize `Controls#scope` to have the required behavior.
12
-
13
- ```ruby
14
- class PostsController < AdminController
15
- def new_controls
16
- Controls.new(current_user)
17
- end
18
-
19
- class Controls < Super::Controls
20
- def initialize(current_user)
21
- @current_user = current_user
22
- end
23
-
24
- def model
25
- Post
26
- end
27
-
28
- def scope(action:)
29
- # Example: admins can read and write; others can only read
30
- if @current_user.admin?
31
- return model.all
32
- end
33
-
34
- if action.read?
35
- return model.all
36
- end
37
-
38
- raise Super::ClientError::Forbidden
39
- end
40
-
41
- # ...
42
- end
43
- end
44
- ```
data/docs/installation.md DELETED
@@ -1,21 +0,0 @@
1
- <!--
2
- # @title Installation
3
- -->
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem "super"
11
- ```
12
-
13
- And then execute:
14
-
15
- ```bash
16
- bundle install
17
- bundle exec rails generate super:install # check out the `--help` option!
18
- ```
19
-
20
- If you prefer, you can configure Super to use Webpacker instead of Sprockets.
21
- Check out the [Webpacker guide](./webpacker.md).
data/docs/quick_start.md DELETED
@@ -1,30 +0,0 @@
1
- <!--
2
- # @title Quick start
3
- -->
4
-
5
- # Quick start
6
-
7
- See [Installation](./installation.md) for the installation guide.
8
-
9
-
10
- ## Usage
11
-
12
- ### Creating new admin pages
13
-
14
- ```bash
15
- bundle exec rails generate super:resource Thing # check out the `--help` option!
16
- ```
17
-
18
- The example above will create a controller called `Admin::ThingsController`. It
19
- generates a `Controls` class inside the controller as well; it's where most
20
- configuration lives. See the documentation on [Controls](./controls.md) for more
21
- info.
22
-
23
- You'll have to manually update your routes file. It'll probably look something
24
- like the following:
25
-
26
- ```ruby
27
- namespace :admin do
28
- resources :things
29
- end
30
- ```
data/docs/webpacker.md DELETED
@@ -1,25 +0,0 @@
1
- <!--
2
- # @title Webpacker
3
- -->
4
-
5
- # Installation with Webpacker
6
-
7
- Super supports using Webpacker instead of Sprockets. You'll first need to set up
8
- Webpacker to handle ERB templates.
9
-
10
- After installing Super (see the [Installation guide](./installation.md)), run
11
- one the following:
12
-
13
- ## Webpacker 4 and 5
14
-
15
- ```bash
16
- bundle exec rails webpacker:install:erb # if you haven't already
17
- bundle exec rails generate super:webpacker
18
- ```
19
-
20
- ## Webpacker 6
21
-
22
- ```bash
23
- yarn add rails-erb-loader # if you haven't already
24
- bundle exec rails generate super:webpacker
25
- ```
@@ -1,41 +0,0 @@
1
- require "yard"
2
-
3
- module FixRelativeLinks
4
- def resolve_links(html)
5
- html = html.gsub(%r{<a href="([^"]+)">([^<]+)</a>}) do
6
- resolve_link_to_docs_subdir(full_match: $&, href: $1, content: $2)
7
- end
8
-
9
- html = html.gsub(%r{(<pre[^<]+)?<code[^>]*>([^<]+)</code>}) do
10
- resolve_link_to_code(full_match: $&, pre: $1, code: $2)
11
- end
12
-
13
- super(html)
14
- end
15
-
16
- def resolve_link_to_docs_subdir(full_match:, href:, content:)
17
- if href =~ /\bdocs\b/
18
- %({file:#{href} #{content}})
19
- else
20
- full_match
21
- end
22
- end
23
-
24
- def resolve_link_to_code(full_match:, pre:, code:)
25
- if pre
26
- return full_match
27
- end
28
-
29
- if code.include?("\n")
30
- return full_match
31
- end
32
-
33
- if !code.start_with?("Super::")
34
- return full_match
35
- end
36
-
37
- "{#{code}}"
38
- end
39
- end
40
-
41
- YARD::Templates::Template.extra_includes << FixRelativeLinks
@@ -1,13 +0,0 @@
1
- module Super
2
- class Controls
3
- # Methods for `Controls` that must be defined for Super to work properly
4
- module Required
5
- # Specifies the model. This is a required method
6
- #
7
- # @return [ActiveRecord::Base]
8
- def model
9
- raise NotImplementedError
10
- end
11
- end
12
- end
13
- end