site_validator 1.1.1 → 1.2.0

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.
@@ -2,9 +2,9 @@
2
2
 
3
3
  Site-wide markup validator. Validate a whole web site on the W3C Markup Validator, from the command line, and generate a comprehensive report of all errors found.
4
4
 
5
- This is the command-line version of http://markupvalidator.com
5
+ This is the command-line version of http://sitevalidator.com
6
6
 
7
- http://markupvalidator.com/images/gem.png
7
+ http://sitevalidator.com/images/gem.png
8
8
 
9
9
  = Installation:
10
10
 
@@ -1,7 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- require 'open-uri'
4
- require 'open_uri_redirections'
5
3
  require 'nokogiri'
6
4
  require 'metainspector'
7
5
  require 'timeout'
@@ -56,7 +54,7 @@ module SiteValidator
56
54
  def pages_in_sitemap
57
55
  pages = xml_locations.select {|loc| looks_like_html?(loc.text)}.map {|loc| SiteValidator::Page.new(loc.text)}
58
56
  if pages.empty?
59
- m = MetaInspector.new(url, :timeout => timeout)
57
+ m = MetaInspector.new(url, :timeout => timeout, :allow_redirections => :all)
60
58
  links = [m.url]
61
59
 
62
60
  m.internal_links.select {|l| looks_like_html?(l)}.map {|l| l.split('#')[0]}.uniq.each do |link|
@@ -87,7 +85,7 @@ module SiteValidator
87
85
  end
88
86
 
89
87
  def doc
90
- @doc ||= open(url, :allow_safe_redirections => true)
88
+ @doc ||= open(url, :allow_redirections => :all)
91
89
  end
92
90
  end
93
91
  end
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset=utf-8>
5
- <title>SiteValidator report for <%= @url %></title>
5
+ <title>Site Validator report for <%= @url %></title>
6
6
  <link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">
7
7
 
8
8
  <style type="text/css">
@@ -57,11 +57,11 @@
57
57
  <div class="topbar">
58
58
  <div class="fill">
59
59
  <div class="container">
60
- <a class="brand" href="http://markupvalidator.com"><strong>SiteValidator</strong></a>
60
+ <a class="brand" href="http://sitevalidator.com"><strong>Site Validator</strong></a>
61
61
  <ul class="nav" data-dropdown="dropdown" >
62
- <li><a href="http://markupvalidator.com/faqs">FAQs</a></li>
63
- <li><a href="http://markupvalidator.com/plans-and-pricing">Plans and pricing</a></li>
64
- <li><a href="http://markupvalidator.com/contact">Contact</a></li>
62
+ <li><a href="http://sitevalidator.com/faqs">FAQs</a></li>
63
+ <li><a href="http://sitevalidator.com/plans-and-pricing">Plans and pricing</a></li>
64
+ <li><a href="http://sitevalidator.com/contact">Contact</a></li>
65
65
  </ul>
66
66
  </div>
67
67
  </div>
@@ -167,7 +167,7 @@
167
167
 
168
168
  <footer>
169
169
  <p>This markup validation report has been generated using the <a href="https://github.com/jaimeiniesta/site_validator">SiteValidator</a> gem.</p>
170
- <p>You can also find an online version that lets you store the results and re-check the URLs later, at <a href="http://markupvalidator.com">markupvalidator.com</a>.</p>
170
+ <p>You can also find an online version that lets you store the results and re-check the URLs later, at <a href="http://sitevalidator.com">sitevalidator.com</a>.</p>
171
171
  <p><strong>SiteValidator</strong> is a lovely site-wide markup validator. We're not associated with the W3C but we love it!</p>
172
172
  </footer>
173
173
  </div>
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module SiteValidator
4
- VERSION = "1.1.1"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -15,13 +15,12 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = SiteValidator::VERSION
17
17
 
18
- gem.add_dependency 'w3c_validators', '~> 1.2'
19
- gem.add_dependency 'nokogiri', '~> 1.5.3'
20
- gem.add_dependency 'open_uri_redirections', '0.0.1'
21
- gem.add_dependency 'metainspector', '~> 1.13.1'
18
+ gem.add_dependency 'w3c_validators', '~> 1.2'
19
+ gem.add_dependency 'nokogiri', '~> 1.5.3'
20
+ gem.add_dependency 'metainspector', '~> 1.15.0'
22
21
 
