wraith 2.7.0 → 2.8.0

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: 7d0d54a5e957a901f42244cecc6523883865a91a
4
- data.tar.gz: 94e209bfface9c61b060e3e9624d5cf9609a59ed
3
+ metadata.gz: bf63697eac76217c8011ef49428c9699433a6e89
4
+ data.tar.gz: 28179715439e86a3102ec17113e9d2e9ae878997
5
5
  SHA512:
6
- metadata.gz: 21ff9b3f556c593da98bdd1bef23ad62b5d16898d8f38589cbf0eb1d4b1c9535a1e57e6bfd1f0bf32fda5207fc7ecbcf87a879c19e291d406e3f2731ee041a66
7
- data.tar.gz: ff94dad2fb1d688a3fbebc110e27c234c656945e56db980a41f7570bd1a598aa05ff9eb520b87426efc2d75655109d78f0fc5da8f1138b65e036c72579285faa
6
+ metadata.gz: 8ab5d69ea95075c115620d955f807e507f5f20d481278a3c30b30281d61cf6458bf690958376d08e7d5f9cdf77729425e21838d2b2fd85225c8bb90509d49f2f
7
+ data.tar.gz: 88c70548dace9ca18d2210cca2bd3438e18fa2b507383228f1135bb031b739cc4409e93cefe51c87c59da4faa4c569e7b5458226b53b848548f74c0200cace09
data/Dockerfile CHANGED
@@ -11,4 +11,10 @@ RUN apt-get install -y libfreetype6 libfontconfig1
11
11
  RUN gem install wraith --no-rdoc --no-ri
12
12
  RUN gem install aws-sdk --no-rdoc --no-ri
13
13
 
14
+ # Make sure decent fonts are installed. Thanks to http://www.dailylinuxnews.com/blog/2014/09/things-to-do-after-installing-debian-jessie/
15
+ RUN echo "deb http://ftp.us.debian.org/debian jessie main contrib non-free" | tee -a /etc/apt/sources.list
16
+ RUN echo "deb http://security.debian.org/ jessie/updates contrib non-free" | tee -a /etc/apt/sources.list
17
+ RUN apt-get update
18
+ RUN apt-get install -y ttf-freefont ttf-mscorefonts-installer ttf-bitstream-vera ttf-dejavu ttf-liberation
19
+
14
20
  ENTRYPOINT [ "wraith" ]
data/README.md CHANGED
@@ -77,7 +77,6 @@ There are other commands also available, these all expect a config_name to be pa
77
77
  wraith reset_shots [config_name] # removes all the files in the shots folder
78
78
  wraith save_images [config_name] # captures screenshots
79
79
  wraith setup # creates config folder and default config
80
- wraith setup_casper # creates config folder and default config for casper
81
80
  wraith setup_folders [config_name] # create folders for images
