peepshot 0.0.2 → 0.0.3
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.
- data/Gemfile +1 -0
- data/README.md +57 -6
- data/VERSION +1 -1
- data/lib/peepshot/rails/helpers.rb +12 -0
- data/lib/peepshot/rails/helpers/image_tags.rb +1 -1
- data/peepshot.gemspec +12 -8
- metadata +31 -15
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -3,20 +3,71 @@ PeepShot
|
|
|
3
3
|
|
|
4
4
|
Provides rails helpers for interfacing with [PeepShot](http://peepshot.com).
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
Examples
|
|
7
|
+
--------
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
PeepShot can be integrated into your Rails application in two ways:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
### Use the PeepShot image tag helper: peepshot_image_tag(url, options)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
The minimum requirements for the peepshot_image_tag is an url and a width. When no height is given, PeepShot will return an un-cropped screenshot of the full page. The following example will return an 320px wide image with a height above 1000px.
|
|
14
|
+
|
|
15
|
+
<%= peepshot_image_tag("http://ui-patterns.com", :width => 450) %>
|
|
16
|
+
|
|
17
|
+
Will return something like this:
|
|
18
|
+
|
|
19
|
+
<img alt="Ui-patterns" src="http://api.peepshot.com/v1/0d03a6bc89/d06c16f085ceba605b5294126517d03a/450?url=http://ui-patterns.com" width="450" />
|
|
20
|
+
|
|
21
|
+
The maximum width of a screenshot is 1024 pixels.
|
|
22
|
+
|
|
23
|
+
Adding a height to the options hash will make PeepShot crop the screenshot with basis in the top left corner.
|
|
24
|
+
|
|
25
|
+
<%= peepshot_image_tag("http://ui-patterns.com", :width => 450, :height => 337) %>
|
|
26
|
+
|
|
27
|
+
Will return something like this:
|
|
28
|
+
|
|
29
|
+
<img alt="Ui-patterns" height="337" src="http://api.peepshot.com/v1/0d03a6bc89/d06c16f085ceba605b5294126517d03a/450x337?url=http://ui-patterns.com" width="450" />
|
|
30
|
+
|
|
31
|
+
You can add any HTML options you'd like as you would with a regular image_tag in rails:
|
|
32
|
+
|
|
33
|
+
<%= peepshot_image_tag("http://ui-patterns.com", :width => 450, :height => 337, :class => 'thumbnail', :alt => "Go to UI-Patterns.com") %>
|
|
34
|
+
|
|
35
|
+
### Use the PeepShot url helper: peepshot_url(url, options)
|
|
36
|
+
|
|
37
|
+
If you'd like to use peepshot in your own homebrewn way, you can skip the image tag, and just get the URL for the thumbnail:
|
|
38
|
+
|
|
39
|
+
peepshot_url("http://ui-patterns.com", :width => 320)
|
|
40
|
+
|
|
41
|
+
### Use a webservice (json or XML) to check if screenshot is ready
|
|
42
|
+
|
|
43
|
+
If you're not interested in showing a "queued" message to your users, you can use the following method to check if the screenshot has been grabbed and is ready to be shown. It calls a webservice, so calling this method a hundred times on one page can be slow.
|
|
44
|
+
|
|
45
|
+
peepshot_image_ready?(url)
|
|
46
|
+
|
|
47
|
+
For instance:
|
|
48
|
+
|
|
49
|
+
peepshot_image_ready?("http://ui-patterns.com")
|
|
50
|
+
|
|
51
|
+
Installation
|
|
52
|
+
------------
|
|
53
|
+
|
|
54
|
+
Prerequisite: You need a peepshot.com account. Have your API Key and API Secret handy.
|
|
55
|
+
|
|
56
|
+
### 1. Install peepshot as a gem in your rails app.
|
|
57
|
+
|
|
58
|
+
Add this to your Gemfile: (change version numbers if needed)
|
|
59
|
+
|
|
60
|
+
gem 'peepshot', '0.2.0'
|
|
61
|
+
|
|
62
|
+
Don’t forget to run “bundle install” command every time you change something in the Gemfile.
|
|
63
|
+
|
|
64
|
+
### 2. Create `config/peepshot.yml` with the appropriate environment.
|
|
14
65
|
|
|
15
66
|
production:
|
|
16
67
|
api_key: <your API key>
|
|
17
68
|
api_secret: <your API secret>
|
|
18
69
|
|
|
19
|
-
3
|
|
70
|
+
### 3. Create `config/initializers/peepshot.rb` and place the following line in it
|
|
20
71
|
|
|
21
72
|
PeepShot.load_peepshot_yaml
|
|
22
73
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.3
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'uri'
|
|
2
|
+
require 'open-uri'
|
|
2
3
|
require 'cgi'
|
|
3
4
|
require 'digest'
|
|
4
5
|
|
|
@@ -8,6 +9,17 @@ module PeepShot
|
|
|
8
9
|
class InvalidDimensions < Exception; end
|
|
9
10
|
include ImageTags
|
|
10
11
|
|
|
12
|
+
def peepshot_image_ready?(url)
|
|
13
|
+
host = 'api.peepshot.com'
|
|
14
|
+
token = Digest::MD5.hexdigest(PeepShot.api_secret + url)
|
|
15
|
+
|
|
16
|
+
url = URI.escape("http://#{host}/v1/#{PeepShot.api_key}/#{token}/ready?url=#{url}")
|
|
17
|
+
|
|
18
|
+
data = JSON.parse(open(url).read)
|
|
19
|
+
|
|
20
|
+
data['status'] == 'OK' ? true : false
|
|
21
|
+
end
|
|
22
|
+
|
|
11
23
|
def peepshot_url(url, options)
|
|
12
24
|
options = {:width => 200,
|
|
13
25
|
:height => nil
|
|
@@ -5,7 +5,7 @@ module PeepShot
|
|
|
5
5
|
def peepshot_image_tag(url, options)
|
|
6
6
|
width = find_width(options).to_s.downcase == 'original' ? 1024 : find_width(options)
|
|
7
7
|
height = find_height(options)
|
|
8
|
-
image_tag(peepshot_url(url, options), :width => width, :height => height)
|
|
8
|
+
image_tag(peepshot_url(url, options), {:width => width, :height => height}.merge(options.except(:width, :height)))
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
data/peepshot.gemspec
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name =
|
|
8
|
-
s.version = "0.0.
|
|
7
|
+
s.name = %q{peepshot}
|
|
8
|
+
s.version = "0.0.3"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Anders Toxboe"]
|
|
12
|
-
s.date =
|
|
13
|
-
s.description =
|
|
14
|
-
s.email =
|
|
12
|
+
s.date = %q{2013-11-26}
|
|
13
|
+
s.description = %q{Use this gem in your rails applications to capture thumbnail screenshots through the PeepShot API}
|
|
14
|
+
s.email = %q{info@ui-patterns.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
16
16
|
"LICENSE.txt",
|
|
17
17
|
"README.md"
|
|
@@ -31,17 +31,18 @@ Gem::Specification.new do |s|
|
|
|
31
31
|
"test/helper.rb",
|
|
32
32
|
"test/test_peepshot.rb"
|
|
33
33
|
]
|
|
34
|
-
s.homepage =
|
|
34
|
+
s.homepage = %q{https://github.com/PeepShot/peepshot}
|
|
35
35
|
s.licenses = ["MIT"]
|
|
36
36
|
s.require_paths = ["lib"]
|
|
37
|
-
s.rubygems_version =
|
|
38
|
-
s.summary =
|
|
37
|
+
s.rubygems_version = %q{1.3.7}
|
|
38
|
+
s.summary = %q{PeepShot URL and view helpers}
|
|
39
39
|
s.test_files = [
|
|
40
40
|
"test/helper.rb",
|
|
41
41
|
"test/test_peepshot.rb"
|
|
42
42
|
]
|
|
43
43
|
|
|
44
44
|
if s.respond_to? :specification_version then
|
|
45
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
45
46
|
s.specification_version = 3
|
|
46
47
|
|
|
47
48
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
@@ -50,12 +51,14 @@ Gem::Specification.new do |s|
|
|
|
50
51
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
51
52
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
52
53
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
|
54
|
+
s.add_development_dependency(%q<json>, [">= 0"])
|
|
53
55
|
else
|
|
54
56
|
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
|
55
57
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
56
58
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
57
59
|
s.add_dependency(%q<rcov>, [">= 0"])
|
|
58
60
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
|
61
|
+
s.add_dependency(%q<json>, [">= 0"])
|
|
59
62
|
end
|
|
60
63
|
else
|
|
61
64
|
s.add_dependency(%q<rspec>, ["~> 2.6.0"])
|
|
@@ -63,6 +66,7 @@ Gem::Specification.new do |s|
|
|
|
63
66
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
64
67
|
s.add_dependency(%q<rcov>, [">= 0"])
|
|
65
68
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
|
69
|
+
s.add_dependency(%q<json>, [">= 0"])
|
|
66
70
|
end
|
|
67
71
|
end
|
|
68
72
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: peepshot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: 25
|
|
5
|
+
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 0.0.
|
|
9
|
+
- 3
|
|
10
|
+
version: 0.0.3
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Anders Toxboe
|
|
@@ -15,7 +15,8 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2013-11-26 00:00:00 +01:00
|
|
19
|
+
default_executable:
|
|
19
20
|
dependencies:
|
|
20
21
|
- !ruby/object:Gem::Dependency
|
|
21
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
|
@@ -29,10 +30,10 @@ dependencies:
|
|
|
29
30
|
- 6
|
|
30
31
|
- 0
|
|
31
32
|
version: 2.6.0
|
|
33
|
+
requirement: *id001
|
|
34
|
+
type: :development
|
|
32
35
|
name: rspec
|
|
33
36
|
prerelease: false
|
|
34
|
-
type: :development
|
|
35
|
-
requirement: *id001
|
|
36
37
|
- !ruby/object:Gem::Dependency
|
|
37
38
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
|
38
39
|
none: false
|
|
@@ -45,10 +46,10 @@ dependencies:
|
|
|
45
46
|
- 0
|
|
46
47
|
- 0
|
|
47
48
|
version: 1.0.0
|
|
49
|
+
requirement: *id002
|
|
50
|
+
type: :development
|
|
48
51
|
name: bundler
|
|
49
52
|
prerelease: false
|
|
50
|
-
type: :development
|
|
51
|
-
requirement: *id002
|
|
52
53
|
- !ruby/object:Gem::Dependency
|
|
53
54
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
|
54
55
|
none: false
|
|
@@ -61,10 +62,10 @@ dependencies:
|
|
|
61
62
|
- 5
|
|
62
63
|
- 2
|
|
63
64
|
version: 1.5.2
|
|
65
|
+
requirement: *id003
|
|
66
|
+
type: :development
|
|
64
67
|
name: jeweler
|
|
65
68
|
prerelease: false
|
|
66
|
-
type: :development
|
|
67
|
-
requirement: *id003
|
|
68
69
|
- !ruby/object:Gem::Dependency
|
|
69
70
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
|
70
71
|
none: false
|
|
@@ -75,10 +76,10 @@ dependencies:
|
|
|
75
76
|
segments:
|
|
76
77
|
- 0
|
|
77
78
|
version: "0"
|
|
79
|
+
requirement: *id004
|
|
80
|
+
type: :development
|
|
78
81
|
name: rcov
|
|
79
82
|
prerelease: false
|
|
80
|
-
type: :development
|
|
81
|
-
requirement: *id004
|
|
82
83
|
- !ruby/object:Gem::Dependency
|
|
83
84
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
|
84
85
|
none: false
|
|
@@ -89,10 +90,24 @@ dependencies:
|
|
|
89
90
|
segments:
|
|
90
91
|
- 0
|
|
91
92
|
version: "0"
|
|
93
|
+
requirement: *id005
|
|
94
|
+
type: :development
|
|
92
95
|
name: rdoc
|
|
93
96
|
prerelease: false
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
|
99
|
+
none: false
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
hash: 3
|
|
104
|
+
segments:
|
|
105
|
+
- 0
|
|
106
|
+
version: "0"
|
|
107
|
+
requirement: *id006
|
|
94
108
|
type: :development
|
|
95
|
-
|
|
109
|
+
name: json
|
|
110
|
+
prerelease: false
|
|
96
111
|
description: Use this gem in your rails applications to capture thumbnail screenshots through the PeepShot API
|
|
97
112
|
email: info@ui-patterns.com
|
|
98
113
|
executables: []
|
|
@@ -116,6 +131,7 @@ files:
|
|
|
116
131
|
- peepshot.gemspec
|
|
117
132
|
- test/helper.rb
|
|
118
133
|
- test/test_peepshot.rb
|
|
134
|
+
has_rdoc: true
|
|
119
135
|
homepage: https://github.com/PeepShot/peepshot
|
|
120
136
|
licenses:
|
|
121
137
|
- MIT
|
|
@@ -145,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
145
161
|
requirements: []
|
|
146
162
|
|
|
147
163
|
rubyforge_project:
|
|
148
|
-
rubygems_version: 1.
|
|
164
|
+
rubygems_version: 1.3.7
|
|
149
165
|
signing_key:
|
|
150
166
|
specification_version: 3
|
|
151
167
|
summary: PeepShot URL and view helpers
|