nanoc3 3.2.3 → 3.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2007-2011 Denis Defreyne and contributors
1
+ Copyright (c) 2007-2012 Denis Defreyne and contributors
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/NEWS.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # nanoc news
2
2
 
3
+ ## 3.2.4 (2012-01-09)
4
+
5
+ * Fixed bug which would cause some reps not to be compiled when invoking nanoc programmatically
6
+ * Made data source configuration location a bit more obvious
7
+ * Fixed watch command under Windows
8
+ * Made filesystem data source ignore UTF-8 BOM
9
+ * Improved compatibility of colorize_syntax filter with older libxml versions
10
+
3
11
  ## 3.2.3 (2011-10-31)
4
12
 
5
13
  * Made syntax colorizer only strip trailing blank lines instead of all blanks
@@ -31,8 +39,7 @@ Base:
31
39
  * Added progress indicator for long-running filters
32
40
  * Made all source data, such as item attributes, frozen during compilation
33
41
  * Added --color option to force color on
34
- * Cleaned up internals, deprecating several parts and/or marking them as
35
- private in the progress
42
+ * Cleaned up internals, deprecating several parts and/or marking them as private in the progress
36
43
  * Allowed custom commands in commands/
37
44
 
38
45
  Extensions:
@@ -77,8 +84,7 @@ Extensions:
77
84
  * Improved metadata section check so that e.g. raw diffs are handled properly
78
85
  * Deprecated using `Nanoc3::Site#initialize` with a non-`"."` argument
79
86
  * Added Ruby engine to version string
80
- * Allowed the `created_at` and `updated_at` attributes used in the `Blogging`
81
- helper to be `Date` instances
87
+ * Allowed the `created_at` and `updated_at` attributes used in the `Blogging` helper to be `Date` instances
82
88
 
83
89
  ## 3.1.4 (2010-07-25)
84
90
 
@@ -93,15 +99,13 @@ Extensions:
93
99
  ## 3.1.3 (2010-04-25)
94
100
 
95
101
  * Removed annoying win32console warning [Eric Sunshine]
96
- * Removed color codes when not writing to a terminal, or when writing to
97
- Windows’ console when win32console is not installed [Eric Sunshine]
102
+ * Removed color codes when not writing to a terminal, or when writing to Windows’ console when win32console is not installed [Eric Sunshine]
98
103
  * Added .xhtml and .xml to list of text extensions
99
104
  * Improved support for relative Sass @imports [Chris Eppstein]
100
105
 
101
106
  ## 3.1.2 (2010-04-07)
102
107
 
103
- * Fixed bug which could cause incorrect output when compilation of an item is
104
- delayed due to an unmet dependency
108
+ * Fixed bug which could cause incorrect output when compilation of an item is delayed due to an unmet dependency
105
109
 
106
110
  ## 3.1.1 (2010-04-05)
107
111
 
@@ -119,16 +123,13 @@ New:
119
123
  * A `view` command that starts a web server in the output directory
120
124
  * A `debug` command that shows information about the items, reps and layouts
