htmlcsstoimage-api 0.1.0 → 0.1.1
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/.github/workflows/ruby.yml +23 -0
- data/.gitignore +0 -1
- data/.yard-gh-pages.yml +3 -0
- data/Gemfile.lock +3 -3
- data/README.md +34 -2
- data/bin/console +2 -5
- data/cassettes/HTMLCSSToImage/_create_template/creates_a_new_template.yml +62 -0
- data/docs/HTMLCSSToImage.html +1065 -0
- data/docs/HTMLCSSToImage/ApiResponse.html +124 -0
- data/docs/_config.yml +1 -0
- data/docs/_index.html +122 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +496 -0
- data/docs/file.README.html +155 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +155 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +99 -0
- data/docs/top-level-namespace.html +110 -0
- data/htmlcsstoimage.gemspec +4 -4
- data/lib/htmlcsstoimage.rb +43 -5
- data/lib/htmlcsstoimage/version.rb +1 -1
- metadata +26 -5
data/lib/htmlcsstoimage.rb
CHANGED
@@ -28,7 +28,7 @@ class HTMLCSSToImage
|
|
28
28
|
# If credentials are not provided, will try to use environment variables.
|
29
29
|
# `HCTI_USER_ID` and `HCTI_API_KEY`.
|
30
30
|
#
|
31
|
-
# @see
|
31
|
+
# @see https://htmlcsstoimage.com/dashboard
|
32
32
|
#
|
33
33
|
# @param user_id [String] the user_id for the account.
|
34
34
|
# @param api_key [String] the api_key for the account.
|
@@ -39,7 +39,7 @@ class HTMLCSSToImage
|
|
39
39
|
|
40
40
|
# Converts HTML/CSS to an image with the API
|
41
41
|
#
|
42
|
-
# @see
|
42
|
+
# @see https://docs.htmlcsstoimage.com/getting-started/using-the-api
|
43
43
|
#
|
44
44
|
# @param html [String] This is the HTML you want to render. You can send an HTML snippet (`<div>Your content</div>`) or an entire webpage.
|
45
45
|
#
|
@@ -62,7 +62,7 @@ class HTMLCSSToImage
|
|
62
62
|
|
63
63
|
# Deletes an image
|
64
64
|
#
|
65
|
-
# @see
|
65
|
+
# @see https://docs.htmlcsstoimage.com/getting-started/using-the-api
|
66
66
|
#
|
67
67
|
# @param image_id [String] The ID for the image you would like to delete
|
68
68
|
def delete_image(image_id)
|
@@ -73,14 +73,13 @@ class HTMLCSSToImage
|
|
73
73
|
response
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
76
|
# Creates a signed URL for generating an image from a template
|
78
77
|
# This URL contains the template_values in it. It is signed with HMAC so that it cannot be changed
|
79
78
|
# by anyone without the API Key.
|
80
79
|
#
|
81
80
|
# Does not make any network requests.
|
82
81
|
#
|
83
|
-
# @see
|
82
|
+
# @see https://docs.htmlcsstoimage.com/getting-started/using-the-api
|
84
83
|
#
|
85
84
|
# @param template_id [String] The ID for the template
|
86
85
|
# @param template_values [Hash] A hash containing the values to replace in the template
|
@@ -101,6 +100,17 @@ class HTMLCSSToImage
|
|
101
100
|
ApiResponse.new(url: url)
|
102
101
|
end
|
103
102
|
|
103
|
+
# Generate a screenshot of a URL
|
104
|
+
#
|
105
|
+
# @see https://docs.htmlcsstoimage.com/getting-started/url-to-image/
|
106
|
+
#
|
107
|
+
# @param url [String] The fully qualified URL to a public webpage. Such as https://htmlcsstoimage.com.
|
108
|
+
# @option params [String] :selector A CSS selector for an element on the webpage. We'll crop the image to this specific element. For example: `section#complete-toolkit.container-lg`
|
109
|
+
# @option params [Integer] :ms_delay The number of milliseconds the API should delay before generating the image. This is useful when waiting for JavaScript. We recommend starting with `500`. Large values slow down the initial render time.
|
110
|
+
# @option params [Double] :device_scale This adjusts the pixel ratio for the screenshot. Minimum: `1`, Maximum: `3`.
|
111
|
+
# @option params [Boolean] :render_when_ready Set to true to control when the image is generated. Call `ScreenshotReady()` from JavaScript to generate the image. [Learn more](https://docs.htmlcsstoimage.com/guides/render-when-ready/).
|
112
|
+
# @option params [Integer] :viewport_width Set the width of Chrome's viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.
|
113
|
+
# @option params [Integer] :viewport_height Set the height of Chrome's viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.
|
104
114
|
def url_to_image(url, params = {})
|
105
115
|
body = { url: url }.merge(params).to_json
|
106
116
|
options = { basic_auth: @auth, body: body, query: { includeId: true } }
|
@@ -108,8 +118,36 @@ class HTMLCSSToImage
|
|
108
118
|
self.class.post("/v1/image", options)
|
109
119
|
end
|
110
120
|
|
121
|
+
# Retrieves all available templates
|
122
|
+
#
|
123
|
+
# @see https://docs.htmlcsstoimage.com/getting-started/templates/
|
111
124
|
def templates(params = {})
|
112
125
|
options = params.merge({ basic_auth: @auth })
|
113
126
|
self.class.get("/v1/template", options)
|
114
127
|
end
|
128
|
+
|
129
|
+
# Creates an image template
|
130
|
+
#
|
131
|
+
# @see https://docs.htmlcsstoimage.com/getting-started/templates/
|
132
|
+
#
|
133
|
+
# @param html [String] This is the HTML you want to render. You can send an HTML snippet (`<div>Your content</div>`) or an entire webpage.
|
134
|
+
#
|
135
|
+
# @option params [String] :name A short name to identify your template max length 64
|
136
|
+
# @option params [String] :description Description to elaborate on the use of your template max length 1024
|
137
|
+
# @option params [String] :css The CSS for your image.
|
138
|
+
# @option params [String] :google_fonts [Google fonts](https://docs.htmlcsstoimage.com/guides/using-google-fonts/) to be loaded. Example: `Roboto`. Multiple fonts can be loaded like this: `Roboto|Open Sans`
|
139
|
+
# @option params [String] :selector A CSS selector for an element on the webpage. We'll crop the image to this specific element. For example: `section#complete-toolkit.container-lg`
|
140
|
+
# @option params [Integer] :ms_delay The number of milliseconds the API should delay before generating the image. This is useful when waiting for JavaScript. We recommend starting with `500`. Large values slow down the initial render time.
|
141
|
+
# @option params [Double] :device_scale This adjusts the pixel ratio for the screenshot. Minimum: `1`, Maximum: `3`.
|
142
|
+
# @option params [Boolean] :render_when_ready Set to true to control when the image is generated. Call `ScreenshotReady()` from JavaScript to generate the image. [Learn more](https://docs.htmlcsstoimage.com/guides/render-when-ready/).
|
143
|
+
# @option params [Integer] :viewport_width Set the width of Chrome's viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.
|
144
|
+
# @option params [Integer] :viewport_height Set the height of Chrome's viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.
|
145
|
+
#
|
146
|
+
# @return [HTMLCSSToImage::ApiResponse] image URL available at `.url`.
|
147
|
+
def create_template(html, params = {})
|
148
|
+
body = { html: html }.merge(params).to_json
|
149
|
+
options = { basic_auth: @auth, body: body }
|
150
|
+
|
151
|
+
self.class.post("/v1/template", options)
|
152
|
+
end
|
115
153
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htmlcsstoimage-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Coutermarsh
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '13.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '13.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,16 +123,19 @@ dependencies:
|
|
123
123
|
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
-
description:
|
126
|
+
description: 'Ruby client for the HTML/CSS to Image API. Generate a png, jpg or webp
|
127
|
+
images with Ruby. Renders exactly like Google Chrome. '
|
127
128
|
email:
|
128
129
|
- support@htmlcsstoimage.com
|
129
130
|
executables: []
|
130
131
|
extensions: []
|
131
132
|
extra_rdoc_files: []
|
132
133
|
files:
|
134
|
+
- ".github/workflows/ruby.yml"
|
133
135
|
- ".gitignore"
|
134
136
|
- ".rspec"
|
135
137
|
- ".ruby-version"
|
138
|
+
- ".yard-gh-pages.yml"
|
136
139
|
- CODE_OF_CONDUCT.md
|
137
140
|
- Gemfile
|
138
141
|
- Gemfile.lock
|
@@ -143,10 +146,28 @@ files:
|
|
143
146
|
- bin/setup
|
144
147
|
- cassettes/HTMLCSSToImage/_create_image/accepts_additional_params.yml
|
145
148
|
- cassettes/HTMLCSSToImage/_create_image/creates_an_image.yml
|
149
|
+
- cassettes/HTMLCSSToImage/_create_template/creates_a_new_template.yml
|
146
150
|
- cassettes/HTMLCSSToImage/_delete_image/deletes_an_image.yml
|
147
151
|
- cassettes/HTMLCSSToImage/_templates/retrieves_templates.yml
|
148
152
|
- cassettes/HTMLCSSToImage/_url_to_image/accepts_additional_params.yml
|
149
153
|
- cassettes/HTMLCSSToImage/_url_to_image/creates_an_image_from_a_url.yml
|
154
|
+
- docs/HTMLCSSToImage.html
|
155
|
+
- docs/HTMLCSSToImage/ApiResponse.html
|
156
|
+
- docs/_config.yml
|
157
|
+
- docs/_index.html
|
158
|
+
- docs/class_list.html
|
159
|
+
- docs/css/common.css
|
160
|
+
- docs/css/full_list.css
|
161
|
+
- docs/css/style.css
|
162
|
+
- docs/file.README.html
|
163
|
+
- docs/file_list.html
|
164
|
+
- docs/frames.html
|
165
|
+
- docs/index.html
|
166
|
+
- docs/js/app.js
|
167
|
+
- docs/js/full_list.js
|
168
|
+
- docs/js/jquery.js
|
169
|
+
- docs/method_list.html
|
170
|
+
- docs/top-level-namespace.html
|
150
171
|
- htmlcsstoimage.gemspec
|
151
172
|
- lib/htmlcsstoimage.rb
|
152
173
|
- lib/htmlcsstoimage/version.rb
|
@@ -172,5 +193,5 @@ requirements: []
|
|
172
193
|
rubygems_version: 3.0.3
|
173
194
|
signing_key:
|
174
195
|
specification_version: 4
|
175
|
-
summary: Ruby
|
196
|
+
summary: Ruby client for the HTML/CSS to Image API.
|
176
197
|
test_files: []
|