Last active
May 27, 2024 07:35
-
-
Save averyvery/6e4576023b395de1aaf5 to your computer and use it in GitHub Desktop.
Revisions
-
averyvery revised this gist
Jan 2, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ config.assets.precompile += [ # precompile any CSS or JS file that doesn't start with _ /(^inline[^_\/]|\/[^_])[^\/]*.(js|css)$/, ... -
averyvery revised this gist
Jan 2, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ config.assets.precompile += [ # css -
averyvery revised this gist
Jan 2, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ /(^(desktop|mobile|all)[^_\/]|\/[^_])[^\/]*.css$/, config.assets.precompile += [ # css /(^views[^_\/]|\/[^_])[^\/]*.css$/, ... -
averyvery revised this gist
Jan 2, 2015 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -21,4 +21,11 @@ def inline_js(asset_path) def inline_css(asset_path) "<style>#{inline_file asset_path}</style>" end # use a method like this to automatically load CSS that # follows the current controller/action name structure # example: assets/stylesheets/views/users/show.sass def current_view_stylesheet inline_css("views/#{params[:controller]}/#{params[:action]}") + end -
averyvery revised this gist
Jan 2, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,11 @@ def read_file_contents(stylesheet) if %w(test development).include?(Rails.env.to_s) # if we're running the full asset pipeline, # just grab the body of the final output stylesheet.body else # in a production-like environment, read the # fingerprinted and compiled file File.read(File.join(Rails.root, 'public', 'assets', stylesheet.digest_path)) end end -
averyvery created this gist
Jan 2, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ def read_file_contents(stylesheet) if %w(test development).include?(Rails.env.to_s) stylesheet.body else File.read(File.join(Rails.root, 'public', 'assets', stylesheet.digest_path)) end end def inline_file(asset_path) file = Rails.application.assets.find_asset(asset_path) file.nil? ? '' : read_file_contents(file) end def inline_js(asset_path) "<script>#{inline_file asset_path}</script>" end def inline_css(asset_path) "<style>#{inline_file asset_path}</style>" end