blinkr 0.3.3 → 0.3.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6d0248a7f8b5ffd6fb131c9bfd554d542fcf4e2
4
- data.tar.gz: cc36b93643ea59c8b2874f31fbec41f0460a353b
3
+ metadata.gz: 1df6688e98868b28398b0bb8cd3e31f4ad47e450
4
+ data.tar.gz: d21bfa1954fbf9f2328c0baefefaff23eee6c98c
5
5
  SHA512:
6
- metadata.gz: a48ff2eb5cc0d25694bc17f6d34c7443199cf4521bd6564e21f197e99bc0d39d6ced7a4169049ff32f6f72c163b771914bd60f298b491b8d873f169cbb70f0ae
7
- data.tar.gz: 521419f058076d99248ed4bf0642a5be3152ad7d698f0089e0d5bf6031d1e8b7f1544b2279712437f2c36ce91008591978aa7d81bf5099ea41e507d77afeb9d6
6
+ metadata.gz: 9db0fb41e32a587e2f20384473ed72642113a35545688f2777de887cb5a085be94baab09ff92832649a8618a927ac6b4f1977f9feb0da34f1ea98210e4812d8a
7
+ data.tar.gz: e2bf502da1bf99a5e98120c934cd0d9507a9afd37bfe1fcf3a43f17cb29cb86f3eb979b921ea4dfbcc7894b514f93b689574c5f4ade17696dd7cb9e980904f2a
@@ -9,7 +9,9 @@ module Blinkr
9
9
  end
10
10
 
11
11
  DEFAULTS = {:skips => [], :ignores => [], :max_retrys => 3, :browser => 'typhoeus',
12
- :viewport => 1200, :phantomjs_threads => 8, :report => 'blinkr.html'}
12
+ :viewport => 1200, :phantomjs_threads => 8, :report => 'blinkr.html',
13
+ :warning_on_300s => false
14
+ }
13
15
 
14
16
  def initialize(hash={})
15
17
  super(DEFAULTS.merge(hash))
@@ -37,9 +37,14 @@ module Blinkr
37
37
  processed = 0
38
38
  # Find the internal links
39
39
  @links.select{|k| k.start_with? @config.base_url}.each do |url, locations|
40
+ # TODO figure out what to do about relative links
40
41
  link = URI.parse(url)
42
+
43
+ # fix up links so they're proper, also drop fragments and queries as they won't be in the sitemap that way
41
44
  link.fragment = nil
42
45
  link.query = nil
46
+ link.path = link.path.gsub(/\/+/, '/') if link.path
47
+
43
48
  unless context.pages.keys.include?(link.to_s) || context.pages.keys.include?((link.to_s + '/'))
44
49
  locations.each do |location|
45
50
  location[:page].errors << Blinkr::Error.new({:severity => :warning,
@@ -60,10 +65,11 @@ module Blinkr
60
65
  external_links.each do |url, metadata|
61
66
  # if link start_with? @config.base_url check to see if it's in the sitemap.xml
62
67
  browser.process(url, @config.max_retrys, :method => :get, :followlocation => true, :timeout => 30,
68
+ :cookiefile => '_tmp/cookies', :cookiejar => '_tmp/cookies',
63
69
  :connecttimeout => 10, :maxredirs => 3) do |resp|
64
70
  puts "Loaded #{url} via #{browser.name} #{'(cached)' if resp.cached?}" if @config.verbose
65
71
 
66
- if resp.code.to_i < 200 || resp.code.to_i > 300
72
+ if resp.code.to_i < 200 || (resp.code.to_i > 300 && @config.warning_on_300s)
67
73
  response = resp
68
74
 
69
75
  metadata.each do |src|
@@ -80,12 +86,12 @@ module Blinkr
80
86
  severity = :warning
81
87
  end
82
88
  src[:page].errors << Blinkr::Error.new({:severity => severity,
83
- :category => 'Resources missing',
84
- :type => '<a href=""> target cannot be loaded',
85
- :url => url, :title => "#{url} (line #{src[:line]})",
86
- :code => response.code.to_i, :message => message,
87
- :detail => detail, :snippet => src[:snippet],
88
- :icon => 'fa-bookmark-o'}) unless response.success?
89
+ :category => 'Resources missing',
90
+ :type => '<a href=""> target cannot be loaded',
91
+ :url => url, :title => "#{url} (line #{src[:line]})",
92
+ :code => response.code.to_i, :message => message,
93
+ :detail => detail, :snippet => src[:snippet],
94
+ :icon => 'fa-bookmark-o'}) unless response.success?
89
95
  end
90
96
  end
91
97
  processed += 1
@@ -39,7 +39,7 @@ module Blinkr
39
39
  lines << elm.line
40
40
  snippets << elm.to_s
41
41
  end
