super 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/super/application.js +5299 -5925
- data/app/assets/stylesheets/super/application.css +115322 -72920
- data/app/controllers/super/application_controller.rb +5 -0
- data/app/views/layouts/super/application.html.erb +15 -12
- data/app/views/super/application/_layout.html.erb +1 -1
- data/frontend/super-frontend/dist/application.css +115322 -72920
- data/frontend/super-frontend/dist/application.js +5299 -5925
- data/lib/generators/super/webpacker/webpacker_generator.rb +9 -5
- data/lib/super.rb +2 -1
- data/lib/super/assets.rb +44 -23
- data/lib/super/cheat.rb +17 -0
- data/lib/super/compatibility.rb +19 -0
- data/lib/super/link.rb +37 -31
- data/lib/super/link_builder.rb +58 -0
- data/lib/super/navigation.rb +164 -0
- data/lib/super/version.rb +1 -1
- data/lib/tasks/super/cheat.rake +9 -0
- metadata +6 -3
- data/lib/super/navigation/automatic.rb +0 -73
data/lib/super/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.14
|
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-04-
|
11
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -287,6 +287,7 @@ files:
|
|
287
287
|
- lib/super.rb
|
288
288
|
- lib/super/action_inquirer.rb
|
289
289
|
- lib/super/assets.rb
|
290
|
+
- lib/super/cheat.rb
|
290
291
|
- lib/super/client_error.rb
|
291
292
|
- lib/super/compatibility.rb
|
292
293
|
- lib/super/configuration.rb
|
@@ -312,7 +313,8 @@ files:
|
|
312
313
|
- lib/super/form/strong_params.rb
|
313
314
|
- lib/super/layout.rb
|
314
315
|
- lib/super/link.rb
|
315
|
-
- lib/super/
|
316
|
+
- lib/super/link_builder.rb
|
317
|
+
- lib/super/navigation.rb
|
316
318
|
- lib/super/pagination.rb
|
317
319
|
- lib/super/panel.rb
|
318
320
|
- lib/super/partial.rb
|
@@ -327,6 +329,7 @@ files:
|
|
327
329
|
- lib/super/useful/enum.rb
|
328
330
|
- lib/super/version.rb
|
329
331
|
- lib/super/view_helper.rb
|
332
|
+
- lib/tasks/super/cheat.rake
|
330
333
|
homepage:
|
331
334
|
licenses:
|
332
335
|
- LGPL-3.0-only
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Super
|
4
|
-
class Navigation
|
5
|
-
# Traverses the defined Rails Routes and attempts to build a list of links.
|
6
|
-
# This is used for building the nav bar on each admin page.
|
7
|
-
class Automatic
|
8
|
-
def initialize(route_namespace: Super.configuration.path)
|
9
|
-
route_namespace = route_namespace.strip.gsub(%r{\A/+}, "").gsub(%r{/+\z}, "").strip
|
10
|
-
|
11
|
-
if route_namespace.include?("/")
|
12
|
-
raise "Can't be nested namespace"
|
13
|
-
end
|
14
|
-
|
15
|
-
@route_namespace = route_namespace
|
16
|
-
end
|
17
|
-
|
18
|
-
def each
|
19
|
-
if !block_given?
|
20
|
-
return enum_for(:each)
|
21
|
-
end
|
22
|
-
|
23
|
-
navigable_namespace_routes = Rails.application.routes.routes.select do |route|
|
24
|
-
path_spec = route.path.spec
|
25
|
-
|
26
|
-
next if route.verb != "GET"
|
27
|
-
next if !path_spec.respond_to?(:right)
|
28
|
-
next if path_spec.right.left.to_s != @route_namespace
|
29
|
-
next if route.required_parts.any?
|
30
|
-
next if route.defaults.empty?
|
31
|
-
|
32
|
-
true
|
33
|
-
end
|
34
|
-
|
35
|
-
navigable_defaults = navigable_namespace_routes.map do |route|
|
36
|
-
controller_name = route.defaults[:controller] + "_controller"
|
37
|
-
_controller =
|
38
|
-
begin
|
39
|
-
controller_name.camelize.constantize
|
40
|
-
rescue NameError
|
41
|
-
warn("[super] Couldn't find controller: #{controller_name}")
|
42
|
-
next
|
43
|
-
end
|
44
|
-
|
45
|
-
route.defaults
|
46
|
-
end
|
47
|
-
|
48
|
-
grouped_navigable_defaults =
|
49
|
-
navigable_defaults.compact.uniq.group_by { |d| d[:controller] }
|
50
|
-
|
51
|
-
grouped_navigable_defaults.each do |controller, defaults|
|
52
|
-
actions = defaults.map { |d| [d[:action], d[:action]] }.to_h
|
53
|
-
action = actions["index"] || actions["show"]
|
54
|
-
|
55
|
-
next if action.nil?
|
56
|
-
|
57
|
-
path =
|
58
|
-
begin
|
59
|
-
Rails.application.routes.url_for(
|
60
|
-
controller: controller,
|
61
|
-
action: action,
|
62
|
-
only_path: true
|
63
|
-
)
|
64
|
-
rescue ActionController::UrlGenerationError
|
65
|
-
next
|
66
|
-
end
|
67
|
-
|
68
|
-
yield(controller.split("/").last.humanize, path)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|