super 0.0.11 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +0 -9
  3. data/README.md +42 -54
  4. data/app/assets/javascripts/super/application.js +5617 -3806
  5. data/app/assets/stylesheets/super/application.css +114687 -71486
  6. data/app/controllers/super/application_controller.rb +41 -47
  7. data/app/controllers/super/substructure_controller.rb +265 -0
  8. data/app/helpers/super/form_builder_helper.rb +7 -0
  9. data/app/views/layouts/super/application.html.erb +4 -21
  10. data/app/views/super/application/_collection_header.html.erb +2 -2
  11. data/app/views/super/application/{_super_schema_display_actions.html.erb → _display_actions.html.erb} +1 -1
  12. data/app/views/super/application/{_super_schema_display_index.html.erb → _display_index.html.erb} +5 -5
  13. data/app/views/super/application/_display_show.html.erb +8 -0
  14. data/app/views/super/application/_filter_type_select.html.erb +1 -1
  15. data/app/views/super/application/_filter_type_text.html.erb +1 -1
  16. data/app/views/super/application/_filter_type_timestamp.html.erb +3 -3
  17. data/app/views/super/application/{_super_schema_form.html.erb → _form.html.erb} +2 -2
  18. data/app/views/super/application/_form_field.html.erb +5 -0
  19. data/app/views/super/application/{_super_layout.html.erb → _layout.html.erb} +8 -8
  20. data/app/views/super/application/_member_header.html.erb +2 -2
  21. data/app/views/super/application/{_super_pagination.html.erb → _pagination.html.erb} +1 -1
  22. data/app/views/super/application/{_super_panel.html.erb → _panel.html.erb} +2 -2
  23. data/app/views/super/application/_site_footer.html.erb +3 -0
  24. data/app/views/super/application/_site_header.html.erb +17 -0
  25. data/app/views/super/feather/README.md +0 -1
  26. data/frontend/super-frontend/dist/application.css +114687 -71486
  27. data/frontend/super-frontend/dist/application.js +5617 -3806
  28. data/lib/generators/super/install/install_generator.rb +16 -23
  29. data/lib/generators/super/install/templates/base_controller.rb.tt +1 -1
  30. data/lib/generators/super/install/templates/initializer.rb.tt +9 -2
  31. data/lib/generators/super/resource/resource_generator.rb +105 -30
  32. data/lib/generators/super/resource/templates/resources_controller.rb.tt +4 -10
  33. data/lib/generators/super/webpacker/webpacker_generator.rb +9 -5
  34. data/lib/super.rb +6 -2
  35. data/lib/super/action_inquirer.rb +18 -3
  36. data/lib/super/assets.rb +44 -23
  37. data/lib/super/badge.rb +60 -0
  38. data/lib/super/cheat.rb +17 -0
  39. data/lib/super/compatibility.rb +19 -0
  40. data/lib/super/configuration.rb +14 -23
  41. data/lib/super/display.rb +16 -8
  42. data/lib/super/display/guesser.rb +2 -0
  43. data/lib/super/display/schema_types.rb +116 -29
  44. data/lib/super/error.rb +7 -0
  45. data/lib/super/form.rb +1 -1
  46. data/lib/super/form/builder.rb +107 -27
  47. data/lib/super/form/guesser.rb +10 -1
  48. data/lib/super/form/schema_types.rb +73 -7
  49. data/lib/super/layout.rb +1 -1
  50. data/lib/super/link.rb +42 -31
  51. data/lib/super/link_builder.rb +58 -0
  52. data/lib/super/navigation.rb +164 -0
  53. data/lib/super/pagination.rb +3 -45
  54. data/lib/super/panel.rb +1 -1
  55. data/lib/super/reset.rb +22 -0
  56. data/lib/super/useful/builder.rb +25 -0
  57. data/lib/super/useful/enum.rb +63 -0
  58. data/lib/super/version.rb +1 -1
  59. data/lib/tasks/super/cheat.rake +9 -0
  60. metadata +27 -31
  61. data/CONTRIBUTING.md +0 -56
  62. data/Rakefile +0 -36
  63. data/STABILITY.md +0 -50
  64. data/app/views/super/application/_form_field_checkbox.html.erb +0 -1
  65. data/app/views/super/application/_form_field_rich_text_area.html.erb +0 -1
  66. data/app/views/super/application/_form_field_text.html.erb +0 -1
  67. data/app/views/super/application/_super_schema_display_show.html.erb +0 -8
  68. data/app/views/super/feather/_chevron_down.html +0 -1
  69. data/docs/README.md +0 -8
  70. data/docs/action_text.md +0 -48
  71. data/docs/cheat.md +0 -41
  72. data/docs/faq.md +0 -44
  73. data/docs/installation.md +0 -21
  74. data/docs/quick_start.md +0 -30
  75. data/docs/webpacker.md +0 -25
  76. data/docs/yard_customizations.rb +0 -43
  77. data/lib/super/controls.rb +0 -17
  78. data/lib/super/controls/optional.rb +0 -112
  79. data/lib/super/controls/required.rb +0 -15
  80. data/lib/super/controls/steps.rb +0 -106
  81. data/lib/super/controls/view.rb +0 -55
  82. data/lib/super/navigation/automatic.rb +0 -73