82
81
  ```
83
82
 
@@ -35,6 +35,25 @@ class Wraith::CLI < Thor
35
35
  create.create_folders
36
36
  end
37
37
 
38
+ desc "copy_base_images [config_name]", "copies the required base images over for comparison with latest images"
39
+ def copy_base_images(config_name)
40
+ copy = Wraith::FolderManager.new(config_name)
41
+ copy.copy_base_images
42
+ end
43
+
44
+ desc "make_sure_base_shots_exists [config_name]", "warns user if config is missing base shots"
45
+ def make_sure_base_shots_exists(config_name)
46
+ wraith = Wraith::Wraith.new(config_name)
47
+ if wraith.history_dir.nil?
48
+ puts "You need to specify a `history_dir` property at #{config_name} before you can run `wraith latest`!"
49
+ exit 1
50
+ end
51
+ if !File.directory?(wraith.history_dir)
52
+ puts "You need to run `wraith history` at least once before you can run `wraith latest`!"
53
+ exit 1
54
+ end
55
+ end
56
+
38
57
  no_commands do
39
58
  def check_for_paths(config_name)
40
59
  spider = Wraith::Spidering.new(config_name)
@@ -45,15 +64,11 @@ class Wraith::CLI < Thor
45
64
  create = Wraith::FolderManager.new(config_name)
46
65
  create.copy_old_shots
47
66
  end
48
-
49
- def restore_shots(config_name)
50
- create = Wraith::FolderManager.new(config_name)
51
- create.restore_shots
52
- end
53
67
  end
54
68
 
55
69
  desc "save_images [config_name]", "captures screenshots"
56
70
  def save_images(config_name, history = false)
71
+ puts "SAVING IMAGES"
57
72
  save_images = Wraith::SaveImages.new(config_name, history)
58
73
  save_images.save_images
59
74
  end
@@ -66,18 +81,21 @@ class Wraith::CLI < Thor
66
81
 
67
82
  desc "compare_images [config_name]", "compares images to generate diffs"
68
83
  def compare_images(config_name)
84
+ puts "COMPARING IMAGES"
69
85
  compare = Wraith::CompareImages.new(config_name)
70
86
  compare.compare_images
71
87
  end
72
88
 
73
89
  desc "generate_thumbnails [config_name]", "create thumbnails for gallery"
74
90
  def generate_thumbnails(config_name)
91
+ puts "GENERATING THUMBNAILS"
75
92
  thumbs = Wraith::Thumbnails.new(config_name)
76
93
  thumbs.generate_thumbnails
77
94
  end
78
95
 
79
96
  desc "generate_gallery [config_name]", "create page for viewing images"
80
97
  def generate_gallery(config_name, multi = false)
98
+ puts "GENERATING GALLERY"
81
99
  gallery = Wraith::GalleryGenerator.new(config_name, multi)
82
100
  gallery.generate_gallery
83
101
  end
@@ -113,9 +131,10 @@ class Wraith::CLI < Thor
113
131
 
114
132
  desc "latest [config_name]", "Capture new shots to compare with baseline"
115
133
  def latest(config)
134
+ make_sure_base_shots_exists(config)
116
135
  reset_shots(config)
117
- restore_shots(config)
118
136
  save_images(config, true)
137
+ copy_base_images(config)
119
138
  crop_images(config)
120
139
  compare_images(config)
121
140
  generate_thumbnails(config)
@@ -16,6 +16,7 @@ class Wraith::CompareImages
16
16
  Parallel.each(files.each_slice(2), :in_processes => Parallel.processor_count) do |base, compare|
17
17
  diff = base.gsub(/([a-zA-Z0-9]+).png$/, "diff.png")
18
18
  info = base.gsub(/([a-zA-Z0-9]+).png$/, "data.txt")
19
+ puts "Comparing #{base} and #{compare}"
19
20
  compare_task(base, compare, diff, info)
20
21
  puts "Saved diff"
21
22
  end
@@ -41,9 +41,13 @@ class Wraith::FolderManager
41
41
  end
42
42
  end
43
43
 
44
- def restore_shots
45
- puts "restoring"
46
- FileUtils.cp_r(Dir.glob("#{history_dir}/*"), dir)
44
+ def copy_base_images
45
+ puts "COPYING BASE IMAGES"
46
+ wraith.paths.each do |path|
47
+ path = path[0]
48
+ puts "Copying #{history_dir}/#{path} to #{dir}"
49
+ FileUtils.cp_r(Dir.glob("#{history_dir}/#{path}"), dir)
50
+ end
47
51
  end
48
52
 
49
53
  def create_folders
@@ -74,7 +78,9 @@ class Wraith::FolderManager
74
78
  dirs.each do |_folder_name, shot_info|
75
79
  shot_info.each do |_k, v|
76
80
  begin
77
- if v[:data] > wraith.threshold
81
+ if !v.include?(:diff)
82
+ return false
83
+ elsif v[:data] > wraith.threshold
78
84
  return false
79
85
  end
80
86
  rescue
@@ -8,13 +8,10 @@ class Wraith::GalleryGenerator
8
8
 
9
9
  MATCH_FILENAME = /(\S+)_(\S+)\.\S+/
10
10
 
11
- TEMPLATE_LOCATION = File.expand_path("gallery_template/gallery_template.erb", File.dirname(__FILE__))
12
- TEMPLATE_BY_DOMAIN_LOCATION = File.expand_path("gallery_template/gallery_template.erb", File.dirname(__FILE__))
13
-
14
11
  def initialize(config, multi)
15
12
  @wraith = Wraith::Wraith.new(config)
16
13
  @location = wraith.directory
17
- @mutli = multi
14
+ @multi = multi
18
15
  @folder_manager = Wraith::FolderManager.new(config)
19
16
  end
20
17
 
@@ -53,6 +50,7 @@ class Wraith::GalleryGenerator
53
50
  @group = get_group_from_match match
54
51
  @filepath = category + "/" + filename
55
52
  @thumbnail = "thumbnails/#{category}/#{filename}"
53
+ @url = figure_out_url @group, category
56
54
 
57
55
  if @dirs[category][@size].nil?
58
56
  @dirs[category][@size] = { :variants => [] }
@@ -63,6 +61,14 @@ class Wraith::GalleryGenerator
63
61
  data_group(@group, size_dict, dirname, @filepath)
64
62
  end
65
63
 
64
+ def figure_out_url(group, category)
65
+ root = wraith.domains["#{group}"]
66
+ return '' if root.nil?
67
+ path = wraith.paths["#{category}"]['path']
68
+ url = root + path
69
+ url
70
+ end
71
+
66
72
  def get_group_from_match(match)
67
73
  group = match[2]
68
74
  dash = match[2].rindex('-')
@@ -88,7 +94,8 @@ class Wraith::GalleryGenerator
88
94
  size_dict[:variants] << {
89
95
  :name => group,
90
96
  :filename => @filepath,
91
- :thumb => @thumbnail
97
+ :thumb => @thumbnail,
98
+ :url => @url
92
99
  }
93
100
  size_dict[:variants].sort! { |a, b| a[:name] <=> b[:name] }
94
101
  end
@@ -130,16 +137,32 @@ class Wraith::GalleryGenerator
130
137
  def generate_gallery(with_path = "")
131
138
  dest = "#{@location}/gallery.html"
132
139
  directories = parse_directories(@location)
133
- generate_html(@location, directories, TEMPLATE_BY_DOMAIN_LOCATION, dest, with_path)
140
+
141
+ slideshow_template = File.expand_path("gallery_template/#{wraith.gallery_template}.erb", File.dirname(__FILE__))
142
+
143
+ generate_html(@location, directories, slideshow_template, dest, with_path)
144
+
134
145
  puts "Gallery generated"
135
146
  check_failed_shots
136
147
  end
137
148
 
138
149
  def check_failed_shots
139
- if @mutli
150
+ if @multi
140
151
  return true
141
152
  elsif @failed_shots == false
142
- puts "Failures detected"
153
+ puts "Failures detected:"
154
+
155
+ @dirs.each do |dir, sizes|
156
+ sizes.to_a.sort.each do |size, files|
157
+ file = dir.gsub('__', '/')
158
+ if !files.include?(:diff)
159
+ puts "\t Unable to create a diff image for #{file}"
160
+ elsif files[:data] > wraith.threshold
161
+ puts "\t #{file} failed at a resolution of #{size} (#{files[:data]}% diff)"
162
+ end
163
+ end
164
+ end
165
+
143
166
  exit 1
144
167
  else
145
168
  true
@@ -0,0 +1,79 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
5
+ <style type="text/css">
6
+ .short-screenshot {
7
+ max-width: 200px;
8
+ }
9
+ .panel li{
10
+ word-wrap: break-word;
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div class="container">
16
+ <div class="row page-header">
17
+ <h1>List of screenshots for <%= location %> <small>taken <%= Time.now.strftime('%Y/%m/%d %H:%M:%S') %></small></h1>
18
+ </div>
19
+ <div class="row">
20
+ <div class="col-lg-2">
21
+ <div class="panel">
22
+ <div class="panel-heading">Screenshots:</div>
23
+ <ul class="list-group list-group-flush">
24
+ <% directories.keys.each do |dir| %>
25
+ <li class="list-group-item"><a href="#<%=path%><%=dir%>"><%=dir.gsub('__', '/')%></a></li>
26
+ <% end %>
27
+ </ul>
28
+ </div>
29
+ </div>
30
+ <div class="col-lg-10">
31
+ <% directories.each do |dir, sizes| %>
32
+ <% sizes.to_a.sort.each do |size, files| %>
33
+ <div class="row">
34
+ <a name="<%= dir %>"></a>
35
+ <% if threshold.nil? %>
36
+ <h2><%= dir.gsub('__', '/') %></h2>
37
+ <% else %>
38
+ <% if files[:data] > threshold %>
39
+ <h2 style="color:#CC0101"><%= dir.gsub('__', '/') %> <span class="glyphicon glyphicon-remove"></span></h2>
40
+ <% else %>
41
+ <h2><%= dir.gsub('__', '/') %></h2>
42
+ <% end %>
43
+ <% end %>
44
+ </div>
45
+ <div class="row">
46
+ <h3 class="col-lg-1 text-muted"><%=size%>px</h3>
47
+ <% files[:variants].each do |file| %>
48
+ <div class="col-lg-3">
49
+ <a href="<%=file[:filename]%>">
50
+ <img class="short-screenshot img-thumbnail" src="<%=path%><%=file[:thumb]%>">
51
+ </a>
52
+ <p class="text-center"><%=file[:name]%></p>
53
+ </div>
54
+ <% end %>
55
+ <div class="col-lg-3">
56
+ <% if files[:diff] %>
57
+ <a href="<%=files[:diff][:filename]%>">
58
+ <img class="short-screenshot img-thumbnail" src="<%=path%><%=files[:diff][:thumb]%>">
59
+ </a>
60
+ <% end %>
61
+ <p class="text-center">diff</p>
62
+ <% if threshold.nil? %>
63
+ <p class="text-center text-muted"><%=files[:data]%> % different</p>
64
+ <% else %>
65
+ <% if files[:data] > threshold %>
66
+ <p style="color:#CC0101" class="text-center text-muted"><%=files[:data]%> % different</p>
67
+ <% else %>
68
+ <p class="text-center text-muted"><%=files[:data]%> % different</p>
69
+ <% end %>
70
+ <% end %>
71
+ </div>
72
+ </div>
73
+ <% end %>
74
+ <% end %>
75
+ </div>
76
+ </div>
77
+ </div>
78
+ </body>
79
+ </html>
@@ -0,0 +1,225 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
5
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
6
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
7
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.cycle/3.03/jquery.cycle.all.min.js"></script>
8
+ <style type="text/css">
9
+ body {
10
+ position: relative;
11
+ float: left;
12
+ width: 100%;
13
+ }
14
+ .slideshow {
15
+ height: 510px;
16
+ margin: 20px 0;
17
+ }
18
+ .slide {
19
+ background-color: #FFF !important;
20
+ width: 100% !important;
21
+ height: 510px !important;
22
+ }
23
+ .prev {
24
+ margin-left: -10px;
25
+ margin-right: 10px;
26
+ }
27
+ .next,
28
+ .prev {
29
+ cursor: pointer;
30
+ background-color: #e7e7e7;
31
+ border: 2px solid #eee;
32
+ height: 400px;
33
+ margin-top: 60px;
34
+ }
35
+
36
+ .prev span:before,
37
+ .next span:before {
38
+ font-size: 35px;
39
+ padding: 10px;
40
+ display: block;
41
+ font-family: "FontAwesome";
42
+ margin-top: 165px;
43
+ display: block;
44
+ }
45
+
46
+ .prev span:before {
47
+ content:"\f0d9";
48
+ }
49
+ .next span:before {
50
+ content:"\f0da";
51
+ }
52
+ .list-group-item.checked a:after {
53
+ color: #23e343;
54
+ }
55
+ .list-group-item a span {
56
+ word-wrap: break-word;
57
+ width: 95%;
58
+ display: block;
59
+ }
60
+ .list-group-item a:after {
61
+ content:"\f00c";
62
+ font-family: "FontAwesome";
63
+ color: #eae6e6;
64
+ position: absolute;
65
+ right: 10px;
66
+ top: 10px;
67
+ }
68
+ .checked a {
69
+ color: #000;
70
+ }
71
+ .current {
72
+ background-color: #e7e7e7;
73
+ }
74
+ .threshold {
75
+ color: red;
76
+ }
77
+ .compare {
78
+ cursor: pointer;
79
+ margin-left: 20px;
80
+ }
81
+
82
+ .compare:before {
83
+ font-family: "FontAwesome";
84
+ content:"\f0c5";
85
+ font-size: 30px;
86
+ }
87
+ .compare-modal {
88
+ position:fixed;
89
+ margin:0;
90
+ top:0;
91
+ left:0;
92
+ width: 100%;
93
+ height: 100%;
94
+ background:rgba(0,0,0,0.7);
95
+ overflow: scroll;
96
+ z-index: 1000;
97
+ }
98
+ .compare-container {
99
+ padding-bottom: 300px;
100
+ z-index: 1000;
101
+ margin-top: 20px;
102
+ text-align: center;
103
+ }
104
+ .compare-container img{
105
+ margin-right: 20px;
106
+ max-width: 30%;
107
+ }
108
+ </style>
109
+ <script type="text/javascript">
110
+ $(function() {
111
+ $('.slideshow').cycle({
112
+ fx: 'cover',
113
+ prev: '.prev',
114
+ next: '.next',
115
+ before: function (curr, next, opts) {
116
+ $('.current').removeClass('current');
117
+ var path = $(next).find('.path').attr('name');
118
+ $.each($('.list-group .list-group-item a'), function() {
119
+ if ($(this).attr('href').substring(1) == path) {
120
+ $(this).parent().addClass('checked');
121
+ $(this).parent().addClass('current');
122
+ }
123
+ })
124
+ },
125
+ timeout: 0
126
+ });
127
+
128
+ $('.list-group .list-group-item a').unbind().on('click', function(){
129
+ var href = $(this).attr('href').substring(1);
130
+
131
+ $('.slideshow').cycle($('.slide.'+href+':first').index());
132
+ })
133
+
134
+ $('.shot').unbind().on('click', function(e){
135
+ e.preventDefault();
136
+ var url = $(this).attr('href');
137
+ window.open(url,'_blank');
138
+ })
139
+
140
+ $('.compare').unbind().on('click', function(){
141
+ var slide = $(this).closest(".slide"),
142
+ newImage = slide.find('a.shot:eq(0)').attr('href'),
143
+ oldImage = slide.find('a.shot:eq(1)').attr('href'),
144
+ diffImage = slide.find('a.shot:eq(2)').attr('href');
145
+ $('.container').append('<div class="compare-modal"><div class="compare-container"><img src="'+newImage+'"/><img src="'+oldImage+'"/><img src="'+diffImage+'"/></div></div>');
146
+ $('.compare-modal').unbind().on('click', function(){
147
+ $(this).remove();
148
+ })
149
+ })
150
+ })
151
+ </script>
152
+ </head>
153
+ <body>
154
+ <div class="container">
155
+ <div class="row">
156
+ <div class="col-sm-12 col-md-3">
157
+ <div class="panel">
158
+ <div class="page-header">
159
+ <h4>List of screenshots for <%= location %> <small>taken <%= Time.now.strftime('%Y/%m/%d %H:%M:%S') %></small></h4>
160
+ </div>
161
+ <div class="panel-heading">Pages:</div>
162
+ <ul class="list-group list-group-flush">
163
+ <% directories.keys.each do |dir| %>
164
+ <li class="list-group-item"><a href="#<%=path%><%=dir%>"><span>/<%=dir.gsub('__', '/')%></span></a></li>
165
+ <% end %>
166
+ </ul>
167
+ </div>
168
+ </div>
169
+ <div class="col-sm-12 col-md-9">
170
+ <div class="slideshow-container">
171
+ <div class="prev col-sm-1"><span></span></div>
172
+ <div class="slideshow pull-left col-sm-10">
173
+ <% directories.each do |dir, sizes| %>
174
+ <% sizes.to_a.sort.each do |size, files| %>
175
+ <div class="row slide <%= dir %>">
176
+ <a class="path" name="<%= dir %>"></a>
177
+ <div class="col-sm-12 text-center">
178
+ <% if threshold.nil? %>
179
+ <h4><%=size%>px - /<%= dir.gsub('__', '/') %></h4>
180
+ <% else %>
181
+ <% if files[:data] > threshold %>
182
+ <h4><%=size%>px - /<%= dir.gsub('__', '/') %></h4>
183
+ <% else %>
184
+ <h4><%=size%>px - /<%= dir.gsub('__', '/') %></h4>
185
+ <% end %>
186
+ <% end %>
187
+ </div>
188
+ <% files[:variants].each do |file| %>
189
+ <div class="col-sm-4">
190
+ <a class="shot" href="<%=file[:filename]%>">
191
+ <img class="short-screenshot img-thumbnail" src="<%=path%><%=file[:thumb]%>">
192
+ </a>
193
+ <p class="text-center"><a target="_blank" href="<%=file[:url]%>"><%=file[:name]%></a></p>
194
+ </div>
195
+ <% end %>
196
+ <div class="col-sm-4">
197
+ <% if files[:diff] %>
198
+ <a class="shot" href="<%=files[:diff][:filename]%>">
199
+ <img class="short-screenshot img-thumbnail" src="<%=path%><%=files[:diff][:thumb]%>">
200
+ </a>
201
+ <% end %>
202
+ <p class="text-center">diff</p>
203
+ </div>
204
+ <div class="difference col-sm-12">
205
+ <% if threshold.nil? %>
206
+ <h4 class="text-center text-muted"><%=files[:data]%> % different<span class="compare"></span></h4>
207
+ <% else %>
208
+ <% if files[:data] > threshold %>
209
+ <h4 class="text-center threshold"><%=files[:data]%> % different<span class="compare"></span></h4>
210
+ <% else %>
211
+ <h4 class="text-center text-muted"><%=files[:data]%> % different<span class="compare"></span></h4>
212
+ <% end %>
213
+ <% end %>
214
+ </div>
215
+ </div>
216
+ <% end %>
217
+ <% end %>
218
+ </div>
219
+ <div class="next col-sm-1"><span></span></div>
220
+ </div>
221
+ </div>
222
+ </div>
223
+ </div>
224
+ </body>
225
+ </html>
@@ -37,10 +37,21 @@ class Wraith::SaveImages
37
37
  end
38
38
 
39
39
  def capture_page_image(browser, url, width, file_name, selector, global_before_capture, path_before_capture)
40
- puts `"#{browser}" #{wraith.phantomjs_options} "#{wraith.snap_file}" "#{url}" "#{width}" "#{file_name}" "#{selector}" "#{global_before_capture}" "#{path_before_capture}"`
40
+ command = "#{browser} #{wraith.phantomjs_options} '#{wraith.snap_file}' '#{url}' '#{width}' '#{file_name}' '#{selector}' '#{global_before_capture}' '#{path_before_capture}'"
41
+
42
+ # @TODO - uncomment the following line when we add a verbose mode
43
+ # puts command
44
+ run_command command
41
45
  end
