From 5e805e110b84e1b44a01e86832c44ac5b5ae1890 Mon Sep 17 00:00:00 2001 From: Scott Ringwelski Date: Thu, 21 Jan 2016 21:41:24 -0800 Subject: [PATCH 1/8] Fix issue with ActionController::API:Class Fix an issue where helper is not a defined method --- lib/css_splitter/engine.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/css_splitter/engine.rb b/lib/css_splitter/engine.rb index 335a5b1..4cdaba0 100644 --- a/lib/css_splitter/engine.rb +++ b/lib/css_splitter/engine.rb @@ -10,7 +10,8 @@ class Engine < ::Rails::Engine initializer 'css_splitter.action_controller' do |app| ActiveSupport.on_load :action_controller do - helper CssSplitter::ApplicationHelper + # Not all controllers use helpers (such as API based controllers) + helper CssSplitter::ApplicationHelper if respond_to?(:helper) end end end From 45cb5bcf460afd0ed4ded6570e1b6d2a470312a1 Mon Sep 17 00:00:00 2001 From: achernyshev Date: Thu, 14 Apr 2016 17:58:16 +0300 Subject: [PATCH 2/8] fix sprockets engine registering for older sprocket-rails versions --- lib/css_splitter/engine.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/css_splitter/engine.rb b/lib/css_splitter/engine.rb index 2f50392..17122f3 100644 --- a/lib/css_splitter/engine.rb +++ b/lib/css_splitter/engine.rb @@ -1,8 +1,12 @@ module CssSplitter class Engine < ::Rails::Engine initializer 'css_splitter.sprockets_engine', after: 'sprockets.environment', group: :all do |app| - app.config.assets.configure do |assets| - assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine + if app.config.assets.public_methods.include? :configure + app.config.assets.configure do |assets| + assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine + end + else + app.assets.register_bundle_processor 'text/css', CssSplitter::SprocketsEngine end end From 2a240553362fafa799f96b6bf6a5f343104df0df Mon Sep 17 00:00:00 2001 From: Jakob Hilden Date: Wed, 25 May 2016 11:19:33 +0200 Subject: [PATCH 3/8] version 0.4.5 --- CHANGELOG.md | 4 ++++ lib/css_splitter/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf1f58c..44ba31a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.4.5 + +* [bugfix] fix sprockets engine registering for older sprocket-rails versions #68 + # 0.4.4 * [bugfix] fix compatibility with with sprockts-rails version 3.x, see #62 diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb index 06e4f4e..c6d5586 100644 --- a/lib/css_splitter/version.rb +++ b/lib/css_splitter/version.rb @@ -1,3 +1,3 @@ module CssSplitter - VERSION = "0.4.4" + VERSION = "0.4.5" end From db0fe7575012e9650c271259e75eb299976ae9f1 Mon Sep 17 00:00:00 2001 From: Jakob Hilden Date: Wed, 1 Jun 2016 15:08:33 +0200 Subject: [PATCH 4/8] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44ba31a..fc25e31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.4.6 (unreleased) + +* [bugfix] Fix issue where helper is not a defined method on controller (e.g. ActionController::API:Class) #65 + # 0.4.5 * [bugfix] fix sprockets engine registering for older sprocket-rails versions #68 From 24017c19c60739d2d1038e985687117839054150 Mon Sep 17 00:00:00 2001 From: Nick Donald Date: Mon, 22 Aug 2016 06:13:32 -0400 Subject: [PATCH 5/8] Follow sproket engine interface guidelines (#70) * Follow sproket engine interface guidelines * Clarify syntax, add comments --- lib/css_splitter/sprockets_engine.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/css_splitter/sprockets_engine.rb b/lib/css_splitter/sprockets_engine.rb index f6ae2a8..551af8c 100644 --- a/lib/css_splitter/sprockets_engine.rb +++ b/lib/css_splitter/sprockets_engine.rb @@ -10,6 +10,22 @@ def self.engine_initialized? def prepare end + def self.call(input) + data_in = input[:data] + + # Instantiate Sprockets::Context to pass along helper methods for Tilt + # processors + context = input[:environment].context_class.new(input) + + # Pass the asset file contents as a block to the template engine, + # then get the results of the engine rendering + engine = self.new { data_in } + rendered_data = engine.render(context, {}) + + # Return the data and any metadata (ie file dependencies, etc) + context.metadata.merge(data: rendered_data.to_str) + end + def evaluate(scope, locals, &block) # Evaluate the split if the asset is named with a trailing _split2, _split3, etc. if scope.logical_path =~ /_split(\d+)$/ From 5010809517f4ed4fc2379af1c2b2573b5ae8a3f2 Mon Sep 17 00:00:00 2001 From: Jakob Hilden Date: Sat, 27 Aug 2016 16:31:53 +0200 Subject: [PATCH 6/8] bump version to 0.4.6 --- CHANGELOG.md | 3 ++- lib/css_splitter/version.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc25e31..cd411e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -# 0.4.6 (unreleased) +# 0.4.6 +* [fix] Implement new engine interface for future sprockets versions #70 * [bugfix] Fix issue where helper is not a defined method on controller (e.g. ActionController::API:Class) #65 # 0.4.5 diff --git a/lib/css_splitter/version.rb b/lib/css_splitter/version.rb index c6d5586..57859d1 100644 --- a/lib/css_splitter/version.rb +++ b/lib/css_splitter/version.rb @@ -1,3 +1,3 @@ module CssSplitter - VERSION = "0.4.5" + VERSION = "0.4.6" end From 749e5410ea67a585b65d75aefbd8c5a0bf1467fd Mon Sep 17 00:00:00 2001 From: khiav reoy Date: Sat, 22 Oct 2016 17:43:12 +0800 Subject: [PATCH 7/8] fix test in different gem version --- test/css_splitter_test.rb | 11 +++++------ test/dummy/config/application.rb | 3 ++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/css_splitter_test.rb b/test/css_splitter_test.rb index 5090a3d..012cf89 100644 --- a/test/css_splitter_test.rb +++ b/test/css_splitter_test.rb @@ -13,18 +13,17 @@ class CssSplitterTest < ActiveSupport::TestCase part2 = "#test{background-color:green}" * CssSplitter::Splitter::MAX_SELECTORS_DEFAULT part3 = "#test{background-color:blue}" - assert_equal "#{part1}#{part2}#{part3}\n", assets["erb_stylesheet"].to_s - assert_equal "#{part2}\n", assets["erb_stylesheet_split2"].to_s - assert_equal "#{part3}\n", assets["erb_stylesheet_split3"].to_s + assert_equal "#{part1}#{part2}#{part3}", assets["erb_stylesheet"].to_s.gsub(/\s/, '') + assert_equal "#{part2}", assets["erb_stylesheet_split2"].to_s.gsub(/\s/, '') + assert_equal "#{part3}", assets["erb_stylesheet_split3"].to_s.gsub(/\s/, '') end test "asset pipeline stylesheet splitting on stylesheet combined using requires" do red = "#test{background-color:red}" * 100 green = "#test{background-color:green}" * CssSplitter::Splitter::MAX_SELECTORS_DEFAULT blue = "#test{background-color:blue}" - - assert_equal "#{red}#{green}#{blue}\n", assets["combined"].to_s - assert_equal "#{"#test{background-color:green}" * 100}#{blue}\n", assets["combined_split2"].to_s + assert_equal "#{red}#{green}#{blue}", assets["combined"].to_s.gsub(/\s/, '') + assert_equal "#{"#test{background-color:green}" * 100}#{blue}", assets["combined_split2"].to_s.gsub(/\s/, '') end private diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 4e42755..7a5b60e 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -38,7 +38,8 @@ class Application < Rails::Application # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] - + config.sass.line_comments = false + config.assets.compress = true # Enable escaping HTML in JSON. config.active_support.escape_html_entities_in_json = true From 6cc4244fdbe6599548bef790dc80c008dca1647e Mon Sep 17 00:00:00 2001 From: Christian Peters Date: Wed, 22 Feb 2023 13:36:45 +0100 Subject: [PATCH 8/8] Clarify that this gem is dead --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 77af792..d1b3805 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ Gem for splitting up stylesheets that go beyond the IE limit of 4096 selectors, ### Development status -Since the original developers of this gem are not actively using it in any project at the moment, it is currently in **limited maintenance** mode. Issues are read and pull requests will be reviewed and merged, but there is currently no acitve maintenance/development. - -If you are an active user of the gem and would be able to help out maintaining it, it would be greatly appreciated. Just look at the current issues/pull requests. +Fortunately, the problem of too large CSS files is long gone. This repo is unmaintained. +It remains as an artefact of dark times in the history of web browsers. ## Installation @@ -100,14 +99,13 @@ Since 0.4.1 in development split stylesheets have `debug: false` option by defau ## Credits & License -This is a joint project by the two German Rails shops [Zweitag](http://zweitag.de) and [Railslove](http://railslove.com), therefore the GitHub name "Zweilove". +This is a joint project by the two German Rails shops [Zweitag](https://zweitag.de) and [Railslove](https://railslove.com), therefore the GitHub name "Zweilove". -The original code was written by [Christian Peters](mailto:christian.peters@zweitag.de) and [Thomas Hollstegge](mailto:thomas.hollstegge@zweitag.de) (see this [Gist](https://gist.github.com/2398394)) and turned into a gem by [Jakob Hilden](mailto:jakobhilden@gmail.com). +The original code was written by Christian Peters and Thomas Hollstegge (see this [Gist](https://gist.github.com/2398394)) and turned into a gem by Jakob Hilden. **Major Contributors** * [@Umofomia](https://github.com/Umofomia) * [@kruszczynski](https://github.com/kruszczynski) -This project rocks and uses MIT-LICENSE. - +This project uses MIT-LICENSE.