@@ -55,7 +55,7 @@ module Super
55
55
  end
56
56
 
57
57
  def to_partial_path
58
- "super_pagination"
58
+ "pagination"
59
59
  end
60
60
 
61
61
  private
@@ -76,52 +76,10 @@ module Super
76
76
  module ControllerMethods
77
77
  def index
78
78
  super
79
- @pagination = controls.initialize_pagination(action: action_inquirer, records: @records, query_params: request.GET)
80
- @records = controls.paginate_records(action: action_inquirer, records: @records, pagination: @pagination)
79
+ @pagination = initialize_pagination
80
+ @records = paginate_records
81
81
  @view.mains.first.parts.push(:@pagination)
82
82
  end
83
83
  end
84
84
  end
85
-
86
- class Controls
87
- module Optional
88
- # Specifies how many records to show per page
89
- #
90
- # @param action [ActionInquirer]
91
- # @param query_params [Hash]
92
- # @return [ActiveRecord::Relation]
93
- def records_per_page(action:, query_params:)
94
- Super.configuration.index_records_per_page
95
- end
96
- end
97
-
98
- module Steps
99
- # Sets up pagination
100
- #
101
- # @param action [ActionInquirer]
102
- # @param records [ActiveRecord::Relation]
103
- # @param query_params [Hash]
104
- # @return [Pagination]
105
- def initialize_pagination(action:, records:, query_params:)
106
- Pagination.new(
107
- total_count: records.size,
108
- limit: records_per_page(action: action, query_params: query_params),
109
- query_params: query_params,
110
- page_query_param: :page
111
- )
112
- end
113
-
114
- # Paginates
115
- #
116
- # @param action [ActionInquirer]
117
- # @param records [ActiveRecord::Relation]
118
- # @param pagination [Pagination]
119
- # @return [ActiveRecord::Relation]
120
- def paginate_records(action:, records:, pagination:)
121
- records
122
- .limit(pagination.limit)
123
- .offset(pagination.offset)
124
- end
125
- end
126
- end
127
85
  end
data/lib/super/panel.rb CHANGED
@@ -26,7 +26,7 @@ module Super
26
26
  end
27
27
 
28
28
  def to_partial_path
29
- "super_panel"
29
+ "panel"
30
30
  end
31
31
  end
32
32
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Super
4
+ module Reset
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ undef_method :index
9
+ undef_method :show
10
+ undef_method :new
11
+ undef_method :create
12
+ undef_method :edit
13
+ undef_method :update
14
+ undef_method :destroy
15
+
16
+ Super::SubstructureController.private_instance_methods(false).each do |imethod|
17
+ next if imethod == :navigation
18
+ undef_method imethod
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Super
4
+ module Useful
5
+ module Builder
6
+ def builder(method_name)
7
+ alias_method("original_#{method_name}", method_name)
8
+
9
+ define_method(method_name) do |*args|
10
+ send("original_#{method_name}", *args)
11
+ self
12
+ end
13
+ end
14
+
15
+ def builder_with_block(method_name)
16
+ alias_method("original_#{method_name}", method_name)
17
+
18
+ define_method(method_name) do |*args, &block|
19
+ send("original_#{method_name}", *args, &block)
20
+ self
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Super
4
+ module Useful
5
+ class Enum
6
+ def initialize(*choices)
7
+ @choices = choices.flatten.map { |choice| [choice, nil] }.to_h
8
+ end
9
+
10
+ def case(chosen)
11
+ Case.new(@choices, chosen)
12
+ end
13
+
14
+ class Case
15
+ def initialize(choices, chosen)
16
+ if !choices.key?(chosen)
17
+ raise Error::Enum::ImpossibleValue,
18
+ "`#{chosen}` isn't in: #{choices.keys.map(&:inspect).join(", ")}"
19
+ end
20
+
21
+ @choices = choices
22
+ @chosen = chosen
23
+ @whens = {}
24
+ end
25
+
26
+ def when(*keys, &block)
27
+ if !block_given?
28
+ raise Error::ArgumentError, "must receive block"
29
+ end
30
+
31
+ keys.each do |key|
32
+ if !@choices.key?(key)
33
+ raise Error::Enum::ImpossibleValue, "`#{key.inspect}` is not a possibility"
34
+ end
35
+
36
+ @whens[key] = block
37
+ end
38
+
39
+ self
40
+ end
41
+
42
+ def result
43
+ if @choices.size != @whens.size
44
+ missing_keys = @choices.keys - @whens.keys
45
+ raise Error::Enum::UndefinedCase, "Unset cases: #{missing_keys.join(", ")}"
46
+ end
47
+
48
+ @whens[@chosen].call(@value)
49
+ end
50
+
51
+ private
52
+
53
+ def matching_possibilities_and_checks?
54
+ if @whens.size == @choices.size
55
+ return true
56
+ end
57
+
58
+ false
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
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.16"
5
5
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :super do
4
+ task :cheat do
5
+ require "super/cheat"
6
+ cheat = Super::Cheat.new
7
+ cheat.controller
8
+ end
9
+ 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.16
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-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -220,61 +220,50 @@ extensions: []
220
220
  extra_rdoc_files: []
221
221
  files:
222
222
  - ".yardopts"
223
- - CONTRIBUTING.md
224
223
  - LICENSE
225
224
  - README.md
226
- - Rakefile
227
- - STABILITY.md
228
225
  - app/assets/config/super_manifest.js
229
226
  - app/assets/javascripts/super/application.js
230
227
  - app/assets/stylesheets/super/application.css
231
228
  - app/controllers/super/application_controller.rb
229
+ - app/controllers/super/substructure_controller.rb
232
230
  - app/helpers/super/form_builder_helper.rb
233
231
  - app/views/layouts/super/application.html.erb
234
232
  - app/views/super/application/_collection_header.html.erb
233
+ - app/views/super/application/_display_actions.html.erb
234
+ - app/views/super/application/_display_index.html.erb
235
235
  - app/views/super/application/_display_rich_text.html.erb
236
+ - app/views/super/application/_display_show.html.erb
236
237
  - app/views/super/application/_filter.html.erb
237
238
  - app/views/super/application/_filter_type_select.html.erb
238
239
  - app/views/super/application/_filter_type_text.html.erb
239
240
  - app/views/super/application/_filter_type_timestamp.html.erb
240
241
  - app/views/super/application/_flash.html.erb
242
+ - app/views/super/application/_form.html.erb
243
+ - app/views/super/application/_form_field.html.erb
241
244
  - app/views/super/application/_form_field__destroy.html.erb
242
- - app/views/super/application/_form_field_checkbox.html.erb
243
- - app/views/super/application/_form_field_rich_text_area.html.erb
244
245
  - app/views/super/application/_form_field_select.html.erb
245
- - app/views/super/application/_form_field_text.html.erb
246
246
  - app/views/super/application/_form_fieldset.html.erb
247
247
  - app/views/super/application/_form_has_many.html.erb
248
248
  - app/views/super/application/_form_has_one.html.erb
249
+ - app/views/super/application/_layout.html.erb
249
250
  - app/views/super/application/_member_header.html.erb
251
+ - app/views/super/application/_pagination.html.erb
252
+ - app/views/super/application/_panel.html.erb
250
253
  - app/views/super/application/_query.html.erb
254
+ - app/views/super/application/_site_footer.html.erb
255
+ - app/views/super/application/_site_header.html.erb
251
256
  - app/views/super/application/_sort.html.erb
252
257
  - 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
