imgkit 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +26 -0
- data/lib/imgkit/imgkit.rb +1 -1
- data/lib/imgkit/version.rb +1 -1
- data/spec/imgkit_spec.rb +11 -3
- metadata +3 -3
data/README.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
# Patch Intention
|
2
|
+
|
3
|
+
To overcome the lack of support for --user-style-sheet option by wkhtmltoimage 0.10.0 rc2 as reported here http://code.google.com/p/wkhtmltopdf/issues/detail?id=387
|
4
|
+
|
5
|
+
require 'imgkit'
|
6
|
+
require 'restclient'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
url = 'http://domain/path/to/stylesheet.css'
|
10
|
+
css = StringIO.new( RestClient.get(url) )
|
11
|
+
|
12
|
+
kit = IMGKit.new(<<EOD)
|
13
|
+
<!DOCTYPE HTML>
|
14
|
+
<html lang="en">
|
15
|
+
<head>
|
16
|
+
<meta charset="UTF-8">
|
17
|
+
<title>coolest converter</title>
|
18
|
+
</head>
|
19
|
+
<body>
|
20
|
+
<div class="cool">image kit</div>
|
21
|
+
</body>
|
22
|
+
</html>
|
23
|
+
EOD
|
24
|
+
|
25
|
+
kit.stylesheets << css
|
26
|
+
|
1
27
|
# IMGKit
|
2
28
|
|
3
29
|
Create JPGs using plain old HTML+CSS. Uses [wkhtmltoimage](http://github.com/antialize/wkhtmltopdf) on the backend which renders HTML using Webkit.
|
data/lib/imgkit/imgkit.rb
CHANGED
data/lib/imgkit/version.rb
CHANGED
data/spec/imgkit_spec.rb
CHANGED
@@ -32,7 +32,7 @@ describe IMGKit do
|
|
32
32
|
end
|
33
33
|
=end
|
34
34
|
|
35
|
-
it "should not have any
|
35
|
+
it "should not have any stylesheet by default" do
|
36
36
|
imgkit = IMGKit.new('<h1>Oh Hai</h1>')
|
37
37
|
imgkit.stylesheets.should be_empty
|
38
38
|
end
|
@@ -124,7 +124,7 @@ describe IMGKit do
|
|
124
124
|
img = imgkit.to_img
|
125
125
|
filetype_of(img).should include('JPEG')
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
it "should have the stylesheet added to the head if it has one" do
|
129
129
|
imgkit = IMGKit.new("<html><head></head><body>Hai!</body></html>")
|
130
130
|
css = File.join(SPEC_ROOT,'fixtures','example.css')
|
@@ -132,7 +132,15 @@ describe IMGKit do
|
|
132
132
|
imgkit.to_img
|
133
133
|
imgkit.source.to_s.should include("<style>#{File.read(css)}</style>")
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
|
+
it "should accept stylesheet as an object which responds to #read" do
|
137
|
+
imgkit = IMGKit.new("<html><head></head><body>Hai!</body></html>")
|
138
|
+
css = StringIO.new( File.read(File.join(SPEC_ROOT,'fixtures','example.css')) )
|
139
|
+
imgkit.stylesheets << css
|
140
|
+
imgkit.to_img
|
141
|
+
imgkit.source.to_s.should include("<style>#{css.string}</style>")
|
142
|
+
end
|
143
|
+
|
136
144
|
it "should prepend style tags if the HTML doesn't have a head tag" do
|
137
145
|
imgkit = IMGKit.new("<html><body>Hai!</body></html>")
|
138
146
|
css = File.join(SPEC_ROOT,'fixtures','example.css')
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: imgkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.3.
|
5
|
+
version: 1.3.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- csquared
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-24 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Uses wkhtmltoimage to create Images using HTML
|
@@ -66,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
hash:
|
69
|
+
hash: 3909095106456771647
|
70
70
|
segments:
|
71
71
|
- 0
|
72
72
|
version: "0"
|