-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make entry show an icon and add icon link to original page (#595)
- Loading branch information
Showing
10 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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,8 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'inline_svg/vite_file_loader' | ||
|
||
InlineSvg.configure do |config| | ||
config.asset_file = InlineSvg::ViteFileLoader | ||
config.raise_on_file_not_found = Rails.env.test? | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'open-uri' | ||
|
||
module InlineSvg | ||
class ViteFileLoader | ||
def self.named(filename) | ||
path = ViteRuby.instance.manifest.path_for(filename) | ||
|
||
return fetch_from_dev_server(path) if ViteRuby.instance.dev_server_running? | ||
|
||
Rails.public_path.join(path[1..]).read | ||
end | ||
|
||
def self.fetch_from_dev_server(path) | ||
config = ViteRuby.config | ||
|
||
path = "#{config.protocol}://#{config.host_with_port}#{path}" | ||
|
||
# rubocop:disable Security/Open | ||
# This is only used in dev to load an inline SVG, so security implications are very limited. | ||
URI.open(path) | ||
# rubocop:enable Security/Open | ||
end | ||
end | ||
end |