tourist 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/rasterize.js +21 -0
  2. data/lib/tourist.rb +6 -3
  3. metadata +3 -18
data/lib/rasterize.js ADDED
@@ -0,0 +1,21 @@
1
+ var page = new WebPage(),
2
+ address, output, size;
3
+
4
+ if (phantom.args.length < 2 || phantom.args.length > 3) {
5
+ console.log('Usage: rasterize.js URL filename');
6
+ phantom.exit();
7
+ } else {
8
+ address = phantom.args[0];
9
+ output = phantom.args[1];
10
+ page.viewportSize = { width: 600, height: 600 };
11
+ page.open(address, function (status) {
12
+ if (status !== 'success') {
13
+ console.log('Unable to load the address!');
14
+ } else {
15
+ window.setTimeout(function () {
16
+ page.render(output);
17
+ phantom.exit();
18
+ }, 1000);
19
+ }
20
+ });
21
+ }
data/lib/tourist.rb CHANGED
@@ -3,7 +3,10 @@ require 'timeout'
3
3
 
4
4
  class Tourist
5
5
 
6
- def self.peep_site(site_name, site_address, image_location, depth = nil)
6
+ def self.tour_site(site_name, site_address, image_location, depth = nil)
7
+ spec = Gem::Specification.find_by_name("tourist")
8
+ gem_root = spec.gem_dir
9
+ gem_lib = gem_root + "/lib"
7
10
 
8
11
  Anemone.crawl(site_address, depth_limit: depth) do |anemone|
9
12
  i = 0
@@ -16,8 +19,8 @@ class Tourist
16
19
  begin
17
20
  status = Timeout::timeout(10) {
18
21
  #image name is the page title plus a hash of the url plus extension
19
- image_name = page.url.to_s.split("/").last.to_s + "." + page.url.hash.to_s + ".jpg"
20
- puts `wkhtmltoimage #{page.url} #{site_dir}/#{image_name}`
22
+ image_name = page.url.to_s.split("/").last.to_s + "." + page.url.hash.to_s + ".png"
23
+ puts `phantomjs #{gem_lib}/rasterize.js #{page.url} #{site_dir}/#{image_name}`
21
24
  }
22
25
  rescue Exception => ex
23
26
  puts ex
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tourist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,22 +11,6 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: imgkit
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
14
  - !ruby/object:Gem::Dependency
31
15
  name: anemone
32
16
  requirement: !ruby/object:Gem::Requirement
@@ -50,6 +34,7 @@ extensions: []
50
34
  extra_rdoc_files: []
51
35
  files:
52
36
  - lib/tourist.rb
37
+ - lib/rasterize.js
53
38
  homepage: http://rubygems.org/gems/tourist
54
39
  licenses: []
55
40
  post_install_message:
@@ -73,6 +58,6 @@ rubyforge_project:
73
58
  rubygems_version: 1.8.24
74
59
  signing_key:
75
60
  specification_version: 3
76
- summary: Quick way to crawl and screenshot your site.
61
+ summary: Switched wkhtmltoimage to phantomjs
77
62
  test_files: []
78
63
  has_rdoc: