nanoc3 3.1.0a2 → 3.1.0a3

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 (46) hide show
  1. data/LICENSE +1 -1
  2. data/NEWS.md +12 -2
  3. data/README.md +2 -0
  4. data/lib/nanoc3/base/code_snippet.rb +6 -2
  5. data/lib/nanoc3/base/compiler.rb +9 -6
  6. data/lib/nanoc3/base/compiler_dsl.rb +15 -9
  7. data/lib/nanoc3/base/data_source.rb +14 -14
  8. data/lib/nanoc3/base/dependency_tracker.rb +9 -9
  9. data/lib/nanoc3/base/directed_graph.rb +6 -7
  10. data/lib/nanoc3/base/errors.rb +48 -13
  11. data/lib/nanoc3/base/filter.rb +62 -16
  12. data/lib/nanoc3/base/item.rb +63 -20
  13. data/lib/nanoc3/base/item_rep.rb +117 -48
  14. data/lib/nanoc3/base/layout.rb +18 -5
  15. data/lib/nanoc3/base/notification_center.rb +8 -8
  16. data/lib/nanoc3/base/plugin_registry.rb +9 -9
  17. data/lib/nanoc3/base/rule.rb +8 -8
  18. data/lib/nanoc3/base/rule_context.rb +5 -5
  19. data/lib/nanoc3/base/site.rb +33 -29
  20. data/lib/nanoc3/cli/base.rb +1 -1
  21. data/lib/nanoc3/cli/commands/create_site.rb +12 -14
  22. data/lib/nanoc3/cli.rb +0 -1
  23. data/lib/nanoc3/data_sources/filesystem.rb +12 -2
  24. data/lib/nanoc3/data_sources/filesystem_unified.rb +22 -19
  25. data/lib/nanoc3/extra/auto_compiler.rb +12 -3
  26. data/lib/nanoc3/extra/chick.rb +12 -6
  27. data/lib/nanoc3/extra/deployers/rsync.rb +30 -27
  28. data/lib/nanoc3/extra/deployers.rb +0 -1
  29. data/lib/nanoc3/extra/file_proxy.rb +2 -15
  30. data/lib/nanoc3/extra/validators/links.rb +242 -0
  31. data/lib/nanoc3/extra/validators/w3c.rb +49 -25
  32. data/lib/nanoc3/extra/validators.rb +2 -2
  33. data/lib/nanoc3/extra/vcs.rb +1 -1
  34. data/lib/nanoc3/extra.rb +4 -1
  35. data/lib/nanoc3/helpers/blogging.rb +57 -29
  36. data/lib/nanoc3/helpers/breadcrumbs.rb +1 -1
  37. data/lib/nanoc3/helpers/capturing.rb +4 -2
  38. data/lib/nanoc3/helpers/filtering.rb +2 -1
  39. data/lib/nanoc3/helpers/link_to.rb +13 -6
  40. data/lib/nanoc3/helpers/rendering.rb +4 -3
  41. data/lib/nanoc3/helpers/tagging.rb +7 -6
  42. data/lib/nanoc3/helpers/text.rb +2 -2
  43. data/lib/nanoc3/tasks/validate.rake +62 -5
  44. data/lib/nanoc3.rb +2 -2
  45. metadata +23 -11
  46. data/lib/nanoc3/base/core_ext/enumerable.rb +0 -41
@@ -17,28 +17,32 @@ module Nanoc3::Helpers
17
17
  # @param [String] text The visible link text
18
18
  #
19
19
  # @param [String, Nanoc3::Item, Nanoc3::ItemRep] target The path/URL,
20
- # item or item representation that should be linked to
20
+ # item or item representation that should be linked to
21
21
  #
22
22
  # @param [Hash] attributes A hash containing HTML attributes (e.g.
23
- # `rel`, `title`, …) that will be added to the link.
23
+ # `rel`, `title`, …) that will be added to the link.
24
24
  #
25
25
  # @return [String] The link text
26
26
  #
27
27
  # @example Linking to a path
28
+ #
28
29
  # link_to('Blog', '/blog/')
29
30
  # # => '<a href="/blog/">Blog</a>'
30
31
  #
31
32
  # @example Linking to an item
33
+ #
32
34
  # about = @items.find { |i| i.identifier == '/about/' }
33
35
  # link_to('About Me', about)
34
36
  # # => '<a href="/about.html">About Me</a>'
35
37
  #
36
38
  # @example Linking to an item representation