121
125
  * A `kramdown` filter ([kramdown site](http://kramdown.rubyforge.org/))
122
- * A diff between the previously compiled content and the last compiled content
123
- is now written to `output.diff` if the `enable_output_diff` site
124
- configuration attribute is true
126
+ * A diff between the previously compiled content and the last compiled content is now written to `output.diff` if the `enable_output_diff` site configuration attribute is true
125
127
  * Assigns, such as `@items`, `@layouts`, `@item`, … are accessible without `@`
126
128
  * Support for binary items
127
129
 
128
130
  Changed:
129
131
 
130
- * New sites now come with a stylesheet item instead of a `style.css` file in
131
- the output directory
132
+ * New sites now come with a stylesheet item instead of a `style.css` file in the output directory
132
133
  * The `deploy:rsync` task now use sensible default options
133
134
  * The `deploy:rsync` task now accepts a config environment variable
134
135
  * The `deploy:rsync` task now uses a lowercase `dry_run` environment variable
@@ -136,10 +137,8 @@ Changed:
136
137
  * The `rainpress` filter now accepts parameters
137
138
  * The `filesystem` data source is now known as `filesystem_verbose`
138
139
  * Meta files and content files are now optional
139
- * The `filesystem_compact` and `filesystem_combined` data sources have been
140
- merged into a new `filesystem_unified` data source
141
- * The metadata section in `filesystem_unified` is now optional [Christopher
142
- Eppstein]
140
+ * The `filesystem_compact` and `filesystem_combined` data sources have been merged into a new `filesystem_unified` data source
141
+ * The metadata section in `filesystem_unified` is now optional [Christopher Eppstein]
143
142
  * The `--server` autocompile option is now known as `--handler`
144
143
  * Assigns in filters are now available as instance variables and methods
145
144
  * The `#breadcrumbs_trail` function now allows missing parents
@@ -149,13 +148,11 @@ Deprecated:
149
148
 
150
149
  * `Nanoc3::FileProxy`; use one of the filename attributes instead
151
150
  * `ItemRep#content_at_snapshot`; use `#compiled_content` instead
152
- * The `last_fm`, `delicious` and `twitter` data sources; fetch online content
153
- into a cache by a rake task and load data from this cache instead
151
+ * The `last_fm`, `delicious` and `twitter` data sources; fetch online content into a cache by a rake task and load data from this cache instead
154
152
 
155
153
  ## 3.0.9 (2010-02-24)
156
154
 
157
- * Fixed 1.8.x parsing bug due to lack of parens which could cause “undefined
158
- method `to_iso8601_time` for #<String:0x…>” errors
155
+ * Fixed 1.8.x parsing bug due to lack of parens which could cause “undefined method `to_iso8601_time` for #<String:0x…>” errors
159
156
 
160
157
  ## 3.0.8 (2010-02-24)
161
158
 
@@ -177,18 +174,11 @@ Deprecated:
177
174
 
178
175
  ## 3.0.5 (2010-01-12)
179
176
 
180
- * Restored pre-3.0.3 behaviour of periods in identifiers. By default, a file
181
- can have multiple extensions (e.g. `content/foo.html.erb` will have the
182
- identifier `/foo/`), but if `allow_periods_in_identifiers` in the site
183
- configuration is true, a file can have only one extension (e.g.
184
- `content/blog/stuff.entry.html` will have the identifier
185
- `/blog/stuff.entry/`).
177
+ * Restored pre-3.0.3 behaviour of periods in identifiers. By default, a file can have multiple extensions (e.g. `content/foo.html.erb` will have the identifier `/foo/`), but if `allow_periods_in_identifiers` in the site configuration is true, a file can have only one extension (e.g. `content/blog/stuff.entry.html` will have the identifier `/blog/stuff.entry/`).
186
178
 
187
179
  ## 3.0.4 (2010-01-07)
188
180
 
189
- * Fixed a bug which would cause the `filesystem_compact` data source to
190
- incorrectly determine the content filename, leading to weird “Expected 1
191
- content file but found 3” errors [Eric Sunshine]
181
+ * Fixed a bug which would cause the `filesystem_compact` data source to incorrectly determine the content filename, leading to weird “Expected 1 content file but found 3” errors [Eric Sunshine]
192
182
 
193
183
  ## 3.0.3 (2010-01-06)
194
184
 
@@ -196,26 +186,22 @@ Deprecated:
196
186
  * The `relativize_paths` filter now only operates inside tags
197
187
  * The autocompiler now handles escaped paths
198
188
  * The `LinkTo` and `Tagging` helpers now output escaped HTML
199
- * Fixed `played_at` attribute assignment in the `LastFM` data source for
200
- tracks playing now, and added a `now_playing` attribute [Nicky Peeters]
189
+ * Fixed `played_at` attribute assignment in the `LastFM` data source for tracks playing now, and added a `now_playing` attribute [Nicky Peeters]
201
190
  * The `filesystem_*` data sources can now handle dots in identifiers
202
191
  * Required enumerator to make sure `#enum_with_index` always works
203
192
  * `Array#stringify_keys` now properly recurses
204
193
 
205
194
  ## 3.0.2 (2009-11-07)
206
195
 
207
- * Children-only identifier patterns no longer erroneously also match parent
208
- (e.g.` /foo/*/` no longer matches `/foo/`)
196
+ * Children-only identifier patterns no longer erroneously also match parent (e.g.` /foo/*/` no longer matches `/foo/`)
209
197
  * The `create_site` command no longer uses those ugly HTML entities
210
198
  * Install message now mentions the IRC channel
211
199
 
212
200
  ## 3.0.1 (2009-10-05)
213
201
 
214
- * The proper exception is now raised when no matching compilation rules can
215
- be found
202
+ * The proper exception is now raised when no matching compilation rules can be found
216
203
  * The autocompile command no longer has a duplicate `--port` option
217
- * The `#url_for` and `#feed_url` methods now check the presence of the
218
- `base_url` site configuration attribute
204
+ * The `#url_for` and `#feed_url` methods now check the presence of the `base_url` site configuration attribute
219
205
  * Several outdated URLs are now up-to-date
220
206
  * Error handling has been improved in general
221
207
 
@@ -246,18 +232,14 @@ Removed:
246
232
 
247
233
  ## 2.2.2 (2009-05-18)
248
234
 
249
- * Removed `relativize_paths` filter; use `relativize_paths_in_html` or
250
- `relativize_paths_in_css` instead
251
- * Fixed bug which could cause nanoc to eat massive amounts of memory when an
252
- exception occurs
253
- * Fixed bug which would cause nanoc to complain about the open file limit
254
- being reached when using a large amount of assets
235
+ * Removed `relativize_paths` filter; use `relativize_paths_in_html` or `relativize_paths_in_css` instead
236
+ * Fixed bug which could cause nanoc to eat massive amounts of memory when an exception occurs
237
+ * Fixed bug which would cause nanoc to complain about the open file limit being reached when using a large amount of assets
255
238
 
256
239
  ## 2.2.1 (2009-04-08)
257
240
 
258
241
  * Fixed bug which prevented `relative_path_to` from working
259
- * Split `relativize_paths` filter into two filter: `relativize_paths_in_html`
260
- and `relativize_paths_in_css`
242
+ * Split `relativize_paths` filter into two filter: `relativize_paths_in_html` and `relativize_paths_in_css`
261
243
  * Removed bundled mime-types library
262
244
 
263
245
  ## 2.2 (2009-04-06)
@@ -276,8 +258,7 @@ New:
276
258
  Changed:
277
259
 
278
260
  * The commandline option parser is now a lot more reliable
279
- * `#atom_feed` now takes optional `:content_proc`, `:excerpt_proc` and
280
- `:articles` parameters
261
+ * `#atom_feed` now takes optional `:content_proc`, `:excerpt_proc` and `:articles` parameters
281
262
  * The compile command show non-written items (those with `skip_output: true`)
282
263
  * The compile command compiles everything by default
283
264
  * Added `--only-outdated` option to compile only outdated pages
@@ -290,17 +271,14 @@ Removed:
290
271
 
291
272
  * The `filesystem_combined` data source now supports empty metadata sections
292
273
  * The `rdoc` filter now works for both RDoc 1.x and 2.x
293
- * The autocompiler now serves a 500 when an exception occurs outside
294
- compilation
295
- * The autocompiler no longer serves index files when the request path does not
296
- end with a slash
274
+ * The autocompiler now serves a 500 when an exception occurs outside compilation
275
+ * The autocompiler no longer serves index files when the request path does not end with a slash
297
276
  * The autocompiler now always serves asset content correctly
298
277
 
299
278
  ## 2.1.5 (2009-02-01)
300
279
 
301
280
  * Added Ruby 1.9 compatibility
302
- * The `filesystem` and `filesystem_combined` data sources now preserve custom
303
- extensions
281
+ * The `filesystem` and `filesystem_combined` data sources now preserve custom extensions
304
282
 
305
283
  ## 2.1.4 (2008-11-15)
306
284
 
@@ -357,14 +335,12 @@ Removed:
357
335
  ## 2.0.4 (2008-05-04)
358
336
 
359
337
  * Fixed `default.rb`’s `#html_escape`
360
- * Updated Haml filter and layout processor so that @page, @pages and @config
361
- are now available as instance variables instead of local variables
338
+ * Updated Haml filter and layout processor so that @page, @pages and @config are now available as instance variables instead of local variables
362
339
 
363
340
  ## 2.0.3 (2008-03-25)
364
341
 
365
342
  * The autocompiler now honors custom paths
366
- * The autocompiler now attempts to serve pages with the most appropriate MIME
367
- type, instead of always serving everything as `text/html`
343
+ * The autocompiler now attempts to serve pages with the most appropriate MIME type, instead of always serving everything as `text/html`
368
344
 
369
345
  ## 2.0.2 (2008-01-26)
370
346
 
@@ -406,8 +382,7 @@ Removed:
406
382
  ## 1.6 (2007-10-13)
407
383
 
408
384
  * Added support for post-layout filters
409
- * Added support for getting a File object for the page, so you can now e.g.
410
- easily get the modification time for a given page (`@page.file.mtime`)
385
+ * Added support for getting a File object for the page, so you can now e.g. easily get the modification time for a given page (`@page.file.mtime`)
411
386
  * Cleaned up the source code a lot
412
387
  * Removed deprecated asset-copying functionality
413
388
 
@@ -422,15 +397,12 @@ Removed:
422
397
 
423
398
  * nanoc now supports ERB (as well as Erubis); Erubis no longer is a dependency
424
399
  * `meta.yaml` can now have `haml_options` property, which is passed to Haml
425
- * Pages can now have a `filename` property, which defaults to `index` [Dennis
426
- Sutch]
427
- * Pages now know in what order they should be compiled, eliminating the need
428
- for custom page ordering [Dennis Sutch]
400
+ * Pages can now have a `filename` property, which defaults to `index` [Dennis Sutch]
401
+ * Pages now know in what order they should be compiled, eliminating the need for custom page ordering [Dennis Sutch]
429
402
 
430
403
  ## 1.3.1 (2007-06-30)
431
404
 
432
- * The contents of the `assets` directory are now copied into the output
433
- directory specified in `config.yaml`
405
+ * The contents of the `assets` directory are now copied into the output directory specified in `config.yaml`
434
406
 
435
407
  ## 1.3 (2007-06-24)
436
408
 
@@ -439,20 +411,16 @@ Removed:
439
411
  * Added new filters
440
412
  * Textile/RedCloth
441
413
  * Sass
442
- * nanoc now warns before overwriting in `create_site`, `create_page` and
443
- `create_template` (but not in compile)
414
+ * nanoc now warns before overwriting in `create_site`, `create_page` and `create_template` (but not in compile)
444
415
 
445
416
  ## 1.2 (2007-06-05)
446
417
 
447
- * Sites now have an `assets` directory, whose contents are copied to the
448
- `output` directory when compiling [Soryu]
418
+ * Sites now have an `assets` directory, whose contents are copied to the `output` directory when compiling [Soryu]
449
419
  * Added support for non-eRuby layouts (Markaby, Haml, Liquid, …)
450
420
  * Added more filters (Markaby, Haml, Liquid, RDoc [Dmitry Bilunov])
451
421
  * Improved error reporting
452
- * Accessing page attributes using instance variables, and not through `@page`,
453
- is no longer possible
454
- * Page attributes can now be accessed using dot notation, i.e. `@page.title`
455
- as well as `@page[:title]`
422
+ * Accessing page attributes using instance variables, and not through `@page`, is no longer possible
423
+ * Page attributes can now be accessed using dot notation, i.e. `@page.title` as well as `@page[:title]`
456
424
 
457
425
  ## 1.1.3 (2007-05-18)
458
426
 
@@ -468,14 +436,12 @@ Removed:
468
436
  * Added support for nested layouts
469
437
  * Added coloured logging
470
438
  * `@page` now hold the page that is currently being processed
471
- * Index files are now called “content” files and are now named after the
472
- directory they are in [Colin Barrett]
439
+ * Index files are now called “content” files and are now named after the directory they are in [Colin Barrett]
473
440
  * It is now possible to access `@page` in the page’s content file
474
441
 
475
442
  ## 1.0.1 (2007-05-05)
476
443
 
477
- * Fixed a bug which would cause a “no such template” error to be displayed
478
- when the template existed but compiling it would raise an exception
444
+ * Fixed a bug which would cause a “no such template” error to be displayed when the template existed but compiling it would raise an exception
479
445
  * Fixed bug which would cause pages not to be sorted by order before compiling
480
446
 
481
447
  ## 1.0 (2007-05-03)
data/README.md CHANGED
@@ -73,6 +73,7 @@ may be interested in the development dependencies:
73
73
 
74
74
  * Ben Armston
75
75
  * Colin Barrett
76
+ * Bil Bas
76
77
  * Dmitry Bilunov
77
78
  * Devon Luke Buchanan
78
79
  * Stefan Bühler
@@ -315,8 +315,7 @@ module Nanoc3
315
315
  #
316
316
  # @return [void]
317
317
  def compile_reps(reps)
318
- outdated_reps = Set.new(reps.select { |rep| outdatedness_checker.outdated?(rep) })
319
- content_dependency_graph = Nanoc3::DirectedGraph.new(outdated_reps)
318
+ content_dependency_graph = Nanoc3::DirectedGraph.new(reps)
320
319
 
321
320
  # Listen to processing start/stop
322
321
  Nanoc3::NotificationCenter.on(:processing_started, self) { |obj| @stack.push(obj) }
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module Nanoc3
2
4
 
3
5
  # Keeps track of the rules in a site.
@@ -22,7 +22,7 @@ module Nanoc3
22
22
  # # => %w( a b c )
23
23
  #
24
24
  # # Modify edges
25
- # graph.remove_edge('a', 'b')
25
+ # graph.delete_edge('a', 'b')
26
26
  #
27
27
  # # Get (direct) predecessors again
28
28
  # graph.direct_predecessors_of('d').sort
@@ -96,7 +96,7 @@ module Nanoc3
96
96
  self,
97
97
  data_source_hash[:items_root],
98
98
  data_source_hash[:layouts_root],
99
- data_source_hash[:config] || {}
99
+ data_source_hash.merge(data_source_hash[:config] || {})
100
100
  )
101
101
  end
102
102
  end
@@ -41,7 +41,7 @@ output_dir: #{Nanoc3::Site::DEFAULT_CONFIG[:output_dir]}
41
41
 
42
42
  # A list of index filenames, i.e. names of files that will be served by a web
43
43
  # server when a directory is requested. Usually, index files are named
44
- # “index.hml”, but depending on the web server, this may be something else,
44
+ # “index.html”, but depending on the web server, this may be something else,
45
45
  # such as “default.htm”. This list is used by nanoc to generate pretty URLs.
46
46
  index_filenames: #{array_to_yaml(Nanoc3::Site::DEFAULT_CONFIG[:index_filenames])}
47
47
 
@@ -27,7 +27,7 @@ end
27
27
  opt :v, :version, 'show version information and quit' do
28
28
  gem_info = defined?(Gem) ? "with RubyGems #{Gem::VERSION}" : "without RubyGems"
29
29
  engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
30
- puts "nanoc #{Nanoc3::VERSION} (c) 2007-2011 Denis Defreyne."
30
+ puts "nanoc #{Nanoc3::VERSION} (c) 2007-2012 Denis Defreyne."
31
31
  puts "Running #{engine} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} #{gem_info}"
32
32
  exit 0
33
33
  end
@@ -92,6 +92,9 @@ module Nanoc3::CLI::Commands
92
92
  # A list of commandline tool names that can be used to send notifications
93
93
  TOOLS = %w( growlnotify notify-send )
94
94
 
95
+ # The tool to use for discovering binaries' locations
96
+ FIND_BINARY_COMMAND = RUBY_PLATFORM =~ /mingw|mswin/ ? "where" : "which"
97
+
95
98
  # Send a notification. If no notifier is found, no notification will be
96
99
  # created.
97
100
  #
@@ -104,7 +107,7 @@ module Nanoc3::CLI::Commands
104
107
  private
105
108
 
106
109
  def tool
107
- @tool ||= TOOLS.find { |t| !`which #{t}`.empty? }
110
+ @tool ||= TOOLS.find { |t| !`#{FIND_BINARY_COMMAND} #{t}`.empty? }
108
111
  end
109
112
 
110
113
  def growlnotify(message)
@@ -283,6 +283,9 @@ module Nanoc3::DataSources
283
283
  raise_encoding_error(filename, original_encoding) if !data.valid_encoding?
284
284
  end
285
285
 
286
+ # Remove UTF-8 BOM (ugly)
287
+ data.gsub!("\xEF\xBB\xBF", '')
288
+
286
289
  data
287
290
  end
288
291
 
@@ -113,7 +113,7 @@ module Nanoc3::Filters
113
113
  # Highlight
114
114
  raw = strip(element.inner_text)
115
115
  highlighted_code = highlight(raw, language, params)
116
- element.inner_html = strip(highlighted_code)
116
+ element.inner_html = Nokogiri::HTML.fragment(strip(highlighted_code), 'utf-8')
117
117
 
118
118
  # Add class
119
119
  unless has_class
@@ -191,6 +191,9 @@ module Nanoc3::Filters
191
191
  require 'systemu'
192
192
  check_availability('pygmentize', '-V')
193
193
 
194
+ params[:encoding] ||= 'utf-8'
195
+ params[:nowrap] ||= 'True'
196
+
194
197
  # Build command
195
198
  cmd = [ 'pygmentize', '-l', language, '-f', 'html' ]
196
199
  cmd << '-O' << params.map { |k,v| "#{k}=#{v}" }.join(',') unless params.empty?
@@ -201,11 +204,7 @@ module Nanoc3::Filters
201
204
 
202
205
  # Get result
203
206
  stdout.rewind
204
- highlighted_code = stdout.read
205
-
206
- # Clean result
207
- doc = Nokogiri::HTML.fragment(highlighted_code)
208
- doc.xpath('./div[@class="highlight"]/pre').inner_html
207
+ stdout.read
209
208
  end
210
209
 
211
210
  SIMON_HIGHLIGHT_OPT_MAP = {
@@ -12,7 +12,7 @@ module Nanoc3::Filters
12
12
  attr_accessor :current
13
13
  end
14
14
 
15
- # Essentially the {Sass::Importers::Filesystem} but registering each
15
+ # Essentially the `Sass::Importers::Filesystem` but registering each
16
16
  # import file path.
17
17
  class SassFilesystemImporter < ::Sass::Importers::Filesystem
18
18
 
@@ -63,9 +63,9 @@ module Nanoc3::Helpers
63
63
  "<a #{attributes}href=\"#{h path}\">#{text}</a>"
64
64
  end
65
65
 
66
- # Creates a HTML link using link_to, except when the linked item is the
67
- # current one. In this case, a span element with class “active” and with
68
- # the given text will be returned. The HTML-escaping rules for
66
+ # Creates a HTML link using {#link_to}, except when the linked item is
67
+ # the current one. In this case, a span element with class “active” and
68
+ # with the given text will be returned. The HTML-escaping rules for
69
69
  # {#link_to} apply here as well.
70
70
  #
71
71
  # @param [String] text The visible link text
@@ -7,24 +7,33 @@ module Nanoc3::Helpers
7
7
 
8
8
  include Nanoc3::Helpers::Capturing
9
9
 
10
- # Returns a string containing the rendered given layout. The given layout
11
- # will first be run through the matching layout rule.
10
+ # Renders the given layout. The given layout will be run through the first
11
+ # matching layout rule.
12
12
  #
13
- # The assigns (`@item`, `@config`, …) will not be available in the
14
- # partial, but it is possible to pass custom assigns to the method. These
15
- # assigns will be made available as instance variables inside the partial.
13
+ # When this method is invoked _without_ a block, the return value will be
14
+ # the rendered layout (a string) and `_erbout` will not be modified.
16
15
  #
17
- # The method can also take a block. In this case, the content of the block
18
- # will be captured (using the {Nanoc3::Helpers::Capturing} helper) and
19
- # this content will be made available with `yield`. In other words, a
20
- # `yield` inside the partial will output the content of the block passed
21
- # to the method.
16
+ # When this method is invoked _with_ a block, an empty string will be
17
+ # returned and the rendered content will be appended to `_erbout`. In this
18
+ # case, the content of the block will be captured (using the
19
+ # {Nanoc3::Helpers::Capturing} helper) and this content will be made
20
+ # available with `yield`. In other words, a `yield` inside the partial
21
+ # will output the content of the block passed to the method.
22
+ #
23
+ # (For the curious: the reason why {#render} with a block has this
24
+ # behaviour of returning an empty string and modifying `_erbout` is
25
+ # because ERB does not support combining the `<%= ... %>` form with a
26
+ # method call that takes a block.)
27
+ #
28
+ # The assigns (`@item`, `@config`, …) will be available in the partial. It
29
+ # is also possible to pass custom assigns to the method; these assigns
30
+ # will be made available as instance variables inside the partial.
22
31
  #
23
32
  # @param [String] identifier The identifier of the layout that should be
24
33
  # rendered
25
34
  #
26
- # @param [Hash] other_assigns A hash containing assigns that will be made
27
- # available as instance variables in the partial
35
+ # @param [Hash] other_assigns A hash containing extra assigns that will be
36
+ # made available as instance variables in the partial
28
37
  #
29
38
  # @example Rendering a head and a foot partial around some text
30
39
  #
@@ -52,10 +61,22 @@ module Nanoc3::Helpers
52
61
  # I'm boxy! Luvz!
53
62
  # <% end %>
54
63
  #
64
+ # # Result
65
+ # <div class="box">
66
+ # I'm boxy! Luvz!
67
+ # </div>
68
+ #
55
69
  # @raise [Nanoc3::Errors::UnknownLayout] if the given layout does not
56
70
  # exist
57
71
  #
58
- # @return [String] The rendered partial
72
+ # @raise [Nanoc3::Errors::CannotDetermineFilter] if there is no layout
73
+ # rule for the given layout
74
+ #
75
+ # @raise [Nanoc3::Errors::UnknownFilter] if the layout rule for the given
76
+ # layout specifies an unknown filter
77
+ #
78
+ # @return [String, nil] The rendered partial, or nil if this method was
79
+ # invoked with a block
59
80
  def render(identifier, other_assigns={}, &block)
60
81
  # Find layout
61
82
  layout = @site.layouts.find { |l| l.identifier == identifier.cleaned_identifier }
data/lib/nanoc3.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Nanoc3
4
4
 
5
5
  # The current nanoc version.
6
- VERSION = '3.2.3'
6
+ VERSION = '3.2.4'
7
7
 
8
8
  end
9
9
 
data/tasks/doc.rake CHANGED
@@ -5,10 +5,12 @@ require 'yard'
5
5
  YARD::Rake::YardocTask.new(:doc) do |yard|
6
6
  yard.files = Dir['lib/**/*.rb']
7
7
  yard.options = [
8
- '--markup', 'markdown',
9
- '--readme', 'README.md',
10
- '--files', 'NEWS.md,LICENSE',
11
- '--output-dir', 'doc/yardoc',
12
- '--template-path', 'doc/yardoc_templates'
8
+ '--markup', 'markdown',
9
+ '--markup-provider', 'kramdown',
10
+ '--charset', 'utf-8',
11
+ '--readme', 'README.md',
12
+ '--files', 'NEWS.md,LICENSE',
13
+ '--output-dir', 'doc/yardoc',
14
+ '--template-path', 'doc/yardoc_templates'
13
15
  ]
14
16
  end
@@ -298,4 +298,19 @@ class Nanoc3::CompilerTest < MiniTest::Unit::TestCase
298
298
  end
299
299
  end
300
300
 
301
+ def test_compile_should_recompile_all_reps
302
+ Nanoc3::CLI.run %w( create_site bar )
303
+
304
+ FileUtils.cd('bar') do
305
+ Nanoc3::CLI.run %w( compile )
306
+
307
+ site = Nanoc3::Site.new('.')
308
+ site.compile
309
+
310
+ # At this point, even the already compiled items in the previous pass
311
+ # should have their compiled content assigned, so this should work:
312
+ site.items[0].reps[0].compiled_content
313
+ end
314
+ end
315
+
301
316
  end
@@ -81,14 +81,14 @@ class Nanoc3::DirectedGraphTest < MiniTest::Unit::TestCase
81
81
  assert graph.vertices.include?(3)
82
82
  end
83
83
 
84
- def test_remove_edge
84
+ def test_delete_edge
85
85
  graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
86
86
  graph.add_edge(1,2)
87
87
 
88
88
  assert_equal [ 2 ], graph.successors_of(1)
89
89
  assert_equal [ 1 ], graph.predecessors_of(2)
90
90
 
91
- graph.remove_edge(1, 2)
91
+ graph.delete_edge(1, 2)
92
92
 
93
93
  assert_equal [], graph.successors_of(1)
94
94
  assert_equal [], graph.predecessors_of(2)
@@ -246,37 +246,37 @@ class Nanoc3::DirectedGraphTest < MiniTest::Unit::TestCase
246
246
  def test_roots_after_removing_edge
247
247
  graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
248
248
  graph.add_edge(1, 2)
249
- graph.remove_edge(1, 2)
249
+ graph.delete_edge(1, 2)
250
250
  assert_equal Set.new([ 1, 2, 3 ]), graph.roots
251
251
 
252
252
  graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
253
253
  graph.add_edge(1, 3)
254
254
  assert_equal Set.new([ 1, 2 ]), graph.roots
255
- graph.remove_edge(1, 2) # no such edge
255
+ graph.delete_edge(1, 2) # no such edge
256
256
  assert_equal Set.new([ 1, 2 ]), graph.roots
257
257
 
258
258
  graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
259
259
  graph.add_edge(2, 1)
260
- graph.remove_edge(2, 1)
260
+ graph.delete_edge(2, 1)
261
261
  assert_equal Set.new([ 1, 2, 3 ]), graph.roots
262
262
 
263
263
  graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
264
264
  graph.add_edge(1, 2)
265
265
  graph.add_edge(2, 3)
266
- graph.remove_edge(1, 2)
266
+ graph.delete_edge(1, 2)
267
267
  assert_equal Set.new([ 1, 2 ]), graph.roots
268
- graph.remove_edge(2, 3)
268
+ graph.delete_edge(2, 3)
269
269
  assert_equal Set.new([ 1, 2, 3 ]), graph.roots
270
270
 
271
271
  graph = Nanoc3::DirectedGraph.new([ 1, 2, 3 ])
272
272
  graph.add_edge(1, 2)
273
273
  graph.add_edge(2, 3)
274
274
  graph.add_edge(3, 1)
275
- graph.remove_edge(1, 2)
275
+ graph.delete_edge(1, 2)
276
276
  assert_equal Set.new([ 2 ]), graph.roots
277
- graph.remove_edge(2, 3)
277
+ graph.delete_edge(2, 3)
278
278
  assert_equal Set.new([ 2, 3 ]), graph.roots
279
- graph.remove_edge(3, 1)
279
+ graph.delete_edge(3, 1)
280
280
  assert_equal Set.new([ 1, 2, 3 ]), graph.roots
281
281
  end
282
282
 
@@ -168,4 +168,23 @@ describe 'Nanoc3::Site#data_sources' do
168
168
  end.must_raise Nanoc3::Errors::UnknownDataSource
169
169
  end
170
170
 
171
+ it 'should also use the toplevel config for data sources' do
172
+ with_site do
173
+ File.open('config.yaml', 'w') do |io|
174
+ io.write "data_sources:\n"
175
+ io.write " -\n"
176
+ io.write " type: filesystem_unified\n"
177
+ io.write " aaa: one\n"
178
+ io.write " config:\n"
179
+ io.write " bbb: two\n"
180
+ end
181
+
182
+ site = Nanoc3::Site.new('.')
183
+ data_sources = site.data_sources
184
+
185
+ assert data_sources.first.config[:aaa] = 'one'
186
+ assert data_sources.first.config[:bbb] = 'two'
187
+ end
188
+ end
189
+
171
190
  end
@@ -365,6 +365,22 @@ class Nanoc3::DataSources::FilesystemTest < MiniTest::Unit::TestCase
365
365
  assert_equal('blah blah', result[1])
366
366
  end
367
367
 
368
+ def test_parse_utf8_bom
369
+ File.open('test.html', 'w') do |io|
370
+ io.write [ 0xEF, 0xBB, 0xBF ].map { |i| i.chr }.join
371
+ io.write "-----\n"
372
+ io.write "utf8bomawareness: high\n"
373
+ io.write "-----\n"
374
+ io.write "content goes here\n"
375
+ end
376
+
377
+ data_source = Nanoc3::DataSources::FilesystemCombined.new(nil, nil, nil, nil)
378
+
379
+ result = data_source.instance_eval { parse('test.html', nil, 'foobar') }
380
+ assert_equal({ 'utf8bomawareness' => 'high' }, result[0])
381
+ assert_equal('content goes here', result[1])
382
+ end
383
+
368
384
  def test_parse_embedded_no_meta
369
385
  content = "blah\n" \
370
386
  "blah blah blah\n" \
@@ -32,7 +32,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
32
32
  autocompiler.stubs(:site).returns(site)
33
33
 
34
34
  # Serve
35
- status, headers, body = autocompiler.instance_eval { call('PATH_INFO' => '/foo/index.html') }
35
+ status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/foo/index.html') }
36
36
 
37
37
  # Check response
38
38
  assert_equal(200, status)
@@ -59,7 +59,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
59
59
  autocompiler.stubs(:site).returns(site)
60
60
 
61
61
  # Serve
62
- status, headers, body = autocompiler.instance_eval { call('PATH_INFO' => '/afjwiagoawf.html') }
62
+ status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/afjwiagoawf.html') }
63
63
 
64
64
  # Check response
65
65
  assert_equal(404, status)
@@ -94,7 +94,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
94
94
  autocompiler.expects(:file_server).returns(file_server)
95
95
 
96
96
  # Run
97
- autocompiler.instance_eval { call('PATH_INFO' => 'somefile.txt') }
97
+ autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'somefile.txt') }
98
98
 