42
46
 
43
- private
47
+ def run_command(command)
48
+ output = []
49
+ IO.popen(command).each do |line|
50
+ puts line
51
+ output << line.chomp!
52
+ end.close
53
+ output
54
+ end
44
55
 
45
56
  def parallel_task(jobs)
46
57
  Parallel.each(jobs, :in_threads => 8) do |_label, _path, width, url, filename, selector, global_before_capture, path_before_capture|
@@ -26,6 +26,6 @@ class Wraith::Thumbnails
26
26
  FileUtils.mkdir_p(File.dirname(output_path))
27
27
  end
28
28
 
29
- `convert #{png_path.shellescape} -thumbnail 200 -crop 200x200+0+0 #{output_path.shellescape}`
29
+ `convert #{png_path.shellescape} -thumbnail 200 -crop #{wraith.thumb_width.to_s}x#{wraith.thumb_height.to_s}+0+0 #{output_path.shellescape}`
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Wraith
2
- VERSION = "2.7.0"
2
+ VERSION = "2.8.0"
3
3
  end
@@ -99,6 +99,33 @@ class Wraith::Wraith
99
99
  @config["threshold"] ? @config["threshold"] : 0
100
100
  end
101
101
 
102
+ def gallery_template
103
+ default = 'basic_template'
104
+ if @config["gallery"].nil?
105
+ default
106
+ else
107
+ @config["gallery"]["template"] || default
108
+ end
109
+ end
110
+
111
+ def thumb_height
112
+ default = 200
113
+ if @config["gallery"].nil?
114
+ default
115
+ else
116
+ @config["gallery"]["thumb_height"] || default
117
+ end
118
+ end
119
+
120
+ def thumb_width
121
+ default = 200
122
+ if @config["gallery"].nil?
123
+ default
124
+ else
125
+ @config["gallery"]["thumb_width"] || default
126
+ end
127
+ end
128
+
102
129
  def phantomjs_options