39
+ #
37
40
  # about = @items.find { |i| i.identifier == '/about/' }
38
41
  # link_to('My vCard', about.rep(:vcard))
39
42
  # # => '<a href="/about.vcf">My vCard</a>'
40
43
  #
41
44
  # @example Linking with custom attributes
45
+ #
42
46
  # link_to('Blog', '/blog/', :title => 'My super cool blog')
43
47
  # # => '<a title="My super cool blog" href="/blog/">Blog</a>'
44
48
  def link_to(text, target, attributes={})
@@ -62,18 +66,20 @@ module Nanoc3::Helpers
62
66
  # @param [String] text The visible link text
63
67
  #
64
68
  # @param [String, Nanoc3::Item, Nanoc3::ItemRep] target The path/URL,
65
- # item or item representation that should be linked to
69
+ # item or item representation that should be linked to
66
70
  #
67
71
  # @param [Hash] attributes A hash containing HTML attributes (e.g.
68
- # `rel`, `title`, …) that will be added to the link.
72
+ # `rel`, `title`, …) that will be added to the link.
69
73
  #
70
74
  # @return [String] The link text
71
75
  #
72
76
  # @example Linking to a different page
77
+ #
73
78
  # link_to_unless_current('Blog', '/blog/')
74
79
  # # => '<a href="/blog/">Blog</a>'
75
80
  #
76
81
  # @example Linking to the same page
82
+ #
77
83
  # link_to_unless_current('This Item', @item)
78
84
  # # => '<span class="active" title="You\'re here.">This Item</span>'
79
85
  def link_to_unless_current(text, target, attributes={})
@@ -92,12 +98,13 @@ module Nanoc3::Helpers
92
98
  # item representation. The returned path will not be HTML-escaped.
93
99
  #
94
100
  # @param [String, Nanoc3::Item, Nanoc3::ItemRep] target The path/URL,
95
- # item or item representation to which the relative path should be
96
- # generated
101
+ # item or item representation to which the relative path should be
102
+ # generated
97
103
  #
98
104
  # @return [String] The relative path to the target
99
105
  #
100
106
  # @example
107
+ #
101
108
  # # if the current item's path is /foo/bar/
102
109
  # relative_path_to('/foo/qux/')
103
110
  # # => '../qux/'
@@ -10,10 +10,10 @@ module Nanoc3::Helpers
10
10
  # Returns a string containing the rendered given layout.
11
11
  #
12
12
  # @param [String] identifier The identifier of the layout that should be
13
- # rendered
13
+ # rendered
14
14
  #
15
15
  # @param [Hash] other_assigns A hash containing assigns that will be made
16
- # available as instance variables in the partial
16
+ # available as instance variables in the partial
17
17
  #
18
18
  # @example Rendering a head and a foot partial around some text
19
19
  #
@@ -29,7 +29,8 @@ module Nanoc3::Helpers
29
29
  # <%= render 'head', :title => 'Foo' %>
30
30
  # # => "<h1>Foo</h1>"
31
31
  #
32
- # @raise [Nanoc3::Errors::UnknownLayout] if the given layout does not exist
32
+ # @raise [Nanoc3::Errors::UnknownLayout] if the given layout does not
33
+ # exist
33
34
  #
34
35
  # @return [String] The rendered partial
35
36
  def render(identifier, other_assigns={}, &block)
@@ -8,6 +8,7 @@ module Nanoc3::Helpers
8
8
  # should be applied to the item.
9
9
  #
10
10
  # @example Adding tags to an item
11
+ #
11
12
  # tags: [ 'foo', 'bar', 'baz' ]
12
13
  module Tagging
13
14
 
@@ -19,14 +20,14 @@ module Nanoc3::Helpers
19
20
  # HTML-escaping rules for {#link_for_tag} apply here as well.
20
21
  #
21
22
  # @option params [String] base_url ("http://technorati.com/tag/") The URL
22
- # to which the tag will be appended to construct the link URL. This URL
23
- # must have a trailing slash.
23
+ # to which the tag will be appended to construct the link URL. This URL
24
+ # must have a trailing slash.
24
25
  #
25
26
  # @option params [String] none_text ("(none)") The text to display when
26
- # the item has no tags
27
+ # the item has no tags
27
28
  #
28
29
  # @option params [String] separator (", ") The separator to put between
29
- # tags
30
+ # tags
30
31
  #
31
32
  # @return [String] A hyperlinked list of tags for the given item
32
33
  def tags_for(item, params={})
