validate-website 0.9.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/validate_website/core.rb +93 -80
- data/lib/validate_website/option_parser.rb +58 -136
- data/lib/validate_website/validator.rb +13 -13
- data/man/man1/validate-website-static.1 +6 -16
- data/man/man1/validate-website.1 +6 -21
- data/spec/core_spec.rb +37 -8
- data/spec/data/html5-linuxfr.html +1049 -291
- data/spec/data/news/ryzom-naissance-du-projet-libre-ryzom-forge.md +0 -0
- data/spec/validator_spec.rb +3 -3
- metadata +18 -3
- data/lib/validate_website/rspec.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 278cca47ee331ef1b68e0c64aaca600af25917d6
|
4
|
+
data.tar.gz: cdb2ba927605214d326b080d5dad5afe4a6a4930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fde7934823f6e0b41d4baa22a784758c756d104ed2a91429585c50291be9b4e3bf9da60f978fe82bdba05e22d01b5157f0bace57a6f5c3398f6492117e941775
|
7
|
+
data.tar.gz: bf687a37f1a933a981a1696e88ef0b00f311c46db635170b2021faf46475bb44c5612715abbedd96a14cb05e159954716d058e056e09db97ec118c221e1953ca
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'set'
|
4
4
|
require 'open-uri'
|
5
|
+
require 'webrick/cookie'
|
5
6
|
|
6
7
|
require 'validate_website/option_parser'
|
7
8
|
require 'validate_website/validator'
|
@@ -13,7 +14,7 @@ module ValidateWebsite
|
|
13
14
|
# Core class for static or website validation
|
14
15
|
class Core
|
15
16
|
attr_accessor :site
|
16
|
-
attr_reader :options, :crawler
|
17
|
+
attr_reader :options, :crawler, :errors_count, :not_founds_count, :host
|
17
18
|
|
18
19
|
include ColorfulMessages
|
19
20
|
|
@@ -25,37 +26,27 @@ module ValidateWebsite
|
|
25
26
|
PING_URL = 'http://www.google.com/'
|
26
27
|
|
27
28
|
def initialize(options = {}, validation_type = :crawl)
|
28
|
-
@
|
29
|
-
@
|
30
|
-
|
29
|
+
@not_founds_count = 0
|
30
|
+
@errors_count = 0
|
31
31
|
@options = Parser.parse(options, validation_type)
|
32
|
-
|
33
|
-
@file = @options[:file]
|
34
|
-
if @file
|
35
|
-
# truncate file
|
36
|
-
open(@file, 'w').write('')
|
37
|
-
end
|
38
|
-
|
39
32
|
@site = @options[:site]
|
33
|
+
puts color(:note, "validating #{@site}\n", @options[:color])
|
40
34
|
end
|
41
35
|
|
42
|
-
##
|
43
|
-
#
|
44
36
|
# @param [Hash] options
|
45
|
-
# :quiet [Boolean] no output (true, false)
|
46
37
|
# :color [Boolean] color output (true, false)
|
47
38
|
# :exclude [String] a String used by Regexp.new
|
48
|
-
# :
|
39
|
+
# :markup [Boolean] Check the markup validity
|
49
40
|
# :not_found [Boolean] Check for not found page (404)
|
50
41
|
#
|
51
|
-
def crawl(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
puts color(:note, "validating #{@site}", opts[:color]) unless opts[:quiet]
|
42
|
+
def crawl(options = {})
|
43
|
+
@options = @options.to_hash.merge(options)
|
44
|
+
@options.merge!(ignore_links: @options[:exclude]) if @options[:exclude]
|
56
45
|
puts color(:warning, "No internet connection") unless internet_connection?
|
57
46
|
|
58
|
-
@
|
47
|
+
@host = URI(@site).host
|
48
|
+
@crawler = Spidr.site(@site, @options) do |crawler|
|
49
|
+
crawler.cookies[@host] = default_cookies if @options[:cookies]
|
59
50
|
crawler.every_css_page do |page|
|
60
51
|
extract_urls_from_css(page).each do |u|
|
61
52
|
crawler.enqueue(u)
|
@@ -67,75 +58,98 @@ module ValidateWebsite
|
|
67
58
|
crawler.enqueue(i)
|
68
59
|
end
|
69
60
|
|
70
|
-
if
|
71
|
-
validate(page.doc, page.body, page.url,
|
61
|
+
if @options[:markup] && page.html?
|
62
|
+
validate(page.doc, page.body, page.url, @options[:ignore])
|
72
63
|
end
|
73
64
|
end
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
puts color(:error, "#{url} linked but not exist", opts[:color])
|
79
|
-
to_file(url)
|
66
|
+
if @options[:not_found]
|
67
|
+
crawler.every_failed_url do |url|
|
68
|
+
not_found_error(url)
|
80
69
|
end
|
81
70
|
end
|
82
71
|
end
|
72
|
+
print_status_line(@crawler.history.size,
|
73
|
+
@crawler.failures.size,
|
74
|
+
@not_founds_count,
|
75
|
+
@errors_count)
|
83
76
|
end
|
84
77
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
def crawl_static(opts = {})
|
92
|
-
opts = @options.merge(opts)
|
93
|
-
puts color(:note, "validating #{@site}", opts[:color])
|
78
|
+
# @param [Hash] options
|
79
|
+
#
|
80
|
+
def crawl_static(options = {})
|
81
|
+
@options = @options.to_hash.merge(options)
|
82
|
+
@site = @options[:site]
|
94
83
|
|
95
|
-
files = Dir.glob(
|
84
|
+
files = Dir.glob(@options[:pattern])
|
96
85
|
files.each do |f|
|
97
86
|
next unless File.file?(f)
|
98
87
|
|
99
|
-
response =
|
100
|
-
page = Spidr::Page.new(URI.
|
88
|
+
response = fake_httpresponse(open(f).read)
|
89
|
+
page = Spidr::Page.new(URI.join(@site, URI.encode(f)), response)
|
101
90
|
|
102
|
-
if
|
103
|
-
|
104
|
-
end
|
105
|
-
if opts[:not_found]
|
106
|
-
check_static_not_found(page.links)
|
107
|
-
end
|
91
|
+
validate(page.doc, page.body, f) if @options[:markup]
|
92
|
+
check_static_not_found(page.links) if @options[:not_found]
|
108
93
|
end
|
94
|
+
print_status_line(files.size, 0, @not_founds_count, @errors_count)
|
95
|
+
end
|
96
|
+
|
97
|
+
def errors?
|
98
|
+
@errors_count > 0
|
99
|
+
end
|
100
|
+
|
101
|
+
def not_founds?
|
102
|
+
@not_founds_count > 0
|
109
103
|
end
|
110
104
|
|
111
105
|
def exit_status
|
112
|
-
if
|
106
|
+
if errors? && not_founds?
|
113
107
|
EXIT_FAILURE_MARKUP_NOT_FOUND
|
114
|
-
elsif
|
108
|
+
elsif errors?
|
115
109
|
EXIT_FAILURE_MARKUP
|
116
|
-
elsif
|
110
|
+
elsif not_founds?
|
117
111
|
EXIT_FAILURE_NOT_FOUND
|
118
112
|
else
|
119
113
|
EXIT_SUCCESS
|
120
114
|
end
|
121
115
|
end
|
122
116
|
|
117
|
+
def default_cookies
|
118
|
+
WEBrick::Cookie.parse(@options[:cookies]).inject({}) do |hash, cookie|
|
119
|
+
hash[cookie.name] = cookie.value
|
120
|
+
hash
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
123
124
|
private
|
124
125
|
|
125
|
-
def
|
126
|
-
|
127
|
-
|
126
|
+
def internet_connection?
|
127
|
+
true if open(ValidateWebsite::Core::PING_URL)
|
128
|
+
rescue
|
129
|
+
false
|
130
|
+
end
|
131
|
+
|
132
|
+
def static_site_link(l)
|
133
|
+
link = URI.parse(URI.encode(l))
|
134
|
+
link = URI.join(@site, link) if link.host.nil?
|
135
|
+
link
|
136
|
+
end
|
137
|
+
|
138
|
+
def in_static_domain?(site, link)
|
139
|
+
URI.parse(site).host == link.host
|
128
140
|
end
|
129
141
|
|
130
142
|
# check files linked on static document
|
131
143
|
# see lib/validate_website/runner.rb
|
132
144
|
def check_static_not_found(links)
|
133
145
|
links.each do |l|
|
134
|
-
|
135
|
-
|
146
|
+
link = static_site_link(l)
|
147
|
+
next unless in_static_domain?(@site, link)
|
148
|
+
file_path = URI.parse(File.join(Dir.getwd, link.path || '/')).path
|
149
|
+
not_found_error(file_path) && next unless File.exist?(file_path)
|
136
150
|
# Check CSS url()
|
137
|
-
if File.extname(
|
138
|
-
response =
|
151
|
+
if File.extname(file_path) == '.css'
|
152
|
+
response = fake_httpresponse(open(file_path).read, ['text/css'])
|
139
153
|
css_page = Spidr::Page.new(l, response)
|
140
154
|
links.concat extract_urls_from_css(css_page)
|
141
155
|
links.uniq!
|
@@ -143,10 +157,10 @@ module ValidateWebsite
|
|
143
157
|
end
|
144
158
|
end
|
145
159
|
|
146
|
-
def not_found_error
|
147
|
-
|
148
|
-
puts color(:error, "#{
|
149
|
-
|
160
|
+
def not_found_error(location)
|
161
|
+
puts "\n"
|
162
|
+
puts color(:error, "#{location} linked but not exist", @options[:color])
|
163
|
+
@not_founds_count += 1
|
150
164
|
end
|
151
165
|
|
152
166
|
# Extract urls from CSS page
|
@@ -178,28 +192,19 @@ module ValidateWebsite
|
|
178
192
|
# @param [Nokogiri::HTML::Document] original_doc
|
179
193
|
# @param [String] The raw HTTP response body of the page
|
180
194
|
# @param [String] url
|
181
|
-
# @param [
|
182
|
-
# :quiet no output (true, false)
|
183
|
-
# :color color output (true, false)
|
195
|
+
# @param [Regexp] Errors to ignore
|
184
196
|
#
|
185
|
-
def validate(doc, body, url,
|
186
|
-
|
187
|
-
validator = Validator.new(doc, body, opts)
|
188
|
-
msg = " well formed? #{validator.valid?}"
|
189
|
-
# TODO: create a formatter
|
197
|
+
def validate(doc, body, url, ignore = nil)
|
198
|
+
validator = Validator.new(doc, body, ignore)
|
190
199
|
if validator.valid?
|
191
|
-
|
192
|
-
print color(:success, '.', opts[:color]) # rspec style
|
193
|
-
else
|
194
|
-
print color(:info, url, opts[:color])
|
195
|
-
puts color(:success, msg, opts[:color])
|
196
|
-
end
|
200
|
+
print color(:success, '.', options[:color]) # rspec style
|
197
201
|
else
|
198
|
-
@
|
199
|
-
|
200
|
-
puts color(:error,
|
201
|
-
|
202
|
-
|
202
|
+
@errors_count += 1
|
203
|
+
puts "\n"
|
204
|
+
puts color(:error, "* #{url}", options[:color])
|
205
|
+
if options[:verbose]
|
206
|
+
puts color(:error, validator.errors.join(', '), options[:color])
|
207
|
+
end
|
203
208
|
end
|
204
209
|
end
|
205
210
|
|
@@ -209,7 +214,7 @@ module ValidateWebsite
|
|
209
214
|
# @param [String] response body
|
210
215
|
# @param [Array] content types
|
211
216
|
# @return [Net::HTTPResponse] fake http response
|
212
|
-
def
|
217
|
+
def fake_httpresponse(body, content_types = ['text/html', 'text/xhtml+xml'])
|
213
218
|
response = Net::HTTPResponse.new '1.1', 200, 'OK'
|
214
219
|
response.instance_variable_set(:@read, true)
|
215
220
|
response.body = body
|
@@ -218,5 +223,13 @@ module ValidateWebsite
|
|
218
223
|
end
|
219
224
|
response
|
220
225
|
end
|
226
|
+
|
227
|
+
def print_status_line(total, failures, not_founds, errors)
|
228
|
+
puts "\n\n"
|
229
|
+
puts color(:info, ["#{total} visited",
|
230
|
+
"#{failures} failures",
|
231
|
+
"#{not_founds} not founds",
|
232
|
+
"#{errors} errors"].join(', '), @options[:color])
|
233
|
+
end
|
221
234
|
end
|
222
235
|
end
|
@@ -1,172 +1,94 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
require '
|
2
|
+
require 'slop'
|
3
3
|
|
4
4
|
module ValidateWebsite
|
5
5
|
# Internal class for parse command line args
|
6
6
|
class Parser
|
7
|
-
|
8
|
-
|
7
|
+
DEFAULT_OPTIONS = {
|
8
|
+
markup: true,
|
9
9
|
# crawler: log not found url (404 status code)
|
10
10
|
# static: log not found url (not on filesystem, `pwd` considered
|
11
11
|
# as root « / »)
|
12
12
|
not_found: false,
|
13
|
-
quiet: false,
|
14
13
|
file: nil,
|
15
14
|
# regex to ignore certain validation errors
|
16
|
-
|
15
|
+
ignore: nil,
|
17
16
|
color: true,
|
18
17
|
# internal verbose for ValidateWebsite
|
19
18
|
verbose: false,
|
20
19
|
}
|
21
20
|
|
22
|
-
|
21
|
+
DEFAULT_OPTIONS_CRAWL = {
|
23
22
|
site: 'http://localhost:3000/',
|
24
23
|
exclude: nil,
|
25
|
-
|
24
|
+
user_agent: nil,
|
25
|
+
}.merge(DEFAULT_OPTIONS)
|
26
26
|
|
27
|
-
|
27
|
+
DEFAULT_OPTIONS_STATIC = {
|
28
28
|
site: 'http://www.example.com/',
|
29
29
|
pattern: '**/*.html',
|
30
|
-
}.merge(
|
30
|
+
}.merge(DEFAULT_OPTIONS)
|
31
31
|
|
32
32
|
def self.parse(options, type)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
else
|
38
|
-
@default_opts.merge(options)
|
39
|
-
end
|
33
|
+
const = "DEFAULT_OPTIONS_#{type.to_s.upcase}"
|
34
|
+
fail ArgumentError unless const_defined?(const)
|
35
|
+
if Array === options
|
36
|
+
send("command_line_parse_#{type}", options)
|
40
37
|
else
|
41
|
-
|
38
|
+
const_get(const).merge(options)
|
42
39
|
end
|
43
40
|
end
|
44
41
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
validity of your documents)
|
52
|
-
o.separator ''
|
42
|
+
# Parse command line for validate-website bin
|
43
|
+
# @params [ARGV]
|
44
|
+
# @return [Hash]
|
45
|
+
def self.command_line_parse_crawl(_args)
|
46
|
+
Slop.parse(help: true) do
|
47
|
+
banner 'Usage: validate-website [OPTIONS]'
|
53
48
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
o.on("-c", "--cookies 'COOKIES'", String,
|
72
|
-
"Set defaults cookies") { |v|
|
73
|
-
options[:cookies] = v
|
74
|
-
}
|
75
|
-
|
76
|
-
o.on("-m", "--[no-]markup-validation",
|
77
|
-
%(Markup validation \
|
78
|
-
(Default: #{@default_opts[:markup_validation]}))) { |v|
|
79
|
-
options[:markup_validation] = v
|
80
|
-
}
|
81
|
-
o.on("-i", "--ignore-errors 'IGNORE'", String,
|
82
|
-
"Validation errors to ignore (regex)") { |v|
|
83
|
-
options[:ignore_errors] = v
|
84
|
-
}
|
85
|
-
o.on("-n", "--not-found",
|
86
|
-
"Log not found url (Default: #{@default_opts[:not_found]})") { |v|
|
87
|
-
options[:not_found] = v
|
88
|
-
}
|
89
|
-
o.on("--[no-]color",
|
90
|
-
"Show colored output (Default: #{@default_opts[:color]})") { |v|
|
91
|
-
options[:color] = v
|
92
|
-
}
|
93
|
-
o.on("-v", "--verbose",
|
94
|
-
%(Show validator errors \
|
95
|
-
(Default: #{@default_opts[:verbose]}))) { |v|
|
96
|
-
options[:verbose] = v
|
97
|
-
}
|
98
|
-
o.on("-q", "--quiet",
|
99
|
-
"Only report errors (Default: #{@default_opts[:quiet]})") { |v|
|
100
|
-
options[:quiet] = v
|
101
|
-
}
|
102
|
-
|
103
|
-
o.separator ""
|
104
|
-
o.on_tail("-h", "--help", "Show this help message.") do
|
105
|
-
puts o
|
106
|
-
exit
|
107
|
-
end
|
49
|
+
on("s", "site=", "Website to crawl",
|
50
|
+
default: DEFAULT_OPTIONS_CRAWL[:site])
|
51
|
+
on(:u, :user_agent=, "Change user agent",
|
52
|
+
default: DEFAULT_OPTIONS_CRAWL[:user_agent])
|
53
|
+
on("e", "exclude=", "Url to exclude (ex: 'redirect|news')",
|
54
|
+
type: :regexp)
|
55
|
+
on("c", "cookies=", "Set defaults cookies")
|
56
|
+
on("m", "markup", "Markup validation",
|
57
|
+
default: DEFAULT_OPTIONS_CRAWL[:markup])
|
58
|
+
on("i", "ignore=", "Validation errors to ignore",
|
59
|
+
type: :regexp)
|
60
|
+
on(:n, :not_found, "Log not found url",
|
61
|
+
default: DEFAULT_OPTIONS_CRAWL[:not_found])
|
62
|
+
on("color", "Show colored output",
|
63
|
+
default: DEFAULT_OPTIONS_CRAWL[:color])
|
64
|
+
on("v", "verbose", "Show validator errors",
|
65
|
+
default: DEFAULT_OPTIONS_CRAWL[:verbose])
|
108
66
|
end
|
109
|
-
command_line_parse!(opts, args, options)
|
110
67
|
end
|
111
68
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
your documents)
|
119
|
-
o.separator ''
|
69
|
+
# Parse command line for validate-website-static bin
|
70
|
+
# @params [ARGV]
|
71
|
+
# @return [Hash]
|
72
|
+
def self.command_line_parse_static(_args)
|
73
|
+
Slop.parse(help: true) do
|
74
|
+
banner 'Usage: validate-website-static [OPTIONS]'
|
120
75
|
|
121
|
-
|
122
|
-
|
123
|
-
(
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
(
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
"Validation errors to ignore (regex)") { |v|
|
137
|
-
options[:ignore_errors] = v
|
138
|
-
}
|
139
|
-
|
140
|
-
o.on("-m", "--[no-]markup-validation",
|
141
|
-
%(Markup validation \
|
142
|
-
(Default: #{@default_opts[:markup_validation]}))) { |v|
|
143
|
-
options[:markup_validation] = v
|
144
|
-
}
|
145
|
-
o.on("-n", "--not-found",
|
146
|
-
%(Log files not on filesystem, pwd considered as root « / » \
|
147
|
-
(Default: #{@default_opts[:not_found]}))) { |v|
|
148
|
-
options[:not_found] = v
|
149
|
-
}
|
150
|
-
o.on("-v", "--verbose",
|
151
|
-
%(Show validator errors \
|
152
|
-
(Default: #{@default_opts[:verbose]}))) { |v|
|
153
|
-
options[:verbose] = v
|
154
|
-
}
|
155
|
-
o.on("-q", "--quiet",
|
156
|
-
"Only report errors (Default: #{@default_opts[:quiet]})") { |v|
|
157
|
-
options[:quiet] = v
|
158
|
-
}
|
76
|
+
on("s", "site=", "Website to crawl",
|
77
|
+
default: DEFAULT_OPTIONS_STATIC[:site])
|
78
|
+
on("p", "pattern=", "Change filenames pattern",
|
79
|
+
type: :regexp, default: DEFAULT_OPTIONS_STATIC[:pattern])
|
80
|
+
on("c", "cookies=", "Set defaults cookies")
|
81
|
+
on("m", "markup", "Markup validation",
|
82
|
+
default: DEFAULT_OPTIONS_STATIC[:markup])
|
83
|
+
on("i", "ignore=", "Validation errors to ignore",
|
84
|
+
type: :regexp)
|
85
|
+
on(:n, :not_found, "Log not found url",
|
86
|
+
default: DEFAULT_OPTIONS_STATIC[:not_found])
|
87
|
+
on("color", "Show colored output",
|
88
|
+
default: DEFAULT_OPTIONS_STATIC[:color])
|
89
|
+
on("v", "verbose", "Show validator errors",
|
90
|
+
default: DEFAULT_OPTIONS_STATIC[:verbose])
|
159
91
|
end
|
160
|
-
command_line_parse!(opts, args, options)
|
161
|
-
end
|
162
|
-
|
163
|
-
def self.command_line_parse!(opts, args, options)
|
164
|
-
opts.parse!(args)
|
165
|
-
@default_opts.merge(options)
|
166
|
-
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
167
|
-
puts $ERROR_INFO.to_s
|
168
|
-
puts opts
|
169
|
-
exit 128
|
170
92
|
end
|
171
93
|
end
|
172
94
|
end
|
@@ -13,13 +13,15 @@ module ValidateWebsite
|
|
13
13
|
##
|
14
14
|
# @param [Nokogiri::HTML::Document] original_doc
|
15
15
|
# @param [String] The raw HTTP response body of the page
|
16
|
-
|
16
|
+
# @param [Regexp] Errors to ignore
|
17
|
+
#
|
18
|
+
def initialize(original_doc, body, ignore = nil)
|
17
19
|
@original_doc = original_doc
|
18
20
|
@body = body
|
19
|
-
@
|
21
|
+
@ignore = ignore
|
20
22
|
@dtd = @original_doc.internal_subset
|
21
23
|
init_namespace(@dtd)
|
22
|
-
|
24
|
+
@errors = []
|
23
25
|
end
|
24
26
|
|
25
27
|
##
|
@@ -29,12 +31,8 @@ module ValidateWebsite
|
|
29
31
|
end
|
30
32
|
|
31
33
|
def errors
|
32
|
-
|
33
|
-
|
34
|
-
@errors.reject { |e| ignore_re =~ e }
|
35
|
-
else
|
36
|
-
@errors
|
37
|
-
end
|
34
|
+
find_errors
|
35
|
+
@ignore ? @errors.reject { |e| @ignore =~ e } : @errors
|
38
36
|
end
|
39
37
|
|
40
38
|
private
|
@@ -48,14 +46,16 @@ module ValidateWebsite
|
|
48
46
|
@namespace = File.basename(@dtd_uri.path, '.dtd')
|
49
47
|
end
|
50
48
|
|
51
|
-
def
|
52
|
-
@
|
49
|
+
def document
|
50
|
+
return @document if @document
|
53
51
|
if @dtd_uri && @body.match(@dtd_uri.to_s)
|
54
|
-
document = @body.sub(@dtd_uri.to_s, @namespace + '.dtd')
|
52
|
+
@document = @body.sub(@dtd_uri.to_s, @namespace + '.dtd')
|
55
53
|
else
|
56
|
-
document = @body
|
54
|
+
@document = @body
|
57
55
|
end
|
56
|
+
end
|
58
57
|
|
58
|
+
def find_errors
|
59
59
|
@doc = Dir.chdir(XHTML_PATH) do
|
60
60
|
Nokogiri::XML(document) { |cfg|
|
61
61
|
cfg.noent.dtdload.dtdvalid
|
@@ -2,12 +2,12 @@
|
|
2
2
|
.\" Title: validate-website-static
|
3
3
|
.\" Author: [see the "AUTHOR" section]
|
4
4
|
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
5
|
-
.\" Date: 09/
|
5
|
+
.\" Date: 09/26/2014
|
6
6
|
.\" Manual: \ \&
|
7
7
|
.\" Source: \ \&
|
8
8
|
.\" Language: English
|
9
9
|
.\"
|
10
|
-
.TH "VALIDATE\-WEBSITE\-S" "1" "09/
|
10
|
+
.TH "VALIDATE\-WEBSITE\-S" "1" "09/26/2014" "\ \&" "\ \&"
|
11
11
|
.\" -----------------------------------------------------------------
|
12
12
|
.\" * Define some portability stuff
|
13
13
|
.\" -----------------------------------------------------------------
|
@@ -48,23 +48,18 @@ http://www\&.example\&.com/)
|
|
48
48
|
Change filenames pattern (Default: **/*\&.html)
|
49
49
|
.RE
|
50
50
|
.PP
|
51
|
-
\fB\-i\fR, \fB\-\-ignore
|
51
|
+
\fB\-i\fR, \fB\-\-ignore\fR \fIIGNORE\fR
|
52
52
|
.RS 4
|
53
53
|
Ignore certain validation errors (ex:
|
54
54
|
\fIautocorrect\fR)
|
55
55
|
.RE
|
56
56
|
.PP
|
57
|
-
\fB\-
|
58
|
-
.RS 4
|
59
|
-
Save not well formed urls
|
60
|
-
.RE
|
61
|
-
.PP
|
62
|
-
\fB\-m\fR, \fB\-\-[no\-]markup\-validation\fR
|
57
|
+
\fB\-m\fR, \fB\-\-[no\-]markup\fR
|
63
58
|
.RS 4
|
64
59
|
Markup validation (Default: true)
|
65
60
|
.RE
|
66
61
|
.PP
|
67
|
-
\fB\-n\fR, \fB\-\-
|
62
|
+
\fB\-n\fR, \fB\-\-notfound\fR
|
68
63
|
.RS 4
|
69
64
|
Log files not on filesystem, pwd considered as root \(Fo / \(Fc (Default: false)
|
70
65
|
.RE
|
@@ -79,11 +74,6 @@ Show colored output (Default: true)
|
|
79
74
|
Show detail of validator errors (Default: false)\&.
|
80
75
|
.RE
|
81
76
|
.PP
|
82
|
-
\fB\-q\fR, \fB\-\-quiet\fR
|
83
|
-
.RS 4
|
84
|
-
Only report errors (Default: false)\&.
|
85
|
-
.RE
|
86
|
-
.PP
|
87
77
|
\fB\-h\fR, \fB\-\-help\fR
|
88
78
|
.RS 4
|
89
79
|
Show help message and exit\&.
|
@@ -116,4 +106,4 @@ Laurent Arnoud <laurent@spkdev\&.net>
|
|
116
106
|
.sp
|
117
107
|
The MIT License
|
118
108
|
.sp
|
119
|
-
Copyright (c) 2009\-
|
109
|
+
Copyright (c) 2009\-2014 Laurent Arnoud <laurent@spkdev\&.net>
|