Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #17 from beanieboi/static-gzip

add ability to generate static gzip files
  • Loading branch information...
commit f706dbef5fead3353a5e90b68ee0c6b055c96f92 2 parents 9c9e5e4 + 948d948
@ixti ixti authored
View
4 README.md
@@ -435,6 +435,10 @@ assets:
# output URL: /assets/javascripts/app-4f41243847da693a4f356c0486114bc6.css
#
cachebust: hard
+ #
+ # saves gzipped versions of the assets next to the un-compressed files
+ #
+ gzip: true
```
View
1  lib/jekyll/assets_plugin/asset_file.rb
@@ -51,6 +51,7 @@ def write dest
@@mtimes[path] = mtime
@asset.write_to dest_path
+ @asset.write_to dest_path + '.gz' if @site.assets_config.gzip
true
end
View
3  lib/jekyll/assets_plugin/configuration.rb
@@ -9,7 +9,8 @@ class Configuration
:dirname => "assets",
:sources => %w{_assets/javascripts _assets/stylesheets _assets/images},
:compress => { :css => nil, :js => nil },
- :cachebust => :hard
+ :cachebust => :hard,
+ :gzip => true
}.freeze
View
14 spec/lib/jekyll/assets_plugin/configuration_spec.rb
@@ -35,6 +35,12 @@ module Jekyll::AssetsPlugin
subject { config.compress.css }
it { should be_nil }
end
+
+ context "gzip" do
+ subject { config.gzip }
+ it { should == true }
+ end
+
end
it "should override specified options and leave defaults for missing" do
@@ -91,5 +97,13 @@ module Jekyll::AssetsPlugin
it { should be_false }
end
end
+
+ context "#gzip" do
+ context "when gzip is disabled" do
+ let(:config){ Configuration.new(:gzip => false) }
+ subject { config.gzip }
+ it { should be false }
+ end
+ end
end
end
View
16 spec/lib/jekyll/assets_plugin/site_patch_spec.rb
@@ -107,6 +107,22 @@ def source
@dest.join("assets", "app.css").exist?.should be_true
end
+ context "#gzip" do
+ subject { site.assets_config }
+
+ it "should generate a static assets if gzip is enabled" do
+ @site.assets_config.gzip = true
+ @site.process
+ @dest.join("assets", "app.css.gz").exist?.should be_true
+ end
+
+ it "should not generate a static assets if gzip is enabled" do
+ @site.assets_config.gzip = false
+ @site.process
+ @dest.join("assets", "app.css.gz").exist?.should be_false
+ end
+
+ end
it "should be included into Jekyll::Site" do
Jekyll::Site.included_modules.should include SitePatch
Please sign in to comment.
Something went wrong with that request. Please try again.