wraith 2.3.1 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b1ef3f4e6afe88d801486999230f8f3284d57ec
4
- data.tar.gz: e4635f5a2433c7951cf2ce13374cfb37f9d6a47c
3
+ metadata.gz: 21c2e2f34b4f57be52b02d9c1812068629fab964
4
+ data.tar.gz: e0db82084db042e981d2141385e95a9f79d3bdf7
5
5
  SHA512:
6
- metadata.gz: f2e3b5f04d9387bfdc9877bc58e7a5769bd0f261a2e23a68a02f6a1a95555761bd85b83283a3015c49bcc2cf7ab324cd0ad2eef8d6da65359ab38c00d8fdcd57
7
- data.tar.gz: 32ba015605d4b92c53da0f70efbb72e37ee45cc43665512d48a75670636135a541d6ed63fdd9fd1ad4a9f3b5616ca1a1766f06fee988ce96071aa516b092e50d
6
+ metadata.gz: fa0e6f3d579ca6e85f8a08a00ad09a059dc54798d82f8e90767585f3e85b718d9aee3a95d910987e9853edb43190ec724c1428f993562f29c167687182559aa5
7
+ data.tar.gz: 2de08d53d57c00f582d1535383d837be73d4a7c4594481081c8d47147f5ee0b02dc8a006b00f2c60e494b1b8b001c0b7bfd973e9f8310dedfc509dadf58a8059
@@ -0,0 +1,42 @@
1
+ #Headless browser option
2
+ browser:
3
+ phantomjs: "phantomjs"
4
+ # slimerjs: "slimerjs"
5
+
6
+ #If you want to have multiple snapping files, set the file name here
7
+ snap_file: "lib/wraith/javascript/customHeight.js"
8
+
9
+ # Type the name of the directory that shots will be stored in
10
+ directory: 'shots'
11
+
12
+ # Add only 2 domains, key will act as a label
13
+ domains:
14
+ english: "http://www.live.bbc.co.uk/news"
15
+ russian: "http://www.live.bbc.co.uk/russian"
16
+
17
+ #Type screen widths below, here are a couple of examples
18
+ screen_widths:
19
+ # - widthxheight
20
+ - 480x320
21
+ - 400x600
22
+ - 600x768
23
+ - 800x1024
24
+ - 720x1280
25
+
26
+ #Type page URL paths below, here are a couple of examples
27
+ paths:
28
+ home: /
29
+ uk_index: /uk
30
+
31
+ #Amount of fuzz ImageMagick will use
32
+ fuzz: '20%'
33
+
34
+ #Set the number of days to keep the site spider file
35
+ spider_days:
36
+ - 10
37
+
38
+ #Choose how results are displayed, by default alphanumeric. Different screen widths are always grouped.
39
+ #alphanumeric - all paths (with, and without, a difference) are shown, sorted by path
40
+ #diffs_first - all paths (with, and without, a difference) are shown, sorted by difference size (largest first)
41
+ #diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
42
+ #mode: diffs_first
data/lib/wraith/cli.rb CHANGED
@@ -83,7 +83,7 @@ class Wraith::CLI < Thor
83
83
  end
84
84
 
85
85
  desc 'generate_gallery [config_name]', 'create page for viewing images'
86
- def generate_gallery(config_name, multi)
86
+ def generate_gallery(config_name, multi = false)
87
87
  gallery = Wraith::GalleryGenerator.new(config_name, multi)
88
88
  gallery.generate_gallery
89
89
  end
data/lib/wraith/folder.rb CHANGED
@@ -34,7 +34,7 @@ class Wraith::FolderManager
34
34
  end
35
35
 
36
36
  def copy_old_shots
37
- FileUtils.cp_r(dir, history_dir)
37
+ FileUtils.cp_r("#{dir}/.", "#{history_dir}/")
38
38
  end
39
39
 
40
40
  def restore_shots
