nanoc 4.9.0 → 4.9.1

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +16 -0
  3. data/lib/nanoc/base/entities/configuration.rb +6 -0
  4. data/lib/nanoc/base/services/action_provider.rb +1 -1
  5. data/lib/nanoc/base/services/checksummer.rb +1 -1
  6. data/lib/nanoc/base/services/compiler_loader.rb +1 -1
  7. data/lib/nanoc/base/services/pruner.rb +9 -1
  8. data/lib/nanoc/base/views/basic_item_rep_collection_view.rb +1 -1
  9. data/lib/nanoc/base/views/basic_item_rep_view.rb +5 -5
  10. data/lib/nanoc/base/views/basic_item_view.rb +8 -8
  11. data/lib/nanoc/base/views/compilation_item_rep_view.rb +3 -3
  12. data/lib/nanoc/base/views/compilation_item_view.rb +1 -1
  13. data/lib/nanoc/base/views/config_view.rb +6 -6
  14. data/lib/nanoc/base/views/identifiable_collection_view.rb +6 -6
  15. data/lib/nanoc/base/views/mixins/document_view_mixin.rb +15 -15
  16. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +4 -4
  17. data/lib/nanoc/base/views/post_compile_item_rep_view.rb +3 -3
  18. data/lib/nanoc/base/views/post_compile_item_view.rb +2 -2
  19. data/lib/nanoc/base/views/view.rb +2 -2
  20. data/lib/nanoc/checking/checks/stale.rb +1 -1
  21. data/lib/nanoc/cli/commands/create-site.rb +8 -88
  22. data/lib/nanoc/cli/commands/shell.rb +5 -2
  23. data/lib/nanoc/cli/commands/show-rules.rb +1 -1
  24. data/lib/nanoc/cli/logger.rb +5 -3
  25. data/lib/nanoc/filters/relativize_paths.rb +21 -6
  26. data/lib/nanoc/helpers/blogging.rb +8 -2
  27. data/lib/nanoc/helpers/capturing.rb +4 -4
  28. data/lib/nanoc/helpers/filtering.rb +2 -2
  29. data/lib/nanoc/helpers/rendering.rb +1 -1
  30. data/lib/nanoc/rule_dsl/action_provider.rb +3 -3
  31. data/lib/nanoc/spec.rb +3 -3
  32. data/lib/nanoc/version.rb +1 -1
  33. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed74af636c6e396ec74288c853dca19336227108e99d4db697f83a655c50d3fc
4
- data.tar.gz: 9e38014cee26d2f3f88e4e77ea1d9f2c493c78f5613e6e7ea6867d3d0828ce94
3
+ metadata.gz: 9ab127f94d9ffc710fc374831e36f805e16e1fd1bf1dcadfc65d48ce8009d4f8
4
+ data.tar.gz: 4f167936c1d475ce4625875ec5788d99d1f0e22fb0499644e5c632d26bfe0ef1
5
5
  SHA512:
