super 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -8
  3. data/README.md +4 -8
  4. data/app/controllers/super/application_controller.rb +5 -5
  5. data/app/views/layouts/super/application.html.erb +1 -3
  6. data/app/views/super/application/{_super_schema_display_actions.html.erb → _display_actions.html.erb} +0 -0
  7. data/app/views/super/application/{_super_schema_display_index.html.erb → _display_index.html.erb} +3 -3
  8. data/app/views/super/application/_display_show.html.erb +8 -0
  9. data/app/views/super/application/{_super_schema_form.html.erb → _form.html.erb} +2 -2
  10. data/app/views/super/application/{_super_layout.html.erb → _layout.html.erb} +7 -7
  11. data/app/views/super/application/{_super_pagination.html.erb → _pagination.html.erb} +1 -1
  12. data/app/views/super/application/{_super_panel.html.erb → _panel.html.erb} +2 -2
  13. data/lib/generators/super/install/install_generator.rb +16 -7
  14. data/lib/generators/super/install/templates/base_controller.rb.tt +9 -1
  15. data/lib/generators/super/install/templates/initializer.rb.tt +9 -2
  16. data/lib/generators/super/resource/resource_generator.rb +105 -30
  17. data/lib/generators/super/resource/templates/resources_controller.rb.tt +3 -9
  18. data/lib/super.rb +2 -0
  19. data/lib/super/configuration.rb +14 -23
  20. data/lib/super/controls.rb +7 -2
  21. data/lib/super/controls/optional.rb +1 -0
  22. data/lib/super/display.rb +16 -8
  23. data/lib/super/display/schema_types.rb +70 -33
  24. data/lib/super/error.rb +7 -0
  25. data/lib/super/form.rb +1 -1
  26. data/lib/super/layout.rb +1 -1
  27. data/lib/super/link.rb +5 -0
  28. data/lib/super/navigation/automatic.rb +2 -2
  29. data/lib/super/pagination.rb +1 -1
  30. data/lib/super/panel.rb +1 -1
  31. data/lib/super/useful/builder.rb +25 -0
  32. data/lib/super/useful/enum.rb +63 -0
  33. data/lib/super/version.rb +1 -1
  34. metadata +17 -19
  35. data/STABILITY.md +0 -50
  36. data/app/views/super/application/_super_schema_display_show.html.erb +0 -8
  37. data/docs/README.md +0 -8
  38. data/docs/action_text.md +0 -48
  39. data/docs/faq.md +0 -44
  40. data/docs/installation.md +0 -21
  41. data/docs/quick_start.md +0 -30
  42. data/docs/webpacker.md +0 -25
  43. data/docs/yard_customizations.rb +0 -43
  44. data/lib/super/controls/required.rb +0 -15
data/lib/super/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Super
4
- VERSION = "0.0.11"
4
+ VERSION = "0.0.12"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Ahn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-03 00:00:00.000000000 Z
11
+ date: 2021-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -224,7 +224,6 @@ files:
224
224
  - LICENSE
225
225
  - README.md
226
226
  - Rakefile
227
- - STABILITY.md
228
227
  - app/assets/config/super_manifest.js
229
228
  - app/assets/javascripts/super/application.js
230
229
  - app/assets/stylesheets/super/application.css
@@ -232,12 +231,16 @@ files:
232
231
  - app/helpers/super/form_builder_helper.rb
233
232
  - app/views/layouts/super/application.html.erb
234
233
  - app/views/super/application/_collection_header.html.erb
234
+ - app/views/super/application/_display_actions.html.erb
235
+ - app/views/super/application/_display_index.html.erb
235
236
  - app/views/super/application/_display_rich_text.html.erb
237
+ - app/views/super/application/_display_show.html.erb
236
238
  - app/views/super/application/_filter.html.erb
237
239
  - app/views/super/application/_filter_type_select.html.erb
238
240
  - app/views/super/application/_filter_type_text.html.erb
239
241
  - app/views/super/application/_filter_type_timestamp.html.erb
240
242
  - app/views/super/application/_flash.html.erb
243
+ - app/views/super/application/_form.html.erb
241
244
  - app/views/super/application/_form_field__destroy.html.erb
242
245
  - app/views/super/application/_form_field_checkbox.html.erb
243
246
  - app/views/super/application/_form_field_rich_text_area.html.erb
@@ -246,17 +249,13 @@ files:
246
249
  - app/views/super/application/_form_fieldset.html.erb
247
250
  - app/views/super/application/_form_has_many.html.erb
248
251
  - app/views/super/application/_form_has_one.html.erb
