htmlcsstoimage-api 0.1.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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +68 -0
- data/LICENSE.txt +21 -0
- data/README.md +83 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cassettes/HTMLCSSToImage/_create_image/accepts_additional_params.yml +66 -0
- data/cassettes/HTMLCSSToImage/_create_image/creates_an_image.yml +64 -0
- data/cassettes/HTMLCSSToImage/_delete_image/deletes_an_image.yml +60 -0
- data/cassettes/HTMLCSSToImage/_templates/retrieves_templates.yml +110 -0
- data/cassettes/HTMLCSSToImage/_url_to_image/accepts_additional_params.yml +64 -0
- data/cassettes/HTMLCSSToImage/_url_to_image/creates_an_image_from_a_url.yml +64 -0
- data/htmlcsstoimage.gemspec +34 -0
- data/lib/htmlcsstoimage.rb +115 -0
- data/lib/htmlcsstoimage/version.rb +3 -0
- metadata +176 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e31f5dd0bf4da3319b38ffc93f91859b65345b424b08bf750aed94a99f35fac3
|
|
4
|
+
data.tar.gz: 18fb9f5a694c1f35d1b4d502c94f0ae61df5d199fffdab3defb11c216bd46156
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 66237da8da333169cac3bdb38c1dbd722fe66012a9d280f318a0c1c2cd4835f1905fb6cc2fa5cfe86974c38bfb9699bf0119e2c006144eb70c0c79f462f6e57c
|
|
7
|
+
data.tar.gz: 21b6b6d5006672aa27f55425eb6f91cee86c3ecaafa303d5a35e19ad8d3cd01466ad857c1bdb68af683d464bb00fcb3593185f56d9d31360b58c0297bbeb3df6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.6.5
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at coutermarsh.mike@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
htmlcsstoimage-api (0.1.0)
|
|
5
|
+
httparty (> 0.10)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
addressable (2.7.0)
|
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
12
|
+
byebug (11.1.3)
|
|
13
|
+
coderay (1.1.3)
|
|
14
|
+
crack (0.4.3)
|
|
15
|
+
safe_yaml (~> 1.0.0)
|
|
16
|
+
diff-lcs (1.4.4)
|
|
17
|
+
hashdiff (1.0.1)
|
|
18
|
+
httparty (0.18.1)
|
|
19
|
+
mime-types (~> 3.0)
|
|
20
|
+
multi_xml (>= 0.5.2)
|
|
21
|
+
method_source (1.0.0)
|
|
22
|
+
mime-types (3.3.1)
|
|
23
|
+
mime-types-data (~> 3.2015)
|
|
24
|
+
mime-types-data (3.2020.0512)
|
|
25
|
+
multi_xml (0.6.0)
|
|
26
|
+
pry (0.13.1)
|
|
27
|
+
coderay (~> 1.1)
|
|
28
|
+
method_source (~> 1.0)
|
|
29
|
+
pry-byebug (3.9.0)
|
|
30
|
+
byebug (~> 11.0)
|
|
31
|
+
pry (~> 0.13.0)
|
|
32
|
+
public_suffix (4.0.5)
|
|
33
|
+
rake (10.5.0)
|
|
34
|
+
rspec (3.9.0)
|
|
35
|
+
rspec-core (~> 3.9.0)
|
|
36
|
+
rspec-expectations (~> 3.9.0)
|
|
37
|
+
rspec-mocks (~> 3.9.0)
|
|
38
|
+
rspec-core (3.9.2)
|
|
39
|
+
rspec-support (~> 3.9.3)
|
|
40
|
+
rspec-expectations (3.9.2)
|
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
42
|
+
rspec-support (~> 3.9.0)
|
|
43
|
+
rspec-mocks (3.9.1)
|
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
+
rspec-support (~> 3.9.0)
|
|
46
|
+
rspec-support (3.9.3)
|
|
47
|
+
safe_yaml (1.0.5)
|
|
48
|
+
vcr (6.0.0)
|
|
49
|
+
webmock (3.8.3)
|
|
50
|
+
addressable (>= 2.3.6)
|
|
51
|
+
crack (>= 0.3.2)
|
|
52
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
|
53
|
+
|
|
54
|
+
PLATFORMS
|
|
55
|
+
ruby
|
|
56
|
+
|
|
57
|
+
DEPENDENCIES
|
|
58
|
+
bundler (> 2.0)
|
|
59
|
+
htmlcsstoimage-api!
|
|
60
|
+
pry
|
|
61
|
+
pry-byebug
|
|
62
|
+
rake (~> 10.0)
|
|
63
|
+
rspec (~> 3.0)
|
|
64
|
+
vcr
|
|
65
|
+
webmock
|
|
66
|
+
|
|
67
|
+
BUNDLED WITH
|
|
68
|
+
2.1.4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Code Happy, LLC
|
|
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
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# HTML/CSS to Image - Ruby
|
|
2
|
+
|
|
3
|
+
Ruby client for the [HTML/CSS to Image API](https://htmlcsstoimage.com).
|
|
4
|
+
|
|
5
|
+
Generate a png, jpg or webp images with Ruby. Renders exactly like Google Chrome.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'htmlcsstoimage-api'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install htmlcsstoimage-api
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Create a new instance of the API client.
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
# Retrieve your user id and api key from https://htmlcsstoimage.com/dashboard
|
|
29
|
+
client = HTMLCSSToImage.new(user_id: "user-id", api_key: "api-key")
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Alternatively, you can set `ENV["HCTI_USER_ID"]` and `ENV["HCTI_API_KEY"]`. These will be loaded automatically.
|
|
33
|
+
|
|
34
|
+
```ruby
|
|
35
|
+
client = HTMLCSSToImage.new
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Create an image
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
image = client.create_image("<div>Hello, world</div>",
|
|
42
|
+
css: "div { background-color: red; font-family: Roboto; }",
|
|
43
|
+
google_fonts: "Roboto")
|
|
44
|
+
|
|
45
|
+
image
|
|
46
|
+
=> #<HTMLCSSToImage::ApiResponse url="https://hcti.io/v1/image/254b444c-dd82-4cc1-94ef-aa4b3a6870a6", id="254b444c-dd82-4cc1-94ef-aa4b3a6870a6">
|
|
47
|
+
image.url
|
|
48
|
+
=> "https://hcti.io/v1/image/254b444c-dd82-4cc1-94ef-aa4b3a6870a6"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Delete an image
|
|
52
|
+
```Ruby
|
|
53
|
+
client.delete_image("254b444c-dd82-4cc1-94ef-aa4b3a6870a6")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### URL to image
|
|
57
|
+
```ruby
|
|
58
|
+
image = client.url_to_image("https://github.com", viewport_width: 800, viewport_height: 1200)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Available parameters
|
|
62
|
+
For detailed information on all the available parameters, visit the docs: https://docs.htmlcsstoimage.com/getting-started/using-the-api/
|
|
63
|
+
|
|
64
|
+
## Development
|
|
65
|
+
|
|
66
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
67
|
+
|
|
68
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
69
|
+
|
|
70
|
+
## Support
|
|
71
|
+
For help with the API, you can also contact `support@htmlcsstoimage.com`.
|
|
72
|
+
|
|
73
|
+
## Contributing
|
|
74
|
+
|
|
75
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/htmlcsstoimage/ruby-client/contributor-covenant.org) code of conduct.
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
80
|
+
|
|
81
|
+
## Code of Conduct
|
|
82
|
+
|
|
83
|
+
Everyone interacting in the project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/htmlcsstoimage/ruby-client/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "htmlcsstoimage"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://hcti.io/v1/image?includeId=true
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"html":"<div>test</div>","css":"body { background-color: orange }","ms_delay":500,"google_fonts":"Roboto"}'
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby
|
|
18
|
+
Authorization:
|
|
19
|
+
- Basic authentication-header
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Fri, 07 Aug 2020 16:26:02 GMT
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json; charset=utf-8
|
|
29
|
+
Transfer-Encoding:
|
|
30
|
+
- chunked
|
|
31
|
+
Connection:
|
|
32
|
+
- keep-alive
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- __cfduid=d2514bf66b55358e89144d7ce2e05ca431596817562; expires=Sun, 06-Sep-20
|
|
35
|
+
16:26:02 GMT; path=/; domain=.hcti.io; HttpOnly; SameSite=Lax
|
|
36
|
+
Cf-Ray:
|
|
37
|
+
- 5bf25b63d9e06d52-SJC
|
|
38
|
+
Access-Control-Allow-Origin:
|
|
39
|
+
- "*"
|
|
40
|
+
Age:
|
|
41
|
+
- '235'
|
|
42
|
+
Cache-Control:
|
|
43
|
+
- max-age=14400, 31536000
|
|
44
|
+
Vary:
|
|
45
|
+
- Accept-Encoding
|
|
46
|
+
Cf-Cache-Status:
|
|
47
|
+
- HIT
|
|
48
|
+
Cf-Request-Id:
|
|
49
|
+
- 046b57726600006d5284153200000001
|
|
50
|
+
Expect-Ct:
|
|
51
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
52
|
+
Request-Context:
|
|
53
|
+
- appId=cid-v1:ef200074-f922-49b8-a889-360bb27d5561
|
|
54
|
+
X-Is-Overage:
|
|
55
|
+
- 'False'
|
|
56
|
+
X-Renders-Allowed:
|
|
57
|
+
- '500000'
|
|
58
|
+
X-Renders-Used:
|
|
59
|
+
- '4539'
|
|
60
|
+
Server:
|
|
61
|
+
- cloudflare
|
|
62
|
+
body:
|
|
63
|
+
encoding: ASCII-8BIT
|
|
64
|
+
string: '{"url":"https://hcti.io/v1/image/254b444c-dd82-4cc1-94ef-aa4b3a6870a6","id":"254b444c-dd82-4cc1-94ef-aa4b3a6870a6"}'
|
|
65
|
+
recorded_at: Fri, 07 Aug 2020 16:26:02 GMT
|
|
66
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://hcti.io/v1/image?includeId=true
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"html":"<div>test</div>"}'
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby
|
|
18
|
+
Authorization:
|
|
19
|
+
- Basic authentication-header
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Fri, 07 Aug 2020 16:26:01 GMT
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json; charset=utf-8
|
|
29
|
+
Transfer-Encoding:
|
|
30
|
+
- chunked
|
|
31
|
+
Connection:
|
|
32
|
+
- keep-alive
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- __cfduid=d3a44d4dbf2273232e5acce7284a8582e1596817561; expires=Sun, 06-Sep-20
|
|
35
|
+
16:26:01 GMT; path=/; domain=.hcti.io; HttpOnly; SameSite=Lax
|
|
36
|
+
Cf-Ray:
|
|
37
|
+
- 5bf25b61183a93be-SJC
|
|
38
|
+
Access-Control-Allow-Origin:
|
|
39
|
+
- "*"
|
|
40
|
+
Cache-Control:
|
|
41
|
+
- max-age=public, 31536000
|
|
42
|
+
Vary:
|
|
43
|
+
- Accept-Encoding
|
|
44
|
+
Cf-Cache-Status:
|
|
45
|
+
- DYNAMIC
|
|
46
|
+
Cf-Request-Id:
|
|
47
|
+
- 046b5770aa000093be5f243200000001
|
|
48
|
+
Expect-Ct:
|
|
49
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
50
|
+
Request-Context:
|
|
51
|
+
- appId=cid-v1:ef200074-f922-49b8-a889-360bb27d5561
|
|
52
|
+
X-Is-Overage:
|
|
53
|
+
- 'False'
|
|
54
|
+
X-Renders-Allowed:
|
|
55
|
+
- '500000'
|
|
56
|
+
X-Renders-Used:
|
|
57
|
+
- '4539'
|
|
58
|
+
Server:
|
|
59
|
+
- cloudflare
|
|
60
|
+
body:
|
|
61
|
+
encoding: ASCII-8BIT
|
|
62
|
+
string: '{"url":"https://hcti.io/v1/image/b1021edd-0af3-4764-9a1c-6d9eae18985d","id":"b1021edd-0af3-4764-9a1c-6d9eae18985d"}'
|
|
63
|
+
recorded_at: Fri, 07 Aug 2020 16:26:02 GMT
|
|
64
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: delete
|
|
5
|
+
uri: https://hcti.io/v1/image/254b444c-dd82-4cc1-94ef-aa4b3a6870a6
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby
|
|
18
|
+
Authorization:
|
|
19
|
+
- Basic authentication-header
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 202
|
|
23
|
+
message: Accepted
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Fri, 07 Aug 2020 16:51:36 GMT
|
|
27
|
+
Content-Length:
|
|
28
|
+
- '0'
|
|
29
|
+
Connection:
|
|
30
|
+
- keep-alive
|
|
31
|
+
Set-Cookie:
|
|
32
|
+
- AWSALB=HZiSeVcPpOrp8Cnv2US5zfSSk4zfNJf/1l6T3PqVI3TgleMUP0b2nZb4TVAApvvUUVtxSVFXNdHGp+1mFZbuW/HdLu5+oJhsQGABcpZB1/81jltlZ915zAZsPiqQ;
|
|
33
|
+
Expires=Fri, 14 Aug 2020 16:51:36 GMT; Path=/
|
|
34
|
+
- AWSALBCORS=HZiSeVcPpOrp8Cnv2US5zfSSk4zfNJf/1l6T3PqVI3TgleMUP0b2nZb4TVAApvvUUVtxSVFXNdHGp+1mFZbuW/HdLu5+oJhsQGABcpZB1/81jltlZ915zAZsPiqQ;
|
|
35
|
+
Expires=Fri, 14 Aug 2020 16:51:36 GMT; Path=/; SameSite=None
|
|
36
|
+
- __cfduid=d2ba84d953b71c6632e925836ec9c13981596819096; expires=Sun, 06-Sep-20
|
|
37
|
+
16:51:36 GMT; path=/; domain=.hcti.io; HttpOnly; SameSite=Lax
|
|
38
|
+
- __cflb=0H28vWzHFPHZw4TS8VrB813a2Y9bcaFsXduaPonfK5N; SameSite=Lax; path=/;
|
|
39
|
+
expires=Sat, 08-Aug-20 15:51:36 GMT; HttpOnly
|
|
40
|
+
Cf-Ray:
|
|
41
|
+
- 5bf280d648daed17-SJC
|
|
42
|
+
Access-Control-Allow-Origin:
|
|
43
|
+
- "*"
|
|
44
|
+
Cf-Cache-Status:
|
|
45
|
+
- DYNAMIC
|
|
46
|
+
Cf-Request-Id:
|
|
47
|
+
- 046b6ed9eb0000ed17e9360200000001
|
|
48
|
+
Expect-Ct:
|
|
49
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
50
|
+
Request-Context:
|
|
51
|
+
- appId=cid-v1:ef200074-f922-49b8-a889-360bb27d5561
|
|
52
|
+
Vary:
|
|
53
|
+
- Accept-Encoding
|
|
54
|
+
Server:
|
|
55
|
+
- cloudflare
|
|
56
|
+
body:
|
|
57
|
+
encoding: UTF-8
|
|
58
|
+
string: ''
|
|
59
|
+
recorded_at: Fri, 07 Aug 2020 16:51:36 GMT
|
|
60
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: https://hcti.io/v1/template
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby
|
|
18
|
+
Authorization:
|
|
19
|
+
- Basic authentication-header
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Thu, 06 Aug 2020 21:25:39 GMT
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json; charset=utf-8
|
|
29
|
+
Transfer-Encoding:
|
|
30
|
+
- chunked
|
|
31
|
+
Connection:
|
|
32
|
+
- keep-alive
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- AWSALB=lVKuyuNFEjqfNaDkDxgqrzytNUb+WNwbEoJYuWl/uaVFNut/FpixcciblHfX4vzn/LdoTZU+RnIgjBB90kY7SUhcqudTAr7X7/ubSM65lP7WykpDrr5CphMc0mkC;
|
|
35
|
+
Expires=Thu, 13 Aug 2020 21:25:38 GMT; Path=/
|
|
36
|
+
- AWSALBCORS=lVKuyuNFEjqfNaDkDxgqrzytNUb+WNwbEoJYuWl/uaVFNut/FpixcciblHfX4vzn/LdoTZU+RnIgjBB90kY7SUhcqudTAr7X7/ubSM65lP7WykpDrr5CphMc0mkC;
|
|
37
|
+
Expires=Thu, 13 Aug 2020 21:25:38 GMT; Path=/; SameSite=None
|
|
38
|
+
- __cfduid=d24954ff54b38cb9910836fadcf6542f01596749138; expires=Sat, 05-Sep-20
|
|
39
|
+
21:25:38 GMT; path=/; domain=.hcti.io; HttpOnly; SameSite=Lax
|
|
40
|
+
- __cflb=02DiuGMQFf4rnadqPFSDhdmYgHrhp7JS62YACr3aZ9wsz; SameSite=Lax; path=/;
|
|
41
|
+
expires=Fri, 07-Aug-20 20:25:39 GMT; HttpOnly
|
|
42
|
+
Cf-Ray:
|
|
43
|
+
- 5bebd4e51d7aeb89-LAX
|
|
44
|
+
Access-Control-Allow-Origin:
|
|
45
|
+
- "*"
|
|
46
|
+
Vary:
|
|
47
|
+
- Accept-Encoding
|
|
48
|
+
Cf-Cache-Status:
|
|
49
|
+
- DYNAMIC
|
|
50
|
+
Cf-Request-Id:
|
|
51
|
+
- 046743632d0000eb8931ba9200000001
|
|
52
|
+
Expect-Ct:
|
|
53
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
54
|
+
Request-Context:
|
|
55
|
+
- appId=cid-v1:ef200074-f922-49b8-a889-360bb27d5561
|
|
56
|
+
Server:
|
|
57
|
+
- cloudflare
|
|
58
|
+
body:
|
|
59
|
+
encoding: ASCII-8BIT
|
|
60
|
+
string: '{"data":[{"css":".code-example {\n background-color: white;\n background-image:
|
|
61
|
+
linear-gradient(0deg,rgba(225,228,232,0),rgba(225,228,232,0) 7px,#e1e4e8 ,rgba(225,228,232,0)
|
|
62
|
+
8px),linear-gradient(90deg,rgba(225,228,232,0),rgba(225,228,232,0) 7px,#e1e4e8
|
|
63
|
+
,rgba(225,228,232,0) 8px);\n background-position: center center;\n background-size:
|
|
64
|
+
45px 45px;\n border: 1px solid #eeebee;\n border-radius: 4px;\n box-sizing:
|
|
65
|
+
border-box;\n height: 300px;\n margin: 30px;\n padding: 30px;\n width:
|
|
66
|
+
600px;\n display: flex;\n align-items: center; justify-content: center;
|
|
67
|
+
flex-direction: column;\n -webkit-box-shadow: 5px 5px 15px -1px rgba(0,0,0,0.36);
|
|
68
|
+
\nbox-shadow: 5px 5px 15px -1px rgba(0,0,0,0.36);\n}\n.hcti-container {\n box-sizing:
|
|
69
|
+
border-box;\n padding: 5px;\n display: flex;\n align-items:center;\n}\nh1
|
|
70
|
+
{\n text-align: center;\n font-size: 40px; \n margin-top: auto;\n}\n.logo-text
|
|
71
|
+
{\n margin-left: 6px;\n font-size: 16px;\n}\n.w-border {\n border: 1px
|
|
72
|
+
dashed #2869e6;\n padding: 5px;\n justify-content: center;\n text-align:
|
|
73
|
+
center;\n vertical-align: middle;\n margin-top: auto;\n margin-bottom:
|
|
74
|
+
10px;\n}\nimg {\n border: 1px solid #eeebee;\n box-sizing: border-box;\n height:
|
|
75
|
+
auto;\n margin: 0;\n max-width: 100%;\n padding: 0;\n vertical-align:
|
|
76
|
+
bottom;\n}\n:root {\n --bg-angle: 10deg; \n}\nbody {\nfont-family: -apple-system,
|
|
77
|
+
BlinkMacSystemFont, \"helvetica neue\", helvetica, Rubik, noto, \"segoe ui\",
|
|
78
|
+
arial, sans-serif;\n background: linear-gradient(var(--bg-angle),#f79533,#f37055,#ef4e7b,#a166ab,#5073b8,#1098ad,#07b39b,#6fba82);\n}","created_at":"2020-08-02T20:01:56.762+00:00","description":null,"device_scale":null,"google_fonts":"Rubik","html":"<div
|
|
79
|
+
class=\"code-example\">\n <h1>{{title}}</h1>\n <div class=\"w-border\">\n <div
|
|
80
|
+
class=\"hcti-container\"><img width=\"45\" src=\"https://docs.htmlcsstoimage.com/assets/images/HCTI.png\"><span
|
|
81
|
+
class=\"logo-text\">HTML/CSS to Image API</span>\n </div>\n </div>\n</div>\n<script>\n //
|
|
82
|
+
Randomly change background color direction.\n var random = Math.floor(Math.random()
|
|
83
|
+
* Math.floor(360))\n var body = document.body;\n body.style.setProperty(''--bg-angle'',
|
|
84
|
+
random + ''deg'');\n</script>","id":"t-9f6526a7-aa2c-4fbb-8723-06eff1c60e89","max_wait_ms":null,"ms_delay":null,"name":null,"render_when_ready":null,"updated_at":"2020-08-02T20:01:56.763+00:00","version":1596398516763,"viewport_height":null,"viewport_width":null},{"css":".code-example
|
|
85
|
+
{\n background-color: white;\n background-image: linear-gradient(0deg,rgba(225,228,232,0),rgba(225,228,232,0)
|
|
86
|
+
7px,#e1e4e8 ,rgba(225,228,232,0) 8px),linear-gradient(90deg,rgba(225,228,232,0),rgba(225,228,232,0)
|
|
87
|
+
7px,#e1e4e8 ,rgba(225,228,232,0) 8px);\n background-position: center center;\n background-size:
|
|
88
|
+
45px 45px;\n border: 1px solid #eeebee;\n border-radius: 4px;\n box-sizing:
|
|
89
|
+
border-box;\n height: 300px;\n margin: 30px;\n padding: 30px;\n width:
|
|
90
|
+
600px;\n display: flex;\n align-items: center; justify-content: center;
|
|
91
|
+
flex-direction: column;\n -webkit-box-shadow: 5px 5px 15px -1px rgba(0,0,0,0.36);
|
|
92
|
+
\nbox-shadow: 5px 5px 15px -1px rgba(0,0,0,0.36);\n}\n.hcti-container {\n box-sizing:
|
|
93
|
+
border-box;\n padding: 5px;\n display: flex;\n align-items:center;\n}\nh1
|
|
94
|
+
{\n text-align: center;\n font-size: 40px; \n margin-top: auto;\n}\n.logo-text
|
|
95
|
+
{\n margin-left: 6px;\n font-size: 16px;\n}\n.w-border {\n border: 1px
|
|
96
|
+
dashed #2869e6;\n padding: 5px;\n justify-content: center;\n text-align:
|
|
97
|
+
center;\n vertical-align: middle;\n margin-top: auto;\n margin-bottom:
|
|
98
|
+
10px;\n}\nimg {\n border: 1px solid #eeebee;\n box-sizing: border-box;\n height:
|
|
99
|
+
auto;\n margin: 0;\n max-width: 100%;\n padding: 0;\n vertical-align:
|
|
100
|
+
bottom;\n}\n:root {\n --bg-angle: 10deg; \n}\nbody {\nfont-family: -apple-system,
|
|
101
|
+
BlinkMacSystemFont, \"helvetica neue\", helvetica, Rubik, noto, \"segoe ui\",
|
|
102
|
+
arial, sans-serif;\n background: linear-gradient(var(--bg-angle),#f79533,#f37055,#ef4e7b,#a166ab,#5073b8,#1098ad,#07b39b,#6fba82);\n}","created_at":"2020-08-02T20:02:01.544+00:00","description":null,"device_scale":null,"google_fonts":"Rubik","html":"<div
|
|
103
|
+
class=\"code-example\">\n <h1>{{title}}</h1>\n <div class=\"w-border\">\n <div
|
|
104
|
+
class=\"hcti-container\"><img width=\"45\" src=\"https://docs.htmlcsstoimage.com/assets/images/HCTI.png\"><span
|
|
105
|
+
class=\"logo-text\">HTML/CSS to Image API</span>\n </div>\n </div>\n</div>\n<script>\n //
|
|
106
|
+
Randomly change background color direction.\n var random = Math.floor(Math.random()
|
|
107
|
+
* Math.floor(360))\n var body = document.body;\n body.style.setProperty(''--bg-angle'',
|
|
108
|
+
random + ''deg'');\n</script>","id":"t-fc18eff2-6e43-4c10-963a-0be753db4065","max_wait_ms":null,"ms_delay":null,"name":null,"render_when_ready":null,"updated_at":"2020-08-02T20:02:01.544+00:00","version":1596398521544,"viewport_height":null,"viewport_width":null}],"pagination":{"next_page_start":null}}'
|
|
109
|
+
recorded_at: Thu, 06 Aug 2020 21:25:39 GMT
|
|
110
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://hcti.io/v1/image?includeId=true
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"url":"https://hcti.io","viewport_width":800,"viewport_height":1200,"ms_delay":500}'
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby
|
|
18
|
+
Authorization:
|
|
19
|
+
- Basic authentication-header
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Fri, 07 Aug 2020 16:26:02 GMT
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json; charset=utf-8
|
|
29
|
+
Transfer-Encoding:
|
|
30
|
+
- chunked
|
|
31
|
+
Connection:
|
|
32
|
+
- keep-alive
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- __cfduid=d3c6239ef3863b255e584197f6109aa701596817562; expires=Sun, 06-Sep-20
|
|
35
|
+
16:26:02 GMT; path=/; domain=.hcti.io; HttpOnly; SameSite=Lax
|
|
36
|
+
Cf-Ray:
|
|
37
|
+
- 5bf25b65bce50252-SJC
|
|
38
|
+
Access-Control-Allow-Origin:
|
|
39
|
+
- "*"
|
|
40
|
+
Cache-Control:
|
|
41
|
+
- max-age=public, 31536000
|
|
42
|
+
Vary:
|
|
43
|
+
- Accept-Encoding
|
|
44
|
+
Cf-Cache-Status:
|
|
45
|
+
- DYNAMIC
|
|
46
|
+
Cf-Request-Id:
|
|
47
|
+
- 046b57739000000252bcac6200000001
|
|
48
|
+
Expect-Ct:
|
|
49
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
50
|
+
Request-Context:
|
|
51
|
+
- appId=cid-v1:ef200074-f922-49b8-a889-360bb27d5561
|
|
52
|
+
X-Is-Overage:
|
|
53
|
+
- 'False'
|
|
54
|
+
X-Renders-Allowed:
|
|
55
|
+
- '500000'
|
|
56
|
+
X-Renders-Used:
|
|
57
|
+
- '4541'
|
|
58
|
+
Server:
|
|
59
|
+
- cloudflare
|
|
60
|
+
body:
|
|
61
|
+
encoding: ASCII-8BIT
|
|
62
|
+
string: '{"url":"https://hcti.io/v1/image/62157984-dfc9-4ec9-956a-de8931749215","id":"62157984-dfc9-4ec9-956a-de8931749215"}'
|
|
63
|
+
recorded_at: Fri, 07 Aug 2020 16:26:03 GMT
|
|
64
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://hcti.io/v1/image?includeId=true
|
|
6
|
+
body:
|
|
7
|
+
encoding: UTF-8
|
|
8
|
+
string: '{"url":"https://hcti.io"}'
|
|
9
|
+
headers:
|
|
10
|
+
Content-Type:
|
|
11
|
+
- application/json
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
User-Agent:
|
|
17
|
+
- Ruby
|
|
18
|
+
Authorization:
|
|
19
|
+
- Basic authentication-header
|
|
20
|
+
response:
|
|
21
|
+
status:
|
|
22
|
+
code: 200
|
|
23
|
+
message: OK
|
|
24
|
+
headers:
|
|
25
|
+
Date:
|
|
26
|
+
- Fri, 07 Aug 2020 16:26:02 GMT
|
|
27
|
+
Content-Type:
|
|
28
|
+
- application/json; charset=utf-8
|
|
29
|
+
Transfer-Encoding:
|
|
30
|
+
- chunked
|
|
31
|
+
Connection:
|
|
32
|
+
- keep-alive
|
|
33
|
+
Set-Cookie:
|
|
34
|
+
- __cfduid=d733844fdf4b2d3fe0551a030daf2ef991596817562; expires=Sun, 06-Sep-20
|
|
35
|
+
16:26:02 GMT; path=/; domain=.hcti.io; HttpOnly; SameSite=Lax
|
|
36
|
+
Cf-Ray:
|
|
37
|
+
- 5bf25b64699fed23-SJC
|
|
38
|
+
Access-Control-Allow-Origin:
|
|
39
|
+
- "*"
|
|
40
|
+
Cache-Control:
|
|
41
|
+
- max-age=public, 31536000
|
|
42
|
+
Vary:
|
|
43
|
+
- Accept-Encoding
|
|
44
|
+
Cf-Cache-Status:
|
|
45
|
+
- DYNAMIC
|
|
46
|
+
Cf-Request-Id:
|
|
47
|
+
- 046b5772c10000ed23cc811200000001
|
|
48
|
+
Expect-Ct:
|
|
49
|
+
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
|
|
50
|
+
Request-Context:
|
|
51
|
+
- appId=cid-v1:ef200074-f922-49b8-a889-360bb27d5561
|
|
52
|
+
X-Is-Overage:
|
|
53
|
+
- 'False'
|
|
54
|
+
X-Renders-Allowed:
|
|
55
|
+
- '500000'
|
|
56
|
+
X-Renders-Used:
|
|
57
|
+
- '4540'
|
|
58
|
+
Server:
|
|
59
|
+
- cloudflare
|
|
60
|
+
body:
|
|
61
|
+
encoding: ASCII-8BIT
|
|
62
|
+
string: '{"url":"https://hcti.io/v1/image/a8a9dda4-2c6e-41ab-9c7e-f851ed923274","id":"a8a9dda4-2c6e-41ab-9c7e-f851ed923274"}'
|
|
63
|
+
recorded_at: Fri, 07 Aug 2020 16:26:02 GMT
|
|
64
|
+
recorded_with: VCR 6.0.0
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "htmlcsstoimage/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "htmlcsstoimage-api"
|
|
8
|
+
spec.version = HTMLCSSToImage::VERSION
|
|
9
|
+
spec.authors = ["Mike Coutermarsh", "Jeffrey Needles"]
|
|
10
|
+
spec.email = ["support@htmlcsstoimage.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Ruby wrapper for the HTML/CSS to Image API.}
|
|
13
|
+
spec.description = %q{Generate images using HTML/CSS and Ruby.}
|
|
14
|
+
spec.homepage = "https://docs.htmlcsstoimage.com/example-code/ruby"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
|
+
end
|
|
22
|
+
spec.bindir = "exe"
|
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
+
spec.require_paths = ["lib"]
|
|
25
|
+
|
|
26
|
+
spec.add_dependency "httparty", "> 0.10"
|
|
27
|
+
spec.add_development_dependency "bundler", "> 2.0"
|
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
30
|
+
spec.add_development_dependency "pry"
|
|
31
|
+
spec.add_development_dependency "pry-byebug"
|
|
32
|
+
spec.add_development_dependency "vcr"
|
|
33
|
+
spec.add_development_dependency "webmock"
|
|
34
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
require "htmlcsstoimage/version"
|
|
2
|
+
require "httparty"
|
|
3
|
+
require "addressable"
|
|
4
|
+
|
|
5
|
+
class HTMLCSSToImage
|
|
6
|
+
include HTTParty
|
|
7
|
+
base_uri 'https://hcti.io'
|
|
8
|
+
headers 'Content-Type' => 'application/json'
|
|
9
|
+
format :json
|
|
10
|
+
|
|
11
|
+
SIGNED_URL_TEMPLATE = Addressable::Template.new("https://hcti.io/v1/image/{template_id}/{signed_token}{/format*}{?query*}")
|
|
12
|
+
|
|
13
|
+
class ApiResponse < OpenStruct
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
parser(
|
|
17
|
+
proc do |body, format|
|
|
18
|
+
case format
|
|
19
|
+
when :json
|
|
20
|
+
JSON.parse(body, object_class: ApiResponse)
|
|
21
|
+
else
|
|
22
|
+
body
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# Creates an instance of HTMLCSSToImage with API credentials.
|
|
28
|
+
# If credentials are not provided, will try to use environment variables.
|
|
29
|
+
# `HCTI_USER_ID` and `HCTI_API_KEY`.
|
|
30
|
+
#
|
|
31
|
+
# @see {https://htmlcsstoimage.com/dashboard}
|
|
32
|
+
#
|
|
33
|
+
# @param user_id [String] the user_id for the account.
|
|
34
|
+
# @param api_key [String] the api_key for the account.
|
|
35
|
+
# @return [HTMLCSSToImage] an instance of the api client.
|
|
36
|
+
def initialize(user_id: ENV["HCTI_USER_ID"], api_key: ENV["HCTI_API_KEY"])
|
|
37
|
+
@auth = { username: user_id, password: api_key }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Converts HTML/CSS to an image with the API
|
|
41
|
+
#
|
|
42
|
+
# @see {https://docs.htmlcsstoimage.com/getting-started/using-the-api}
|
|
43
|
+
#
|
|
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
|
+
#
|
|
46
|
+
# @option params [String] :css The CSS for your image.
|
|
47
|
+
# @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`
|
|
48
|
+
# @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`
|
|
49
|
+
# @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.
|
|
50
|
+
# @option params [Double] :device_scale This adjusts the pixel ratio for the screenshot. Minimum: `1`, Maximum: `3`.
|
|
51
|
+
# @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/).
|
|
52
|
+
# @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.
|
|
53
|
+
# @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.
|
|
54
|
+
#
|
|
55
|
+
# @return [HTMLCSSToImage::ApiResponse] image URL available at `.url`.
|
|
56
|
+
def create_image(html, params = {})
|
|
57
|
+
body = { html: html }.merge(params).to_json
|
|
58
|
+
options = { basic_auth: @auth, body: body, query: { includeId: true } }
|
|
59
|
+
|
|
60
|
+
self.class.post("/v1/image", options)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Deletes an image
|
|
64
|
+
#
|
|
65
|
+
# @see {https://docs.htmlcsstoimage.com/getting-started/using-the-api}
|
|
66
|
+
#
|
|
67
|
+
# @param image_id [String] The ID for the image you would like to delete
|
|
68
|
+
def delete_image(image_id)
|
|
69
|
+
response = self.class.delete("/v1/image/#{image_id}", basic_auth: @auth)
|
|
70
|
+
|
|
71
|
+
return true if response.success?
|
|
72
|
+
|
|
73
|
+
response
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# Creates a signed URL for generating an image from a template
|
|
78
|
+
# This URL contains the template_values in it. It is signed with HMAC so that it cannot be changed
|
|
79
|
+
# by anyone without the API Key.
|
|
80
|
+
#
|
|
81
|
+
# Does not make any network requests.
|
|
82
|
+
#
|
|
83
|
+
# @see {https://docs.htmlcsstoimage.com/getting-started/using-the-api}
|
|
84
|
+
#
|
|
85
|
+
# @param template_id [String] The ID for the template
|
|
86
|
+
# @param template_values [Hash] A hash containing the values to replace in the template
|
|
87
|
+
def create_image_from_template(template_id, template_values = {}, params = {})
|
|
88
|
+
template = SIGNED_URL_TEMPLATE.partial_expand({
|
|
89
|
+
template_id: template_id,
|
|
90
|
+
query: template_values
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
query = Addressable::URI.parse(template.generate).query
|
|
94
|
+
digest = OpenSSL::Digest.new('sha256')
|
|
95
|
+
signed_token = OpenSSL::HMAC.hexdigest(digest, @auth[:password], CGI.unescape(query))
|
|
96
|
+
|
|
97
|
+
url = template.expand({
|
|
98
|
+
signed_token: signed_token
|
|
99
|
+
}).to_s
|
|
100
|
+
|
|
101
|
+
ApiResponse.new(url: url)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def url_to_image(url, params = {})
|
|
105
|
+
body = { url: url }.merge(params).to_json
|
|
106
|
+
options = { basic_auth: @auth, body: body, query: { includeId: true } }
|
|
107
|
+
|
|
108
|
+
self.class.post("/v1/image", options)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def templates(params = {})
|
|
112
|
+
options = params.merge({ basic_auth: @auth })
|
|
113
|
+
self.class.get("/v1/template", options)
|
|
114
|
+
end
|
|
115
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: htmlcsstoimage-api
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mike Coutermarsh
|
|
8
|
+
- Jeffrey Needles
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: exe
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: httparty
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
requirements:
|
|
18
|
+
- - ">"
|
|
19
|
+
- !ruby/object:Gem::Version
|
|
20
|
+
version: '0.10'
|
|
21
|
+
type: :runtime
|
|
22
|
+
prerelease: false
|
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
24
|
+
requirements:
|
|
25
|
+
- - ">"
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: '0.10'
|
|
28
|
+
- !ruby/object:Gem::Dependency
|
|
29
|
+
name: bundler
|
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">"
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '2.0'
|
|
35
|
+
type: :development
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - ">"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '2.0'
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: rake
|
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - "~>"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '10.0'
|
|
49
|
+
type: :development
|
|
50
|
+
prerelease: false
|
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - "~>"
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '10.0'
|
|
56
|
+
- !ruby/object:Gem::Dependency
|
|
57
|
+
name: rspec
|
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - "~>"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '3.0'
|
|
63
|
+
type: :development
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - "~>"
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '3.0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: pry
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
84
|
+
- !ruby/object:Gem::Dependency
|
|
85
|
+
name: pry-byebug
|
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
type: :development
|
|
92
|
+
prerelease: false
|
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - ">="
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0'
|
|
98
|
+
- !ruby/object:Gem::Dependency
|
|
99
|
+
name: vcr
|
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
type: :development
|
|
106
|
+
prerelease: false
|
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
+
requirements:
|
|
109
|
+
- - ">="
|
|
110
|
+
- !ruby/object:Gem::Version
|
|
111
|
+
version: '0'
|
|
112
|
+
- !ruby/object:Gem::Dependency
|
|
113
|
+
name: webmock
|
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
type: :development
|
|
120
|
+
prerelease: false
|
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
+
requirements:
|
|
123
|
+
- - ">="
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: '0'
|
|
126
|
+
description: Generate images using HTML/CSS and Ruby.
|
|
127
|
+
email:
|
|
128
|
+
- support@htmlcsstoimage.com
|
|
129
|
+
executables: []
|
|
130
|
+
extensions: []
|
|
131
|
+
extra_rdoc_files: []
|
|
132
|
+
files:
|
|
133
|
+
- ".gitignore"
|
|
134
|
+
- ".rspec"
|
|
135
|
+
- ".ruby-version"
|
|
136
|
+
- CODE_OF_CONDUCT.md
|
|
137
|
+
- Gemfile
|
|
138
|
+
- Gemfile.lock
|
|
139
|
+
- LICENSE.txt
|
|
140
|
+
- README.md
|
|
141
|
+
- Rakefile
|
|
142
|
+
- bin/console
|
|
143
|
+
- bin/setup
|
|
144
|
+
- cassettes/HTMLCSSToImage/_create_image/accepts_additional_params.yml
|
|
145
|
+
- cassettes/HTMLCSSToImage/_create_image/creates_an_image.yml
|
|
146
|
+
- cassettes/HTMLCSSToImage/_delete_image/deletes_an_image.yml
|
|
147
|
+
- cassettes/HTMLCSSToImage/_templates/retrieves_templates.yml
|
|
148
|
+
- cassettes/HTMLCSSToImage/_url_to_image/accepts_additional_params.yml
|
|
149
|
+
- cassettes/HTMLCSSToImage/_url_to_image/creates_an_image_from_a_url.yml
|
|
150
|
+
- htmlcsstoimage.gemspec
|
|
151
|
+
- lib/htmlcsstoimage.rb
|
|
152
|
+
- lib/htmlcsstoimage/version.rb
|
|
153
|
+
homepage: https://docs.htmlcsstoimage.com/example-code/ruby
|
|
154
|
+
licenses:
|
|
155
|
+
- MIT
|
|
156
|
+
metadata: {}
|
|
157
|
+
post_install_message:
|
|
158
|
+
rdoc_options: []
|
|
159
|
+
require_paths:
|
|
160
|
+
- lib
|
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - ">="
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: '0'
|
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
|
+
requirements:
|
|
168
|
+
- - ">="
|
|
169
|
+
- !ruby/object:Gem::Version
|
|
170
|
+
version: '0'
|
|
171
|
+
requirements: []
|
|
172
|
+
rubygems_version: 3.0.3
|
|
173
|
+
signing_key:
|
|
174
|
+
specification_version: 4
|
|
175
|
+
summary: Ruby wrapper for the HTML/CSS to Image API.
|
|
176
|
+
test_files: []
|