103
130
  @config["phantomjs_options"]
104
131
  end
@@ -49,6 +49,11 @@ history_dir: 'shots_base'
49
49
  # the directory that your latest screenshots will be stored in
50
50
  directory: 'shots'
51
51
 
52
+ gallery:
53
+ template: 'slideshow_template' # 'basic_template' (default)
54
+ thumb_width: 200
55
+ thumb_height: 200
56
+
52
57
  # choose how results are displayed in the gallery (default is `alphanumeric` if omitted)
53
58
  # Different screen widths are always grouped together.
54
59
  # Options:
@@ -45,6 +45,11 @@ history_dir: 'shots_base'
45
45
  # the directory that your latest screenshots will be stored in
46
46
  directory: 'shots'
47
47
 
48
+ gallery:
49
+ template: 'slideshow_template' # 'basic_template' (default)
50
+ thumb_width: 200
51
+ thumb_height: 200
52
+
48
53
  # choose how results are displayed in the gallery (default is `alphanumeric` if omitted)
49
54
  # Different screen widths are always grouped together.
50
55
  # Options:
@@ -1,6 +1,7 @@
1
1
  # Add as many domains as necessary. Key will act as a label
2
2
  domains:
3
3
  my_site: "http://www.example.com"
4
+ my_other_site: "http://www.test.example.com"
4
5
 
