-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Serve gem css, including Bootstrap, via routes/controller (#16)
* Serve gem css, including Bootstrap, via routes/controller # Conflicts: # config/routes.rb * Remove application.css * Fix rubocop violations
- Loading branch information
1 parent
a221459
commit b78027b
Showing
7 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module InnerPerformance | ||
class FrontendsController < ApplicationController | ||
protect_from_forgery with: :exception | ||
skip_after_action :verify_same_origin_request, raise: false | ||
|
||
before_action do | ||
expires_in 1.year, public: true | ||
end | ||
|
||
class << self | ||
def asset_path(path) | ||
Engine.root.join("app/frontend/inner_performance", path) | ||
end | ||
end | ||
|
||
STATIC_ASSETS = { | ||
css: { | ||
bootstrap: asset_path("vendor/bootstrap.min.css"), | ||
}, | ||
}.freeze | ||
|
||
def static | ||
file_stem = params[:stem]&.to_sym | ||
file_format = params[:format]&.to_sym | ||
|
||
file_path = STATIC_ASSETS.dig(file_format, file_stem) || raise(ActionController::RoutingError, "Not Found") | ||
send_file(file_path, disposition: "inline") | ||
end | ||
end | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,7 @@ | |
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
|
||
<%= stylesheet_link_tag "inner_performance/application", media: "all" %> | ||
|
||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | ||
<%= tag.link rel: "stylesheet", href: frontend_static_path(:bootstrap, format: :css), nonce: content_security_policy_nonce %> | ||
</head> | ||
<body> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters