super 0.0.9 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) 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 +5671 -3669
  5. data/app/assets/stylesheets/super/application.css +114693 -71486
  6. data/app/controllers/super/application_controller.rb +24 -13
  7. data/app/helpers/super/form_builder_helper.rb +25 -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} +5 -5
  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 +9 -19
  14. data/app/views/super/application/_filter_type_text.html.erb +7 -11
  15. data/app/views/super/application/_filter_type_timestamp.html.erb +6 -17
  16. data/app/views/super/application/_form.html.erb +15 -0
  17. data/app/views/super/application/_form_field__destroy.html.erb +1 -9
  18. data/app/views/super/application/_form_field_checkbox.html.erb +1 -15
  19. data/app/views/super/application/_form_field_flatpickr_date.html.erb +8 -0
  20. data/app/views/super/application/_form_field_flatpickr_datetime.html.erb +8 -0
  21. data/app/views/super/application/_form_field_flatpickr_time.html.erb +8 -0
  22. data/app/views/super/application/_form_field_rich_text_area.html.erb +1 -13
  23. data/app/views/super/application/_form_field_select.html.erb +1 -23
  24. data/app/views/super/application/_form_field_text.html.erb +1 -13
  25. data/app/views/super/application/{_super_layout.html.erb → _layout.html.erb} +8 -8
  26. data/app/views/super/application/{_super_pagination.html.erb → _pagination.html.erb} +1 -1
  27. data/app/views/super/application/{_super_panel.html.erb → _panel.html.erb} +2 -2
  28. data/app/views/super/application/_query.html.erb +18 -0
  29. data/app/views/super/application/_sort.html.erb +18 -0
  30. data/app/views/super/application/_sort_expression.html.erb +25 -0
  31. data/app/views/super/application/edit.html.erb +1 -0
  32. data/app/views/super/application/index.html.erb +1 -0
  33. data/app/views/super/application/new.html.erb +1 -0
  34. data/app/views/super/application/show.html.erb +1 -0
  35. data/app/views/super/feather/README.md +1 -0
  36. data/app/views/super/feather/_x.html +15 -0
  37. data/config/routes.rb +2 -0
  38. data/frontend/super-frontend/dist/application.css +114693 -71486
  39. data/frontend/super-frontend/dist/application.js +5671 -3669
  40. data/lib/generators/super/action_text/action_text_generator.rb +2 -0
  41. data/lib/generators/super/install/install_generator.rb +18 -7
  42. data/lib/generators/super/install/templates/base_controller.rb.tt +9 -1
  43. data/lib/generators/super/install/templates/initializer.rb.tt +9 -2
  44. data/lib/generators/super/resource/resource_generator.rb +107 -30
  45. data/lib/generators/super/resource/templates/resources_controller.rb.tt +3 -9
  46. data/lib/generators/super/webpacker/webpacker_generator.rb +11 -5
  47. data/lib/super.rb +9 -2
  48. data/lib/super/action_inquirer.rb +2 -0
  49. data/lib/super/assets.rb +46 -23
  50. data/lib/super/cheat.rb +17 -0
  51. data/lib/super/client_error.rb +2 -0
  52. data/lib/super/compatibility.rb +21 -0
  53. data/lib/super/configuration.rb +16 -24
  54. data/lib/super/controls.rb +11 -2
  55. data/lib/super/controls/optional.rb +35 -1
  56. data/lib/super/controls/steps.rb +27 -35
  57. data/lib/super/controls/view.rb +55 -0
  58. data/lib/super/display.rb +29 -13
  59. data/lib/super/display/guesser.rb +4 -0
  60. data/lib/super/display/schema_types.rb +73 -33
  61. data/lib/super/engine.rb +4 -0
  62. data/lib/super/error.rb +21 -0
  63. data/lib/super/filter.rb +2 -0
  64. data/lib/super/filter/form_object.rb +5 -8
  65. data/lib/super/filter/guesser.rb +2 -0
  66. data/lib/super/filter/operator.rb +2 -0
  67. data/lib/super/filter/schema_types.rb +2 -0
  68. data/lib/super/form.rb +3 -1
  69. data/lib/super/form/builder.rb +289 -39
  70. data/lib/super/form/guesser.rb +12 -1
  71. data/lib/super/form/inline_errors.rb +28 -0
  72. data/lib/super/form/schema_types.rb +15 -0
  73. data/lib/super/form/strong_params.rb +2 -0
  74. data/lib/super/layout.rb +3 -1
  75. data/lib/super/link.rb +44 -31
  76. data/lib/super/link_builder.rb +58 -0
  77. data/lib/super/navigation.rb +164 -0
  78. data/lib/super/pagination.rb +3 -1
  79. data/lib/super/panel.rb +3 -1
  80. data/lib/super/partial.rb +2 -0
  81. data/lib/super/partial/resolving.rb +2 -0
  82. data/lib/super/plugin.rb +2 -0
  83. data/lib/super/query/form_object.rb +48 -0
  84. data/lib/super/schema.rb +2 -0
  85. data/lib/super/schema/common.rb +2 -0
  86. data/lib/super/schema/guesser.rb +2 -0
  87. data/lib/super/sort.rb +110 -0
  88. data/lib/super/useful/builder.rb +25 -0
  89. data/lib/super/useful/enum.rb +63 -0
  90. data/lib/super/version.rb +3 -1
  91. data/lib/super/view_helper.rb +2 -19
  92. data/lib/tasks/super/cheat.rake +9 -0
  93. metadata +53 -40
  94. data/CONTRIBUTING.md +0 -56
  95. data/Rakefile +0 -34
  96. data/STABILITY.md +0 -50
  97. data/app/views/super/application/_form_field_generic.html.erb +0 -19
  98. data/app/views/super/application/_form_inline_errors.html.erb +0 -10
  99. data/app/views/super/application/_super_schema_display_show.html.erb +0 -8
  100. data/app/views/super/application/_super_schema_form.html.erb +0 -15
  101. data/docs/README.md +0 -8
  102. data/docs/action_text.md +0 -48
  103. data/docs/faq.md +0 -44
  104. data/docs/installation.md +0 -21
  105. data/docs/quick_start.md +0 -30
  106. data/docs/webpacker.md +0 -25
  107. data/docs/yard_customizations.rb +0 -41
  108. data/frontend/super-frontend/build.js +0 -36
  109. data/frontend/super-frontend/package.json +0 -20
  110. data/frontend/super-frontend/postcss.config.js +0 -6
  111. data/frontend/super-frontend/src/javascripts/super/application.js +0 -15
  112. data/frontend/super-frontend/src/javascripts/super/apply_template_controller.js +0 -17
  113. data/frontend/super-frontend/src/javascripts/super/toggle_pending_destruction_controller.js +0 -15
  114. data/frontend/super-frontend/src/stylesheets/super/application.css +0 -77
  115. data/frontend/super-frontend/tailwind.config.js +0 -15
  116. data/frontend/super-frontend/yarn.lock +0 -5443
  117. data/lib/super/controls/required.rb +0 -13
  118. data/lib/super/filter/plugin.rb +0 -47
  119. 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,19 +0,0 @@
