From 9b2c18110d516be1890a9c84e4355f797498a23c Mon Sep 17 00:00:00 2001 From: zvkemp Date: Tue, 18 Mar 2025 13:04:53 -0400 Subject: [PATCH] no install --- .../vandal_ui/static_controller.rb | 8 +++++ app/views/vandal_ui/static/index.html.erb | 29 +++++++++++++++++++ config/routes.rb | 1 + lib/vandal_ui/engine.rb | 5 ++++ 4 files changed, 43 insertions(+) create mode 100644 app/controllers/vandal_ui/static_controller.rb create mode 100644 app/views/vandal_ui/static/index.html.erb diff --git a/app/controllers/vandal_ui/static_controller.rb b/app/controllers/vandal_ui/static_controller.rb new file mode 100644 index 0000000..98b589f --- /dev/null +++ b/app/controllers/vandal_ui/static_controller.rb @@ -0,0 +1,8 @@ +class VandalUi::StaticController < ActionController::Base + layout false + + def index + vandal_path = VandalUi::Engine.routes.find_script_name({}) + @schema_path = "#{vandal_path}/schema.json" + end +end diff --git a/app/views/vandal_ui/static/index.html.erb b/app/views/vandal_ui/static/index.html.erb new file mode 100644 index 0000000..f143b5d --- /dev/null +++ b/app/views/vandal_ui/static/index.html.erb @@ -0,0 +1,29 @@ + + + + + + + > + + vandal + + + + + + + + + + +
+ + + + + diff --git a/config/routes.rb b/config/routes.rb index 97171c3..42c5272 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,4 @@ VandalUi::Engine.routes.draw do + root to: 'vandal_ui/static#index' get '/schema', to: 'vandal_ui/schemas#show' end diff --git a/lib/vandal_ui/engine.rb b/lib/vandal_ui/engine.rb index bf4f5cc..3e502a1 100644 --- a/lib/vandal_ui/engine.rb +++ b/lib/vandal_ui/engine.rb @@ -1,4 +1,9 @@ module VandalUi class Engine < ::Rails::Engine + config.app_middleware.use( + Rack::Static, + urls: ['/js', '/css', '/assets/img'], + root: VandalUi::Engine.root.join('lib/vandal_ui/static') + ) end end