258
  - app/views/super/application/edit.html.erb
261
259
  - app/views/super/application/index.html.erb
262
260
  - app/views/super/application/new.html.erb
263
261
  - app/views/super/application/nothing.html.erb
264
262
  - app/views/super/application/show.html.erb
265
263
  - app/views/super/feather/README.md
266
- - app/views/super/feather/_chevron_down.html
267
264
  - app/views/super/feather/_x.html
268
265
  - config/locales/en.yml
269
266
  - config/routes.rb
270
- - docs/README.md
271
- - docs/action_text.md
272
- - 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
267
  - frontend/super-frontend/dist/application.css
279
268
  - frontend/super-frontend/dist/application.js
280
269
  - lib/generators/super/action_text/USAGE
@@ -294,14 +283,11 @@ files:
294
283
  - lib/super.rb
295
284
  - lib/super/action_inquirer.rb
296
285
  - lib/super/assets.rb
286
+ - lib/super/badge.rb
287
+ - lib/super/cheat.rb
297
288
  - lib/super/client_error.rb
298
289
  - lib/super/compatibility.rb
299
290
  - lib/super/configuration.rb
300
- - lib/super/controls.rb
301
- - lib/super/controls/optional.rb
302
- - lib/super/controls/required.rb
303
- - lib/super/controls/steps.rb
304
- - lib/super/controls/view.rb
305
291
  - lib/super/display.rb
306
292
  - lib/super/display/guesser.rb
307
293
  - lib/super/display/schema_types.rb
@@ -320,23 +306,33 @@ files:
320
306
  - lib/super/form/strong_params.rb
321
307
  - lib/super/layout.rb
322
308
  - lib/super/link.rb
323
- - lib/super/navigation/automatic.rb
309
+ - lib/super/link_builder.rb
310
+ - lib/super/navigation.rb
324
311
  - lib/super/pagination.rb
325
312
  - lib/super/panel.rb
326
313
  - lib/super/partial.rb
327
314
  - lib/super/partial/resolving.rb
328
315
  - lib/super/plugin.rb
329
316
  - lib/super/query/form_object.rb
317
+ - lib/super/reset.rb
330
318
  - lib/super/schema.rb
331
319
  - lib/super/schema/common.rb
332
320
  - lib/super/schema/guesser.rb
333
321
  - lib/super/sort.rb
322
+ - lib/super/useful/builder.rb
323
+ - lib/super/useful/enum.rb
334
324
  - lib/super/version.rb
335
325
  - lib/super/view_helper.rb
326
+ - lib/tasks/super/cheat.rake
336
327
  homepage:
337
328
  licenses:
338
329
  - LGPL-3.0-only
339
- metadata: {}
330
+ metadata:
331
+ bug_tracker_uri: https://github.com/zachahn/super/issues
332
+ changelog_uri: https://github.com/zachahn/super/blob/main/CHANGELOG.md
333
+ documentation_uri: https://superadministration.github.io/
334
+ homepage_uri: https://github.com/zachahn/super
335
+ source_code_uri: https://github.com/zachahn/super
340
336
  post_install_message:
341
337
  rdoc_options: []
342
338
  require_paths:
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,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- begin
4
- require "bundler/setup"
5
- rescue LoadError
6
- puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
- end
8
-
9
- require "rdoc/task"
10
-
11
- RDoc::Task.new(:rdoc) do |rdoc|
12
- rdoc.rdoc_dir = "rdoc"
13
- rdoc.title = "Super"
14
- rdoc.options << "--line-numbers"
15
- rdoc.rdoc_files.include("README.md")
16
- rdoc.rdoc_files.include("lib/**/*.rb")
17
- end
18
-
19
- require_relative "dummy_path"
20
-
21
- APP_RAKEFILE = File.expand_path("#{SUPER_DUMMY_PATH}/Rakefile", __dir__)
22
- load "rails/tasks/engine.rake"
23
-
24
- load "rails/tasks/statistics.rake"
25
-
26
- require "bundler/gem_tasks"
27
-
28
- require "rake/testtask"
29
-
30
- Rake::TestTask.new(:test) do |t|
31
- t.libs << "test"
32
- t.pattern = "test/**/*_test.rb"
33
- t.verbose = false
34
- end
35
-
36
- 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