Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow additional stylesheets to be included in the admin UI #3179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/views/layouts/alchemy/admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<%= stylesheet_link_tag('alchemy/custom-properties', media: 'screen', 'data-turbo-track' => true) %>
<%= stylesheet_link_tag('alchemy/admin', media: 'screen', 'data-turbo-track' => true) %>
<%= stylesheet_link_tag('alchemy/admin/print', media: 'print', 'data-turbo-track' => true) %>
<%= stylesheet_link_tag('alchemy/admin/custom', 'data-turbo-track' => true) %>
<% Alchemy.admin_stylesheets.each do |stylesheet| %>
<%= stylesheet_link_tag(stylesheet, 'data-turbo-track' => true) %>
<% end %>
<%= yield :stylesheets %>
<script>
// Global Alchemy JavaScript object.
Expand Down
14 changes: 14 additions & 0 deletions lib/alchemy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ def self.admin_importmaps
}])
end

# Additional stylesheets to be included in the Alchemy admin UI
#
# == Example
#
# # lib/alchemy/devise/engine.rb
# initializer "alchemy.devise.stylesheets", before: "alchemy.admin_stylesheets" do
# Alchemy.admin_stylesheets << "alchemy/devise/admin"
# end
#
# @return [Set<String>]
def self.admin_stylesheets
@_admin_stylesheets ||= Set.new(["alchemy/admin/custom"])
end

# Define page publish targets
#
# A publish target is a ActiveJob that gets performed
Expand Down
7 changes: 5 additions & 2 deletions lib/alchemy/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
end
end

initializer "alchemy.assets" do
initializer "alchemy.assets" do |app|
if defined?(Sprockets)
require_relative "../non_stupid_digest_assets"
NonStupidDigestAssets.whitelist += [/^tinymce\//]
Rails.application.config.assets.precompile << "alchemy_manifest.js"
app.config.assets.precompile << "alchemy_manifest.js"
Alchemy.admin_stylesheets.each do |stylesheet|
app.config.assets.precompile << stylesheet

Check warning on line 25 in lib/alchemy/engine.rb

View check run for this annotation

Codecov / codecov/patch

lib/alchemy/engine.rb#L23-L25

Added lines #L23 - L25 were not covered by tests
end
end
end

Expand Down
1 change: 0 additions & 1 deletion spec/dummy/app/assets/config/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
//= link_tree ../images
//= link tinymce/langs/de.js
//= link_tree ../builds
//= link alchemy/admin/custom.css