6
- metadata.gz: 44254d1810d3d2bfbbf12b9155035c968d641cdf1880fef342baee260cc4e0fc2fd17731df76b7108292917becb1b2c48902aa87feee47422b33b3941ada97ea
7
- data.tar.gz: 271d3c575afbf515409eb5d635eaf53b0a387e97bea37eaf18a8a424d522a961a2138d36d85cb49b988cfdaae782ab5145b2bc596744b3ef5c3b24853a191f59
6
+ metadata.gz: 3ce94577815ee770cb5e572d232357a60fd4447ab68c101d0a6215e9b45c1f25866433ac90e478475dbccf92cbbf97d5a01c1b6a40198a715a6e5364f68f6064
7
+ data.tar.gz: 38dec7119c8a3239ec8ab5a2922fe4aca8857645446100f6601bffebe75c6ff2414d0b0886bebc633b95f7df8c12ef25a6d59926e1101cc63917584ad13170de
data/NEWS.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.9.1 (2018-02-22)
4
+
5
+ Fixes:
6
+
7
+ * Fixed issue which could cause terminal output to be jumbled up (#1312, #1316)
8
+ * Made pruner ignore `output_dir` configuration attribute when checking for excludes (#1313, #1317)
9
+ * Fixed handling of interrupts (SIGINT) in the `shell` command (#1309, #1318)
10
+ * Added workaround for `relativize_paths` mangling `gcse:search` elements (#1319, #1320)
11
+
12
+ Enhancements:
13
+
14
+ * Allowed overriding `<id>` and `<link rel="alternate">` elements in Atom feed generator (#1301) [Ian Young]
15
+ * Made `sh` an alias for the `shell` command (#1308)
16
+ * Simplified the default configuration (#1311)
17
+ * Removed routing rules from newly-created sites (#1310)
18
+
3
19
  ## 4.9.0 (2018-01-31)
4
20
 
5
21
  Features:
@@ -33,6 +33,7 @@ module Nanoc::Int
33
33
  enable_output_diff: false,
34
34
  prune: { auto_prune: false, exclude: ['.git', '.hg', '.svn', 'CVS'] },
35
35
  string_pattern_type: 'glob',
36
+ action_provider: 'rule_dsl',
36
37
  }.freeze
37
38
 
38
39
  # @return [String, nil] The active environment for the configuration
@@ -158,6 +159,11 @@ module Nanoc::Int
158
159
  self[:output_dir]
159
160
  end
160
161
 
162
+ contract C::None => Symbol
163
+ def action_provider
164
+ self[:action_provider].to_sym
165
+ end
166
+
161
167
  contract C::None => C::IterOf[String]
162
168
  def output_dirs
163
169
  envs = @wrapped.fetch(ENVIRONMENTS_CONFIG_KEY, {})
@@ -13,7 +13,7 @@ module Nanoc::Int
13
13
  raise NotImplementedError
14
14
  end
15
15
 
16
- def action_sequence_for(_rep)
16
+ def action_sequence_for(_obj)
17
17
  raise NotImplementedError
18
18
  end
19
19
 
@@ -176,7 +176,7 @@ module Nanoc::Int
176
176
 
177
177
  class UnwrapUpdateBehavior < UpdateBehavior
178
178
  def self.update(obj, _digest)
179
- yield(obj.unwrap)
179
+ yield(obj._unwrap)
180
180
  end
181
181
  end
182
182
 
@@ -14,7 +14,7 @@ module Nanoc::Int
14
14
  checksum_store =
15
15
  Nanoc::Int::ChecksumStore.new(config: site.config, objects: objects)
16
16
 
17
- action_provider ||= Nanoc::Int::ActionProvider.named(:rule_dsl).for(site)
17
+ action_provider ||= Nanoc::Int::ActionProvider.named(site.config.action_provider).for(site)
18
18
 
19
19
  outdatedness_store =
20
20
  Nanoc::Int::OutdatednessStore.new(config: site.config)
@@ -43,10 +43,18 @@ module Nanoc
43
43
  #
44
44
  # @return [Boolean] true if the given file is excluded, false otherwise
45
45
  def filename_excluded?(filename)
46
- pathname = Pathname.new(filename)
46
+ pathname = Pathname.new(strip_output_dir(filename))
47
47
  @exclude.any? { |e| pathname_components(pathname).include?(e) }
48
48
  end
49
49
 
50
+ def strip_output_dir(filename)
51
+ if filename.start_with?(@config[:output_dir])
52
+ filename[@config[:output_dir].size..-1]
53
+ else
54
+ filename
55
+ end
56
+ end
57
+
50
58
  def pathname_components(pathname)
51
59
  components = []
52
60
  tmp = pathname
@@ -17,7 +17,7 @@ module Nanoc
17
17
  end
18
18
 
19
19
  # @api private
20
- def unwrap
20
+ def _unwrap
21
21
  @item_reps
22
22
  end
23
23
 
@@ -14,7 +14,7 @@ module Nanoc
14
14
  end
15
15
 
16
16
  # @api private
17
- def unwrap
17
+ def _unwrap
18
18
  @item_rep
19
19
  end
20
20
 
@@ -41,7 +41,7 @@ module Nanoc
41
41
  end
42
42
 
43
43
  def snapshot?(name)
44
- @context.dependency_tracker.bounce(unwrap.item, compiled_content: true)
44
+ @context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
45
45
  @item_rep.snapshot?(name)
46
46
  end
47
47
 
@@ -55,7 +55,7 @@ module Nanoc
55
55
  #
56
56
  # @return [String] The item rep’s path.
57
57
  def path(snapshot: :last)
58
- @context.dependency_tracker.bounce(unwrap.item, path: true)
58
+ @context.dependency_tracker.bounce(_unwrap.item, path: true)
59
59
  @item_rep.path(snapshot: snapshot)
60
60
  end
61
61
 
@@ -68,8 +68,8 @@ module Nanoc
68
68
 
69
69
  # @api private
70
70
  def binary?
71
- snapshot_def = unwrap.snapshot_defs.find { |sd| sd.name == :last }
72
- raise Nanoc::Int::Errors::NoSuchSnapshot.new(unwrap, :last) if snapshot_def.nil?
71
+ snapshot_def = _unwrap.snapshot_defs.find { |sd| sd.name == :last }
72
+ raise Nanoc::Int::Errors::NoSuchSnapshot.new(_unwrap, :last) if snapshot_def.nil?
73
73
  snapshot_def.binary?
74
74
  end
75
75
 
@@ -9,11 +9,11 @@ module Nanoc
9
9
  #
10
10
  # @return [Enumerable<Nanoc::CompilationItemView>]
11
11
  def children
12
- unless unwrap.identifier.legacy?
13
- raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(unwrap.identifier)
12
+ unless _unwrap.identifier.legacy?
13
+ raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(_unwrap.identifier)
14
14
  end
15
15
 
16
- children_pattern = Nanoc::Int::Pattern.from(unwrap.identifier.to_s + '*/')
16
+ children_pattern = Nanoc::Int::Pattern.from(_unwrap.identifier.to_s + '*/')
17
17
  children = @context.items.select { |i| children_pattern.match?(i.identifier) }
18
18
 
19
19
  children.map { |i| self.class.new(i, @context) }.freeze
@@ -26,11 +26,11 @@ module Nanoc
26
26
  #
27
27
  # @return [nil] if the item has no parent
28
28
  def parent
29
- unless unwrap.identifier.legacy?
30
- raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(unwrap.identifier)
29
+ unless _unwrap.identifier.legacy?
30
+ raise Nanoc::Int::Errors::CannotGetParentOrChildrenOfNonLegacyItem.new(_unwrap.identifier)
31
31
  end
32
32
 
33
- parent_identifier = '/' + unwrap.identifier.components[0..-2].join('/') + '/'
33
+ parent_identifier = '/' + _unwrap.identifier.components[0..-2].join('/') + '/'
34
34
  parent_identifier = '/' if parent_identifier == '//'
35
35
 
36
36
  parent = @context.items[parent_identifier]
@@ -40,12 +40,12 @@ module Nanoc
40
40
 
41
41
  # @return [Boolean] True if the item is binary, false otherwise
42
42
  def binary?
43
- unwrap.content.binary?
43
+ _unwrap.content.binary?
44
44
  end
45
45
 
46
46
  # @api private
47
47
  def raw_filename
48
- unwrap.content.filename
48
+ _unwrap.content.filename
49
49
  end
50
50
  end
51
51
  end
@@ -15,7 +15,7 @@ module Nanoc
15
15
  #
16
16
  # @return [String] The item rep’s raw path.
17
17
  def raw_path(snapshot: :last)
18
- @context.dependency_tracker.bounce(unwrap.item, compiled_content: true)
18
+ @context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
19
19
 
20
20
  res = @item_rep.raw_path(snapshot: snapshot)
21
21
 
@@ -42,8 +42,8 @@ module Nanoc
42
42
  #
43
43
  # @return [String] The content at the given snapshot.
44
44
  def compiled_content(snapshot: nil)
45
- @context.dependency_tracker.bounce(unwrap.item, compiled_content: true)
46
- @context.snapshot_repo.compiled_content(rep: unwrap, snapshot: snapshot)
45
+ @context.dependency_tracker.bounce(_unwrap.item, compiled_content: true)
46
+ @context.snapshot_repo.compiled_content(rep: _unwrap, snapshot: snapshot)
47
47
  end
48
48
  end
49
49
  end
@@ -39,7 +39,7 @@ module Nanoc
39
39
  #
40
40
  # @return [Nanoc::BasicItemRepCollectionView]
41
41
  def reps
42
- Nanoc::CompilationItemRepCollectionView.new(@context.reps[unwrap], @context)
42
+ Nanoc::CompilationItemRepCollectionView.new(@context.reps[_unwrap], @context)
43
43
  end
44
44
  end
45
45
  end
@@ -12,13 +12,13 @@ module Nanoc
12
12
  end
13
13
 
14
14
  # @api private
15
- def unwrap
15
+ def _unwrap
16
16
  @config
17
17
  end
18
18
 
19
19
  # @see Hash#fetch
20
20
  def fetch(key, fallback = NONE, &_block)
21
- @context.dependency_tracker.bounce(unwrap, attributes: [key])
21
+ @context.dependency_tracker.bounce(_unwrap, attributes: [key])
22
22
  @config.fetch(key) do
23
23
  if !fallback.equal?(NONE)
24
24
  fallback
@@ -32,25 +32,25 @@ module Nanoc
32
32
 
33
33
  # @see Hash#key?
34
34
  def key?(key)
35
- @context.dependency_tracker.bounce(unwrap, attributes: [key])
35
+ @context.dependency_tracker.bounce(_unwrap, attributes: [key])
36
36
  @config.key?(key)
37
37
  end
38
38
 
39
39
  # @see Hash#[]
40
40
  def [](key)
41
- @context.dependency_tracker.bounce(unwrap, attributes: [key])
41
+ @context.dependency_tracker.bounce(_unwrap, attributes: [key])
42
42
  @config[key]
43
43
  end
44
44
 
45
45
  # @see Hash#each
46
46
  def each(&block)
47
- @context.dependency_tracker.bounce(unwrap, attributes: true)
47
+ @context.dependency_tracker.bounce(_unwrap, attributes: true)
48
48
  @config.each(&block)
49
49
  end
50
50
 
51
51
  # @see Hash#dig
52
52
  def dig(*keys)
53
- @context.dependency_tracker.bounce(unwrap, attributes: keys.take(1))
53
+ @context.dependency_tracker.bounce(_unwrap, attributes: keys.take(1))
54
54
  @config.dig(*keys)
55
55
  end
56
56
  end
@@ -13,7 +13,7 @@ module Nanoc
13
13
  end
14
14
 
15
15
  # @api private
16
- def unwrap
16
+ def _unwrap
17
17
  @objects
18
18
  end
19
19
 
@@ -32,14 +32,14 @@ module Nanoc
32
32
  #
33
33
  # @return [self]
34
34
  def each
35
- @context.dependency_tracker.bounce(unwrap, raw_content: true)
35
+ @context.dependency_tracker.bounce(_unwrap, raw_content: true)
36
36
  @objects.each { |i| yield view_class.new(i, @context) }
37
37
  self
38
38
  end
39
39
 
40
40
  # @return [Integer]
41
41
  def size
42
- @context.dependency_tracker.bounce(unwrap, raw_content: true)
42
+ @context.dependency_tracker.bounce(_unwrap, raw_content: true)
43
43
  @objects.size
44
44
  end
45
45
 
@@ -50,7 +50,7 @@ module Nanoc
50
50
  # @return [Enumerable]
51
51
  def find_all(arg = NOTHING, &block)
52
52
  if NOTHING.equal?(arg)
53
- @context.dependency_tracker.bounce(unwrap, raw_content: true)
53
+ @context.dependency_tracker.bounce(_unwrap, raw_content: true)
54
54
  return @objects.select(&block).map { |i| view_class.new(i, @context) }
55
55
  end
56
56
 
@@ -64,7 +64,7 @@ module Nanoc
64
64
  true
65
65
  end
66
66
 
67
- @context.dependency_tracker.bounce(unwrap, raw_content: prop_attribute)
67
+ @context.dependency_tracker.bounce(_unwrap, raw_content: prop_attribute)
68
68
  @objects.find_all(arg).map { |i| view_class.new(i, @context) }
69
69
  end
70
70
 
@@ -101,7 +101,7 @@ module Nanoc
101
101
  true
102
102
  end
103
103
 
104
- @context.dependency_tracker.bounce(unwrap, raw_content: prop_attribute)
104
+ @context.dependency_tracker.bounce(_unwrap, raw_content: prop_attribute)
105
105
  res = @objects[arg]
106
106
  res && view_class.new(res, @context)
107
107
  end
@@ -12,7 +12,7 @@ module Nanoc
12
12
  end
13
13
 
14
14
  # @api private
15
- def unwrap
15
+ def _unwrap
16
16
  @document
17
17
  end
18
18
 
@@ -33,28 +33,28 @@ module Nanoc
33
33
 
34
34
  # @return [Nanoc::Identifier]
35
35
  def identifier
36
- unwrap.identifier
36
+ _unwrap.identifier
37
37
  end
38
38
 
39
39
  # @see Hash#[]
40
40
  def [](key)
41
- @context.dependency_tracker.bounce(unwrap, attributes: [key])
42
- unwrap.attributes[key]
41
+ @context.dependency_tracker.bounce(_unwrap, attributes: [key])
42
+ _unwrap.attributes[key]
43
43
  end
44
44
 
45
45
  # @return [Hash]
46
46
  def attributes
47
47
  # TODO: Refine dependencies
48
- @context.dependency_tracker.bounce(unwrap, attributes: true)
49
- unwrap.attributes
48
+ @context.dependency_tracker.bounce(_unwrap, attributes: true)
49
+ _unwrap.attributes
50
50
  end
51
51
 
52
52
  # @see Hash#fetch
53
53
  def fetch(key, fallback = NONE, &_block)
54
- @context.dependency_tracker.bounce(unwrap, attributes: [key])
54
+ @context.dependency_tracker.bounce(_unwrap, attributes: [key])
55
55
 
56
- if unwrap.attributes.key?(key)
57
- unwrap.attributes[key]
56
+ if _unwrap.attributes.key?(key)
57
+ _unwrap.attributes[key]
58
58
  elsif !fallback.equal?(NONE)
59
59
  fallback
60
60
  elsif block_given?
@@ -66,23 +66,23 @@ module Nanoc
66
66
 
67
67
  # @see Hash#key?
68
68
  def key?(key)
69
- @context.dependency_tracker.bounce(unwrap, attributes: [key])
70
- unwrap.attributes.key?(key)
69
+ @context.dependency_tracker.bounce(_unwrap, attributes: [key])
70
+ _unwrap.attributes.key?(key)
71
71
  end
72
72
 
73
73
  # @api private
74
74
  def reference
75
- unwrap.reference
75
+ _unwrap.reference
76
76
  end
77
77
 
78
78
  # @api private
79
79
  def raw_content
80
- @context.dependency_tracker.bounce(unwrap, raw_content: true)
81
- unwrap.content.string
80
+ @context.dependency_tracker.bounce(_unwrap, raw_content: true)
81
+ _unwrap.content.string
82
82
  end
83
83
 
84
84
  def inspect
85
- "<#{self.class} identifier=#{unwrap.identifier}>"
85
+ "<#{self.class} identifier=#{_unwrap.identifier}>"
86
86
  end
87
87
  end
88
88
  end
@@ -16,7 +16,7 @@ module Nanoc
16
16
  end
17
17
 
18
18
  def raw_content=(arg)
19
- unwrap.content = Nanoc::Int::Content.create(arg)
19
+ _unwrap.content = Nanoc::Int::Content.create(arg)
20
20
  end
21
21
 
22
22
  # Sets the value for the given attribute.
@@ -35,14 +35,14 @@ module Nanoc
35
35
  raise DisallowedAttributeValueError.new(value)
36
36
  end
37
37
 
38
- unwrap.set_attribute(key, value)
38
+ _unwrap.set_attribute(key, value)
39
39
  end
40
40
 
41
41
  # Sets the identifier to the given argument.
42
42
  #
43
43
  # @param [String, Nanoc::Identifier] arg
44
44
  def identifier=(arg)
45
- unwrap.identifier = Nanoc::Identifier.from(arg)
45
+ _unwrap.identifier = Nanoc::Identifier.from(arg)
46
46
  end
47
47
 
48
48
  # Updates the attributes based on the given hash.
@@ -51,7 +51,7 @@ module Nanoc
51
51
  #
52
52
  # @return [self]
53
53
  def update_attributes(hash)
54
- hash.each { |k, v| unwrap.set_attribute(k, v) }
54
+ hash.each { |k, v| _unwrap.set_attribute(k, v) }
55
55
  self
56
56
  end
57
57
  end
@@ -8,17 +8,17 @@ module Nanoc
8
8
 
9
9
  def compiled_content(snapshot: nil)
10
10
  compilation_context = @context.compilation_context
11
- snapshot_contents = compilation_context.compiled_content_cache[unwrap]
11
+ snapshot_contents = compilation_context.compiled_content_cache[_unwrap]
12
12
 
13
13
  snapshot_name = snapshot || (snapshot_contents[:pre] ? :pre : :last)
14
14
 
15
15
  unless snapshot_contents[snapshot_name]
16
- raise Nanoc::Int::Errors::NoSuchSnapshot.new(unwrap, snapshot_name)
16
+ raise Nanoc::Int::Errors::NoSuchSnapshot.new(_unwrap, snapshot_name)
17
17
  end
18
18
 
19
19
  content = snapshot_contents[snapshot_name]
20
20
  if content.binary?
21
- raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(unwrap)
21
+ raise Nanoc::Int::Errors::CannotGetCompiledContentOfBinaryItem.new(_unwrap)
22
22
  end
23
23
 
24
24
  content.string
@@ -3,7 +3,7 @@
3
3
  module Nanoc
4
4
  class PostCompileItemView < Nanoc::CompilationItemView
5
5
  def reps
6
- Nanoc::PostCompileItemRepCollectionView.new(@context.reps[unwrap], @context)
6
+ Nanoc::PostCompileItemRepCollectionView.new(@context.reps[_unwrap], @context)
7
7
  end
8
8
 
9
9
  # @deprecated Use {#modified_reps} instead
@@ -12,7 +12,7 @@ module Nanoc
12
12
  end
13
13
 
14
14
  def modified_reps
15
- reps.select { |rep| rep.unwrap.modified? }
15
+ reps.select { |rep| rep._unwrap.modified? }
16
16
  end
17
17
  end
18
18
  end
@@ -13,7 +13,7 @@ module Nanoc
13
13
  end
14
14
 
15
15
  # @api private
16
- def unwrap
16
+ def _unwrap
17
17
  raise NotImplementedError
18
18
  end
19
19
 
@@ -23,7 +23,7 @@ module Nanoc
23
23
  #
24
24
  # @see Object#frozen?
25
25
  def frozen?
26
- unwrap.frozen?
26
+ _unwrap.frozen?
27
27
  end
28
28
 
29
29
  def inspect
@@ -24,7 +24,7 @@ module Nanoc::Checking::Checks
24
24
  Set.new(
25
25
  @items
26
26
  .flat_map(&:reps)
27
- .map(&:unwrap)
27
+ .map(&:_unwrap)
28
28
  .flat_map(&:raw_paths)
29
29
  .flat_map(&:values)
30
30
  .flatten,
@@ -18,103 +18,30 @@ module Nanoc::CLI::Commands
18
18
  end
19
19
 
20
20
  DEFAULT_CONFIG = <<~EOS unless defined? DEFAULT_CONFIG
21
- # The syntax to use for patterns in the Rules file. Can be either `"glob"`
22
- # (default) or `"legacy"`. The former will enable glob patterns, which behave
23
- # like Ruby’s File.fnmatch. The latter will enable Nanoc 3.x-style patterns.
24
- string_pattern_type: glob
25
-
26
21
  # A list of file extensions that Nanoc will consider to be textual rather than
27
22
  # binary. If an item with an extension not in this list is found, the file
28
23
  # will be considered as binary.
29
24
  text_extensions: #{array_to_yaml(Nanoc::Int::Configuration::DEFAULT_CONFIG[:text_extensions])}
30
25
 
31
- # The path to the directory where all generated files will be written to. This
32
- # can be an absolute path starting with a slash, but it can also be path
33
- # relative to the site directory.
34
- output_dir: #{Nanoc::Int::Configuration::DEFAULT_CONFIG[:output_dir]}
35
-
36
- # A list of index filenames, i.e. names of files that will be served by a web
37
- # server when a directory is requested. Usually, index files are named
38
- # “index.html”, but depending on the web server, this may be something else,
39
- # such as “default.htm”. This list is used by Nanoc to generate pretty URLs.
40
- index_filenames: #{array_to_yaml(Nanoc::Int::Configuration::DEFAULT_CONFIG[:index_filenames])}
41
-
42
- # Whether or not to generate a diff of the compiled content when compiling a
43
- # site. The diff will contain the differences between the compiled content
44
- # before and after the last site compilation.
45
- enable_output_diff: false
46
-
47
26
  prune:
48
- # Whether to automatically remove files not managed by Nanoc from the output
49
- # directory.
50
27
  auto_prune: true
51
28
 
52
- # Which files and directories you want to exclude from pruning. If you version
53
- # your output directory, you should probably exclude VCS directories such as
54
- # .git, .svn etc.
55
- exclude: [ '.git', '.hg', '.svn', 'CVS' ]
56
-
57
- # The data sources where Nanoc loads its data from. This is an array of
58
- # hashes; each array element represents a single data source. By default,
59
- # there is only a single data source that reads data from the “content/” and
60
- # “layout/” directories in the site directory.
61
29
  data_sources:
62
- -
63
- # The type is the identifier of the data source.
64
- type: #{Nanoc::Int::Configuration::DEFAULT_DATA_SOURCE_CONFIG[:type]}
65
-
66
- # The path where items should be mounted (comparable to mount points in
67
- # Unix-like systems). This is “/” by default, meaning that items will have
68
- # “/” prefixed to their identifiers. If the items root were “/en/”
69
- # instead, an item at content/about.html would have an identifier of
70
- # “/en/about/” instead of just “/about/”.
71
- items_root: #{Nanoc::Int::Configuration::DEFAULT_DATA_SOURCE_CONFIG[:items_root]}
72
-
73
- # The path where layouts should be mounted. The layouts root behaves the
74
- # same as the items root, but applies to layouts rather than items.
75
- layouts_root: #{Nanoc::Int::Configuration::DEFAULT_DATA_SOURCE_CONFIG[:layouts_root]}
76
-
77
- # The encoding to use for input files. If your input files are not in
78
- # UTF-8 (which they should be!), change this.
30
+ - type: filesystem
79
31
  encoding: utf-8
80
-
81
- # The kind of identifier to use for items and layouts. The default is
82
- # “full”, meaning that identifiers include file extensions. This can also
83
- # be “legacy”, primarily used by older Nanoc sites.
84
- identifier_type: full
85
-
86
- # Configuration for the “check” command, which run unit tests on the site.
87
- checks:
88
- # Configuration for the “internal_links” checker, which checks whether all
89
- # internal links are valid.
90
- internal_links:
91
- # A list of patterns, specified as regular expressions, to exclude from the check.
92
- # If an internal link matches this pattern, the validity check will be skipped.
93
- # E.g.:
94
- # exclude: ['^/server_status']
95
- exclude: []
96
-
97
- # Configuration for the “external_links” checker, which checks whether all
98
- # external links are valid.
99
- external_links:
100
- # A list of patterns, specified as regular expressions, to exclude from the check.
101
- # If an external link matches this pattern, the validity check will be skipped.
102
- # E.g.:
103
- # exclude: ['^http://example.com$']
104
- exclude: []
105
-
106
- # A list of file patterns, specified as regular expressions, to exclude from the check.
107
- # If a file matches this pattern, the links from this file will not be checked.
108
- # E.g.:
109
- # exclude_files: ['blog/page']
110
- exclude_files: []
111
32
  EOS
112
33
 
113
34
  DEFAULT_RULES = <<~EOS unless defined? DEFAULT_RULES
114
35
  #!/usr/bin/env ruby
115
36
 
37
+ compile '/index.html' do
38
+ layout '/default.*'
39
+ write '/index.html'
40
+ end
41
+
116
42
  compile '/**/*.html' do
117
43
  layout '/default.*'
44
+ write item.identifier.without_ext + '/index.html'
118
45
  end
119
46
 
120
47
  # This is an example rule that matches Markdown (.md) files, and filters them
@@ -124,16 +51,9 @@ EOS
124
51
  #compile '/**/*.md' do
125
52
  # filter :kramdown
126
53
  # layout '/default.*'
54
+ # write item.identifier.without_ext + '/index.html'
127
55
  #end
128
56
 
129
- route '/**/*.{html,md}' do
130
- if item.identifier =~ '/index.*'
131
- '/index.html'
132
- else
133
- item.identifier.without_ext + '/index.html'
134
- end
135
- end
136
-
137
57
  compile '/**/*' do
138
58
  write item.identifier.to_s
139
59
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  usage 'shell'
4
4
  summary 'open a shell on the Nanoc environment'
5
- aliases 'console'
5
+ aliases 'console', 'sh'
6
6
  description "
7
7
  Open an IRB shell on a context that contains @items, @layouts, and @config.
8
8
  "
@@ -13,6 +13,9 @@ module Nanoc::CLI::Commands
13
13
  def run
14
14
  require 'pry'
15
15
 
16
+ # Needed to make pry behave properly sometimes -- see nanoc/nanoc#1309
17
+ Signal.trap('SIGINT') { raise Interrupt }
18
+
16
19
  @site = load_site
17
20
  Nanoc::Int::Compiler.new_for(@site).run_until_preprocessed if options[:preprocess]
18
21
 
@@ -25,7 +28,7 @@ module Nanoc::CLI::Commands
25
28
 
26
29
  def self.reps_for(site)
27
30
  Nanoc::Int::ItemRepRepo.new.tap do |reps|
28
- action_provider = Nanoc::Int::ActionProvider.named(:rule_dsl).for(site)
31
+ action_provider = Nanoc::Int::ActionProvider.named(site.config.action_provider).for(site)
29
32
  builder = Nanoc::Int::ItemRepBuilder.new(site, action_provider, reps)
30
33
  builder.run
31
34
  end
@@ -15,7 +15,7 @@ module Nanoc::CLI::Commands
15
15
  res = Nanoc::Int::Compiler.new_for(site).run_until_reps_built
16
16
  reps = res.fetch(:reps)
17
17
 
18
- action_provider = Nanoc::Int::ActionProvider.named(:rule_dsl).for(site)
18
+ action_provider = Nanoc::Int::ActionProvider.named(site.config.action_provider).for(site)
19
19
  rules = action_provider.rules_collection
20
20
 
21
21
  items = site.items.sort_by(&:identifier)
@@ -28,6 +28,7 @@ module Nanoc::CLI
28
28
 
29
29
  def initialize
30
30
  @level = :high
31
+ @mutex = Mutex.new
31
32
  end
32
33
 
33
34
  # Logs a file-related action.
@@ -63,11 +64,12 @@ module Nanoc::CLI
63
64
  #
64
65
  # @return [void]
65
66
  def log(level, message, io = $stdout)
66
- # Don't log when logging is disabled
67
67
  return if @level == :off
68
+ return if @level != :low && @level != level
68
69
 
69
- # Log when level permits it
70
- io.puts(message) if @level == :low || @level == level
70
+ @mutex.synchronize do
71
+ io.puts(message)
72
+ end
71
73
  end
72
74
  end
73
75
  end
@@ -10,6 +10,8 @@ module Nanoc::Filters
10
10
 
11
11
  SELECTORS = ['*/@href', '*/@src', 'object/@data', 'param[@name="movie"]/@content', 'form/@action', 'comment()'].freeze
12
12
 
13
+ GCSE_SEARCH_WORKAROUND = 'nanoc__gcse_search__f7ac3462f628a053f86fe6563c0ec98f1fe45cee'
14
+
13
15
  # Relativizes all paths in the given content, which can be HTML, XHTML, XML
14
16
  # or CSS. This filter is quite useful if a site needs to be hosted in a
15
17
  # subdirectory instead of a subdomain. In HTML, all `href` and `src`
@@ -106,6 +108,8 @@ module Nanoc::Filters
106
108
  # Ensure that all prefixes are strings
107
109
  namespaces = namespaces.reduce({}) { |new, (prefix, uri)| new.merge(prefix.to_s => uri) }
108
110
 
111
+ content = apply_gcse_search_workaround(content)
112
+
109
113
  doc = content =~ /<html[\s>]/ ? klass.parse(content) : klass.fragment(content)
110
114
  selector = selectors.map { |sel| "descendant-or-self::#{sel}" }.join('|')
111
115
  doc.xpath(selector, namespaces).each do |node|
@@ -116,12 +120,23 @@ module Nanoc::Filters
116
120
  end
117
121
  end
118
122
 
119
- case type
120
- when :html5
121
- doc.to_html(save_with: nokogiri_save_options)
122
- else
123
- doc.send("to_#{type}", save_with: nokogiri_save_options)
124
- end
123
+ output =
124
+ case type
125
+ when :html5
126
+ doc.to_html(save_with: nokogiri_save_options)
127
+ else
128
+ doc.send("to_#{type}", save_with: nokogiri_save_options)
129
+ end
130
+
131
+ revert_gcse_search_workaround(output)
132
+ end
133
+
134
+ def apply_gcse_search_workaround(content)
135
+ content.gsub('gcse:search', GCSE_SEARCH_WORKAROUND)
136
+ end
137
+
138
+ def revert_gcse_search_workaround(content)
139
+ content.gsub(GCSE_SEARCH_WORKAROUND, 'gcse:search')
125
140
  end
126
141
 
127
142
  def nokogiri_process_comment(node, doc, selectors, namespaces, klass, type)
@@ -29,6 +29,8 @@ module Nanoc::Helpers
29
29
 
30
30
  attr_accessor :config
31
31
 
32
+ attr_accessor :alt_link
33
+ attr_accessor :id
32
34
  attr_accessor :limit
33
35
  attr_accessor :relevant_articles
34
36
  attr_accessor :preserve_order
@@ -110,14 +112,14 @@ module Nanoc::Helpers
110
112
  xml.instruct!
111
113
  xml.feed(xmlns: 'http://www.w3.org/2005/Atom', 'xml:base' => root_url) do
112
114
  # Add primary attributes
113
- xml.id root_url
115
+ xml.id(id || root_url)
114
116
  xml.title title
115
117
 
116
118
  # Add date
117
119
  xml.updated(updated.__nanoc_to_iso8601_time)
118
120
 
119
121
  # Add links
120
- xml.link(rel: 'alternate', href: root_url)
122
+ xml.link(rel: 'alternate', href: (alt_link || root_url))
121
123
  xml.link(rel: 'self', href: feed_url)
122
124
 
123
125
  # Add author information
@@ -175,6 +177,8 @@ module Nanoc::Helpers
175
177
  # @option params [Boolean] :preserve_order
176
178
  # @option params [Proc] :content_proc
177
179
  # @option params [Proc] :excerpt_proc
180
+ # @option params [String] :alt_link
181
+ # @option params [String] :id
178
182
  # @option params [String] :title
179
183
  # @option params [String] :author_name
180
184
  # @option params [String] :author_uri
@@ -189,6 +193,8 @@ module Nanoc::Helpers
189
193
  builder = AtomFeedBuilder.new(@config, @item)
190
194
 
191
195
  # Fill builder
196
+ builder.alt_link = params[:alt_link]
197
+ builder.id = params[:id]
192
198
  builder.limit = params[:limit] || 5
193
199
  builder.relevant_articles = params[:articles] || articles || []
194
200
  builder.preserve_order = params.fetch(:preserve_order, false)
@@ -21,7 +21,7 @@ module Nanoc::Helpers
21
21
 
22
22
  # Get existing contents and prep for store
23
23
  snapshot_repo = @item._context.snapshot_repo
24
- rep = @item.reps[:default].unwrap
24
+ rep = @item.reps[:default]._unwrap
25
25
  capture_name = "__capture_#{@name}".to_sym
26
26
  old_content_string =
27
27
  case existing_behavior
@@ -59,12 +59,12 @@ module Nanoc::Helpers
59
59
  end
60
60
 
61
61
  def run
62
- rep = @requested_item.reps[:default].unwrap
62
+ rep = @requested_item.reps[:default]._unwrap
63
63
 
64
64
  # Create dependency
65
- if @item.nil? || @requested_item != @item.unwrap
65
+ if @item.nil? || @requested_item != @item._unwrap
66
66
  dependency_tracker = @config._context.dependency_tracker
67
- dependency_tracker.bounce(@requested_item.unwrap, compiled_content: true)
67
+ dependency_tracker.bounce(@requested_item._unwrap, compiled_content: true)
68
68
 
69
69
  unless rep.compiled?
70
70
  Fiber.yield(Nanoc::Int::Errors::UnmetDependency.new(rep))
@@ -30,9 +30,9 @@ module Nanoc::Helpers
30
30
  filter = klass.new(assigns)
31
31
 
32
32
  # Filter captured data
33
- Nanoc::Int::NotificationCenter.post(:filtering_started, @item_rep.unwrap, filter_name)
33
+ Nanoc::Int::NotificationCenter.post(:filtering_started, @item_rep._unwrap, filter_name)
34
34
  filtered_data = filter.setup_and_run(data, arguments)
35
- Nanoc::Int::NotificationCenter.post(:filtering_ended, @item_rep.unwrap, filter_name)
35
+ Nanoc::Int::NotificationCenter.post(:filtering_ended, @item_rep._unwrap, filter_name)
36
36
 
37
37
  # Append filtered data to buffer
38
38
  buffer = eval('_erbout', block.binding)
@@ -18,7 +18,7 @@ module Nanoc::Helpers
18
18
  layout_view = @layouts[identifier]
19
19
  layout_view ||= @layouts[identifier.__nanoc_cleaned_identifier]
20
20
  raise Nanoc::Int::Errors::UnknownLayout.new(identifier) if layout_view.nil?
21
- layout = layout_view.unwrap
21
+ layout = layout_view._unwrap
22
22
 
23
23
  # Visit
24
24
  dependency_tracker = @config._context.dependency_tracker
@@ -34,8 +34,8 @@ module Nanoc::RuleDSL
34
34
  matching_rules.map(&:rep_name).uniq
35
35
  end
36
36
 
37
- def action_sequence_for(rep)
38
- @action_sequence_calculator[rep]
37
+ def action_sequence_for(obj)
38
+ @action_sequence_calculator[obj]
39
39
  end
40
40
 
41
41
  def need_preprocessing?
@@ -50,7 +50,7 @@ module Nanoc::RuleDSL
50
50
  end
51
51
 
52
52
  site.data_source =
53
- Nanoc::Int::InMemDataSource.new(ctx.items.unwrap, ctx.layouts.unwrap, site.data_source)
53
+ Nanoc::Int::InMemDataSource.new(ctx.items._unwrap, ctx.layouts._unwrap, site.data_source)
54
54
  end
55
55
 
56
56
  def postprocess(site, compiler)
@@ -98,7 +98,7 @@ module Nanoc
98
98
  # @param [String] path The path of the `:last` snapshot of this item representation
99
99
  # @param [Symbol] rep The rep name to create
100
100
  def create_rep(item, path, rep = :default)
101
- rep = Nanoc::Int::ItemRep.new(item.unwrap, rep)
101
+ rep = Nanoc::Int::ItemRep.new(item._unwrap, rep)
102
102
  rep.paths[:last] = [path]
103
103
  @reps << rep
104
104
  self
@@ -112,11 +112,11 @@ module Nanoc
112
112
  end
113
113
 
114
114
  def item=(item)
115
- @item = item ? item.unwrap : nil
115
+ @item = item ? item._unwrap : nil
116
116
  end
117
117
 
118
118
  def item_rep=(item_rep)
119
- @item_rep = item_rep ? item_rep.unwrap : nil
119
+ @item_rep = item_rep ? item_rep._unwrap : nil
120
120
  end
121
121
 
122
122
  # @return [Nanoc::MutableConfigView]
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.9.0'
5
+ VERSION = '4.9.1'
6
6
  end
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.0
4
+ version: 4.9.1
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-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -423,7 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
423
423
  version: '0'
424
424
  requirements: []
425
425
  rubyforge_project:
426
- rubygems_version: 2.7.4
426
+ rubygems_version: 2.7.6
427
427
  signing_key:
428
428
  specification_version: 4
429
429
  summary: A static-site generator with a focus on flexibility.