wrap_it_ruby 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/wrap_it_ruby/proxy_controller.rb +4 -1
- data/app/helpers/wrap_it_ruby/iframe_helper.rb +1 -3
- data/app/helpers/wrap_it_ruby/menu_helper.rb +53 -4
- data/config/routes.rb +1 -3
- data/lib/wrap_it_ruby/engine.rb +14 -0
- data/lib/wrap_it_ruby/version.rb +1 -1
- data/lib/wrap_it_ruby.rb +0 -1
- metadata +1 -7
- data/app/controllers/wrap_it_ruby/application_controller.rb +0 -9
- data/app/controllers/wrap_it_ruby/home_controller.rb +0 -8
- data/app/views/wrap_it_ruby/home/index.html.erb +0 -1
- data/app/views/wrap_it_ruby/layouts/application.html.erb +0 -30
- data/app/views/wrap_it_ruby/shared/_navbar.html.ruby +0 -11
- data/lib/wrap_it_ruby/menu.rb +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ce1f71d5f276d68be720746927f8329d7bc67b7a10feead3c3192f12cc4e419
|
|
4
|
+
data.tar.gz: c66c7abbdd059a99148798242cc0796694410f98cbd96dec504e7bf1ee1342d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3a604c19cba59629d6714be6f04ee0a5481578be2dd4de4e8c40225521dd6c1408ea4f6ddd6702a957938273db2bc1350fa881ffbdcb568187c87e762977138
|
|
7
|
+
data.tar.gz: 5583c57ac4793d85d57d96d04dab4f0e984358485e366bb311b089ac7187b1dee34ded804cacc4f5e15999c214ff0ef97559cfe88689969253b2dad352d7676f
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module WrapItRuby
|
|
4
|
-
class ProxyController < ApplicationController
|
|
4
|
+
class ProxyController < ::ApplicationController
|
|
5
|
+
include WrapItRuby::MenuHelper
|
|
6
|
+
include WrapItRuby::IframeHelper
|
|
7
|
+
|
|
5
8
|
def show
|
|
6
9
|
get_menu_item.then do |menu_item|
|
|
7
10
|
target_path = request.path.delete_prefix(menu_item["route"])
|
|
@@ -1,9 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
require "yaml"
|
|
2
2
|
|
|
3
3
|
module WrapItRuby
|
|
4
|
-
#
|
|
5
|
-
#
|
|
4
|
+
# Loads and queries the menu configuration from the host app's
|
|
5
|
+
# config/menu.yml file.
|
|
6
|
+
#
|
|
7
|
+
# Can be used as a module (extend self) or included in controllers/helpers.
|
|
8
|
+
#
|
|
9
|
+
# The render_menu method requires the view context (ComponentHelper from
|
|
10
|
+
# rails-active-ui must be available), so call it from views/layouts, not
|
|
11
|
+
# as a bare module method.
|
|
12
|
+
#
|
|
6
13
|
module MenuHelper
|
|
7
|
-
|
|
14
|
+
def menu_config = load_menu
|
|
15
|
+
|
|
16
|
+
# Renders the sidebar menu using rails-active-ui component helpers.
|
|
17
|
+
# Must be called from a view context where ComponentHelper is included.
|
|
18
|
+
def render_menu
|
|
19
|
+
Menu(attached: true) {
|
|
20
|
+
WrapItRuby::MenuHelper.menu_config.each do |group|
|
|
21
|
+
if group["items"]
|
|
22
|
+
group["items"].each do |item|
|
|
23
|
+
MenuItem(href: item["route"]) { text item["label"] }
|
|
24
|
+
end
|
|
25
|
+
else
|
|
26
|
+
MenuItem(href: group["route"]) { text group["label"] }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def all_menu_items
|
|
33
|
+
menu_config.flat_map { |item| [item, *item.fetch("items", [])] }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def all_proxy_menu_items
|
|
37
|
+
all_menu_items.select { |item| item["type"] == "proxy" }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def proxy_paths
|
|
41
|
+
all_menu_items
|
|
42
|
+
.select { |item| item["type"] == "proxy" }
|
|
43
|
+
.map { |item| item["route"] }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
extend self
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
def menu_file
|
|
51
|
+
Rails.root.join("config/menu.yml")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def load_menu
|
|
55
|
+
@menu_config ||= YAML.load_file(menu_file)
|
|
56
|
+
end
|
|
8
57
|
end
|
|
9
58
|
end
|
data/config/routes.rb
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
WrapItRuby::Engine.routes.draw do
|
|
4
|
-
root "home#index"
|
|
5
|
-
|
|
6
4
|
get "/*path", to: "proxy#show", constraints: ->(req) {
|
|
7
|
-
WrapItRuby::
|
|
5
|
+
WrapItRuby::MenuHelper.proxy_paths.any? { |p| req.path.start_with?(p) }
|
|
8
6
|
}
|
|
9
7
|
end
|
data/lib/wrap_it_ruby/engine.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "ui"
|
|
3
4
|
require "wrap_it_ruby/middleware/proxy_middleware"
|
|
4
5
|
require "wrap_it_ruby/middleware/root_relative_proxy_middleware"
|
|
5
6
|
require "wrap_it_ruby/middleware/script_injection_middleware"
|
|
@@ -34,6 +35,19 @@ module WrapItRuby
|
|
|
34
35
|
initializer "wrap_it_ruby.assets" do |app|
|
|
35
36
|
app.config.assets.paths << Engine.root.join("app/assets/javascripts")
|
|
36
37
|
app.config.assets.paths << Engine.root.join("app/assets/stylesheets")
|
|
38
|
+
|
|
39
|
+
# rails-active-ui ships stylesheets.css directly in app/assets/
|
|
40
|
+
app.config.assets.paths << Ui::Engine.root.join("app/assets")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Make engine helpers (MenuHelper, IframeHelper) available in host app views.
|
|
44
|
+
# MenuHelper#render_menu depends on ComponentHelper from rails-active-ui,
|
|
45
|
+
# which is already injected into ActionView by the Ui engine.
|
|
46
|
+
initializer "wrap_it_ruby.helpers" do
|
|
47
|
+
ActiveSupport.on_load(:action_view) do
|
|
48
|
+
include WrapItRuby::MenuHelper
|
|
49
|
+
include WrapItRuby::IframeHelper
|
|
50
|
+
end
|
|
37
51
|
end
|
|
38
52
|
end
|
|
39
53
|
end
|
data/lib/wrap_it_ruby/version.rb
CHANGED
data/lib/wrap_it_ruby.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wrap_it_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Kidd
|
|
@@ -105,23 +105,17 @@ files:
|
|
|
105
105
|
- Rakefile
|
|
106
106
|
- app/assets/javascripts/wrap_it_ruby/interception.js
|
|
107
107
|
- app/assets/stylesheets/wrap_it_ruby/application.css
|
|
108
|
-
- app/controllers/wrap_it_ruby/application_controller.rb
|
|
109
|
-
- app/controllers/wrap_it_ruby/home_controller.rb
|
|
110
108
|
- app/controllers/wrap_it_ruby/proxy_controller.rb
|
|
111
109
|
- app/helpers/wrap_it_ruby/iframe_helper.rb
|
|
112
110
|
- app/helpers/wrap_it_ruby/menu_helper.rb
|
|
113
111
|
- app/javascript/wrap_it_ruby/controllers/iframe_proxy_controller.js
|
|
114
|
-
- app/views/wrap_it_ruby/home/index.html.erb
|
|
115
|
-
- app/views/wrap_it_ruby/layouts/application.html.erb
|
|
116
112
|
- app/views/wrap_it_ruby/proxy/show.html.ruby
|
|
117
|
-
- app/views/wrap_it_ruby/shared/_navbar.html.ruby
|
|
118
113
|
- config/importmap.rb
|
|
119
114
|
- config/routes.rb
|
|
120
115
|
- lib/generators/wrap_it_ruby/install/install_generator.rb
|
|
121
116
|
- lib/generators/wrap_it_ruby/install/templates/menu.yml
|
|
122
117
|
- lib/wrap_it_ruby.rb
|
|
123
118
|
- lib/wrap_it_ruby/engine.rb
|
|
124
|
-
- lib/wrap_it_ruby/menu.rb
|
|
125
119
|
- lib/wrap_it_ruby/middleware/proxy_middleware.rb
|
|
126
120
|
- lib/wrap_it_ruby/middleware/root_relative_proxy_middleware.rb
|
|
127
121
|
- lib/wrap_it_ruby/middleware/script_injection_middleware.rb
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<p>Welcome, <%= current_user&.display_name || current_user&.uid %>.</p>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title><%= content_for(:title) || site_title %></title>
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
7
|
-
<meta name="application-name" content="<%= site_title %>">
|
|
8
|
-
<meta name="mobile-web-app-capable" content="yes">
|
|
9
|
-
<%= csrf_meta_tags %>
|
|
10
|
-
<%= csp_meta_tag %>
|
|
11
|
-
|
|
12
|
-
<%= yield :head %>
|
|
13
|
-
|
|
14
|
-
<link rel="icon" href="/icon.png" type="image/png">
|
|
15
|
-
<link rel="icon" href="/icon.svg" type="image/svg+xml">
|
|
16
|
-
<link rel="apple-touch-icon" href="/icon.png">
|
|
17
|
-
|
|
18
|
-
<%= stylesheet_link_tag "semantic.min.css", "data-turbo-track": "reload" %>
|
|
19
|
-
<%= stylesheet_link_tag "wrap_it_ruby/application", "data-turbo-track": "reload" %>
|
|
20
|
-
<%= fui_javascript_tags %>
|
|
21
|
-
<%= javascript_importmap_tags %>
|
|
22
|
-
</head>
|
|
23
|
-
|
|
24
|
-
<body>
|
|
25
|
-
<div id="site-wrapper">
|
|
26
|
-
<div id="site-menu"><%= render "wrap_it_ruby/shared/navbar" %></div>
|
|
27
|
-
<div id="site-content"><%= yield %></div>
|
|
28
|
-
</div>
|
|
29
|
-
</body>
|
|
30
|
-
</html>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
Menu(attached: true) {
|
|
2
|
-
WrapItRuby::Menu.menu_config.each do |group|
|
|
3
|
-
if group["items"]
|
|
4
|
-
group["items"].each do |item|
|
|
5
|
-
MenuItem(href: item["route"]) { text item["label"] }
|
|
6
|
-
end
|
|
7
|
-
else
|
|
8
|
-
MenuItem(href: group["route"]) { text group["label"] }
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
}
|
data/lib/wrap_it_ruby/menu.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "yaml"
|
|
4
|
-
|
|
5
|
-
module WrapItRuby
|
|
6
|
-
# Loads and queries the menu configuration from the host app's
|
|
7
|
-
# config/menu.yml file.
|
|
8
|
-
#
|
|
9
|
-
# Can be used as a module (extend self) or included in controllers/helpers.
|
|
10
|
-
#
|
|
11
|
-
module Menu
|
|
12
|
-
def menu_config = load_menu
|
|
13
|
-
|
|
14
|
-
def all_menu_items
|
|
15
|
-
menu_config.flat_map { |item| [item, *item.fetch("items", [])] }
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def all_proxy_menu_items
|
|
19
|
-
all_menu_items.select { |item| item["type"] == "proxy" }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def proxy_paths
|
|
23
|
-
all_menu_items
|
|
24
|
-
.select { |item| item["type"] == "proxy" }
|
|
25
|
-
.map { |item| item["route"] }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
extend self
|
|
29
|
-
|
|
30
|
-
private
|
|
31
|
-
|
|
32
|
-
def menu_file
|
|
33
|
-
Rails.root.join("config/menu.yml")
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def load_menu
|
|
37
|
-
@menu_config ||= YAML.load_file(menu_file)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|