pdfbucket 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/pdfbucket.rb +30 -0
- data/lib/pdfbucket/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d69835003ac37c1a070c0dca78860219ce255a5b
|
4
|
+
data.tar.gz: fd2d427153bba4db28df8a501f4aecdf281a9d34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aa6d13ee50b2c6801df7b2f8a75158f2f8ebd99cabc6eb5cf41d12e7d7b1e06e10eff61ac70b61f315a09a4860ea73da47f0acbc7618962742f7a3261106298
|
7
|
+
data.tar.gz: 62890495c4eccb68d0e8971dbb9cdb9f7d4421c777f76b85944ab6a9aceeae03e5b9b63c2b359e7a861dfc2807def2048fe5a02e2e1f91d8d862033aadc7af88
|
data/README.md
CHANGED
@@ -31,6 +31,12 @@ other_pdf_bucket = PDFBucket::PDFBucket.new(api_key: '123', api_secret: '321', a
|
|
31
31
|
encrypted_url = pdf_bucket.generate_url('http://example.com', :landscape, :a4, '2px', '0.7')
|
32
32
|
```
|
33
33
|
|
34
|
+
Also you can pass the plain URL to PDFBucket
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
plain_url = pdf_bucket.generate_plain_url('http://example.com', :landscape, :a4, '2px', '0.7')
|
38
|
+
```
|
39
|
+
|
34
40
|
* Possible values for orientation: :landscape, :portrait
|
35
41
|
* Possible values for page size: :letter, :a4
|
36
42
|
* Possible values for margin: https://developer.mozilla.org/en-US/docs/Web/CSS/margin#Formal_syntax
|
data/lib/pdfbucket.rb
CHANGED
@@ -51,8 +51,38 @@ module PDFBucket
|
|
51
51
|
query: query).to_s
|
52
52
|
end
|
53
53
|
|
54
|
+
def generate_plain_url(url, orientation, page_size, margin, zoom)
|
55
|
+
signature = sign(api_secret, api_key, url, orientation, page_size, margin, zoom)
|
56
|
+
query = URI.encode_www_form(
|
57
|
+
orientation: ORIENTATIONS[orientation],
|
58
|
+
page_size: PAGE_SIZES[page_size],
|
59
|
+
margin: margin,
|
60
|
+
zoom: zoom,
|
61
|
+
api_key: api_key,
|
62
|
+
uri: url,
|
63
|
+
signature: signature)
|
64
|
+
|
65
|
+
URI::HTTPS.build(
|
66
|
+
host: api_host,
|
67
|
+
path: '/api/convert',
|
68
|
+
query: query).to_s
|
69
|
+
end
|
70
|
+
|
54
71
|
private
|
55
72
|
|
73
|
+
def sign(api_secret, api_key, url, orientation, page_size, margin, zoom)
|
74
|
+
params = [
|
75
|
+
api_key,
|
76
|
+
url,
|
77
|
+
ORIENTATIONS[orientation],
|
78
|
+
PAGE_SIZES[page_size],
|
79
|
+
margin,
|
80
|
+
zoom
|
81
|
+
].join(',')
|
82
|
+
|
83
|
+
Digest::SHA1.hexdigest("#{params}#{api_secret}")
|
84
|
+
end
|
85
|
+
|
56
86
|
def encrypt(key, content)
|
57
87
|
binary_key = Base64.decode64(key)
|
58
88
|
alg = 'AES-256-CTR'
|
data/lib/pdfbucket/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdfbucket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sanrodari
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|