nanoc 3.6.7 → 3.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CONTRIBUTING.md +9 -13
- data/Gemfile +5 -1
- data/Gemfile.lock +70 -45
- data/NEWS.md +15 -1
- data/README.md +12 -119
- data/doc/yardoc_handlers/identifier.rb +34 -0
- data/lib/nanoc/base/compilation/checksum_store.rb +2 -2
- data/lib/nanoc/base/compilation/compiler.rb +3 -3
- data/lib/nanoc/base/compilation/compiler_dsl.rb +20 -15
- data/lib/nanoc/base/compilation/dependency_tracker.rb +4 -4
- data/lib/nanoc/base/compilation/filter.rb +5 -5
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +2 -2
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +3 -3
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +49 -46
- data/lib/nanoc/base/compilation/rule.rb +6 -4
- data/lib/nanoc/base/compilation/rule_context.rb +10 -4
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +8 -7
- data/lib/nanoc/base/compilation/rule_memory_store.rb +2 -2
- data/lib/nanoc/base/compilation/rules_collection.rb +2 -2
- data/lib/nanoc/base/core_ext/array.rb +2 -2
- data/lib/nanoc/base/core_ext/date.rb +4 -2
- data/lib/nanoc/base/core_ext/hash.rb +3 -3
- data/lib/nanoc/base/core_ext/pathname.rb +1 -1
- data/lib/nanoc/base/directed_graph.rb +6 -6
- data/lib/nanoc/base/errors.rb +1 -1
- data/lib/nanoc/base/memoization.rb +4 -4
- data/lib/nanoc/base/notification_center.rb +1 -1
- data/lib/nanoc/base/ordered_hash.rb +207 -179
- data/lib/nanoc/base/plugin_registry.rb +7 -7
- data/lib/nanoc/base/result_data/item_rep.rb +25 -26
- data/lib/nanoc/base/source_data/code_snippet.rb +2 -2
- data/lib/nanoc/base/source_data/configuration.rb +1 -1
- data/lib/nanoc/base/source_data/data_source.rb +2 -2
- data/lib/nanoc/base/source_data/item.rb +16 -15
- data/lib/nanoc/base/source_data/item_array.rb +4 -4
- data/lib/nanoc/base/source_data/layout.rb +5 -5
- data/lib/nanoc/base/source_data/site.rb +6 -6
- data/lib/nanoc/base/store.rb +8 -8
- data/lib/nanoc/cli/cleaning_stream.rb +11 -12
- data/lib/nanoc/cli/command_runner.rb +8 -8
- data/lib/nanoc/cli/commands/autocompile.rb +5 -4
- data/lib/nanoc/cli/commands/check.rb +12 -11
- data/lib/nanoc/cli/commands/compile.rb +50 -52
- data/lib/nanoc/cli/commands/create-item.rb +6 -6
- data/lib/nanoc/cli/commands/create-layout.rb +6 -6
- data/lib/nanoc/cli/commands/create-site.rb +10 -13
- data/lib/nanoc/cli/commands/deploy.rb +11 -11
- data/lib/nanoc/cli/commands/prune.rb +10 -10
- data/lib/nanoc/cli/commands/shell.rb +7 -7
- data/lib/nanoc/cli/commands/show-data.rb +22 -23
- data/lib/nanoc/cli/commands/show-plugins.rb +3 -3
- data/lib/nanoc/cli/commands/show-rules.rb +8 -8
- data/lib/nanoc/cli/commands/sync.rb +4 -2
- data/lib/nanoc/cli/commands/update.rb +4 -4
- data/lib/nanoc/cli/commands/validate-css.rb +3 -3
- data/lib/nanoc/cli/commands/validate-html.rb +3 -3
- data/lib/nanoc/cli/commands/validate-links.rb +3 -3
- data/lib/nanoc/cli/commands/view.rb +5 -3
- data/lib/nanoc/cli/commands/watch.rb +12 -12
- data/lib/nanoc/cli/error_handler.rb +58 -58
- data/lib/nanoc/cli/logger.rb +6 -6
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +1 -1
- data/lib/nanoc/cli/stream_cleaners.rb +0 -1
- data/lib/nanoc/cli.rb +24 -22
- data/lib/nanoc/data_sources/deprecated/delicious.rb +1 -1
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +16 -14
- data/lib/nanoc/data_sources/deprecated/twitter.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +22 -20
- data/lib/nanoc/data_sources/filesystem_unified.rb +4 -5
- data/lib/nanoc/data_sources/filesystem_verbose.rb +2 -3
- data/lib/nanoc/data_sources/static.rb +2 -2
- data/lib/nanoc/extra/auto_compiler.rb +3 -3
- data/lib/nanoc/extra/checking/check.rb +3 -3
- data/lib/nanoc/extra/checking/checks/css.rb +2 -2
- data/lib/nanoc/extra/checking/checks/external_links.rb +9 -9
- data/lib/nanoc/extra/checking/checks/html.rb +2 -3
- data/lib/nanoc/extra/checking/checks/internal_links.rb +6 -7
- data/lib/nanoc/extra/checking/checks/stale.rb +6 -6
- data/lib/nanoc/extra/checking/dsl.rb +1 -1
- data/lib/nanoc/extra/checking/runner.rb +19 -19
- data/lib/nanoc/extra/chick.rb +11 -9
- data/lib/nanoc/extra/core_ext/pathname.rb +1 -2
- data/lib/nanoc/extra/core_ext/time.rb +2 -2
- data/lib/nanoc/extra/core_ext.rb +0 -1
- data/lib/nanoc/extra/deployer.rb +2 -2
- data/lib/nanoc/extra/deployers/fog.rb +12 -12
- data/lib/nanoc/extra/deployers/rsync.rb +6 -6
- data/lib/nanoc/extra/file_proxy.rb +1 -1
- data/lib/nanoc/extra/filesystem_tools.rb +5 -5
- data/lib/nanoc/extra/link_collector.rb +4 -3
- data/lib/nanoc/extra/pruner.rb +5 -5
- data/lib/nanoc/extra/validators/links.rb +3 -3
- data/lib/nanoc/extra/vcs.rb +1 -1
- data/lib/nanoc/filters/asciidoc.rb +3 -3
- data/lib/nanoc/filters/bluecloth.rb +1 -1
- data/lib/nanoc/filters/coderay.rb +2 -2
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +16 -16
- data/lib/nanoc/filters/erb.rb +5 -5
- data/lib/nanoc/filters/erubis.rb +1 -1
- data/lib/nanoc/filters/haml.rb +1 -1
- data/lib/nanoc/filters/handlebars.rb +2 -2
- data/lib/nanoc/filters/kramdown.rb +1 -1
- data/lib/nanoc/filters/less.rb +1 -1
- data/lib/nanoc/filters/markaby.rb +1 -1
- data/lib/nanoc/filters/maruku.rb +1 -1
- data/lib/nanoc/filters/mustache.rb +1 -1
- data/lib/nanoc/filters/pandoc.rb +1 -1
- data/lib/nanoc/filters/rainpress.rb +1 -1
- data/lib/nanoc/filters/rdiscount.rb +1 -1
- data/lib/nanoc/filters/rdoc.rb +1 -1
- data/lib/nanoc/filters/redcarpet.rb +2 -2
- data/lib/nanoc/filters/redcloth.rb +9 -9
- data/lib/nanoc/filters/relativize_paths.rb +7 -8
- data/lib/nanoc/filters/rubypants.rb +1 -1
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +1 -1
- data/lib/nanoc/filters/sass.rb +1 -1
- data/lib/nanoc/filters/slim.rb +1 -1
- data/lib/nanoc/filters/typogruby.rb +1 -1
- data/lib/nanoc/filters/uglify_js.rb +1 -1
- data/lib/nanoc/filters/xsl.rb +9 -7
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers/blogging.rb +6 -6
- data/lib/nanoc/helpers/breadcrumbs.rb +1 -1
- data/lib/nanoc/helpers/capturing.rb +2 -2
- data/lib/nanoc/helpers/filtering.rb +1 -1
- data/lib/nanoc/helpers/html_escape.rb +3 -3
- data/lib/nanoc/helpers/link_to.rb +6 -6
- data/lib/nanoc/helpers/rendering.rb +2 -2
- data/lib/nanoc/helpers/tagging.rb +2 -2
- data/lib/nanoc/helpers/text.rb +1 -1
- data/lib/nanoc/helpers/xml_sitemap.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- data/lib/nanoc.rb +3 -2
- data/nanoc.gemspec +2 -6
- data/tasks/rubocop.rake +5 -0
- data/test/base/test_compiler_dsl.rb +20 -1
- data/test/cli/commands/test_compile.rb +4 -3
- data/test/cli/test_error_handler.rb +32 -0
- data/test/filters/test_erb.rb +1 -1
- data/test/filters/test_less.rb +1 -1
- data/test/filters/test_xsl.rb +95 -8
- metadata +30 -84
@@ -33,7 +33,7 @@ module Nanoc::CLI::Commands
|
|
33
33
|
# @abstract Subclasses must override {#start} and may override {#stop}.
|
34
34
|
class Listener
|
35
35
|
|
36
|
-
def initialize(params={})
|
36
|
+
def initialize(params = {})
|
37
37
|
end
|
38
38
|
|
39
39
|
# @param [Nanoc::CLI::CommandRunner] command_runner The command runner for this listener
|
@@ -51,7 +51,7 @@ module Nanoc::CLI::Commands
|
|
51
51
|
#
|
52
52
|
# @abstract
|
53
53
|
def start
|
54
|
-
raise NotImplementedError,
|
54
|
+
raise NotImplementedError, 'Subclasses of Listener should implement #start'
|
55
55
|
end
|
56
56
|
|
57
57
|
# Stops the listener. The default implementation removes self from all notification center observers.
|
@@ -73,7 +73,7 @@ module Nanoc::CLI::Commands
|
|
73
73
|
# @see Listener#start
|
74
74
|
def start
|
75
75
|
require 'tempfile'
|
76
|
-
|
76
|
+
setup_diffs
|
77
77
|
old_contents = {}
|
78
78
|
Nanoc::NotificationCenter.on(:will_write_rep) do |rep, snapshot|
|
79
79
|
path = rep.raw_path(:snapshot => snapshot)
|
@@ -93,7 +93,7 @@ module Nanoc::CLI::Commands
|
|
93
93
|
# @see Listener#stop
|
94
94
|
def stop
|
95
95
|
super
|
96
|
-
|
96
|
+
teardown_diffs
|
97
97
|
end
|
98
98
|
|
99
99
|
protected
|
@@ -161,7 +161,7 @@ module Nanoc::CLI::Commands
|
|
161
161
|
end
|
162
162
|
|
163
163
|
# @option params [Array<Nanoc::ItemRep>] :reps The list of item representations in the site
|
164
|
-
def initialize(params={})
|
164
|
+
def initialize(params = {})
|
165
165
|
@times = {}
|
166
166
|
|
167
167
|
@reps = params.fetch(:reps)
|
@@ -180,7 +180,7 @@ module Nanoc::CLI::Commands
|
|
180
180
|
|
181
181
|
# @see Listener#stop
|
182
182
|
def stop
|
183
|
-
|
183
|
+
print_profiling_feedback
|
184
184
|
super
|
185
185
|
end
|
186
186
|
|
@@ -194,8 +194,8 @@ module Nanoc::CLI::Commands
|
|
194
194
|
# Print warning if necessary
|
195
195
|
if @reps.any? { |r| !r.compiled? }
|
196
196
|
$stderr.puts
|
197
|
-
$stderr.puts
|
198
|
-
|
197
|
+
$stderr.puts 'Warning: profiling information may not be accurate because ' +
|
198
|
+
'some items were not compiled.'
|
199
199
|
end
|
200
200
|
|
201
201
|
# Print header
|
@@ -204,7 +204,7 @@ module Nanoc::CLI::Commands
|
|
204
204
|
puts '-' * max_filter_name_length + '-+-----------------------------------'
|
205
205
|
|
206
206
|
durations_per_filter.to_a.sort_by { |r| r[1] }.each do |row|
|
207
|
-
|
207
|
+
print_row(row, max_filter_name_length)
|
208
208
|
end
|
209
209
|
end
|
210
210
|
|
@@ -215,8 +215,8 @@ module Nanoc::CLI::Commands
|
|
215
215
|
# Calculate stats
|
216
216
|
count = samples.size
|
217
217
|
min = samples.min
|
218
|
-
tot = samples.
|
219
|
-
avg = tot/count
|
218
|
+
tot = samples.reduce(0) { |memo, i| memo + i }
|
219
|
+
avg = tot / count
|
220
220
|
max = samples.max
|
221
221
|
|
222
222
|
# Format stats
|
@@ -234,7 +234,8 @@ module Nanoc::CLI::Commands
|
|
234
234
|
def durations_per_filter
|
235
235
|
@_durations_per_filter ||= begin
|
236
236
|
@times.keys.each_with_object({}) do |filter_name, result|
|
237
|
-
|
237
|
+
durations = durations_for_filter(filter_name)
|
238
|
+
if durations
|
238
239
|
result[filter_name] = durations
|
239
240
|
end
|
240
241
|
end
|
@@ -256,10 +257,10 @@ module Nanoc::CLI::Commands
|
|
256
257
|
|
257
258
|
# @see Listener#enable_for?
|
258
259
|
def self.enable_for?(command_runner)
|
259
|
-
!
|
260
|
+
!ENV.key?('TRAVIS')
|
260
261
|
end
|
261
262
|
|
262
|
-
def initialize(params={})
|
263
|
+
def initialize(params = {})
|
263
264
|
@gc_count = 0
|
264
265
|
end
|
265
266
|
|
@@ -329,9 +330,8 @@ module Nanoc::CLI::Commands
|
|
329
330
|
class FileActionPrinter < Listener
|
330
331
|
|
331
332
|
# @option params [Array<Nanoc::ItemRep>] :reps The list of item representations in the site
|
332
|
-
def initialize(params={})
|
333
|
+
def initialize(params = {})
|
333
334
|
@start_times = {}
|
334
|
-
@stop_times = {}
|
335
335
|
|
336
336
|
@reps = params.fetch(:reps)
|
337
337
|
end
|
@@ -341,13 +341,21 @@ module Nanoc::CLI::Commands
|
|
341
341
|
Nanoc::NotificationCenter.on(:compilation_started) do |rep|
|
342
342
|
@start_times[rep.raw_path] = Time.now
|
343
343
|
end
|
344
|
-
Nanoc::NotificationCenter.on(:compilation_ended) do |rep|
|
345
|
-
@stop_times[rep.raw_path] = Time.now
|
346
|
-
end
|
347
344
|
Nanoc::NotificationCenter.on(:rep_written) do |rep, path, is_created, is_modified|
|
348
|
-
|
349
|
-
|
350
|
-
|
345
|
+
duration = path && @start_times[path] ? Time.now - @start_times[path] : nil
|
346
|
+
action =
|
347
|
+
case
|
348
|
+
when is_created then :create
|
349
|
+
when is_modified then :update
|
350
|
+
else :identical
|
351
|
+
end
|
352
|
+
level =
|
353
|
+
case
|
354
|
+
when is_created then :high
|
355
|
+
when is_modified then :high
|
356
|
+
else :low
|
357
|
+
end
|
358
|
+
log(level, action, path, duration)
|
351
359
|
end
|
352
360
|
end
|
353
361
|
|
@@ -356,22 +364,12 @@ module Nanoc::CLI::Commands
|
|
356
364
|
super
|
357
365
|
@reps.select { |r| !r.compiled? }.each do |rep|
|
358
366
|
rep.raw_paths.each do |snapshot_name, raw_path|
|
359
|
-
log(:low, :skip, raw_path,
|
367
|
+
log(:low, :skip, raw_path, nil)
|
360
368
|
end
|
361
369
|
end
|
362
370
|
end
|
363
371
|
|
364
|
-
|
365
|
-
|
366
|
-
def duration_for(rep)
|
367
|
-
return nil if rep.raw_path.nil?
|
368
|
-
|
369
|
-
start = @start_times[rep.raw_path]
|
370
|
-
stop = @stop_times[rep.raw_path]
|
371
|
-
return nil if start.nil? || stop.nil?
|
372
|
-
|
373
|
-
stop - start
|
374
|
-
end
|
372
|
+
private
|
375
373
|
|
376
374
|
def log(level, action, path, duration)
|
377
375
|
Nanoc::CLI::Logger.instance.file(level, action, path, duration)
|
@@ -379,21 +377,21 @@ module Nanoc::CLI::Commands
|
|
379
377
|
|
380
378
|
end
|
381
379
|
|
382
|
-
def initialize(options, arguments, command, params={})
|
380
|
+
def initialize(options, arguments, command, params = {})
|
383
381
|
super(options, arguments, command)
|
384
|
-
@listener_classes = params.fetch(:listener_classes,
|
382
|
+
@listener_classes = params.fetch(:listener_classes, default_listener_classes)
|
385
383
|
end
|
386
384
|
|
387
385
|
def run
|
388
386
|
time_before = Time.now
|
389
387
|
|
390
|
-
|
391
|
-
|
388
|
+
load_site
|
389
|
+
check_for_deprecated_usage
|
392
390
|
|
393
|
-
puts
|
394
|
-
|
395
|
-
|
396
|
-
|
391
|
+
puts 'Compiling site…'
|
392
|
+
run_listeners_while do
|
393
|
+
site.compile
|
394
|
+
prune
|
397
395
|
end
|
398
396
|
|
399
397
|
time_after = Time.now
|
@@ -404,8 +402,8 @@ module Nanoc::CLI::Commands
|
|
404
402
|
protected
|
405
403
|
|
406
404
|
def prune
|
407
|
-
if
|
408
|
-
Nanoc::Extra::Pruner.new(
|
405
|
+
if site.config[:prune][:auto_prune]
|
406
|
+
Nanoc::Extra::Pruner.new(site, :exclude => prune_config_exclude).run
|
409
407
|
end
|
410
408
|
end
|
411
409
|
|
@@ -422,7 +420,7 @@ module Nanoc::CLI::Commands
|
|
422
420
|
def setup_listeners
|
423
421
|
@listeners = @listener_classes.
|
424
422
|
select { |klass| klass.enable_for?(self) }.
|
425
|
-
map { |klass| klass.new(:reps =>
|
423
|
+
map { |klass| klass.new(:reps => reps) }
|
426
424
|
|
427
425
|
@listeners.each { |s| s.start }
|
428
426
|
end
|
@@ -432,10 +430,10 @@ module Nanoc::CLI::Commands
|
|
432
430
|
end
|
433
431
|
|
434
432
|
def run_listeners_while
|
435
|
-
|
433
|
+
setup_listeners
|
436
434
|
yield
|
437
435
|
ensure
|
438
|
-
|
436
|
+
teardown_listeners
|
439
437
|
end
|
440
438
|
|
441
439
|
def teardown_listeners
|
@@ -443,14 +441,14 @@ module Nanoc::CLI::Commands
|
|
443
441
|
end
|
444
442
|
|
445
443
|
def reps
|
446
|
-
|
444
|
+
site.items.map { |i| i.reps }.flatten
|
447
445
|
end
|
448
446
|
memoize :reps
|
449
447
|
|
450
448
|
def check_for_deprecated_usage
|
451
449
|
# Check presence of --all option
|
452
|
-
if options.
|
453
|
-
$stderr.puts
|
450
|
+
if options.key?(:all) || options.key?(:force)
|
451
|
+
$stderr.puts 'Warning: the --force option (and its deprecated --all alias) are, as of nanoc 3.2, no longer supported and have no effect.'
|
454
452
|
end
|
455
453
|
|
456
454
|
# Warn if trying to compile a single item
|
@@ -462,11 +460,11 @@ module Nanoc::CLI::Commands
|
|
462
460
|
end
|
463
461
|
|
464
462
|
def prune_config
|
465
|
-
|
463
|
+
site.config[:prune] || {}
|
466
464
|
end
|
467
465
|
|
468
466
|
def prune_config_exclude
|
469
|
-
|
467
|
+
prune_config[:exclude] || {}
|
470
468
|
end
|
471
469
|
|
472
470
|
end
|
@@ -24,16 +24,16 @@ module Nanoc::CLI::Commands
|
|
24
24
|
identifier = arguments[0].cleaned_identifier
|
25
25
|
|
26
26
|
# Make sure we are in a nanoc site directory
|
27
|
-
|
27
|
+
require_site
|
28
28
|
|
29
29
|
# Set VCS if possible
|
30
|
-
|
30
|
+
set_vcs(options[:vcs])
|
31
31
|
|
32
32
|
# Check whether item is unique
|
33
|
-
if !
|
33
|
+
if !site.items.find { |i| i.identifier == identifier }.nil?
|
34
34
|
raise Nanoc::Errors::GenericTrivial,
|
35
35
|
"An item already exists at #{identifier}. Please " +
|
36
|
-
|
36
|
+
'pick a unique name for the item you are creating.'
|
37
37
|
end
|
38
38
|
|
39
39
|
# Setup notifications
|
@@ -42,10 +42,10 @@ module Nanoc::CLI::Commands
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# Create item
|
45
|
-
data_source =
|
45
|
+
data_source = site.data_sources[0]
|
46
46
|
data_source.create_item(
|
47
47
|
"Hi, I'm a new item!\n",
|
48
|
-
{ :title =>
|
48
|
+
{ :title => 'A New Item' },
|
49
49
|
identifier
|
50
50
|
)
|
51
51
|
|
@@ -22,23 +22,23 @@ module Nanoc::CLI::Commands
|
|
22
22
|
identifier = arguments[0].cleaned_identifier
|
23
23
|
|
24
24
|
# Make sure we are in a nanoc site directory
|
25
|
-
|
25
|
+
require_site
|
26
26
|
|
27
27
|
# Set VCS if possible
|
28
|
-
|
28
|
+
set_vcs(options[:vcs])
|
29
29
|
|
30
30
|
# Check whether layout is unique
|
31
|
-
if !
|
31
|
+
if !site.layouts.find { |l| l.identifier == identifier }.nil?
|
32
32
|
raise Nanoc::Errors::GenericTrivial,
|
33
33
|
"A layout already exists at #{identifier}. Please " +
|
34
|
-
|
34
|
+
'pick a unique name for the layout you are creating.'
|
35
35
|
end
|
36
36
|
|
37
37
|
# Check whether layout is not at /
|
38
38
|
if identifier == '/'
|
39
39
|
raise Nanoc::Errors::GenericTrivial,
|
40
40
|
"There cannot be a layout with the identifier '/'; " +
|
41
|
-
|
41
|
+
'please pick a different identifier for this layout.'
|
42
42
|
end
|
43
43
|
|
44
44
|
# Setup notifications
|
@@ -47,7 +47,7 @@ module Nanoc::CLI::Commands
|
|
47
47
|
end
|
48
48
|
|
49
49
|
# Create layout
|
50
|
-
data_source =
|
50
|
+
data_source = site.data_sources[0]
|
51
51
|
data_source.create_layout(
|
52
52
|
"<html>\n" +
|
53
53
|
" <head>\n" +
|
@@ -3,9 +3,9 @@
|
|
3
3
|
usage 'create-site [options] path'
|
4
4
|
aliases :create_site, :cs
|
5
5
|
summary 'create a site'
|
6
|
-
description
|
6
|
+
description "
|
7
7
|
Create a new site at the given path. The site will use the `filesystem_unified` data source by default, but this can be changed using the `--datasource` commandline option.
|
8
|
-
|
8
|
+
"
|
9
9
|
|
10
10
|
required :d, :datasource, 'specify the data source for the new site'
|
11
11
|
|
@@ -102,12 +102,10 @@ EOS
|
|
102
102
|
# item, use the pattern “/about/*/”; “/about/*” will also select the parent,
|
103
103
|
# because “*” matches zero or more characters.
|
104
104
|
|
105
|
-
compile '/stylesheet/' do
|
106
|
-
# don’t filter or layout
|
107
|
-
end
|
108
|
-
|
109
105
|
compile '*' do
|
110
|
-
if item
|
106
|
+
if item[:extension] == 'css'
|
107
|
+
# don’t filter stylesheets
|
108
|
+
elsif item.binary?
|
111
109
|
# don’t filter binary items
|
112
110
|
else
|
113
111
|
filter :erb
|
@@ -115,12 +113,11 @@ compile '*' do
|
|
115
113
|
end
|
116
114
|
end
|
117
115
|
|
118
|
-
route '/stylesheet/' do
|
119
|
-
'/style.css'
|
120
|
-
end
|
121
|
-
|
122
116
|
route '*' do
|
123
|
-
if item
|
117
|
+
if item[:extension] == 'css'
|
118
|
+
# Write item with identifier /foo/ to /foo.css
|
119
|
+
item.identifier.chop + '.css'
|
120
|
+
elsif item.binary?
|
124
121
|
# Write item with identifier /foo/ to /foo.ext
|
125
122
|
item.identifier.chop + '.' + item[:extension]
|
126
123
|
else
|
@@ -358,7 +355,7 @@ EOS
|
|
358
355
|
# Create home page
|
359
356
|
data_source.create_item(
|
360
357
|
DEFAULT_ITEM,
|
361
|
-
{ :title =>
|
358
|
+
{ :title => 'Home' },
|
362
359
|
'/'
|
363
360
|
)
|
364
361
|
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
usage 'deploy [options]'
|
4
4
|
summary 'deploy the compiled site'
|
5
|
-
description
|
5
|
+
description "
|
6
6
|
Deploys the compiled site. The compiled site contents in the output directory will be uploaded to the destination, which is specified using the `--target` option.
|
7
|
-
|
7
|
+
"
|
8
8
|
|
9
9
|
option :t, :target, 'specify the location to deploy to (default: `default`)', :argument => :required
|
10
10
|
flag :C, :'no-check', 'do not run the issue checks marked for deployment'
|
@@ -17,13 +17,13 @@ module Nanoc::CLI::Commands
|
|
17
17
|
class Deploy < ::Nanoc::CLI::CommandRunner
|
18
18
|
|
19
19
|
def run
|
20
|
-
|
20
|
+
load_site
|
21
21
|
|
22
22
|
# List deployers
|
23
23
|
if options[:'list-deployers']
|
24
24
|
deployers = Nanoc::PluginRegistry.instance.find_all(Nanoc::Extra::Deployer)
|
25
25
|
deployer_names = deployers.keys.sort_by { |k| k.to_s }
|
26
|
-
puts
|
26
|
+
puts 'Available deployers:'
|
27
27
|
deployer_names.each do |name|
|
28
28
|
puts " #{name}"
|
29
29
|
end
|
@@ -35,9 +35,9 @@ module Nanoc::CLI::Commands
|
|
35
35
|
|
36
36
|
if options[:list]
|
37
37
|
if deploy_configs.empty?
|
38
|
-
puts
|
38
|
+
puts 'No deployment configurations.'
|
39
39
|
else
|
40
|
-
puts
|
40
|
+
puts 'Available deployment configurations:'
|
41
41
|
deploy_configs.keys.each do |name|
|
42
42
|
puts " #{name}"
|
43
43
|
end
|
@@ -47,7 +47,7 @@ module Nanoc::CLI::Commands
|
|
47
47
|
|
48
48
|
# Can't proceed further without a deploy config
|
49
49
|
if deploy_configs.empty?
|
50
|
-
raise Nanoc::Errors::GenericTrivial,
|
50
|
+
raise Nanoc::Errors::GenericTrivial, 'The site has no deployment configurations.'
|
51
51
|
end
|
52
52
|
|
53
53
|
# Get target
|
@@ -59,7 +59,7 @@ module Nanoc::CLI::Commands
|
|
59
59
|
# Get deployer
|
60
60
|
names = Nanoc::Extra::Deployer.all.keys
|
61
61
|
name = config.fetch(:kind) do
|
62
|
-
$stderr.puts
|
62
|
+
$stderr.puts 'Warning: The specified deploy target does not have a kind attribute. Assuming rsync.'
|
63
63
|
'rsync'
|
64
64
|
end
|
65
65
|
deployer_class = Nanoc::Extra::Deployer.named(name)
|
@@ -71,13 +71,13 @@ module Nanoc::CLI::Commands
|
|
71
71
|
unless options[:'no-check']
|
72
72
|
runner = Nanoc::Extra::Checking::Runner.new(site)
|
73
73
|
if runner.has_dsl?
|
74
|
-
puts
|
74
|
+
puts 'Running issue checks…'
|
75
75
|
ok = runner.run_for_deploy
|
76
76
|
if !ok
|
77
|
-
puts
|
77
|
+
puts 'Issues found, deploy aborted.'
|
78
78
|
return
|
79
79
|
end
|
80
|
-
puts
|
80
|
+
puts 'No issues found. Deploying!'
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -19,16 +19,16 @@ module Nanoc::CLI::Commands
|
|
19
19
|
class Prune < ::Nanoc::CLI::CommandRunner
|
20
20
|
|
21
21
|
def run
|
22
|
-
|
22
|
+
load_site
|
23
23
|
|
24
|
-
if options.
|
25
|
-
Nanoc::Extra::Pruner.new(
|
26
|
-
elsif options.
|
27
|
-
Nanoc::Extra::Pruner.new(
|
24
|
+
if options.key?(:yes)
|
25
|
+
Nanoc::Extra::Pruner.new(site, :exclude => prune_config_exclude).run
|
26
|
+
elsif options.key?(:'dry-run')
|
27
|
+
Nanoc::Extra::Pruner.new(site, :exclude => prune_config_exclude, :dry_run => true).run
|
28
28
|
else
|
29
|
-
$stderr.puts
|
29
|
+
$stderr.puts 'WARNING: Since the prune command is a destructive command, it requires an additional --yes flag in order to work.'
|
30
30
|
$stderr.puts
|
31
|
-
$stderr.puts
|
31
|
+
$stderr.puts 'Please ensure that the output directory does not contain any files (such as images or stylesheets) that are necessary but are not managed by nanoc. If you want to get a list of all files that would be removed, pass --dry-run.'
|
32
32
|
exit 1
|
33
33
|
end
|
34
34
|
end
|
@@ -36,13 +36,13 @@ module Nanoc::CLI::Commands
|
|
36
36
|
protected
|
37
37
|
|
38
38
|
def prune_config
|
39
|
-
|
39
|
+
site.config[:prune] || {}
|
40
40
|
end
|
41
41
|
|
42
42
|
def prune_config_exclude
|
43
|
-
|
43
|
+
prune_config[:exclude] || {}
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
usage 'shell'
|
4
4
|
summary 'open a shell on the nanoc environment'
|
5
5
|
aliases 'console'
|
6
|
-
description
|
6
|
+
description "
|
7
7
|
Open an IRB shell on a context that contains @items, @layouts, @config and @site.
|
8
|
-
|
8
|
+
"
|
9
9
|
|
10
10
|
module Nanoc::CLI::Commands
|
11
11
|
|
@@ -14,7 +14,7 @@ module Nanoc::CLI::Commands
|
|
14
14
|
def run
|
15
15
|
require 'pry'
|
16
16
|
|
17
|
-
|
17
|
+
require_site
|
18
18
|
|
19
19
|
Nanoc::Context.new(env).pry
|
20
20
|
end
|
@@ -23,10 +23,10 @@ module Nanoc::CLI::Commands
|
|
23
23
|
|
24
24
|
def env
|
25
25
|
{
|
26
|
-
:site =>
|
27
|
-
:items =>
|
28
|
-
:layouts =>
|
29
|
-
:config =>
|
26
|
+
:site => site,
|
27
|
+
:items => site.items,
|
28
|
+
:layouts => site.layouts,
|
29
|
+
:config => site.config
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
@@ -13,23 +13,22 @@ module Nanoc::CLI::Commands
|
|
13
13
|
class ShowData < ::Nanoc::CLI::CommandRunner
|
14
14
|
|
15
15
|
def run
|
16
|
-
|
16
|
+
load_site
|
17
17
|
|
18
18
|
# Get data
|
19
|
-
items
|
20
|
-
|
21
|
-
layouts = self.site.layouts
|
19
|
+
items = site.items
|
20
|
+
layouts = site.layouts
|
22
21
|
|
23
22
|
# Get dependency tracker
|
24
|
-
compiler =
|
23
|
+
compiler = site.compiler
|
25
24
|
compiler.load
|
26
25
|
dependency_tracker = compiler.dependency_tracker
|
27
26
|
|
28
27
|
# Print data
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
print_item_dependencies(items, dependency_tracker)
|
29
|
+
print_item_rep_paths(items)
|
30
|
+
print_item_rep_outdatedness(items, compiler)
|
31
|
+
print_layouts(layouts, compiler)
|
33
32
|
end
|
34
33
|
|
35
34
|
protected
|
@@ -54,7 +53,7 @@ module Nanoc::CLI::Commands
|
|
54
53
|
|
55
54
|
def print_header(title)
|
56
55
|
header = '=' * 78
|
57
|
-
header[3..(title.length+5)] = " #{title} "
|
56
|
+
header[3..(title.length + 5)] = " #{title} "
|
58
57
|
|
59
58
|
puts
|
60
59
|
puts header
|
@@ -62,9 +61,9 @@ module Nanoc::CLI::Commands
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def print_item_dependencies(items, dependency_tracker)
|
65
|
-
|
64
|
+
print_header('Item dependencies')
|
66
65
|
|
67
|
-
|
66
|
+
sorted_with_prev(items) do |item, prev|
|
68
67
|
puts if prev
|
69
68
|
puts "item #{item.identifier} depends on:"
|
70
69
|
predecessors = dependency_tracker.objects_causing_outdatedness_of(item).sort_by { |i| i ? i.identifier : '' }
|
@@ -72,21 +71,21 @@ module Nanoc::CLI::Commands
|
|
72
71
|
if pred
|
73
72
|
puts " [ #{format '%6s', pred.type} ] #{pred.identifier}"
|
74
73
|
else
|
75
|
-
puts
|
74
|
+
puts ' ( removed item )'
|
76
75
|
end
|
77
76
|
end
|
78
|
-
puts
|
77
|
+
puts ' (nothing)' if predecessors.empty?
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
82
81
|
def print_item_rep_paths(items)
|
83
|
-
|
82
|
+
print_header('Item representation paths')
|
84
83
|
|
85
|
-
|
84
|
+
sorted_reps_with_prev(items) do |rep, prev|
|
86
85
|
puts if prev
|
87
86
|
puts "item #{rep.item.identifier}, rep #{rep.name}:"
|
88
87
|
if rep.raw_paths.empty?
|
89
|
-
puts
|
88
|
+
puts ' (not written)'
|
90
89
|
end
|
91
90
|
length = rep.raw_paths.keys.map { |s| s.to_s.length }.max
|
92
91
|
rep.raw_paths.each do |snapshot_name, raw_path|
|
@@ -96,31 +95,31 @@ module Nanoc::CLI::Commands
|
|
96
95
|
end
|
97
96
|
|
98
97
|
def print_item_rep_outdatedness(items, compiler)
|
99
|
-
|
98
|
+
print_header('Item representation outdatedness')
|
100
99
|
|
101
|
-
|
100
|
+
sorted_reps_with_prev(items) do |rep, prev|
|
102
101
|
puts if prev
|
103
102
|
puts "item #{rep.item.identifier}, rep #{rep.name}:"
|
104
103
|
outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(rep)
|
105
104
|
if outdatedness_reason
|
106
105
|
puts " is outdated: #{outdatedness_reason.message}"
|
107
106
|
else
|
108
|
-
puts
|
107
|
+
puts ' is not outdated'
|
109
108
|
end
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
112
|
def print_layouts(layouts, compiler)
|
114
|
-
|
113
|
+
print_header('Layouts')
|
115
114
|
|
116
|
-
|
115
|
+
sorted_with_prev(layouts) do |layout, prev|
|
117
116
|
puts if prev
|
118
117
|
puts "layout #{layout.identifier}:"
|
119
118
|
outdatedness_reason = compiler.outdatedness_checker.outdatedness_reason_for(layout)
|
120
119
|
if outdatedness_reason
|
121
120
|
puts " is outdated: #{outdatedness_reason.message}"
|
122
121
|
else
|
123
|
-
puts
|
122
|
+
puts ' is not outdated'
|
124
123
|
end
|
125
124
|
puts
|
126
125
|
end
|
@@ -20,7 +20,7 @@ module Nanoc::CLI::Commands
|
|
20
20
|
|
21
21
|
# Get list of plugins (before and after)
|
22
22
|
plugins_before = Nanoc::Plugin.all
|
23
|
-
|
23
|
+
site.code_snippets if site
|
24
24
|
plugins_after = Nanoc::Plugin.all
|
25
25
|
|
26
26
|
# Divide list of plugins into builtin and custom
|
@@ -28,7 +28,7 @@ module Nanoc::CLI::Commands
|
|
28
28
|
plugins_custom = plugins_after - plugins_before
|
29
29
|
|
30
30
|
# Find max identifiers length
|
31
|
-
plugin_with_longest_identifiers = plugins_after.
|
31
|
+
plugin_with_longest_identifiers = plugins_after.reduce do |longest, current|
|
32
32
|
longest[:identifiers].join(', ').size > current[:identifiers].join(', ').size ? longest : current
|
33
33
|
end
|
34
34
|
max_identifiers_length = plugin_with_longest_identifiers[:identifiers].join(', ').size
|
@@ -52,7 +52,7 @@ module Nanoc::CLI::Commands
|
|
52
52
|
# Print type
|
53
53
|
puts " #{type}:"
|
54
54
|
if relevant_plugins.empty?
|
55
|
-
puts
|
55
|
+
puts ' (none)'
|
56
56
|
next
|
57
57
|
end
|
58
58
|
|