html-proofer 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/htmlproofer +1 -0
- data/lib/html-proofer/check/opengraph.rb +44 -0
- data/lib/html-proofer/configuration.rb +1 -0
- data/lib/html-proofer/runner.rb +1 -0
- data/lib/html-proofer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd65ec0e68209dd5779fe7fc1b7eb2ee685b67b
|
4
|
+
data.tar.gz: e2a1ba66e4ff4294d1cc13d7374c9319abfab422
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 775c6de3a7beb3bd5af2c9897fd3ce2497ffa6e5667e4fce5a7b90b49fa3ab847f78dba354cb7e9628e8fbc4fde5747a89565db0e61964e128262a7b003b347a
|
7
|
+
data.tar.gz: 8c7475082e66945cc1f3b821da41284a0a7500edb73f7902942a3873aaead54a6edf1e04018925a9aa80082a6bfbc086fd5980cc22414e5a792f16e0e0ab2b57
|
data/bin/htmlproofer
CHANGED
@@ -22,6 +22,7 @@ Mercenary.program(:htmlproofer) do |p|
|
|
22
22
|
p.option 'check_favicon', '--check-favicon', 'Enables the favicon checker (default: `false`).'
|
23
23
|
p.option 'check_html', '--check-html', 'Enables HTML validation errors from Nokogiri (default: `false`).'
|
24
24
|
p.option 'check_img_http', '--check-img-http', 'Fails an image if it\'s marked as `http` (default: `false`).'
|
25
|
+
p.option 'check_opengraph', '--check-opengraph', 'Enables the Open Graph checker (default: `false`).'
|
25
26
|
p.option 'directory_index_file', '--directory-index-file', String, 'Sets the file to look for when a link refers to a directory. (default: `index.html`)'
|
26
27
|
p.option 'disable_external', '--disable-external', 'If `true`, does not run the external link checker, which can take a lot of time (default: `false`)'
|
27
28
|
p.option 'empty_alt_ignore', '--empty-alt-ignore', 'If `true`, ignores images with empty alt tags'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class OpenGraphElement < ::HTMLProofer::Element
|
4
|
+
def src
|
5
|
+
@content
|
6
|
+
end
|
7
|
+
|
8
|
+
def url
|
9
|
+
src
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class OpenGraphCheck < ::HTMLProofer::Check
|
14
|
+
def missing_src?
|
15
|
+
!@opengraph.src
|
16
|
+
end
|
17
|
+
|
18
|
+
def empty_src?
|
19
|
+
blank?(@opengraph.src)
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
@html.css('meta[property="og:url"], meta[property="og:image"]').each do |m|
|
24
|
+
@opengraph = OpenGraphElement.new(m, self)
|
25
|
+
|
26
|
+
next if @opengraph.ignore?
|
27
|
+
|
28
|
+
# does the opengraph exist?
|
29
|
+
if missing_src?
|
30
|
+
add_issue('open graph has no content attribute', line: m.line, content: m.content)
|
31
|
+
elsif empty_src?
|
32
|
+
add_issue('open graph content attribute is empty', line: m.line, content: m.content)
|
33
|
+
elsif !@opengraph.valid?
|
34
|
+
add_issue("#{@opengraph.src} is an invalid URL", line: m.line)
|
35
|
+
elsif @opengraph.remote?
|
36
|
+
add_to_external_urls(@opengraph.url)
|
37
|
+
else
|
38
|
+
add_issue("internal open graph #{@opengraph.url} does not exist", line: m.line, content: m.content) unless @opengraph.exists?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
external_urls
|
43
|
+
end
|
44
|
+
end
|
data/lib/html-proofer/runner.rb
CHANGED
@@ -150,6 +150,7 @@ module HTMLProofer
|
|
150
150
|
@checks = HTMLProofer::Check.subchecks.map(&:name)
|
151
151
|
@checks.delete('FaviconCheck') unless @options[:check_favicon]
|
152
152
|
@checks.delete('HtmlCheck') unless @options[:check_html]
|
153
|
+
@checks.delete('OpenGraphCheck') unless @options[:check_opengraph]
|
153
154
|
@options[:checks_to_ignore].each { |ignored| @checks.delete(ignored) }
|
154
155
|
@checks
|
155
156
|
end
|
data/lib/html-proofer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-proofer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -228,6 +228,7 @@ files:
|
|
228
228
|
- lib/html-proofer/check/html.rb
|
229
229
|
- lib/html-proofer/check/images.rb
|
230
230
|
- lib/html-proofer/check/links.rb
|
231
|
+
- lib/html-proofer/check/opengraph.rb
|
231
232
|
- lib/html-proofer/check/scripts.rb
|
232
233
|
- lib/html-proofer/configuration.rb
|
233
234
|
- lib/html-proofer/element.rb
|