nanoc 4.9.2 → 4.9.3
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 +6 -0
- data/lib/nanoc/base/contracts_support.rb +1 -3
- data/lib/nanoc/cli/error_handler.rb +1 -1
- data/lib/nanoc/cli/stack_trace_writer.rb +1 -1
- data/lib/nanoc/filters/relativize_paths.rb +35 -11
- data/lib/nanoc/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d01ae1a36cc8bd7ac120b0f9f26ec0017083ec01086d2c954a45f0e4814b0fa7
|
4
|
+
data.tar.gz: f2bb6242846d090fb321f1136a70f955dba3b43696a0266965c225fb0fb13d7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2180c9c63d7d19d2e87aafa2ffe0094d9685e8b0b821b7bb171ad016009668850c3aab9860f5d78a0704b90f93602f34587c987bcff748aafce1910ca4b43782
|
7
|
+
data.tar.gz: 53285c7562eb828a349f3d2ba42a0c022f4dd83a0e801432e5cffdf7d659e8755e9d742b4bd253d8fe05bef2ea293886892f8d57e270f2109f4f352715ee79f5
|
data/NEWS.md
CHANGED
@@ -6,11 +6,9 @@ module Nanoc::Int
|
|
6
6
|
class Ignorer
|
7
7
|
include Singleton
|
8
8
|
|
9
|
-
# rubocop:disable Style/
|
10
|
-
def method_missing(*_args)
|
9
|
+
def method_missing(*_args) # rubocop:disable Style/MethodMissingSuper
|
11
10
|
self
|
12
11
|
end
|
13
|
-
# rubocop:enable Style/MethodMissing
|
14
12
|
|
15
13
|
def respond_to_missing?(*_args)
|
16
14
|
true
|
@@ -38,7 +38,7 @@ module Nanoc::CLI
|
|
38
38
|
@stream.puts " ... #{error.backtrace.size - count} lines omitted (see crash.log for details)"
|
39
39
|
end
|
40
40
|
|
41
|
-
backtrace.each_with_index.to_a.
|
41
|
+
backtrace.each_with_index.to_a.reverse_each do |(item, index)|
|
42
42
|
if index.zero?
|
43
43
|
@stream.puts " #{item}"
|
44
44
|
else
|
@@ -8,6 +8,8 @@ module Nanoc::Filters
|
|
8
8
|
require 'nanoc/helpers/link_to'
|
9
9
|
include Nanoc::Helpers::LinkTo
|
10
10
|
|
11
|
+
DDMemoize.activate(self)
|
12
|
+
|
11
13
|
SELECTORS = ['*/@href', '*/@src', 'object/@data', 'param[@name="movie"]/@content', 'form/@action', 'comment()'].freeze
|
12
14
|
|
13
15
|
GCSE_SEARCH_WORKAROUND = 'nanoc__gcse_search__f7ac3462f628a053f86fe6563c0ec98f1fe45cee'
|
@@ -41,7 +43,7 @@ module Nanoc::Filters
|
|
41
43
|
# Filter
|
42
44
|
case params[:type]
|
43
45
|
when :css
|
44
|
-
relativize_css(content)
|
46
|
+
relativize_css(content, params)
|
45
47
|
when :html, :html5, :xml, :xhtml
|
46
48
|
relativize_html_like(content, params)
|
47
49
|
else
|
@@ -53,15 +55,37 @@ module Nanoc::Filters
|
|
53
55
|
|
54
56
|
protected
|
55
57
|
|
56
|
-
def relativize_css(content)
|
58
|
+
def relativize_css(content, params)
|
57
59
|
# FIXME: parse CSS the proper way using csspool or something
|
58
60
|
content.gsub(/url\((['"]?)(\/(?:[^\/].*?)?)\1\)/) do
|
59
61
|
quote = Regexp.last_match[1]
|
60
62
|
path = Regexp.last_match[2]
|
61
|
-
|
63
|
+
|
64
|
+
if exclude?(path, params)
|
65
|
+
Regexp.last_match[0]
|
66
|
+
else
|
67
|
+
'url(' + quote + relative_path_to(path) + quote + ')'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
memoized def excludes(params)
|
73
|
+
raw = [params.fetch(:exclude, [])].flatten
|
74
|
+
raw.map do |exclusion|
|
75
|
+
case exclusion
|
76
|
+
when Regexp
|
77
|
+
exclusion
|
78
|
+
when String
|
79
|
+
/\A#{exclusion}(\z|\/)/
|
80
|
+
end
|
62
81
|
end
|
63
82
|
end
|
64
83
|
|
84
|
+
def exclude?(path, params)
|
85
|
+
# TODO: Use #match? on newer Ruby versions
|
86
|
+
excludes(params).any? { |ex| path =~ ex }
|
87
|
+
end
|
88
|
+
|
65
89
|
def relativize_html_like(content, params)
|
66
90
|
selectors = params.fetch(:select, SELECTORS)
|
67
91
|
namespaces = params.fetch(:namespaces, {})
|
@@ -71,7 +95,7 @@ module Nanoc::Filters
|
|
71
95
|
parser = parser_for(type)
|
72
96
|
content = fix_content(content, type)
|
73
97
|
|
74
|
-
nokogiri_process(content, selectors, namespaces, parser, type, nokogiri_save_options)
|
98
|
+
nokogiri_process(content, selectors, namespaces, parser, type, nokogiri_save_options, params)
|
75
99
|
end
|
76
100
|
|
77
101
|
def parser_for(type)
|
@@ -104,7 +128,7 @@ module Nanoc::Filters
|
|
104
128
|
end
|
105
129
|
end
|
106
130
|
|
107
|
-
def nokogiri_process(content, selectors, namespaces, klass, type, nokogiri_save_options
|
131
|
+
def nokogiri_process(content, selectors, namespaces, klass, type, nokogiri_save_options, params)
|
108
132
|
# Ensure that all prefixes are strings
|
109
133
|
namespaces = namespaces.reduce({}) { |new, (prefix, uri)| new.merge(prefix.to_s => uri) }
|
110
134
|
|
@@ -114,8 +138,8 @@ module Nanoc::Filters
|
|
114
138
|
selector = selectors.map { |sel| "descendant-or-self::#{sel}" }.join('|')
|
115
139
|
doc.xpath(selector, namespaces).each do |node|
|
116
140
|
if node.name == 'comment'
|
117
|
-
nokogiri_process_comment(node, doc, selectors, namespaces, klass, type)
|
118
|
-
elsif path_is_relativizable?(node.content)
|
141
|
+
nokogiri_process_comment(node, doc, selectors, namespaces, klass, type, params)
|
142
|
+
elsif path_is_relativizable?(node.content, params)
|
119
143
|
node.content = relative_path_to(node.content)
|
120
144
|
end
|
121
145
|
end
|
@@ -139,20 +163,20 @@ module Nanoc::Filters
|
|
139
163
|
content.gsub(GCSE_SEARCH_WORKAROUND, 'gcse:search')
|
140
164
|
end
|
141
165
|
|
142
|
-
def nokogiri_process_comment(node, doc, selectors, namespaces, klass, type)
|
166
|
+
def nokogiri_process_comment(node, doc, selectors, namespaces, klass, type, params)
|
143
167
|
content = node.content.dup.sub(%r{^(\s*\[.+?\]>\s*)(.+?)(\s*<!\[endif\])}m) do |_m|
|
144
168
|
beginning = Regexp.last_match[1]
|
145
169
|
body = Regexp.last_match[2]
|
146
170
|
ending = Regexp.last_match[3]
|
147
171
|
|
148
|
-
beginning + nokogiri_process(body, selectors, namespaces, klass, type) + ending
|
172
|
+
beginning + nokogiri_process(body, selectors, namespaces, klass, type, nil, params) + ending
|
149
173
|
end
|
150
174
|
|
151
175
|
node.replace(Nokogiri::XML::Comment.new(doc, content))
|
152
176
|
end
|
153
177
|
|
154
|
-
def path_is_relativizable?(path)
|
155
|
-
path.start_with?('/')
|
178
|
+
def path_is_relativizable?(path, params)
|
179
|
+
path.start_with?('/') && !exclude?(path, params)
|
156
180
|
end
|
157
181
|
end
|
158
182
|
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.9.
|
4
|
+
version: 4.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -437,7 +437,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
437
437
|
version: '0'
|
438
438
|
requirements: []
|
439
439
|
rubyforge_project:
|
440
|
-
rubygems_version: 2.7.
|
440
|
+
rubygems_version: 2.7.7
|
441
441
|
signing_key:
|
442
442
|
specification_version: 4
|
443
443
|
summary: A static-site generator with a focus on flexibility.
|