@@ -0,0 +1,99 @@
1
+ var system = require('system');
2
+ var page = require('webpage').create();
3
+ var fs = require('fs');
4
+
5
+ if (system.args.length === 3) {
6
+ console.log('Usage: snap.js <some URL> <view port width> <target image name>');
7
+ phantom.exit();
8
+ }
9
+
10
+ var url = system.args[1];
11
+ var image_name = system.args[3];
12
+ var dimensions = /(\d*)x?((\d*))?/i.exec(system.args[2]);
13
+ var view_port_width = dimensions[1];
14
+ var view_port_height = dimensions[2] || 1500;
15
+ var current_requests = 0;
16
+ var last_request_timeout;
17
+ var final_timeout;
18
+
19
+
20
+ page.viewportSize = { width: view_port_width, height: view_port_height};
21
+ page.settings = { loadImages: true, javascriptEnabled: true };
22
+
23
+ // If you want to use additional phantomjs commands, place them here
24
+ page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.17';
25
+
26
+ // You can place custom headers here, example below.
27
+ // page.customHeaders = {
28
+
29
+ // 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/'
30
+
31
+ // };
32
+
33
+ // If you want to set a cookie, just add your details below in the following way.
34
+
35
+ // phantom.addCookie({
36
+ // 'name': 'ckns_policy',
37
+ // 'value': '111',
38
+ // 'domain': '.bbc.co.uk'
39
+ // });
40
+ // phantom.addCookie({
41
+ // 'name': 'locserv',
42
+ // 'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
43
+ // 'domain': '.bbc.co.uk'
44
+ // });
45
+
46
+ page.onResourceRequested = function(req) {
47
+ current_requests += 1;
48
+ };
49
+
50
+ page.onResourceReceived = function(res) {
51
+ if (res.stage === 'end') {
52
+ current_requests -= 1;
53
+ debounced_render();
54
+ }
55
+ };
56
+
57
+ page.open(url, function(status) {
58
+ if (status !== 'success') {
59
+ console.log('Error with page ' + url);
60
+ phantom.exit();
61
+ }
62
+ });
63
+
64
+
65
+ function debounced_render() {
66
+ clearTimeout(last_request_timeout);
67
+ clearTimeout(final_timeout);
68
+
69
+ // If there's no more ongoing resource requests, wait for 1 second before
70
+ // rendering, just in case the page kicks off another request
71
+ if (current_requests < 1) {
72
+ clearTimeout(final_timeout);
73
+ last_request_timeout = setTimeout(function() {
74
+ console.log('Snapping ' + url + ' at width ' + view_port_width);
75
+ page.clipRect = {
76
+ top: 0,
77
+ left: 0,
78
+ height: view_port_height,
79
+ width: view_port_width
80
+ };
81
+ page.render(image_name);
82
+ phantom.exit();
83
+ }, 1000);
84
+ }
85
+
86
+ // Sometimes, straggling requests never make it back, in which
87
+ // case, timeout after 5 seconds and render the page anyway
88
+ final_timeout = setTimeout(function() {
89
+ console.log('Snapping ' + url + ' at width ' + view_port_width);
90
+ page.clipRect = {
91
+ top: 0,
92
+ left: 0,
93
+ height: view_port_height,
94
+ width: view_port_width
95
+ };
96
+ page.render(image_name);
97
+ phantom.exit();
98
+ }, 5000);
99
+ }
@@ -1,3 +1,3 @@
1
1
  module Wraith
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wraith
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Blooman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-31 00:00:00.000000000 Z
12
+ date: 2015-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
@@ -189,6 +189,7 @@ files:
189
189
  - configs/component.yaml
190
190
  - configs/config.yaml
191
191
  - configs/config_nojs.yaml
192
+ - configs/custom_height.yaml
192
193
  - configs/history.yaml
193
194
  - configs/test_config.yaml
194
195
  - lib/wraith.rb
@@ -200,6 +201,7 @@ files:
200
201
  - lib/wraith/gallery_template/bootstrap.min.css
201
202
  - lib/wraith/gallery_template/gallery_template.erb
202
203
  - lib/wraith/javascript/casper.js
204
+ - lib/wraith/javascript/customHeight.js
203
205
  - lib/wraith/javascript/nojs.js
204
206
  - lib/wraith/javascript/snap.js
205
207
  - lib/wraith/save_images.rb