252
+ - app/views/super/application/_layout.html.erb
249
253
  - app/views/super/application/_member_header.html.erb
254
+ - app/views/super/application/_pagination.html.erb
255
+ - app/views/super/application/_panel.html.erb
250
256
  - app/views/super/application/_query.html.erb
251
257
  - app/views/super/application/_sort.html.erb
252
258
  - app/views/super/application/_sort_expression.html.erb
253
- - app/views/super/application/_super_layout.html.erb
254
- - app/views/super/application/_super_pagination.html.erb
255
- - app/views/super/application/_super_panel.html.erb
256
- - app/views/super/application/_super_schema_display_actions.html.erb
257
- - app/views/super/application/_super_schema_display_index.html.erb
258
- - app/views/super/application/_super_schema_display_show.html.erb
259
- - app/views/super/application/_super_schema_form.html.erb
260
259
  - app/views/super/application/edit.html.erb
261
260
  - app/views/super/application/index.html.erb
262
261
  - app/views/super/application/new.html.erb
@@ -267,14 +266,7 @@ files:
267
266
  - app/views/super/feather/_x.html
268
267
  - config/locales/en.yml
269
268
  - config/routes.rb
270
- - docs/README.md
271
- - docs/action_text.md
272
269
  - docs/cheat.md
273
- - docs/faq.md
274
- - docs/installation.md
275
- - docs/quick_start.md
276
- - docs/webpacker.md
277
- - docs/yard_customizations.rb
278
270
  - frontend/super-frontend/dist/application.css
279
271
  - frontend/super-frontend/dist/application.js
280
272
  - lib/generators/super/action_text/USAGE
@@ -299,7 +291,6 @@ files:
299
291
  - lib/super/configuration.rb
300
292
  - lib/super/controls.rb
301
293
  - lib/super/controls/optional.rb
302
- - lib/super/controls/required.rb
303
294
  - lib/super/controls/steps.rb
304
295
  - lib/super/controls/view.rb
305
296
  - lib/super/display.rb
@@ -331,12 +322,19 @@ files:
331
322
  - lib/super/schema/common.rb
332
323
  - lib/super/schema/guesser.rb
333
324
  - lib/super/sort.rb
325
+ - lib/super/useful/builder.rb
326
+ - lib/super/useful/enum.rb
334
327
  - lib/super/version.rb
335
328
  - lib/super/view_helper.rb
336
329
  homepage:
337
330
  licenses:
338
331
  - LGPL-3.0-only
339
- metadata: {}
332
+ metadata:
333
+ bug_tracker_uri: https://github.com/zachahn/super/issues
334
+ changelog_uri: https://github.com/zachahn/super/blob/main/CHANGELOG.md
335
+ documentation_uri: https://superadministration.github.io/
336
+ homepage_uri: https://github.com/zachahn/super
337
+ source_code_uri: https://github.com/zachahn/super
340
338
  post_install_message:
341
339
  rdoc_options: []
342
340
  require_paths:
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,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>
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 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,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "yard"
4
-
5
- module FixRelativeLinks
6
- def resolve_links(html)
7
- html = html.gsub(%r{<a href="([^"]+)">([^<]+)</a>}) do
8
- resolve_link_to_docs_subdir(full_match: $&, href: $1, content: $2)
9
- end
10
-
11
- html = html.gsub(%r{(<pre[^<]+)?<code[^>]*>([^<]+)</code>}) do
12
- resolve_link_to_code(full_match: $&, pre: $1, code: $2)
13
- end
14
-
15
- super(html)
16
- end
17
-
18
- def resolve_link_to_docs_subdir(full_match:, href:, content:)
19
- if href =~ /\bdocs\b/
20
- %({file:#{href} #{content}})
21
- else
22
- full_match
23
- end
24
- end
25
-
26
- def resolve_link_to_code(full_match:, pre:, code:)
27
- if pre
28
- return full_match
29
- end
30
-
31
- if code.include?("\n")
32
- return full_match
33
- end
34
-
35
- if !code.start_with?("Super::")
36
- return full_match
37
- end
38
-
39
- "{#{code}}"
40
- end
41
- end
42
-
43
- YARD::Templates::Template.extra_includes << FixRelativeLinks
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Super
4
- class Controls
5
- # Methods for `Controls` that must be defined for Super to work properly
6
- module Required
7
- # Specifies the model. This is a required method
8
- #
9
- # @return [ActiveRecord::Base]
10
- def model
11
- raise NotImplementedError
12
- end
13
- end
14
- end
15
- end