5
6
  # Notice the absence of a `paths` property. When no paths are provided, Wraith defaults to
6
7
  # spidering mode to check your entire website.
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.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Blooman
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-22 00:00:00.000000000 Z
13
+ date: 2015-11-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
@@ -196,7 +196,8 @@ files:
196
196
  - lib/wraith/crop.rb
197
197
  - lib/wraith/folder.rb
198
198
  - lib/wraith/gallery.rb
199
- - lib/wraith/gallery_template/gallery_template.erb
199
+ - lib/wraith/gallery_template/basic_template.erb
200
+ - lib/wraith/gallery_template/slideshow_template.erb
200
201
  - lib/wraith/save_images.rb
201
202
  - lib/wraith/spider.rb
202
203
  - lib/wraith/thumbnails.rb
@@ -1,79 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
5
- <style type="text/css">
6
- .short-screenshot {
7
- max-width: 200px;
8
- }
9
- .panel li{
10
- word-wrap: break-word;
11
- }
12
- </style>
13
- </head>
14
- <body>
15
- <div class="container">
16
- <div class="row page-header">
17
- <h1>List of screenshots for <%= location %> <small>taken <%= Time.now.strftime('%Y/%m/%d %H:%M:%S') %></small></h1>
18
- </div>
19
- <div class="row">
20
- <div class="col-lg-2">
21
- <div class="panel">
22
- <div class="panel-heading">Screenshots:</div>
23
- <ul class="list-group list-group-flush">
24
- <% directories.keys.each do |dir| %>
25
- <li class="list-group-item"><a href="#<%=path%><%=dir%>"><%=dir.gsub('__', '/')%></a></li>
26
- <% end %>
27
- </ul>
28
- </div>
29
- </div>
30
- <div class="col-lg-10">
31
- <% directories.each do |dir, sizes| %>
32
- <% sizes.to_a.sort.each do |size, files| %>
33
- <div class="row">
34
- <a name="<%= dir %>"></a>
35
- <% if threshold.nil? %>
36
- <h2><%= dir.gsub('__', '/') %></h2>
37
- <% else %>
38
- <% if files[:data] > threshold %>
39
- <h2 style="color:#CC0101"><%= dir.gsub('__', '/') %> <span class="glyphicon glyphicon-remove"></span></h2>
40
- <% else %>
41
- <h2><%= dir.gsub('__', '/') %></h2>
42
- <% end %>
43
- <% end %>
44
- </div>
45
- <div class="row">
46
- <h3 class="col-lg-1 text-muted"><%=size%>px</h3>
47
- <% files[:variants].each do |file| %>
48
- <div class="col-lg-3">
49
- <a href="<%=file[:filename]%>">
50
- <img class="short-screenshot img-thumbnail" src="<%=path%><%=file[:thumb]%>">
51
- </a>
52
- <p class="text-center"><%=file[:name]%></p>
53
- </div>
54
- <% end %>
55
- <div class="col-lg-3">
56
- <% if files[:diff] %>
57
- <a href="<%=files[:diff][:filename]%>">
58
- <img class="short-screenshot img-thumbnail" src="<%=path%><%=files[:diff][:thumb]%>">
59
- </a>
60
- <% end %>
61
- <p class="text-center">diff</p>
62
- <% if threshold.nil? %>
63
- <p class="text-center text-muted"><%=files[:data]%> % different</p>
64
- <% else %>
65
- <% if files[:data] > threshold %>
66
- <p style="color:#CC0101" class="text-center text-muted"><%=files[:data]%> % different</p>
67
- <% else %>
68
- <p class="text-center text-muted"><%=files[:data]%> % different</p>
69
- <% end %>
70
- <% end %>
71
- </div>
72
- </div>
73
- <% end %>
74
- <% end %>
75
- </div>
76
- </div>
77
- </div>
78
- </body>
79
- </html>