Class: SpectatorSport::Dashboard::FrontendsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- SpectatorSport::Dashboard::FrontendsController
- Defined in:
- app/controllers/spectator_sport/dashboard/frontends_controller.rb
Overview
rubocop:disable Rails/ApplicationController
Constant Summary collapse
- STATIC_ASSETS =
{ css: { bootstrap: asset_path("vendor/bootstrap/bootstrap.min.css"), "rrweb-player": asset_path("vendor/rrweb-player/rrweb-player.min.css"), style: asset_path("style.css") }, js: { bootstrap: asset_path("vendor/bootstrap/bootstrap.bundle.min.js"), es_module_shims: asset_path("vendor/es_module_shims.js") }, svg: { icons: asset_path("icons.svg") } }.freeze
- MODULE_OVERRIDES =
{ application: asset_path("application.js"), "rrweb-player": asset_path("vendor/rrweb-player/rrweb-player.min.js"), stimulus: asset_path("vendor/stimulus.js"), turbo: asset_path("vendor/turbo.js") }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.asset_path(path) ⇒ Object
9 10 11 |
# File 'app/controllers/spectator_sport/dashboard/frontends_controller.rb', line 9 def self.asset_path(path) Engine.root.join("app/frontend/spectator_sport/dashboard", path) end |
.js_modules ⇒ Object
35 36 37 38 39 40 |
# File 'app/controllers/spectator_sport/dashboard/frontends_controller.rb', line 35 def self.js_modules @_js_modules ||= asset_path("modules").children.select(&:file?).each_with_object({}) do |file, modules| key = File.basename(file.basename.to_s, ".js").to_sym modules[key] = file end.merge(MODULE_OVERRIDES) end |
Instance Method Details
#module ⇒ Object
51 52 53 54 55 56 |
# File 'app/controllers/spectator_sport/dashboard/frontends_controller.rb', line 51 def module raise(ActionController::RoutingError, "Not Found") if params[:format] != "js" file_path = self.class.js_modules[params[:id]&.to_sym] || raise(ActionController::RoutingError, "Not Found") send_file file_path, disposition: "inline" end |
#static ⇒ Object
46 47 48 49 |
# File 'app/controllers/spectator_sport/dashboard/frontends_controller.rb', line 46 def static file_path = STATIC_ASSETS.dig(params[:format]&.to_sym, params[:id]&.to_sym) || raise(ActionController::RoutingError, "Not Found") send_file file_path, disposition: "inline" end |