octopress-minify-html 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +2 -2
- data/lib/octopress-minify-html.rb +33 -15
- data/lib/octopress-minify-html/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 456847651114a0a363910733b1695f760955b906
|
4
|
+
data.tar.gz: c65ca6648aa6538030ad3ddfc96f66b84635ca1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47042eb9e4d44dcbcb9a2e535e070eb923ea89d06948031a904aa5cbfd6d371711b721b7d6b74fb8f3b3044d030468f1f86610c0ff9fea44469631266f39fffb
|
7
|
+
data.tar.gz: 50135e2d7b260bb29abc13bd0d11527ebcb279f4e28c47d759e18ad3602aeae87e6f14f6a23180aa0e916879d5ead5386623ad3f483efddd5e6c8a01bc9cef73
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Octopress Minify Html
|
2
2
|
|
3
|
-
[](http://badge.fury.io/rb/octopress-minify-html)
|
4
|
+
[](https://travis-ci.org/octopress/minify-html)
|
5
5
|
|
6
6
|
|
7
7
|
Minify Jekyll's HTML output with [HtmlPress](https://github.com/stereobooster/html_press)
|
@@ -1,29 +1,34 @@
|
|
1
1
|
require 'html_press'
|
2
|
-
|
2
|
+
|
3
3
|
require 'octopress-minify-html/version'
|
4
4
|
|
5
5
|
module Octopress
|
6
6
|
module MinifyHTML
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def minify(item)
|
11
|
+
options = symbolize(item.site.config['html_press'] || {})
|
12
|
+
if minify?(item)
|
13
|
+
HtmlPress.press(item.output, options)
|
14
|
+
else
|
15
|
+
item.output
|
11
16
|
end
|
17
|
+
end
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
def minify?(item)
|
20
|
+
config = item.site.config
|
21
|
+
if item.destination(config['destination']).end_with?('html')
|
22
|
+
minify = config['minify_html']
|
23
|
+
production = config['env'].nil? || config['env'] =~ /production/i
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
25
|
+
# Minify if configuration explicitly requires minification
|
26
|
+
# or if Jekyll env is production
|
27
|
+
minify || (minify.nil? && production)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
26
|
-
def
|
31
|
+
def symbolize(obj)
|
27
32
|
return obj.reduce({}) do |memo, (k, v)|
|
28
33
|
memo.tap { |m| m[k.to_sym] = symbolize(v) }
|
29
34
|
end if obj.is_a? Hash
|
@@ -34,6 +39,19 @@ module Octopress
|
|
34
39
|
|
35
40
|
obj
|
36
41
|
end
|
42
|
+
|
43
|
+
if defined?(Jekyll::Hooks)
|
44
|
+
Jekyll::Hooks.register [:post, :page, :document], :post_render do |item|
|
45
|
+
item.output = MinifyHTML.minify(item)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
require 'octopress-hooks'
|
49
|
+
class MinifyPage < Octopress::Hooks::All
|
50
|
+
def post_render(item)
|
51
|
+
item.output = MinifyHTML.minify(item)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
37
55
|
end
|
38
56
|
end
|
39
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octopress-minify-html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Mathis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: jekyll
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.4.7
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Minify Jekyll's HTML output using html_press
|