@@ -55,10 +56,10 @@ module Nanoc3::Helpers
55
56
  # escaped, as will the content of the `a` element.
56
57
  #
57
58
  # @param [String] tag The name of the tag, which should consist of letters
58
- # and numbers (no spaces, slashes, or other special characters).
59
+ # and numbers (no spaces, slashes, or other special characters).
59
60
  #
60
61
  # @param [String] base_url The URL to which the tag will be appended to
61
- # construct the link URL. This URL must have a trailing slash.
62
+ # construct the link URL. This URL must have a trailing slash.
62
63
  #
63
64
  # @return [String] A link for the given tag and the given base URL
64
65
  def link_for_tag(tag, base_url)
@@ -12,10 +12,10 @@ module Nanoc3::Helpers
12
12
  # @param [String] string The string for which to build an excerpt
13
13
  #
14
14
  # @option params [Number] length (25) The maximum number of characters
15
- # this excerpt can contain, including the omission.
15
+ # this excerpt can contain, including the omission.
16
16
  #
17
17
  # @option params [String] omission ("...") The string to append to the
18
- # excerpt when the excerpt is shorter than the original string
18
+ # excerpt when the excerpt is shorter than the original string
19
19
  #
20
20
  # @return [String] The excerpt of the given string
21
21
  def excerptize(string, params={})
@@ -4,31 +4,88 @@ namespace :validate do
4
4
 
5
5
  desc 'Validate the site\'s HTML files'
6
6
  task :html do
7
- # Load site
7
+ # Get output directory
8
8
  site = Nanoc3::Site.new('.')
9
9
  if site.nil?
10
10
  $stderr.puts 'The current working directory does not seem to be a ' +
11
11
  'valid/complete nanoc site directory; aborting.'
12
12
  exit 1
13
13
  end
14
+ dir = site.config[:output_dir]
14
15
 
15
16
  # Validate
16
- validator = ::Nanoc3::Extra::Validators::W3C.new(site, :html)
17
+ validator = ::Nanoc3::Extra::Validators::W3C.new(dir, [ :html ])
17
18
  validator.run
18
19
  end
19
20
 
20
21
  desc 'Validate the site\'s CSS files'
21
22
  task :css do
22
- # Load site
23
- site = Nanoc3::Site.new(YAML.load_file(File.join(Dir.getwd, 'config.yaml')))
23
+ # Get output directory
24
+ site = Nanoc3::Site.new('.')
25
+ if site.nil?
26
+ $stderr.puts 'The current working directory does not seem to be a ' +
27
+ 'valid/complete nanoc site directory; aborting.'
28
+ exit 1
29
+ end
30
+ dir = site.config[:output_dir]
31
+
32
+ # Validate
33
+ validator = ::Nanoc3::Extra::Validators::W3C.new(dir, [ :css ])
34
+ validator.run
35
+ end
36
+
37
+ namespace :links do
38
+
39
+ desc 'Validate the site’s internal links'
40
+ task :internal do
41
+ # Get output directory
42
+ site = Nanoc3::Site.new('.')
43
+ if site.nil?
44
+ $stderr.puts 'The current working directory does not seem to be a ' +
45
+ 'valid/complete nanoc site directory; aborting.'
46
+ exit 1
47
+ end
48
+ dir = site.config[:output_dir]
49
+ index_filenames = site.config[:index_filenames]
50
+
51
+ # Validate
52
+ validator = ::Nanoc3::Extra::Validators::Links.new(dir, index_filenames, :internal => true)
53
+ validator.run
54
+ end
55
+
56
+ desc 'Validate the site’s internal links'
57
+ task :external do
58
+ # Get output directory
59
+ site = Nanoc3::Site.new('.')
60
+ if site.nil?
61
+ $stderr.puts 'The current working directory does not seem to be a ' +
62
+ 'valid/complete nanoc site directory; aborting.'
63
+ exit 1
64
+ end
65
+ dir = site.config[:output_dir]
66
+ index_filenames = site.config[:index_filenames]
67
+
68
+ # Validate
69
+ validator = ::Nanoc3::Extra::Validators::Links.new(dir, index_filenames, :external => true)
70
+ validator.run
71
+ end
72
+
73
+ end
74
+
75
+ desc 'Validate the site’s internal and external links'
76
+ task :links do
77
+ # Get output directory
78
+ site = Nanoc3::Site.new('.')
24
79
  if site.nil?
25
80
  $stderr.puts 'The current working directory does not seem to be a ' +
