middleman-svg-fallback 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +3 -5
- data/CHANGELOG.md +8 -0
- data/LICENSE +21 -0
- data/README.md +43 -15
- data/Rakefile +12 -0
- data/features/support/env.rb +4 -0
- data/features/svg-fallback.feature +36 -0
- data/fixtures/image-app/source/images/sample.svg +17 -0
- data/fixtures/image-app/source/images/sample2.svgz +0 -0
- data/lib/middleman/svg_fallback.rb +36 -0
- data/lib/middleman-svg-fallback.rb +5 -7
- data/middleman-svg-fallback.gemspec +11 -6
- metadata +100 -24
- data/lib/middleman-svg-fallback/extension.rb +0 -42
- data/lib/middleman-svg-fallback/version.rb +0 -5
- data/lib/middleman_extension.rb +0 -1
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
M2M4NzM4OTAxNGE5YjAxMTE1MzcyZWM0NzA3OWMyNDAxNTc2Y2MwMg==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c7d83bf9de5ce0590258e6eaf65979d1f28af8dcd78698ae342d7d9f67325156
|
4
|
+
data.tar.gz: d53d4112953eea550a819332574a74d22bbe4e6da2527d6bf6855446627d6923
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OGM1MmE5NGM2Mzc4NDEzNmI0NzUyOWFhM2MwZjRjOWZlYWU3MzUwZGYyMTZk
|
11
|
-
OTAwNDY3NTgzMGIwMmQyYWEzMmY0NmRjNzg3ZjgxYjhjOTY0Nzk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OGIwOWFlYWIzM2M0ZGYyMWVkOGU5Mjg2MTQwNmMwNjA1ZjZjY2E4ZTk1ZTVh
|
14
|
-
ZTIyMzc3MGI0NTE3YmFmNjAwNjk1ZmU4MjM5NTUyYWVjYWJkYTc5OTM2OTU3
|
15
|
-
YjIyZjk4ZTIyYTdkMDczM2M5ZTMzODQ3ZTkwMjYyZGM1YTVkMjI=
|
6
|
+
metadata.gz: 0afa98f3a0c9b407e59a58f32c2737538780ce4c4bf0fa868c0f9a13a37f7e9484be7f41a67a2a36d2baec852d506920ed417dae431b9e981eb130004ee0aa56
|
7
|
+
data.tar.gz: c09cc10f4db603102c2d680daf716d46c3595dec67d6e2642abaf08f456bb1fee8b4413910d1b3eef8349d6bb4f3e295b77efbe20f8116d1a30506227af9929b
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012-2017 Jan Schulz-Hofen
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -14,18 +14,36 @@ Add this line to your `Gemfile`:
|
|
14
14
|
gem 'middleman-svg-fallback'
|
15
15
|
```
|
16
16
|
|
17
|
-
|
17
|
+
|
18
|
+
## Configuration
|
19
|
+
|
20
|
+
Activate the plugin in your config.rb:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
activate :svg_fallback
|
24
|
+
```
|
25
|
+
|
26
|
+
You may provide the path to your inkscape binary, if it's not in the `PATH`.
|
27
|
+
E.g. on macOS, you may use the following configuration:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
activate :svg_fallback, inkscape_bin: '/Applications/Inkscape.app/Contents/Resources/bin/inkscape'
|
31
|
+
```
|
32
|
+
|
33
|
+
Furthermore, you may configure command line arguments, that should be passed on
|
34
|
+
to inkscape:
|
18
35
|
|
19
36
|
```ruby
|
20
|
-
|
21
|
-
activate :svg_fallback,
|
22
|
-
:inkscape_bin => '/Applications/Inkscape.app/Contents/Resources/bin/inkscape',
|
23
|
-
:inkscape_options => '--export-dpi=100 --export-background-opacity=0'
|
37
|
+
activate :svg_fallback, inkscape_options: '--export-dpi=100 --export-background-opacity=0'
|
24
38
|
```
|
25
39
|
|
26
|
-
(supposed you're working on a Mac)
|
27
40
|
|
28
|
-
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
If configured properly, middleman-svg-fallback will generate fallback images
|
44
|
+
(PNGs and JPGs) for all SVGs within your `images_dir` as you would expect. You
|
45
|
+
can use them with a [modernizr](http://modernizr.com/) based CSS rule, like this
|
46
|
+
for example:
|
29
47
|
|
30
48
|
```css
|
31
49
|
.illustration {
|
@@ -37,17 +55,15 @@ Then, during build, middleman-svg-fallback will generate the fallbacks as you wo
|
|
37
55
|
}
|
38
56
|
```
|
39
57
|
|
40
|
-
The JPEG files are intended for use with [OpenGraph](http://ogp.me/).
|
58
|
+
The generated JPEG files are intended for use with [OpenGraph](http://ogp.me/).
|
59
|
+
Facebook doesn't like PNGs in `og:image` properties, so the JPG versions will
|
60
|
+
come in handy.
|
41
61
|
|
42
|
-
## License
|
43
62
|
|
44
|
-
|
45
|
-
|
46
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
63
|
+
## License
|
47
64
|
|
48
|
-
|
65
|
+
This software is licensed under the MIT License. [View the license](LICENSE).
|
49
66
|
|
50
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
51
67
|
|
52
68
|
## Contributing
|
53
69
|
|
@@ -55,4 +71,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
55
71
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
72
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
57
73
|
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
-
5. Create new Pull Request
|
74
|
+
5. Create new Pull Request
|
75
|
+
|
76
|
+
|
77
|
+
## Running the tests
|
78
|
+
|
79
|
+
To run the tests follow these steps:
|
80
|
+
|
81
|
+
1. Clone the repository
|
82
|
+
2. Run `bundle install` to install all development dependencies
|
83
|
+
3. Use `rake` to execute the test suite
|
84
|
+
a. If inkscape is not in your PATH, you may provide the optional
|
85
|
+
`INKSCAPE_PATH` environment variable, e.g.
|
86
|
+
`INKSCAPE_PATH=/path/to/inkscape rake`
|
data/Rakefile
CHANGED
@@ -1,2 +1,14 @@
|
|
1
1
|
require 'bundler'
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
7
|
+
t.cucumber_opts = '--color --tags ~@wip --strict'
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rake/clean'
|
11
|
+
|
12
|
+
task test: ['cucumber']
|
13
|
+
|
14
|
+
task default: :test
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: Create fallbacks for SVG images
|
2
|
+
|
3
|
+
Scenario: No changes if svg-fallback is not activated
|
4
|
+
Given a fixture app "image-app"
|
5
|
+
And a file named "config.rb" with:
|
6
|
+
"""
|
7
|
+
"""
|
8
|
+
And a successfully built app at "image-app"
|
9
|
+
Then the file "build/images/sample.svg" should exist
|
10
|
+
And the file "build/images/sample.png" should not exist
|
11
|
+
And the file "build/images/sample.jpg" should not exist
|
12
|
+
And the file "build/images/sample.svgz" should not exist
|
13
|
+
|
14
|
+
And the file "build/images/sample2.svgz" should exist
|
15
|
+
And the file "build/images/sample2.png" should not exist
|
16
|
+
And the file "build/images/sample2.jpg" should not exist
|
17
|
+
And the file "build/images/sample2.svg" should not exist
|
18
|
+
|
19
|
+
|
20
|
+
Scenario: Creates svgz, jpg, and png if svg-fallback is activated
|
21
|
+
Given a fixture app "image-app"
|
22
|
+
And a file named "config.rb" with:
|
23
|
+
"""
|
24
|
+
activate :svg_fallback, inkscape_bin: ENV['INKSCAPE_BIN'] || 'inkscape'
|
25
|
+
"""
|
26
|
+
And a successfully built app at "image-app"
|
27
|
+
|
28
|
+
Then the file "build/images/sample.svg" should exist
|
29
|
+
And the file "build/images/sample.png" should exist
|
30
|
+
And the file "build/images/sample.jpg" should exist
|
31
|
+
And the file "build/images/sample.svgz" should exist
|
32
|
+
|
33
|
+
And the file "build/images/sample2.svgz" should exist
|
34
|
+
And the file "build/images/sample2.png" should exist
|
35
|
+
And the file "build/images/sample2.jpg" should exist
|
36
|
+
And the file "build/images/sample2.svg" should exist
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
3
|
+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
|
5
|
+
<svg xmlns="http://www.w3.org/2000/svg"
|
6
|
+
width="467" height="462">
|
7
|
+
<rect x="80" y="60" width="250" height="250" rx="20"
|
8
|
+
style="fill:#ff0000; stroke:#000000;stroke-width:2px;" />
|
9
|
+
|
10
|
+
<rect x="140" y="120" width="250" height="250" rx="40"
|
11
|
+
style="fill:#0000ff; stroke:#000000; stroke-width:2px;
|
12
|
+
fill-opacity:0.7;" />
|
13
|
+
|
14
|
+
<rect x="140" y="120" width="250" height="250" rx="40"
|
15
|
+
style="fill:#00ff00; stroke:#0000cc; stroke-width:5px;
|
16
|
+
fill-opacity:1.0;" />
|
17
|
+
</svg>
|
Binary file
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class Middleman::SVGFallback < Middleman::Extension
|
2
|
+
option :inkscape_bin, 'inkscape', 'Path to Inkscape binary, e.g. "/Applications/Inkscape.app/Contents/Resources/bin/inkscape" on a Mac, defaults to "inkscape"'
|
3
|
+
option :inkscape_options, '', 'Command line arguments, that shall be passed on to inkscape, e.g. "--export-dpi=100 --export-background-opacity=0", defaults to ""'
|
4
|
+
|
5
|
+
option :convert_bin, 'convert', 'Path to convert binary, e.g. "/usr/local/bin/convert" on a Mac, defaults to "convert"'
|
6
|
+
option :convert_options, '', 'Command line arguments, that shall be passed on to convert", defaults to ""'
|
7
|
+
|
8
|
+
def after_build(builder)
|
9
|
+
dir = File.join(app.config[:build_dir], app.config[:images_dir])
|
10
|
+
|
11
|
+
run_args = { capture: true, verbose: app.config.cli_options['verbose'] }
|
12
|
+
|
13
|
+
Dir[File.join(dir, '**', '*.svg*')].each do |file|
|
14
|
+
# make sure we have both an svg and an svgz version
|
15
|
+
unprefixed = file.sub(/\.svgz?$/, '')
|
16
|
+
basename = File.expand_path(unprefixed)
|
17
|
+
|
18
|
+
unless File.exists? "#{basename}.svg"
|
19
|
+
builder.thor.run("gunzip --to-stdout #{basename}.svgz > #{basename}.svg", run_args)
|
20
|
+
builder.thor.say_status :svg, "#{unprefixed}.svg"
|
21
|
+
end
|
22
|
+
|
23
|
+
unless File.exists? "#{basename}.svgz"
|
24
|
+
builder.thor.run("gzip --to-stdout #{basename}.svg > #{basename}.svgz", run_args)
|
25
|
+
builder.thor.say_status :svgz, "#{unprefixed}.svgz"
|
26
|
+
end
|
27
|
+
|
28
|
+
# generate fallbacks
|
29
|
+
builder.thor.run("#{options.inkscape_bin} --export-filename=#{basename}.png #{options.inkscape_options} #{basename}.svg", run_args)
|
30
|
+
builder.thor.say_status :svg_fallback, "#{unprefixed}.png"
|
31
|
+
|
32
|
+
builder.thor.run("#{options.convert_bin} #{options.convert_options} #{basename}.png #{basename}.jpg", run_args)
|
33
|
+
builder.thor.say_status :svg_fallback, "#{unprefixed}.jpg"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require 'middleman-core'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
::Middleman::SVGFallback
|
8
|
-
end
|
3
|
+
Middleman::Extensions.register(:svg_fallback) do
|
4
|
+
require 'middleman/svg_fallback'
|
5
|
+
Middleman::SVGFallback
|
6
|
+
end
|
@@ -1,21 +1,26 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "middleman-svg-fallback/version"
|
4
2
|
|
5
3
|
Gem::Specification.new do |s|
|
6
4
|
s.name = "middleman-svg-fallback"
|
7
|
-
s.version =
|
5
|
+
s.version = "0.2.0"
|
8
6
|
s.platform = Gem::Platform::RUBY
|
9
7
|
s.authors = ["Jan Schulz-Hofen"]
|
10
8
|
s.email = ["jan@launchco.com"]
|
11
|
-
s.homepage = "https://github.com/
|
9
|
+
s.homepage = "https://github.com/planio-gmbh/middleman-svg-fallback"
|
12
10
|
s.summary = %q{Generate nice JPEG and PNG files from any SVG files.}
|
13
11
|
s.description = s.summary
|
12
|
+
s.license = "MIT"
|
14
13
|
|
15
14
|
s.files = `git ls-files`.split("\n")
|
16
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
16
|
s.require_paths = ["lib"]
|
18
17
|
|
19
|
-
s.add_runtime_dependency("middleman",
|
20
|
-
|
18
|
+
s.add_runtime_dependency("middleman-core", "~> 4.2")
|
19
|
+
|
20
|
+
s.add_development_dependency("aruba")
|
21
|
+
s.add_development_dependency("bundler")
|
22
|
+
s.add_development_dependency("capybara")
|
23
|
+
s.add_development_dependency("cucumber")
|
24
|
+
s.add_development_dependency("middleman-cli")
|
25
|
+
s.add_development_dependency("rake")
|
21
26
|
end
|
metadata
CHANGED
@@ -1,41 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-svg-fallback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Schulz-Hofen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: middleman
|
14
|
+
name: middleman-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aruba
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: cucumber
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: middleman-cli
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
27
97
|
- !ruby/object:Gem::Dependency
|
28
98
|
name: rake
|
29
99
|
requirement: !ruby/object:Gem::Requirement
|
30
100
|
requirements:
|
31
|
-
- -
|
101
|
+
- - ">="
|
32
102
|
- !ruby/object:Gem::Version
|
33
103
|
version: '0'
|
34
|
-
type: :
|
104
|
+
type: :development
|
35
105
|
prerelease: false
|
36
106
|
version_requirements: !ruby/object:Gem::Requirement
|
37
107
|
requirements:
|
38
|
-
- -
|
108
|
+
- - ">="
|
39
109
|
- !ruby/object:Gem::Version
|
40
110
|
version: '0'
|
41
111
|
description: Generate nice JPEG and PNG files from any SVG files.
|
@@ -45,36 +115,42 @@ executables: []
|
|
45
115
|
extensions: []
|
46
116
|
extra_rdoc_files: []
|
47
117
|
files:
|
48
|
-
- .gitignore
|
118
|
+
- ".gitignore"
|
119
|
+
- CHANGELOG.md
|
49
120
|
- Gemfile
|
121
|
+
- LICENSE
|
50
122
|
- README.md
|
51
123
|
- Rakefile
|
124
|
+
- features/support/env.rb
|
125
|
+
- features/svg-fallback.feature
|
126
|
+
- fixtures/image-app/source/images/sample.svg
|
127
|
+
- fixtures/image-app/source/images/sample2.svgz
|
52
128
|
- lib/middleman-svg-fallback.rb
|
53
|
-
- lib/middleman
|
54
|
-
- lib/middleman-svg-fallback/version.rb
|
55
|
-
- lib/middleman_extension.rb
|
129
|
+
- lib/middleman/svg_fallback.rb
|
56
130
|
- middleman-svg-fallback.gemspec
|
57
|
-
homepage: https://github.com/
|
58
|
-
licenses:
|
131
|
+
homepage: https://github.com/planio-gmbh/middleman-svg-fallback
|
132
|
+
licenses:
|
133
|
+
- MIT
|
59
134
|
metadata: {}
|
60
|
-
post_install_message:
|
135
|
+
post_install_message:
|
61
136
|
rdoc_options: []
|
62
137
|
require_paths:
|
63
138
|
- lib
|
64
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
140
|
requirements:
|
66
|
-
- -
|
141
|
+
- - ">="
|
67
142
|
- !ruby/object:Gem::Version
|
68
143
|
version: '0'
|
69
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
145
|
requirements:
|
71
|
-
- -
|
146
|
+
- - ">="
|
72
147
|
- !ruby/object:Gem::Version
|
73
148
|
version: '0'
|
74
149
|
requirements: []
|
75
|
-
|
76
|
-
|
77
|
-
signing_key:
|
150
|
+
rubygems_version: 3.0.3
|
151
|
+
signing_key:
|
78
152
|
specification_version: 4
|
79
153
|
summary: Generate nice JPEG and PNG files from any SVG files.
|
80
|
-
test_files:
|
154
|
+
test_files:
|
155
|
+
- features/support/env.rb
|
156
|
+
- features/svg-fallback.feature
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'rake'
|
2
|
-
module Middleman
|
3
|
-
module SVGFallback
|
4
|
-
class << self
|
5
|
-
def registered(app, options={})
|
6
|
-
|
7
|
-
options[:inkscape_bin] ||= 'inkscape'
|
8
|
-
|
9
|
-
app.after_configuration do
|
10
|
-
|
11
|
-
dir = File.join(build_dir, images_dir)
|
12
|
-
prefix = build_dir + File::SEPARATOR
|
13
|
-
|
14
|
-
after_build do |builder|
|
15
|
-
files = FileList["#{dir}/**/*.svg*"]
|
16
|
-
|
17
|
-
files.each do |file|
|
18
|
-
# make sure we have both an svg and an svgz version
|
19
|
-
basename = File.expand_path(file.sub(/\.svgz?$/,''))
|
20
|
-
|
21
|
-
unless File.exists? "#{basename}.svg"
|
22
|
-
`gunzip --to-stdout --suffix .svgz #{basename}.svgz > #{basename}.svg`
|
23
|
-
builder.say_status :svg, "#{basename}.svg"
|
24
|
-
end
|
25
|
-
unless File.exists? "#{basename}.svgz"
|
26
|
-
`gzip --to-stdout #{basename}.svg > #{basename}.svgz`
|
27
|
-
builder.say_status :svgz, "#{basename}.svgz"
|
28
|
-
end
|
29
|
-
|
30
|
-
# generate fallbacks
|
31
|
-
%w(jpg png).each do |ext|
|
32
|
-
`#{options[:inkscape_bin]} --export-png=#{basename}.#{ext} #{options[:inkscape_options]} --without-gui #{basename}.svg > /dev/null 2>&1`
|
33
|
-
builder.say_status :svg_fallback, "#{basename}.#{ext}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
alias :included :registered
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/lib/middleman_extension.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "middleman-svg-fallback"
|