middleman-inline-style 0.5.1 → 0.6.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/.gitignore +20 -2
- data/Gemfile +1 -1
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +1 -8
- data/lib/middleman-inline-style.rb +3 -99
- data/lib/middleman-inline-style/middleman-extension.rb +1 -1
- data/lib/middleman-inline-style/rack-middleware.rb +3 -1
- data/lib/middleman-inline-style/version.rb +2 -2
- data/middleman-inline-style.gemspec +17 -23
- metadata +16 -106
- data/.rspec +0 -1
- data/Gemfile.lock +0 -55
- data/README.rdoc +0 -127
- data/example.rb +0 -5
- data/lib/middleman-inline-style/css_parser_wrapper.rb +0 -15
- data/lib/middleman-inline-style/csspool_wrapper.rb +0 -12
- data/lib/middleman-inline-style/mail-interceptor.rb +0 -37
- data/lib/middleman-inline-style/rule.rb +0 -18
- data/spec/css_inlining_spec.rb +0 -90
- data/spec/css_parsing_spec.rb +0 -146
- data/spec/fixtures/all.css +0 -3
- data/spec/fixtures/boletin.html +0 -261
- data/spec/fixtures/box-model.html +0 -37
- data/spec/fixtures/inline.html +0 -107
- data/spec/fixtures/none.css +0 -3
- data/spec/fixtures/print.css +0 -3
- data/spec/fixtures/selectors.html +0 -27
- data/spec/fixtures/style.css +0 -3
- data/spec/interceptor_spec.rb +0 -64
- data/spec/rack_middleware_spec.rb +0 -60
- data/spec/spec_helper.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 677ad33830746a1c3f553a1d9bb705dd6a89ef42
|
4
|
+
data.tar.gz: 38c460fa9378722186efadaee2f6509bff0dd4c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4039068172e0749fd7f2c42207904b685b35eedc62c32d61332c1cea5a4f1ddcdd7d403b792e095121271bda6f1b4798d037fb5c3dcaeabf81441bac416f5641
|
7
|
+
data.tar.gz: e734b18410dcc8b6ef01a75c8e24f2f5e84258d7894f575354113acf43f950f98d2969c6144026a16453942e2054555495d06c6064f7f86a4d84602396728224
|
data/.gitignore
CHANGED
@@ -1,4 +1,22 @@
|
|
1
|
-
pkg/*
|
2
1
|
*.gem
|
2
|
+
*.rbc
|
3
3
|
.bundle
|
4
|
-
|
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
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Trenton Broughton
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# middleman-inline-style
|
2
|
+
|
3
|
+
Inline all of your styles. Why would you do such a horrible thing? Probably only for developing email templates.
|
4
|
+
|
5
|
+
This takes some of the pain out of developing templates by allowing you to centralize your CSS, and not worrying about writing style attributes for every element.
|
6
|
+
|
7
|
+
This uses the [inline-style][0] gem from Macario Ortega to do all the work
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'middleman-inline-style'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install middleman-inline-style
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Add this to your config.rb:
|
26
|
+
|
27
|
+
require "middleman-inline-style"
|
28
|
+
activate :inline_style
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( https://github.com/trenton42/middleman-inline-style/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create a new Pull Request
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
MIT
|
41
|
+
|
42
|
+
[0]: https://github.com/maca/inline-style
|
data/Rakefile
CHANGED
@@ -1,105 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
5
|
-
|
6
|
-
require "middleman-inline-style/rule"
|
7
|
-
require "middleman-inline-style/rack-middleware" # This two may be should be required by user if she needs it
|
8
|
-
require "middleman-inline-style/mail-interceptor"
|
1
|
+
require "middleman-inline-style/version"
|
2
|
+
require "middleman-inline-style/rack-middleware"
|
9
3
|
|
10
4
|
require "middleman-core"
|
11
5
|
|
12
6
|
::Middleman::Extensions.register(:inline_style) do
|
13
7
|
require "middleman-inline-style/middleman-extension"
|
14
8
|
::Middleman::InlineStyleExtension
|
15
|
-
end
|
16
|
-
|
17
|
-
class InlineStyle
|
18
|
-
CSSParser =
|
19
|
-
if const_defined? :CSSPool
|
20
|
-
require 'middleman-inline-style/csspool_wrapper'
|
21
|
-
CSSPoolWrapper
|
22
|
-
else
|
23
|
-
require 'middleman-inline-style/css_parser_wrapper'
|
24
|
-
CssParserWrapper
|
25
|
-
end
|
26
|
-
|
27
|
-
# @param [String, Nokogiri::HTML::Document] html Html or Nokogiri html to be inlined
|
28
|
-
# @param [Hash] opts Processing options
|
29
|
-
#
|
30
|
-
# @option opts [String] :stylesheets_path (ENV['DOCUMENT_ROOT'])
|
31
|
-
# Stylesheets root path or app's public directory where the stylesheets are to be found
|
32
|
-
def self.process html, opts = {}
|
33
|
-
new(html, opts).process
|
34
|
-
end
|
35
|
-
|
36
|
-
def initialize html, opts = {}
|
37
|
-
@stylesheets_path = opts[:stylesheets_path] || ENV['DOCUMENT_ROOT'] || '.'
|
38
|
-
@html = html
|
39
|
-
@dom = String === html ? Nokogiri.HTML(html) : html
|
40
|
-
end
|
41
|
-
|
42
|
-
def process
|
43
|
-
nodes_with_rules.each_pair do |node, rules|
|
44
|
-
rules = rules.sort_by{ |sel| "#{sel.specificity}%04d" % rules.index(sel) }
|
45
|
-
|
46
|
-
styles = []
|
47
|
-
rules.each do |rule|
|
48
|
-
next if rule.dynamic_pseudo_class
|
49
|
-
rule.declarations.each do |declaration|
|
50
|
-
if defined = styles.assoc(declaration.first)
|
51
|
-
styles[styles.index(defined)] = declaration # overrides defined declaration
|
52
|
-
else
|
53
|
-
styles << declaration
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
style = styles.map{ |declaration| declaration.join(': ') }.join('; ')
|
59
|
-
node['style'] = "#{style};" unless style.empty?
|
60
|
-
end
|
61
|
-
pre_parsed? ? @dom : @dom.to_s
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
def nodes_with_rules
|
66
|
-
nodes, body = {}, @dom.css('body')
|
67
|
-
|
68
|
-
parse_css.rules.each do |rule|
|
69
|
-
body.css(rule.selector).each do |node|
|
70
|
-
nodes[node] ||= []
|
71
|
-
nodes[node].push rule
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
body.css('[style]').each do |node|
|
76
|
-
nodes[node] ||= []
|
77
|
-
nodes[node].push Rule.new ':inline', node['style'], '1000' # :inline is not really a pseudoclass
|
78
|
-
end
|
79
|
-
|
80
|
-
nodes
|
81
|
-
end
|
82
|
-
|
83
|
-
def pre_parsed?
|
84
|
-
@html == @dom
|
85
|
-
end
|
86
|
-
|
87
|
-
# Returns parsed CSS
|
88
|
-
def extract_css
|
89
|
-
@dom.css('style, link[rel=stylesheet]').collect do |node|
|
90
|
-
next unless /^$|screen|all/ === node['media'].to_s
|
91
|
-
node.remove
|
92
|
-
|
93
|
-
if node.name == 'style'
|
94
|
-
node.content
|
95
|
-
else
|
96
|
-
uri = %r{^https?://} === node['href'] ? node['href'] : File.join(@stylesheets_path, node['href'].sub(/\?.+$/,''))
|
97
|
-
open(uri).read
|
98
|
-
end
|
99
|
-
end.join("\n")
|
100
|
-
end
|
101
|
-
|
102
|
-
def parse_css
|
103
|
-
CSSParser.new extract_css
|
104
|
-
end
|
105
|
-
end
|
9
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
class
|
2
|
-
VERSION =
|
1
|
+
class MiddlemanInlineStyle
|
2
|
+
VERSION = "0.6.0"
|
3
3
|
end
|
@@ -1,29 +1,23 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
3
|
require "middleman-inline-style/version"
|
4
4
|
|
5
|
-
Gem::Specification.new do |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.post_install_message = %{Please read documentation for changes on the default css parser gem, specifically if you use csspool}
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "middleman-inline-style"
|
7
|
+
spec.version = MiddlemanInlineStyle::VERSION
|
8
|
+
spec.authors = ["Trenton Broughton"]
|
9
|
+
spec.email = ["trenton@ikso.us"]
|
10
|
+
spec.summary = "Middleman extension to inline your css"
|
11
|
+
spec.description = "Inline the css in your templates. Useful for developing email templates"
|
12
|
+
spec.homepage = "https://github.com/trenton42/middleman-inline-style"
|
13
|
+
spec.license = "MIT"
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
spec.files = `git ls-files`.split("\n")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
s.add_development_dependency 'mail'
|
25
|
-
|
26
|
-
s.add_dependency 'nokogiri'
|
27
|
-
s.add_dependency 'css_parser'
|
28
|
-
s.add_dependency 'maca-fork-csspool'
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_dependency "inline-style"
|
29
23
|
end
|
metadata
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-inline-style
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Macario Ortega
|
8
|
-
- Eric Anderson
|
9
7
|
- Trenton Broughton
|
10
8
|
autorequire:
|
11
9
|
bindir: bin
|
@@ -13,49 +11,21 @@ cert_chain: []
|
|
13
11
|
date: 2014-09-03 00:00:00.000000000 Z
|
14
12
|
dependencies:
|
15
13
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
14
|
+
name: bundler
|
17
15
|
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
requirements:
|
26
|
-
- - '>='
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
version: '0'
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: rack
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - '>='
|
17
|
+
- - ~>
|
34
18
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
36
|
-
type: :development
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - '>='
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '0'
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
|
-
name: rspec-core
|
45
|
-
requirement: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - '>='
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '0'
|
19
|
+
version: '1.6'
|
50
20
|
type: :development
|
51
21
|
prerelease: false
|
52
22
|
version_requirements: !ruby/object:Gem::Requirement
|
53
23
|
requirements:
|
54
|
-
- -
|
24
|
+
- - ~>
|
55
25
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
26
|
+
version: '1.6'
|
57
27
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
28
|
+
name: rake
|
59
29
|
requirement: !ruby/object:Gem::Requirement
|
60
30
|
requirements:
|
61
31
|
- - '>='
|
@@ -69,35 +39,7 @@ dependencies:
|
|
69
39
|
- !ruby/object:Gem::Version
|
70
40
|
version: '0'
|
71
41
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
73
|
-
requirement: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
type: :runtime
|
79
|
-
prerelease: false
|
80
|
-
version_requirements: !ruby/object:Gem::Requirement
|
81
|
-
requirements:
|
82
|
-
- - '>='
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: '0'
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: css_parser
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - '>='
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '0'
|
92
|
-
type: :runtime
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - '>='
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
name: maca-fork-csspool
|
42
|
+
name: inline-style
|
101
43
|
requirement: !ruby/object:Gem::Requirement
|
102
44
|
requirements:
|
103
45
|
- - '>='
|
@@ -110,7 +52,7 @@ dependencies:
|
|
110
52
|
- - '>='
|
111
53
|
- !ruby/object:Gem::Version
|
112
54
|
version: '0'
|
113
|
-
description:
|
55
|
+
description: Inline the css in your templates. Useful for developing email templates
|
114
56
|
email:
|
115
57
|
- trenton@ikso.us
|
116
58
|
executables: []
|
@@ -118,39 +60,20 @@ extensions: []
|
|
118
60
|
extra_rdoc_files: []
|
119
61
|
files:
|
120
62
|
- .gitignore
|
121
|
-
- .rspec
|
122
63
|
- Gemfile
|
123
|
-
-
|
124
|
-
- README.
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
125
66
|
- Rakefile
|
126
|
-
- example.rb
|
127
67
|
- lib/middleman-inline-style.rb
|
128
|
-
- lib/middleman-inline-style/css_parser_wrapper.rb
|
129
|
-
- lib/middleman-inline-style/csspool_wrapper.rb
|
130
|
-
- lib/middleman-inline-style/mail-interceptor.rb
|
131
68
|
- lib/middleman-inline-style/middleman-extension.rb
|
132
69
|
- lib/middleman-inline-style/rack-middleware.rb
|
133
|
-
- lib/middleman-inline-style/rule.rb
|
134
70
|
- lib/middleman-inline-style/version.rb
|
135
71
|
- middleman-inline-style.gemspec
|
136
|
-
- spec/css_inlining_spec.rb
|
137
|
-
- spec/css_parsing_spec.rb
|
138
|
-
- spec/fixtures/all.css
|
139
|
-
- spec/fixtures/boletin.html
|
140
|
-
- spec/fixtures/box-model.html
|
141
|
-
- spec/fixtures/inline.html
|
142
|
-
- spec/fixtures/none.css
|
143
|
-
- spec/fixtures/print.css
|
144
|
-
- spec/fixtures/selectors.html
|
145
|
-
- spec/fixtures/style.css
|
146
|
-
- spec/interceptor_spec.rb
|
147
|
-
- spec/rack_middleware_spec.rb
|
148
|
-
- spec/spec_helper.rb
|
149
72
|
homepage: https://github.com/trenton42/middleman-inline-style
|
150
|
-
licenses:
|
73
|
+
licenses:
|
74
|
+
- MIT
|
151
75
|
metadata: {}
|
152
|
-
post_install_message:
|
153
|
-
gem, specifically if you use csspool
|
76
|
+
post_install_message:
|
154
77
|
rdoc_options: []
|
155
78
|
require_paths:
|
156
79
|
- lib
|
@@ -169,18 +92,5 @@ rubyforge_project:
|
|
169
92
|
rubygems_version: 2.0.14
|
170
93
|
signing_key:
|
171
94
|
specification_version: 4
|
172
|
-
summary:
|
173
|
-
test_files:
|
174
|
-
- spec/css_inlining_spec.rb
|
175
|
-
- spec/css_parsing_spec.rb
|
176
|
-
- spec/fixtures/all.css
|
177
|
-
- spec/fixtures/boletin.html
|
178
|
-
- spec/fixtures/box-model.html
|
179
|
-
- spec/fixtures/inline.html
|
180
|
-
- spec/fixtures/none.css
|
181
|
-
- spec/fixtures/print.css
|
182
|
-
- spec/fixtures/selectors.html
|
183
|
-
- spec/fixtures/style.css
|
184
|
-
- spec/interceptor_spec.rb
|
185
|
-
- spec/rack_middleware_spec.rb
|
186
|
-
- spec/spec_helper.rb
|
95
|
+
summary: Middleman extension to inline your css
|
96
|
+
test_files: []
|