1
- <% if !local_assigns[:ungrouped] %>
2
- <div class="super-field-group">
3
- <% end %>
4
- <% if !local_assigns[:hide_label] %>
5
- <%= form.label(column, class: "block") %>
6
- <% end %>
7
- <div class="<%= Super::ViewHelper.classes(["mt-1", !local_assigns[:hide_label]]) %>">
8
- <%= form.public_send(
9
- local_assigns.fetch(:form_builder_method),
10
- column,
11
- class: "super-input w-full"
12
- ) %>
13
- <% if !local_assigns[:hide_form_inline_errors] %>
14
- <%= render "form_inline_errors", form: form, column: column %>
15
- <% end %>
16
- </div>
17
- <% if !local_assigns[:ungrouped] %>
18
- </div>
19
- <% end %>
@@ -1,10 +0,0 @@
1
- <% if form.object %>
2
- <% Super::ViewHelper.errors_accounting_for_reflections(form.object, column).each do |error_message| %>
3
- <p class="text-red-400 text-xs italic pt-1"><%= error_message %></p>
4
- <% end %>
5
- <% else %>
6
- <p class="text-red-400 text-xs italic pt-1">
7
- This form doesn't have an object, so something is probably wrong.
8
- Maybe <code>accepts_nested_attributes_for</code> isn't set up?
9
- </p>
10
- <% end %>
@@ -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,15 +0,0 @@
1
- <%= form_for(Super.configuration.path_parts(@record), builder: Super::Form::Builder) do |f| %>
2
- <div class="max-w-3xl">
3
- <% super_schema_form.each_attribute do |field, type| %>
4
- <%= render(
5
- type,
6
- form: f,
7
- column: field
8
- ) %>
9
- <% end %>
10
-
11
- <div>
12
- <%= f.submit class: "super-button super-button--fill-blue mt-2" %>
13
- </div>
14
- </div>
15
- <% end %>
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/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,36 +0,0 @@
1
- const Bundler = require("parcel-bundler");
2
- const fs = require("fs");
3
- const path = require("path");
4
-
5
- const entryFiles = [
6
- "src/stylesheets/super/application.css",
7
- "src/javascripts/super/application.js",
8
- ];
9
-
10
- const options = {
11
- outDir: "../../app/assets",
12
- watch: process.argv.includes("--watch"),
13
- cacheDir: "tmp/parcel/cache",
14
- global: "Super",
15
- contentHash: false,
16
- minify: false,
17
- sourceMaps: false,
18
- hmr: false,
19
- };
20
-
21
- const bundler = new Bundler(entryFiles, options);
22
-
23
- bundler.on("bundled", function(bundle) {
24
- bundle.childBundles.forEach(function(childBundle) {
25
- var basename = path.basename(childBundle.name);
26
- var destDir = path.join(__dirname, "dist");
27
- var destPath = path.join(destDir, basename);
28
-
29
- console.log(destPath);
30
- fs.copyFileSync(childBundle.name, destPath);
31
- });
32
- console.log();
33
- console.log();
34
- });
35
-
36
- bundler.bundle();