23
- gem.add_development_dependency 'rspec', '~> 2.5.0'
24
- gem.add_development_dependency 'mocha', '~> 0.11.4'
25
- gem.add_development_dependency 'rake', '~> 0.9.2'
22
+ gem.add_development_dependency 'rspec', '~> 2.5.0'
23
+ gem.add_development_dependency 'mocha', '~> 0.11.4'
24
+ gem.add_development_dependency 'rake', '~> 0.9.2'
26
25
  gem.add_development_dependency 'fakeweb', '~> 1.3.0'
27
26
  end
@@ -0,0 +1,23 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx
3
+ Date: Mon, 03 Dec 2012 11:37:51 GMT
4
+ Content-Type: text/html; charset=utf-8
5
+ Connection: keep-alive
6
+ Status: 200 OK
7
+ X-Runtime: 10
8
+ ETag: "a9e1dd587bb233eb670ec06f7d553dbc"
9
+ X-Frame-Options: deny
10
+ Set-Cookie: _gh_sess=BAh7BzoPc2Vzc2lvbl9pZCIlZTc4ZDNlOGEwM2NlZDQ3Y2VhMDdlMTQyOTA4NWVmYzA6EF9jc3JmX3Rva2VuIjE0U2xsYUoybFFNSWxhWEtudHNvalJCVjZtVnJZcFVlRVk4WlpMbEZKWktRPQ%3D%3D--8ea4a235fd3c5e727d462e24b992fabd8f50050d; path=/; expires=Sat, 01-Jan-2022 00:00:00 GMT; secure; HttpOnly
11
+ Content-Length: 21814
12
+ Cache-Control: private, max-age=0, must-revalidate
13
+ Strict-Transport-Security: max-age=2592000
14
+
15
+ <html>
16
+ <body>
17
+ <h1>Hello from Unsafe</h1>
18
+ <p>
19
+ <a href="/1.html">one</a>
20
+ <a href="/2.html">two</a>
21
+ </p>
22
+ </body>
23
+ </html>
@@ -0,0 +1,9 @@
1
+ HTTP/1.1 301 Moved Permanently
2
+ Server: nginx
3
+ Date: Mon, 03 Dec 2012 11:36:17 GMT
4
+ Content-Type: text/html
5
+ Content-Length: 178
6
+ Connection: close
7
+ Location: http://unsafe.com/
8
+
9
+ Redirecting to http://unsafe.com.
@@ -15,6 +15,7 @@ describe SiteValidator::Sitemap do
15
15
  @sitemap_for_absolute_urls = SiteValidator::Sitemap.new('http://markupvalidator.com/faqs')
16
16
  @sitemap_international = SiteValidator::Sitemap.new('http://example.com/international')
17
17
  @sitemap_with_safe_redirect = SiteValidator::Sitemap.new('http://github.com')
18
+ @sitemap_with_unsafe_redirect = SiteValidator::Sitemap.new('https://unsafe.com')
18
19
 
19
20
  MarkupValidator.any_instance.stubs(:validate_uri).returns(stubbed_validator_results)
20
21
  end
@@ -77,6 +78,14 @@ describe SiteValidator::Sitemap do
77
78
  @sitemap_with_safe_redirect.pages.length.should == 37
78
79
  end
79
80
 
81
+ it "should follow unsafe (https => http) redirects" do
82
+ expect {
83
+ @sitemap_with_unsafe_redirect.pages
84
+ }.to_not raise_error
85
+
86
+ @sitemap_with_unsafe_redirect.pages.length.should == 3
87
+ end
88
+
80
89
  it "should get correct absolute links for internal pages" do
81
90
  @sitemap_for_absolute_urls.pages.length.should == 9
82
91
  @sitemap_for_absolute_urls.pages.map {|p| p.url}
