jekyll-minify-html 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGUyMTc4YzRjZTY1MTQ5MWZhZTcxMGMxY2U2ZTc3YzAxNjljOWE2OQ==
5
+ data.tar.gz: !binary |-
6
+ MWVkMzE0YjEzMmM2YzU2OTY1NWYwYTNlMmJlMWQwNmE5YWJiY2Q5Zg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZDlmNWE4NTZjZmUwZjNhNjg3ZTFmYWY5ODBmMzM5ZTliMjlhMDdjNzlhYTk1
10
+ YjdlOGJhZWZiNjBmYmM4ODVmZjFhMDY5OTlhZTBmNzhkZGVlN2NhYWQxNzEx
11
+ ZjlmZWQ4YTNmZWRmYTkwNmEyN2E3ZGVkZGYxM2FiY2IxMjAzYjg=
12
+ data.tar.gz: !binary |-
13
+ YzU4NGEzZmNlZWQxZTVjMDhiYjNkMTcxOWU3ZDA5Njg4Yzc4ZWFiOTNkZGIw
14
+ MTc0MmQ5NzU4M2RmMTUwNmNkM2M4ZmU0ZWUxMWUyODliODU2MmNiZWRkMTc5
15
+ Y2IwODM4NTc2ZTYwYmExZjIzMzI5ZGFlZTZhYTVjNWIzZDYwMmY=
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm: 1.9.3
3
+ script: cd test && ruby test.rb
4
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-minify-html.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Brandon Mathis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # Jekyll Minify Html
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/jekyll-minify-html.png)](http://badge.fury.io/rb/jekyll-minify-html) [![Build Status](https://travis-ci.org/imathis/jekyll-minify-html.png)](https://travis-ci.org/imathis/jekyll-minify-html)
4
+
5
+ Minify Jekyll's HTML output with [html_press](https://github.com/stereobooster/html_press)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile under
10
+ the :jekyll_plugins group:
11
+
12
+ ```ruby
13
+ group :jekyll_plugins do
14
+ gem 'jekyll-minify-html'
15
+ end
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Next add this to your plugins folder to automatically load any Jekyll plugins in your :jekyll_plugins group.
23
+
24
+ ```ruby
25
+ # in _plugins/bundler.rb
26
+ require "bundler/setup"
27
+ Bundler.require(:jekyll_plugins)
28
+
29
+ ```
30
+
31
+ Or you can just create a ruby file in your Jekyll plugins directory with the line `require "jekyll-minify-html"`
32
+
33
+ ## Usage
34
+
35
+ Set Jekyll's environment to production in your Jekyll configuration file.
36
+
37
+ ```yml
38
+ env: production
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-minify-html/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-minify-html"
8
+ spec.version = Jekyll::MinifyHTMLVersion::VERSION
9
+ spec.authors = ["Brandon Mathis"]
10
+ spec.email = ["brandon@imathis.com"]
11
+ spec.description = %q{Minify Jekyll's HTML output using html_press}
12
+ spec.summary = %q{Minify Jekyll's HTML output using html_press}
13
+ spec.homepage = "https://github.com/imathis/jekyll-minify-html"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_runtime_dependency "jekyll", "~> 1.0"
25
+ spec.add_runtime_dependency "html_press", "~> 0.8.2"
26
+ end
@@ -0,0 +1,55 @@
1
+ require 'html_press'
2
+
3
+ module Jekyll
4
+ module MinifyHTML
5
+ def output_file(dest, content)
6
+ FileUtils.mkdir_p(File.dirname(dest))
7
+ File.open(dest, 'w') do |f|
8
+ f.write(content)
9
+ end
10
+ end
11
+
12
+ def output_html(path, content)
13
+ if @site.config['env'] && @site.config['env'].downcase === 'production'
14
+ content = HtmlPress.press(content)
15
+ end
16
+ output_file(path, content)
17
+ end
18
+
19
+ end
20
+
21
+ class Post
22
+ include MinifyHTML
23
+
24
+ def write(dest)
25
+ dest_path = destination(dest)
26
+ output_html(dest_path, output)
27
+ end
28
+ end
29
+
30
+ class Page
31
+ include MinifyHTML
32
+
33
+ def write(dest)
34
+ dest_path = destination(dest)
35
+ if File.extname(dest_path).downcase == '.html'
36
+ output_html(dest_path, output)
37
+ else
38
+ output_file(dest_path, output)
39
+ end
40
+ end
41
+ end
42
+ class ConvertiblePage
43
+ include MinifyHTML
44
+
45
+ def write(dest)
46
+ dest_path = destination(dest)
47
+ if File.extname(dest_path).downcase == '.html'
48
+ output_html(dest_path, output)
49
+ else
50
+ output_file(dest_path, output)
51
+ end
52
+ end
53
+ end
54
+ end
55
+
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module MinifyHTMLVersion
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ _site
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jekyll-markdown-block.gemspec
4
+ group :jekyll_plugins do
5
+ gem "jekyll-minify-html", path: "../"
6
+ end
7
+
@@ -0,0 +1,6 @@
1
+ name: Your New Jekyll Site
2
+ markdown: redcarpet
3
+ source: source
4
+ plugins: source/_plugins
5
+ destination: site
6
+ pygments: false
@@ -0,0 +1 @@
1
+ env: production
@@ -0,0 +1,7 @@
1
+ <!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>Your New Jekyll Site</title><meta name="viewport" content="width=device-width"><link rel="stylesheet" href="/css/syntax.css"><link rel="stylesheet" href="/css/main.css"></head><body><div class="site"><div class="header"><h1 class="title"><a href="/">Your New Jekyll Site</a></h1> <a class="extra" href="/">home</a></div><h1>Test</h1><div> Here's some stuff to compress</div><div class="highlight"><pre><code class="text language-text" data-lang="text">Here's a code block.
2
+ Don't compress this!
3
+
4
+ ^ empty line suckas!
5
+ What are you going to do about it?
6
+ I'm a code block!
7
+ </code></pre></div><p>OK.</p><p>This is probably good enough.</p><p>Peace out.</p><div class="footer"><div class="contact"><p> Your Name<br/> What You Are<br/> you@example.com</p></div><div class="contact"><p> <a href="https://github.com/yourusername">github.com/yourusername</a><br/> <a href="https://twitter.com/yourusername">twitter.com/yourusername</a><br/></p></div></div></div></body></html>
@@ -0,0 +1,61 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>Your New Jekyll Site</title>
7
+ <meta name="viewport" content="width=device-width">
8
+
9
+ <!-- syntax highlighting CSS -->
10
+ <link rel="stylesheet" href="/css/syntax.css">
11
+
12
+ <!-- Custom CSS -->
13
+ <link rel="stylesheet" href="/css/main.css">
14
+
15
+ </head>
16
+ <body>
17
+
18
+ <div class="site">
19
+ <div class="header">
20
+ <h1 class="title"><a href="/">Your New Jekyll Site</a></h1>
21
+ <a class="extra" href="/">home</a>
22
+ </div>
23
+
24
+ <h1>Test</h1>
25
+
26
+ <div> Here's some stuff to
27
+
28
+ compress</div>
29
+ <div class="highlight"><pre><code class="text language-text" data-lang="text">Here's a code block.
30
+ Don't compress this!
31
+
32
+ ^ empty line suckas!
33
+ What are you going to do about it?
34
+ I'm a code block!
35
+ </code></pre></div>
36
+ <p>OK.</p>
37
+
38
+ <p>This is probably good enough.</p>
39
+
40
+ <p>Peace out.</p>
41
+
42
+
43
+ <div class="footer">
44
+ <div class="contact">
45
+ <p>
46
+ Your Name<br />
47
+ What You Are<br />
48
+ you@example.com
49
+ </p>
50
+ </div>
51
+ <div class="contact">
52
+ <p>
53
+ <a href="https://github.com/yourusername">github.com/yourusername</a><br />
54
+ <a href="https://twitter.com/yourusername">twitter.com/yourusername</a><br />
55
+ </p>
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ </body>
61
+ </html>
@@ -0,0 +1,61 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>Your New Jekyll Site</title>
7
+ <meta name="viewport" content="width=device-width">
8
+
9
+ <!-- syntax highlighting CSS -->
10
+ <link rel="stylesheet" href="/css/syntax.css">
11
+
12
+ <!-- Custom CSS -->
13
+ <link rel="stylesheet" href="/css/main.css">
14
+
15
+ </head>
16
+ <body>
17
+
18
+ <div class="site">
19
+ <div class="header">
20
+ <h1 class="title"><a href="/">Your New Jekyll Site</a></h1>
21
+ <a class="extra" href="/">home</a>
22
+ </div>
23
+
24
+ <h1>Test</h1>
25
+
26
+ <div> Here's some stuff to
27
+
28
+ compress</div>
29
+ <div class="highlight"><pre><code class="text language-text" data-lang="text">Here's a code block.
30
+ Don't compress this!
31
+
32
+ ^ empty line suckas!
33
+ What are you going to do about it?
34
+ I'm a code block!
35
+ </code></pre></div>
36
+ <p>OK.</p>
37
+
38
+ <p>This is probably good enough.</p>
39
+
40
+ <p>Peace out.</p>
41
+
42
+
43
+ <div class="footer">
44
+ <div class="contact">
45
+ <p>
46
+ Your Name<br />
47
+ What You Are<br />
48
+ you@example.com
49
+ </p>
50
+ </div>
51
+ <div class="contact">
52
+ <p>
53
+ <a href="https://github.com/yourusername">github.com/yourusername</a><br />
54
+ <a href="https://twitter.com/yourusername">twitter.com/yourusername</a><br />
55
+ </p>
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ </body>
61
+ </html>
@@ -0,0 +1,44 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>{{ page.title }}</title>
7
+ <meta name="viewport" content="width=device-width">
8
+
9
+ <!-- syntax highlighting CSS -->
10
+ <link rel="stylesheet" href="/css/syntax.css">
11
+
12
+ <!-- Custom CSS -->
13
+ <link rel="stylesheet" href="/css/main.css">
14
+
15
+ </head>
16
+ <body>
17
+
18
+ <div class="site">
19
+ <div class="header">
20
+ <h1 class="title"><a href="/">{{ site.name }}</a></h1>
21
+ <a class="extra" href="/">home</a>
22
+ </div>
23
+
24
+ {{ content }}
25
+
26
+ <div class="footer">
27
+ <div class="contact">
28
+ <p>
29
+ Your Name<br />
30
+ What You Are<br />
31
+ you@example.com
32
+ </p>
33
+ </div>
34
+ <div class="contact">
35
+ <p>
36
+ <a href="https://github.com/yourusername">github.com/yourusername</a><br />
37
+ <a href="https://twitter.com/yourusername">twitter.com/yourusername</a><br />
38
+ </p>
39
+ </div>
40
+ </div>
41
+ </div>
42
+
43
+ </body>
44
+ </html>
@@ -0,0 +1,3 @@
1
+ require "bundler/setup"
2
+ Bundler.require(:jekyll_plugins)
3
+
@@ -0,0 +1,24 @@
1
+ ---
2
+ layout: default
3
+ title: Your New Jekyll Site
4
+ ---
5
+
6
+ # Test
7
+
8
+ <div> Here's some stuff to
9
+
10
+ compress</div>
11
+
12
+
13
+ Here's a code block.
14
+ Don't compress this!
15
+
16
+ ^ empty line suckas!
17
+ What are you going to do about it?
18
+ I'm a code block!
19
+
20
+ OK.
21
+
22
+ This is probably good enough.
23
+
24
+ Peace out.
@@ -0,0 +1,30 @@
1
+ require 'colorator'
2
+
3
+ has_failed = false
4
+
5
+ `bundle exec jekyll build --config _config.yml,_production.yml --trace`
6
+
7
+ compressed_diff = `diff expected/compressed.html site/index.html`
8
+
9
+ `bundle exec jekyll build --trace`
10
+
11
+ uncompressed_diff = `diff expected/uncompressed.html site/index.html`
12
+
13
+ if compressed_diff.size == 0
14
+ puts "Compression passed".green
15
+ else
16
+ puts "Compression failed".red
17
+ puts compressed_diff
18
+ has_failed = true
19
+ end
20
+
21
+ if uncompressed_diff.size == 0
22
+ puts "Disabling compression passed".green
23
+ else
24
+ puts "Disabling compression failed".red
25
+ puts uncompressed_diff
26
+ has_failed = true
27
+ end
28
+
29
+ abort if has_failed
30
+
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-minify-html
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Mathis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: html_press
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.2
69
+ description: Minify Jekyll's HTML output using html_press
70
+ email:
71
+ - brandon@imathis.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .travis.yml
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - jekyll-minify-html.gemspec
83
+ - lib/jekyll-minify-html.rb
84
+ - lib/jekyll-minify-html/version.rb
85
+ - test/.gitignore
86
+ - test/Gemfile
87
+ - test/_config.yml
88
+ - test/_production.yml
89
+ - test/expected/compressed.html
90
+ - test/expected/uncompressed.html
91
+ - test/site/index.html
92
+ - test/source/_layouts/default.html
93
+ - test/source/_plugins/bundler.rb
94
+ - test/source/index.md
95
+ - test/test.rb
96
+ homepage: https://github.com/imathis/jekyll-minify-html
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.0.7
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Minify Jekyll's HTML output using html_press
120
+ test_files:
121
+ - test/.gitignore
122
+ - test/Gemfile
123
+ - test/_config.yml
124
+ - test/_production.yml
125
+ - test/expected/compressed.html
126
+ - test/expected/uncompressed.html
127
+ - test/site/index.html
128
+ - test/source/_layouts/default.html
129
+ - test/source/_plugins/bundler.rb
130
+ - test/source/index.md
131
+ - test/test.rb