middleman-critical 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +18 -0
- data/lib/middleman-critical/extension.rb +36 -0
- data/lib/middleman-critical.rb +6 -0
- data/lib/middleman-extension.rb +1 -0
- data/middleman-critical.gemspec +14 -0
- metadata +9 -2
- data/lib/extension.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f13c35dbe01bfea9d9a9dbe434958a16a732e66b
|
4
|
+
data.tar.gz: ae733f7c07cff862efb8feb829c0cd9eee662497
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3787a1ec8f6a692f8ecd71c5c28d8669494ee94c11d9c5d998aa71e7bad7240fa175f81119b64926355812f744651095e724030b7b313d40653b11d424fcab0a
|
7
|
+
data.tar.gz: a1df35359e49569105d193bf0cb5a2a70a6a0e46f227725622e49299917d8049635c5337fbd4a549eea8f738a8205378a2edc33a6a820b3fdaae584fbd27a3a2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Robert Gründler
|
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,18 @@
|
|
1
|
+
## Middleman-Critical
|
2
|
+
|
3
|
+
[Middleman](https://middlemanapp.com/) extension to generate critical-path css using [critical](https://github.com/addyosmani/critical)
|
4
|
+
|
5
|
+
### Dependencies
|
6
|
+
|
7
|
+
The `critical` binary must be available on the system.
|
8
|
+
|
9
|
+
|
10
|
+
### Usage
|
11
|
+
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# config.rb
|
15
|
+
|
16
|
+
activate :critical, :binary => '/usr/local/bin/critical' # binary defaults to 'critical'
|
17
|
+
|
18
|
+
```
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'middleman-core'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
|
5
|
+
class CriticalExtension < Extension
|
6
|
+
|
7
|
+
option :binary, 'critical', 'The critical binary to use'
|
8
|
+
|
9
|
+
def initialize(app, options_hash={}, &block)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def after_build(builder)
|
14
|
+
|
15
|
+
rootPath = app.root
|
16
|
+
buildDir = app.config[:build_dir]
|
17
|
+
htmlDir = buildDir + File::SEPARATOR + '**' + File::SEPARATOR + '*.html'
|
18
|
+
|
19
|
+
# cssDir = buildDir + File::SEPARATOR + app.config[:css_dir] + File::SEPARATOR + '**' + File::SEPARATOR + '*.css'
|
20
|
+
#cssDirs = []
|
21
|
+
|
22
|
+
#Dir.glob(cssDir) do |file|
|
23
|
+
# cssDirs.push(rootPath + File::SEPARATOR + file)
|
24
|
+
#end
|
25
|
+
|
26
|
+
Dir.glob(htmlDir) do |file|
|
27
|
+
assetPath = rootPath + File::SEPARATOR + file
|
28
|
+
file.slice! buildDir + File::SEPARATOR
|
29
|
+
%x(#{options.binary} #{assetPath} --base #{buildDir} --htmlTarget #{file} --extract --inline)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "middleman-critical"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = 'middleman-critical'
|
3
|
+
gem.version = '0.0.2'
|
4
|
+
gem.date = '2015-05-30'
|
5
|
+
gem.summary = "Middleman extension for critical path css generation"
|
6
|
+
gem.description = "Middleman extension for critical path css generation. Requires the critical binary"
|
7
|
+
gem.authors = ["Robert Gründler"]
|
8
|
+
gem.email = 'robert@dubture.com'
|
9
|
+
gem.files = `git ls-files`.split($\)
|
10
|
+
gem.homepage = 'https://github.com/pulse00/middleman-critical'
|
11
|
+
gem.license = 'MIT'
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-critical
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Gründler
|
@@ -17,7 +17,14 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
-
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- lib/middleman-critical.rb
|
25
|
+
- lib/middleman-critical/extension.rb
|
26
|
+
- lib/middleman-extension.rb
|
27
|
+
- middleman-critical.gemspec
|
21
28
|
homepage: https://github.com/pulse00/middleman-critical
|
22
29
|
licenses:
|
23
30
|
- MIT
|
data/lib/extension.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'middleman-core'
|
2
|
-
|
3
|
-
class Critical < ::Middleman::Extension
|
4
|
-
|
5
|
-
option :binary, 'critical', 'The critical binary to use'
|
6
|
-
|
7
|
-
def initialize(app, options_hash={}, &block)
|
8
|
-
super
|
9
|
-
end
|
10
|
-
|
11
|
-
def after_build(builder)
|
12
|
-
|
13
|
-
rootPath = app.root
|
14
|
-
buildDir = app.config[:build_dir]
|
15
|
-
htmlDir = buildDir + File::SEPARATOR + '**' + File::SEPARATOR + '*.html'
|
16
|
-
|
17
|
-
# cssDir = buildDir + File::SEPARATOR + app.config[:css_dir] + File::SEPARATOR + '**' + File::SEPARATOR + '*.css'
|
18
|
-
#cssDirs = []
|
19
|
-
|
20
|
-
#Dir.glob(cssDir) do |file|
|
21
|
-
# cssDirs.push(rootPath + File::SEPARATOR + file)
|
22
|
-
#end
|
23
|
-
|
24
|
-
Dir.glob(htmlDir) do |file|
|
25
|
-
assetPath = rootPath + File::SEPARATOR + file
|
26
|
-
file.slice! buildDir + File::SEPARATOR
|
27
|
-
%x(#{options.binary} #{assetPath} --base #{buildDir} --htmlTarget #{file} --extract --inline)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
Critical.register(:critical)
|