nanoc 4.11.5 → 4.11.6
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 +4 -4
- data/NEWS.md +14 -0
- data/lib/nanoc/base/services/outdatedness_checker.rb +4 -1
- data/lib/nanoc/base/views/config_view.rb +6 -0
- data/lib/nanoc/checking/checks/external_links.rb +1 -1
- data/lib/nanoc/checking/checks/internal_links.rb +16 -14
- data/lib/nanoc/cli/commands/view.rb +2 -2
- data/lib/nanoc/extra/link_collector.rb +58 -16
- data/lib/nanoc/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f496f51806769179378bf62baf2dbb44b25d30d693b6633e660e4fcbb231018
|
4
|
+
data.tar.gz: 0f5537bcfaf52c942b5f9e700f6db79cea7e377a26ff5efa06ee1f268d0b5bbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d2c628542ba571d14a032338e4f8cc7ccf27d35836f727056d8fb68621065118dfdd3f5f53bf91eea5734de66cfde6f74478345f748129a88f30c9fd47dec6e
|
7
|
+
data.tar.gz: 89e5f4747eb9596dc3af6c905600672ba1be957d350f13508443836450d58121bb81fa6082efe8fed95763fe3fec2298bfa36f543021c2343ebc4dcd0bc9905e
|
data/NEWS.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Nanoc news
|
2
2
|
|
3
|
+
## 4.11.6 (2019-07-06)
|
4
|
+
|
5
|
+
Fixes:
|
6
|
+
|
7
|
+
* Fixed crash in the `show-data` command when printing layout outdatedness (#1432)
|
8
|
+
* Fixed crash in the `view` command when host/port is not specified
|
9
|
+
|
10
|
+
Enhancements:
|
11
|
+
|
12
|
+
* Added `#env_name` to `@config` (#1437)
|
13
|
+
* Made the `external_links` checker detect more kinds of broken links (#1422) [Daniel Aleksandersen]
|
14
|
+
* Made the `external_links` checker shuffle the list of links (#1429) [Daniel Aleksandersen]
|
15
|
+
|
3
16
|
## 4.11.5 (2019-04-30)
|
4
17
|
|
5
18
|
Fixes:
|
@@ -18,6 +31,7 @@ Enhancements:
|
|
18
31
|
|
19
32
|
* Set a User-Agent for HTTP requests made by the `external_links` check (#1417) [Daniel Aleksandersen]
|
20
33
|
* Added `atom:link[type]` attributes (#1415) [Daniel Aleksandersen]
|
34
|
+
* Made the `external_links` check treat permanent redirects as errors (#1419) [Daniel Aleksandersen]
|
21
35
|
|
22
36
|
## 4.11.2 (2019-02-16)
|
23
37
|
|
@@ -156,11 +156,14 @@ module Nanoc
|
|
156
156
|
@_basic ||= Basic.new(outdatedness_checker: self, reps: @reps)
|
157
157
|
end
|
158
158
|
|
159
|
-
contract
|
159
|
+
contract C_OBJ, Hamster::Set => C::Bool
|
160
160
|
def outdated_due_to_dependencies?(obj, processed = Hamster::Set.new)
|
161
161
|
# Convert from rep to item if necessary
|
162
162
|
obj = obj.item if obj.is_a?(Nanoc::Core::ItemRep)
|
163
163
|
|
164
|
+
# Only items can have dependencies
|
165
|
+
return false unless obj.is_a?(Nanoc::Core::Item)
|
166
|
+
|
164
167
|
# Get from cache
|
165
168
|
if @objects_outdated_due_to_dependencies.key?(obj)
|
166
169
|
return @objects_outdated_due_to_dependencies[obj]
|
@@ -53,6 +53,12 @@ module Nanoc
|
|
53
53
|
@config.each(&block)
|
54
54
|
end
|
55
55
|
|
56
|
+
# @see Configuration#env_name
|
57
|
+
def env_name
|
58
|
+
@context.dependency_tracker.bounce(_unwrap, attributes: true)
|
59
|
+
@config.env_name
|
60
|
+
end
|
61
|
+
|
56
62
|
# @see Hash#dig
|
57
63
|
def dig(*keys)
|
58
64
|
@context.dependency_tracker.bounce(_unwrap, attributes: keys.take(1))
|
@@ -12,7 +12,7 @@ module ::Nanoc::Checking::Checks
|
|
12
12
|
# TODO: de-duplicate this (duplicated in internal links check)
|
13
13
|
filenames = output_html_filenames.reject { |f| excluded_file?(f) }
|
14
14
|
hrefs_with_filenames = ::Nanoc::Extra::LinkCollector.new(filenames, :external).filenames_per_href
|
15
|
-
results = select_invalid(hrefs_with_filenames.keys)
|
15
|
+
results = select_invalid(hrefs_with_filenames.keys.shuffle)
|
16
16
|
|
17
17
|
# Report them
|
18
18
|
results.each do |res|
|
@@ -16,10 +16,8 @@ module Nanoc::Checking::Checks
|
|
16
16
|
def run
|
17
17
|
# TODO: de-duplicate this (duplicated in external links check)
|
18
18
|
filenames = output_html_filenames
|
19
|
-
|
20
|
-
resource_uris_with_filenames = ::Nanoc::Extra::LinkCollector.new(filenames, :internal).filenames_per_resource_uri
|
19
|
+
uris = ::Nanoc::Extra::LinkCollector.new(filenames, :internal).filenames_per_href
|
21
20
|
|
22
|
-
uris = hrefs_with_filenames.merge(resource_uris_with_filenames)
|
23
21
|
uris.each_pair do |href, fns|
|
24
22
|
fns.each do |filename|
|
25
23
|
next if valid?(href, filename)
|
@@ -39,11 +37,23 @@ module Nanoc::Checking::Checks
|
|
39
37
|
# FIXME: this is ugly and won’t always be correct
|
40
38
|
return true if href == '.'
|
41
39
|
|
40
|
+
# Turn file: into output_dir-as-root relative paths
|
41
|
+
|
42
|
+
output_dir = @config.output_dir
|
43
|
+
output_dir += '/' unless output_dir.end_with?('/')
|
44
|
+
base_uri = URI("file://#{output_dir}")
|
45
|
+
path = href.sub(/#{base_uri.to_s}/, '').sub(/file:\/{1,3}/, '')
|
46
|
+
|
47
|
+
path = "/#{path}" unless path.start_with?('/')
|
48
|
+
|
42
49
|
# Skip hrefs that are specified in the exclude configuration
|
43
|
-
return true if excluded?(
|
50
|
+
return true if excluded?(path, origin)
|
44
51
|
|
45
|
-
#
|
46
|
-
path =
|
52
|
+
# Make an absolute path
|
53
|
+
path = ::File.join(output_dir, path[1..path.length])
|
54
|
+
|
55
|
+
# Remove fragment
|
56
|
+
path = path.sub(/#.*$/, '')
|
47
57
|
return true if path.empty?
|
48
58
|
|
49
59
|
# Remove query string
|
@@ -53,14 +63,6 @@ module Nanoc::Checking::Checks
|
|
53
63
|
# Decode URL (e.g. '%20' -> ' ')
|
54
64
|
path = CGI.unescape(path)
|
55
65
|
|
56
|
-
# Make absolute
|
57
|
-
path =
|
58
|
-
if path[0, 1] == '/'
|
59
|
-
@config.output_dir + path
|
60
|
-
else
|
61
|
-
::File.expand_path(path, ::File.dirname(origin))
|
62
|
-
end
|
63
|
-
|
64
66
|
# Check whether file exists
|
65
67
|
return true if File.file?(path)
|
66
68
|
|
@@ -31,8 +31,8 @@ module Nanoc::CLI::Commands
|
|
31
31
|
root: File.absolute_path(config.output_dir),
|
32
32
|
live: options[:'live-reload'],
|
33
33
|
index_filenames: config[:index_filenames],
|
34
|
-
host: options
|
35
|
-
port: options
|
34
|
+
host: options[:host],
|
35
|
+
port: options[:port],
|
36
36
|
handler: options[:handler],
|
37
37
|
)
|
38
38
|
|
@@ -3,16 +3,24 @@
|
|
3
3
|
module ::Nanoc::Extra
|
4
4
|
# @api private
|
5
5
|
class LinkCollector
|
6
|
+
# HTML5 element attributes
|
6
7
|
URI_ATTRS = {
|
7
|
-
'a' =>
|
8
|
-
'
|
9
|
-
'
|
10
|
-
'
|
11
|
-
'
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
8
|
+
'a' => %i[href ping],
|
9
|
+
'area' => %i[href ping],
|
10
|
+
'audio' => %i[src],
|
11
|
+
'base' => %i[href],
|
12
|
+
'blockquote' => %i[cite],
|
13
|
+
'form' => %i[action],
|
14
|
+
'iframe' => %i[src],
|
15
|
+
'img' => %i[src srcset],
|
16
|
+
'link' => %i[href],
|
17
|
+
'object' => %i[data],
|
18
|
+
'script' => %i[src],
|
19
|
+
'source' => %i[src srcset],
|
20
|
+
'video' => %i[poster src],
|
15
21
|
}.freeze
|
22
|
+
# HTML+RDFa global URI attributes
|
23
|
+
GLOBAL_ATTRS = %i[about resource].freeze
|
16
24
|
|
17
25
|
def initialize(filenames, mode = nil)
|
18
26
|
Nanoc::Extra::JRubyNokogiriWarner.check_and_warn
|
@@ -25,7 +33,7 @@ module ::Nanoc::Extra
|
|
25
33
|
when :external
|
26
34
|
->(h) { external_href?(h) }
|
27
35
|
when :internal
|
28
|
-
->(h) {
|
36
|
+
->(h) { internal_href?(h) }
|
29
37
|
else
|
30
38
|
raise ArgumentError, 'Expected mode argument to be :internal, :external or nil'
|
31
39
|
end
|
@@ -40,15 +48,25 @@ module ::Nanoc::Extra
|
|
40
48
|
end
|
41
49
|
|
42
50
|
def external_href?(href)
|
51
|
+
return false if internal_href?(href)
|
52
|
+
|
43
53
|
href =~ %r{^(\/\/|[a-z\-]+:)}
|
44
54
|
end
|
45
55
|
|
56
|
+
def internal_href?(href)
|
57
|
+
return false if href.nil?
|
58
|
+
|
59
|
+
href.start_with?('file:/')
|
60
|
+
end
|
61
|
+
|
62
|
+
# all links
|
46
63
|
def hrefs_in_file(filename)
|
47
|
-
uris_in_file filename,
|
64
|
+
uris_in_file filename, nil
|
48
65
|
end
|
49
66
|
|
67
|
+
# embedded resources, used by the mixed-content checker
|
50
68
|
def resource_uris_in_file(filename)
|
51
|
-
uris_in_file filename, %w[audio form img
|
69
|
+
uris_in_file filename, %w[audio base form iframe img link object script source video]
|
52
70
|
end
|
53
71
|
|
54
72
|
private
|
@@ -67,16 +85,40 @@ module ::Nanoc::Extra
|
|
67
85
|
|
68
86
|
def uris_in_file(filename, tag_names)
|
69
87
|
uris = Set.new
|
88
|
+
base_uri = URI("file://#{filename}")
|
70
89
|
doc = Nokogiri::HTML(::File.read(filename))
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
90
|
+
doc.traverse do |tag|
|
91
|
+
next unless tag_names.nil? || tag_names.include?(tag.name)
|
92
|
+
|
93
|
+
attrs = []
|
94
|
+
attrs += URI_ATTRS[tag.name] unless URI_ATTRS[tag.name].nil?
|
95
|
+
attrs += GLOBAL_ATTRS if tag_names.nil?
|
96
|
+
next if attrs.nil?
|
97
|
+
|
98
|
+
attrs.each do |attr_name|
|
99
|
+
next if tag[attr_name].nil?
|
100
|
+
|
101
|
+
if attr_name == :srcset
|
102
|
+
uris = uris.merge(tag[attr_name].split(',').map { |v| v.strip.split[0].strip }.compact)
|
103
|
+
elsif %i[about ping resource].include?(attr_name)
|
104
|
+
uris = uris.merge(tag[attr_name].split.map(&:strip).compact)
|
105
|
+
else
|
106
|
+
uris << tag[attr_name.to_s]
|
107
|
+
end
|
75
108
|
end
|
76
109
|
end
|
77
110
|
|
78
111
|
# Strip fragment
|
79
|
-
uris.map! { |
|
112
|
+
uris.map! { |uri| uri.gsub(/#.*$/, '') }
|
113
|
+
|
114
|
+
# Resolve paths relative to the filename, return invalid URIs as-is
|
115
|
+
uris.map! do |uri|
|
116
|
+
begin
|
117
|
+
URI.join(base_uri, uri).to_s
|
118
|
+
rescue
|
119
|
+
uri
|
120
|
+
end
|
121
|
+
end
|
80
122
|
|
81
123
|
uris.select(&@filter)
|
82
124
|
end
|
data/lib/nanoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.11.
|
4
|
+
version: 4.11.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 4.11.
|
61
|
+
version: 4.11.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 4.11.
|
68
|
+
version: 4.11.6
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: parallel
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
401
401
|
- !ruby/object:Gem::Version
|
402
402
|
version: '0'
|
403
403
|
requirements: []
|
404
|
-
rubygems_version: 3.0.
|
404
|
+
rubygems_version: 3.0.4
|
405
405
|
signing_key:
|
406
406
|
specification_version: 4
|
407
407
|
summary: A static-site generator with a focus on flexibility.
|