26
81
  'valid/complete nanoc site directory; aborting.'
27
82
  exit 1
28
83
  end
84
+ dir = site.config[:output_dir]
85
+ index_filenames = site.config[:index_filenames]
29
86
 
30
87
  # Validate
31
- validator = ::Nanoc3::Extra::Validators::W3C.new(site, :css)
88
+ validator = ::Nanoc3::Extra::Validators::Links.new(dir, index_filenames, :internal => true, :external => true)
32
89
  validator.run
33
90
  end
34
91
 
data/lib/nanoc3.rb CHANGED
@@ -3,13 +3,13 @@
3
3
  module Nanoc3
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.1.0a2'
6
+ VERSION = '3.1.0a3'
7
7
 
8
8
  # Loads all nanoc3 plugins, i.e. requires all ruby gems whose name start
9
9
  # with `nanoc3-`.
10
10
  #
11
11
  # @return [Boolean] true if all plugins were loaded successfully, false if
12
- # rubygems isn’t loaded.
12
+ # rubygems isn’t loaded.
13
13
  def self.load_plugins
14
14
  # Don’t load if there’s no rubygems
15
15
  return false if !defined?(Gem)
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0a2
4
+ prerelease: true
5
+ segments:
6
+ - 3
7
+ - 1
8
+ - 0a3
9
+ version: 3.1.0a3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Denis Defreyne
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-20 00:00:00 +01:00
17
+ date: 2010-02-28 00:00:00 +01:00
13
18
  default_executable: nanoc3
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: cri
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 0
23
31
  version: 1.0.0
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description:
26
35
  email: denis.defreyne@stoneship.org
27
36
  executables:
@@ -44,7 +53,6 @@ files:
44
53
  - lib/nanoc3/base/compiler_dsl.rb
45
54
  - lib/nanoc3/base/context.rb
46
55
  - lib/nanoc3/base/core_ext/array.rb
47
- - lib/nanoc3/base/core_ext/enumerable.rb
48
56
  - lib/nanoc3/base/core_ext/hash.rb
49
57
  - lib/nanoc3/base/core_ext/string.rb
50
58
  - lib/nanoc3/base/core_ext.rb
@@ -158,7 +166,7 @@ post_install_message: |
158
166
  ------------------------------------------------------------------------------
159
167
 
160
168
  rdoc_options:
161
- - --readme
169
+ - --main
162
170
  - README.md
163
171
  require_paths:
164
172
  - lib
@@ -166,18 +174,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
174
  requirements:
167
175
  - - ">="
168
176
  - !ruby/object:Gem::Version
177
+ segments:
178
+ - 0
169
179
  version: "0"
170
- version:
171
180
  required_rubygems_version: !ruby/object:Gem::Requirement
172
181
  requirements:
173
182
  - - ">"
174
183
  - !ruby/object:Gem::Version
184
+ segments:
185
+ - 1
186
+ - 3
187
+ - 1
175
188
  version: 1.3.1
176
- version:
177
189
  requirements: []
178
190
 
179
191
  rubyforge_project:
180
- rubygems_version: 1.3.5
192
+ rubygems_version: 1.3.6
181
193
  signing_key:
182
194
  specification_version: 3
183
195
  summary: a web publishing system written in Ruby for building small to medium-sized websites.
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Nanoc3::EnumerableExtensions
4
-
5
- module GroupBy
6
-
7
- # Returns a hash, which keys are evaluated result from the block, and
8
- # values are arrays of elements in enum corresponding to the key. This
9
- # method is provided for backward compatibility with Ruby 1.8.6 and lower,
10
- # since {#group_by} is only available in 1.8.7 and higher.
11
- #
12
- # @yieldparam [Object] obj The object to classify
13
- #
14
- # @return [Hash]
15
- #
16
- # @example Grouping integers by rest by division through 3
17
- #
18
- # (1..6).group_by { |i| i % 3 }
19
- # # => { 0 => [3, 6], 1 => [1, 4], 2 => [2, 5] }
20
- def group_by
21
- groups = {}
22
- each do |item|
23
- key = yield(item)
24
-
25
- groups[key] ||= []
26
- groups[key] << item
27
- end
28
- groups
29
- end
30
-
31
- end
32
-
33
- end
34
-
35
- module Enumerable
36
-
37
- if !Enumerable.instance_methods.include?('group_by')
38
- include Nanoc3::EnumerableExtensions::GroupBy
39
- end
40
-
41
- end