@@ -19,6 +19,8 @@ FakeWeb.register_uri(:get, "http://markupvalidator.com/faqs", :response => open(
19
19
  FakeWeb.register_uri(:get, "http://example.com/international", :response => open("#{$samples_dir}/international.response").read)
20
20
  FakeWeb.register_uri(:get, "http://github.com", :response => open("#{$samples_dir}/http_github.response").read)
21
21
  FakeWeb.register_uri(:get, "https://github.com", :response => open("#{$samples_dir}/https_github.response").read)
22
+ FakeWeb.register_uri(:get, "https://unsafe.com", :response => open("#{$samples_dir}/https_unsafe_redirect.response").read)
23
+ FakeWeb.register_uri(:get, "http://unsafe.com", :response => open("#{$samples_dir}/http_unsafe_redirect.response").read)
22
24
 
23
25
  def message_text(message_id)
24
26
  message_texts = {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_validator
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
8
+ - 2
9
+ - 0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jaime Iniesta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-13 00:00:00 Z
18
+ date: 2013-01-19 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: w3c_validators
@@ -48,42 +48,26 @@ dependencies:
48
48
  version: 1.5.3
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: open_uri_redirections
53
- prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
57
- - - "="
58
- - !ruby/object:Gem::Version
59
- hash: 29
60
- segments:
61
- - 0
62
- - 0
63
- - 1
64
- version: 0.0.1
65
- type: :runtime
66
- version_requirements: *id003
67
51
  - !ruby/object:Gem::Dependency
68
52
  name: metainspector
69
53
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
71
55
  none: false
72
56
  requirements:
73
57
  - - ~>
74
58
  - !ruby/object:Gem::Version
75
- hash: 33
59
+ hash: 43
76
60
  segments:
77
61
  - 1
78
- - 13
79
- - 1
80
- version: 1.13.1
62
+ - 15
63
+ - 0
64
+ version: 1.15.0
81
65
  type: :runtime
82
- version_requirements: *id004
66
+ version_requirements: *id003
83
67
  - !ruby/object:Gem::Dependency
84
68
  name: rspec
85
69
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
70
+ requirement: &id004 !ruby/object:Gem::Requirement
87
71
  none: false
88
72
  requirements:
89
73
  - - ~>
@@ -95,11 +79,11 @@ dependencies:
95
79
  - 0
96
80
  version: 2.5.0
97
81
  type: :development
98
- version_requirements: *id005
82
+ version_requirements: *id004
99
83
  - !ruby/object:Gem::Dependency
100
84
  name: mocha
101
85
  prerelease: false
102
- requirement: &id006 !ruby/object:Gem::Requirement
86
+ requirement: &id005 !ruby/object:Gem::Requirement
103
87
  none: false
104
88
  requirements:
105
89
  - - ~>
@@ -111,11 +95,11 @@ dependencies:
111
95
  - 4
112
96
  version: 0.11.4
113
97
  type: :development
114
- version_requirements: *id006
98
+ version_requirements: *id005
115
99
  - !ruby/object:Gem::Dependency
116
100
  name: rake
117
101
  prerelease: false
118
- requirement: &id007 !ruby/object:Gem::Requirement
102
+ requirement: &id006 !ruby/object:Gem::Requirement
119
103
  none: false
120
104
  requirements:
121
105
  - - ~>
@@ -127,11 +111,11 @@ dependencies:
127
111
  - 2
128
112
  version: 0.9.2
129
113
  type: :development
130
- version_requirements: *id007
114
+ version_requirements: *id006
131
115
  - !ruby/object:Gem::Dependency
132
116
  name: fakeweb
133
117
  prerelease: false
134
- requirement: &id008 !ruby/object:Gem::Requirement
118
+ requirement: &id007 !ruby/object:Gem::Requirement
135
119
  none: false
136
120
  requirements:
137
121
  - - ~>
@@ -143,7 +127,7 @@ dependencies:
143
127
  - 0
144
128
  version: 1.3.0
145
129
  type: :development
146
- version_requirements: *id008
130
+ version_requirements: *id007
147
131
  description: command-line tool to validate the markup of a whole site against the W3C validator
148
132
  email:
149
133
  - jaimeiniesta@gmail.com
@@ -180,7 +164,9 @@ files:
180
164
  - spec/samples/exclusions.xml
181
165
  - spec/samples/guides.rubyonrails.org.html
182
166
  - spec/samples/http_github.response
167
+ - spec/samples/http_unsafe_redirect.response
183
168
  - spec/samples/https_github.response
169
+ - spec/samples/https_unsafe_redirect.response
184
170
  - spec/samples/international.response
185
171
  - spec/samples/markup_validator_faqs.response
186
172
  - spec/samples/protocol_relative.html