99
99
  # Check
100
100
  assert_equal(file_server.expected_path_info, file_server.actual_path_info)
@@ -128,7 +128,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
128
128
  autocompiler.expects(:file_server).returns(file_server)
129
129
 
130
130
  # Run
131
- autocompiler.instance_eval { call('PATH_INFO' => '/foo/bar/') }
131
+ autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/foo/bar/') }
132
132
 
133
133
  # Check
134
134
  assert_equal(file_server.expected_path_info, file_server.actual_path_info)
@@ -162,7 +162,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
162
162
  autocompiler.expects(:file_server).returns(file_server)
163
163
 
164
164
  # Run
165
- autocompiler.instance_eval { call('PATH_INFO' => 'foo/bar/') }
165
+ autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar/') }
166
166
 
167
167
  # Check
168
168
  assert_equal(file_server.expected_path_info, file_server.actual_path_info)
@@ -196,7 +196,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
196
196
  autocompiler.expects(:file_server).returns(file_server)
197
197
 
198
198
  # Run
199
- autocompiler.instance_eval { call('PATH_INFO' => 'foo/bar') }
199
+ autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar') }
200
200
 
201
201
  # Check
202
202
  assert_equal(file_server.expected_path_info, file_server.actual_path_info)
@@ -230,7 +230,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
230
230
  autocompiler.expects(:file_server).returns(file_server)
231
231
 
232
232
  # Run
233
- autocompiler.instance_eval { call('PATH_INFO' => 'foo/bar') }
233
+ autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'foo/bar') }
234
234
 
235
235
  # Check
236
236
  assert_equal(file_server.expected_path_info, file_server.actual_path_info)
@@ -260,7 +260,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
260
260
  autocompiler.expects(:file_server).returns(file_server)
261
261
 
262
262
  # Run
263
- autocompiler.instance_eval { call('PATH_INFO' => 'four-oh-four.txt') }
263
+ autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => 'four-oh-four.txt') }
264
264
 
265
265
  # Check
266
266
  assert_equal(file_server.expected_path_info, file_server.actual_path_info)
@@ -314,7 +314,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
314
314
  autocompiler.stubs(:site).returns(site)
315
315
 
316
316
  # Serve
317
- status, headers, body = autocompiler.instance_eval { call('PATH_INFO' => '/') }
317
+ status, headers, body = autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/') }
318
318
 
319
319
  # Check response
320
320
  assert_equal(200, status)
@@ -348,7 +348,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
348
348
 
349
349
  # Serve
350
350
  assert_raises(RuntimeError) do
351
- autocompiler.instance_eval { call('PATH_INFO' => '/whatever/') }
351
+ autocompiler.instance_eval { call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/whatever/') }
352
352
  end
353
353
  end
354
354
  end
@@ -375,7 +375,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
375
375
  File.utime(Time.now+5, Time.now+5, 'config.yaml')
376
376
 
377
377
  # Check
378
- status, headers, body = autocompiler.call('PATH_INFO' => '/')
378
+ status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
379
379
  body.each do |b|
380
380
  assert_match /The Grand Value of Configuration is Foo!/, b
381
381
  end
@@ -387,7 +387,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
387
387
  File.utime(Time.now+5, Time.now+5, 'config.yaml')
388
388
 
389
389
  # Check
390
- status, headers, body = autocompiler.call('PATH_INFO' => '/')
390
+ status, headers, body = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/')
391
391
  body.each do |b|
392
392
  assert_match /The Grand Value of Configuration is Bar!/, b
393
393
  end
@@ -408,7 +408,7 @@ class Nanoc3::Extra::AutoCompilerTest < MiniTest::Unit::TestCase
408
408
  autocompiler.stubs(:site).returns(site)
409
409
 
410
410
  # Test
411
- result = autocompiler.call('PATH_INFO' => '/%73oftware')
411
+ result = autocompiler.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/%73oftware')
412
412
  assert_equal 404, result[0]
413
413
  assert_match "File not found: /software\n", result[2][0]
414
414
  end
@@ -11,7 +11,7 @@ class Nanoc3::Filters::RDocTest < MiniTest::Unit::TestCase
11
11
 
12
12
  # Run filter
13
13
  result = filter.run("= Foo")
14
- assert_match(%r{<h1>Foo</h1>\Z}, result)
14
+ assert_match(%r{<h1( id="label-Foo")?>Foo</h1>\Z}, result)
15
15
  end
16
16
  end
17
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-31 00:00:00.000000000 Z
12
+ date: 2012-01-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cri
16
- requirement: &70345936282400 !ruby/object:Gem::Requirement
16
+ requirement: &70158392072000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70345936282400
24
+ version_requirements: *70158392072000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70345936281900 !ruby/object:Gem::Requirement
27
+ requirement: &70158392070860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70345936281900
35
+ version_requirements: *70158392070860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: mocha
38
- requirement: &70345936281040 !ruby/object:Gem::Requirement
38
+ requirement: &70158392069520 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70345936281040
46
+ version_requirements: *70158392069520
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70345936280540 !ruby/object:Gem::Requirement
49
+ requirement: &70158392065560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70345936280540
57
+ version_requirements: *70158392065560
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rdiscount
60
- requirement: &70345936279920 !ruby/object:Gem::Requirement
60
+ requirement: &70158392058260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70345936279920
68
+ version_requirements: *70158392058260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &70345936279240 !ruby/object:Gem::Requirement
71
+ requirement: &70158392056380 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70345936279240
79
+ version_requirements: *70158392056380
80
80
  description: nanoc is a simple but very flexible static site generator written in
81
81
  Ruby. It operates on local files, and therefore does not run on the server. nanoc
82
82
  “compiles” the local source files into HTML (usually), by evaluating eRuby, Markdown,