Skip to content

Commit

Permalink
Merge pull request #1112 from denny/fix/halcyonic-theme-accessibility
Browse files Browse the repository at this point in the history
Tweak asset precompile config for themes
  • Loading branch information
denny authored May 7, 2021
2 parents 07c875b + 76f5c1e commit a4704a6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions plugins/ShinyCMS/config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# ShinyCMS is free software; you can redistribute it and/or modify it under the terms of the GPL (version 2 or later)

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '2021.02.14.0800'
Rails.application.config.assets.version = '2021.05.07.1700'

# Add node_modules directory to the asset load path.
# Rails.application.config.assets.paths << Rails.root.join( 'node_modules' )
Expand All @@ -24,11 +24,23 @@ def available_themes
end

def add_theme_to_asset_load_path( theme_name )
add_theme_images_to_asset_load_path( theme_name )
add_theme_styles_to_asset_load_path( theme_name )
end

def add_theme_images_to_asset_load_path( theme_name )
images_dir = Rails.root.join "themes/#{theme_name}/images"
return unless Dir.exist? images_dir

Rails.application.config.assets.paths << images_dir
end

def add_theme_styles_to_asset_load_path( theme_name )
stylesheets_dir = Rails.root.join "themes/#{theme_name}/stylesheets"
images_dir = Rails.root.join "themes/#{theme_name}/images"
return unless Dir.exist? stylesheets_dir

Rails.application.config.assets.paths << stylesheets_dir if Dir.exist? stylesheets_dir
Rails.application.config.assets.paths << images_dir if Dir.exist? images_dir
Rails.application.config.assets.paths << stylesheets_dir
Rails.application.config.assets.precompile += %W[ #{theme_name}.css ]
end

add_all_themes_to_asset_load_path

0 comments on commit a4704a6

Please # to comment.