42
- page.errors << Blinkr::Error.new({:severity => :info, :category => 'HTML Compatibility/Correctness',
42
+ page.errors << Blinkr::Error.new({:severity => :danger, :category => 'HTML Compatibility/Correctness',
43
43
  :type => '<title> tag declared more than once',
44
44
  :title => %Q{<title> declared more than once (lines #{lines.join(', ')})},
45
45
  :message => %Q{<title> declared more than onc},
@@ -53,13 +53,13 @@ module Blinkr
53
53
  @titles[title] ||= {}
54
54
  @titles[title][page.response.effective_url] = page
55
55
  if title.length < 20
56
- page.errors << Blinkr::Error.new({:severity => :info, :category => 'SEO', :type => 'page title too short',
56
+ page.errors << Blinkr::Error.new({:severity => :warning, :category => 'SEO', :type => 'page title too short',
57
57
  :title => %Q{<title> too short (line #{elms.first.line})},
58
58
  :message => %Q{<title> too short (< 20 characters)},
59
59
  :snippet => elms.first.to_s, :icon => 'fa-header'})
60
60
  end
61
61
  if title.length > 55
62
- page.errors << Blinkr::Error.new({:severity => :info, :category => 'SEO', :type => 'page title too long',
62
+ page.errors << Blinkr::Error.new({:severity => :warning, :category => 'SEO', :type => 'page title too long',
63
63
  :title => %Q{<title> too long (line #{elms.first.line})},
64
64
  :message => %Q{<title> too long (> 55 characters)},
65
65
  :snippet => elms.first.to_s, :icon => 'fa-header'})
@@ -76,13 +76,13 @@ module Blinkr
76
76
  lines << elm.line
77
77
  snippets << elm.to_s
78
78
  end
79
- page.errors << Blinkr::Error.new({:severity => :info, :category => 'HTML Compatibility/Correctness',
79
+ page.errors << Blinkr::Error.new({:severity => :danger, :category => 'HTML Compatibility/Correctness',
80
80
  :type => '<meta name="description"> tag declared more than once',
81
81
  :title => %Q{<meta name="description"> tag declared more than once (lines #{lines.join(', ')})},
82
82
  :message => %Q{<meta name="description"> tag declared more than once},
83
83
  :snippet => snippets.join('\n'), :icon => 'fa-header'})
84
84
  elsif elms.empty?
85
- page.errors << Blinkr::Error.new({:severity => :info, :category => 'SEO',
85
+ page.errors << Blinkr::Error.new({:severity => :warning, :category => 'SEO',
86
86
  :type => '<meta name="description"> tag missing',
87
87
  :title => %Q{<meta name="description"> tag missing},
88
88
  :message => %Q{<meta name="description"> tag missing},
@@ -92,14 +92,14 @@ module Blinkr
92
92
  @descriptions[desc] ||= {}
93
93
  @descriptions[desc][page.response.effective_url] = page
94
94
  if desc.length < 60
95
- page.errors << Blinkr::Error.new({:severity => :info, :category => 'SEO',
95
+ page.errors << Blinkr::Error.new({:severity => :warning, :category => 'SEO',
96
96
  :type => '<meta name="description"> too short',
97
97
  :title => %Q{<meta name="description"> too short (lines #{elms.first.line})},
98
98
  :message => %Q{<meta name="description"> too short (< 60 characters)},
99
99
  :snippet => elms.first.to_s, :icon => 'fa-header'})
100
100
  end
101
101
  if desc.length > 115
102
- page.errors << Blinkr::Error.new({:severity => :info, :category => 'SEO',
102
+ page.errors << Blinkr::Error.new({:severity => :warning, :category => 'SEO',
103
103
  :type => '<meta name="description"> too long',
104
104
  :title => %Q{<meta name="description"> too long (lines #{elms.first.line})},
105
105
  :message => %Q{<meta name="description"> too long (> 115 characters)},
@@ -30,6 +30,12 @@ module Blinkr
30
30
  # If we have an absolute path URI, join it to the base URL
31
31
  dest_uri = URI.join(base_uri.scheme, base_uri.hostname, base_uri.port, dest_uri) if empty?(dest_uri.scheme) && empty?(dest_uri.hostname)
32
32
 
33
+ # switch multiple '/' to just one. Those types of URIs don't affect the browser,
34
+ # but they do affect our checking
35
+ dest_uri.path = dest_uri.path.gsub(/\/+/, '/') if dest_uri.path
36
+ dest_uri.query = dest_uri.query.gsub(/\/+/, '/') if dest_uri.query
37
+ dest_uri.fragment = dest_uri.query.gsub(/\/+/, '/') if dest_uri.fragment
38
+
33
39
  dest = dest_uri.to_s
34
40
  rescue URI::InvalidURIError, URI::InvalidComponentError, URI::BadURIError
35
41
  # ignored
@@ -1,4 +1,4 @@
1
1
  module Blinkr
2
- VERSION='0.3.3'
2
+ VERSION='0.3.4'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blinkr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Muir
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-24 00:00:00.000000000 Z
12
+ date: 2015-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler