nanoc 3.8.0 → 4.0.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +322 -0
- data/NEWS.md +6 -0
- data/bin/nanoc +0 -18
- data/lib/nanoc.rb +5 -3
- data/lib/nanoc/base.rb +24 -6
- data/lib/nanoc/base/checksummer.rb +6 -4
- data/lib/nanoc/base/compilation/checksum_store.rb +4 -4
- data/lib/nanoc/base/compilation/compiled_content_cache.rb +5 -5
- data/lib/nanoc/base/compilation/compiler.rb +60 -65
- data/lib/nanoc/base/compilation/compiler_dsl.rb +11 -9
- data/lib/nanoc/base/compilation/dependency_tracker.rb +24 -38
- data/lib/nanoc/base/compilation/filter.rb +22 -7
- data/lib/nanoc/base/compilation/item_rep_proxy.rb +14 -12
- data/lib/nanoc/base/compilation/item_rep_recorder_proxy.rb +8 -8
- data/lib/nanoc/base/compilation/outdatedness_checker.rb +32 -32
- data/lib/nanoc/base/compilation/outdatedness_reasons.rb +3 -1
- data/lib/nanoc/base/compilation/rule.rb +9 -7
- data/lib/nanoc/base/compilation/rule_context.rb +15 -15
- data/lib/nanoc/base/compilation/rule_memory_calculator.rb +3 -3
- data/lib/nanoc/base/compilation/rule_memory_store.rb +7 -7
- data/lib/nanoc/base/compilation/rules_collection.rb +28 -30
- data/lib/nanoc/base/context.rb +2 -2
- data/lib/nanoc/base/core_ext/array.rb +17 -25
- data/lib/nanoc/base/core_ext/hash.rb +17 -25
- data/lib/nanoc/base/core_ext/pathname.rb +4 -2
- data/lib/nanoc/base/core_ext/string.rb +5 -3
- data/lib/nanoc/base/directed_graph.rb +4 -9
- data/lib/nanoc/base/error.rb +7 -0
- data/lib/nanoc/base/errors.rb +16 -23
- data/lib/nanoc/base/memoization.rb +4 -2
- data/lib/nanoc/base/notification_center.rb +3 -1
- data/lib/nanoc/base/plugin_registry.rb +14 -21
- data/lib/nanoc/base/result_data/item_rep.rb +43 -88
- data/lib/nanoc/base/source_data/code_snippet.rb +6 -4
- data/lib/nanoc/base/source_data/configuration.rb +3 -1
- data/lib/nanoc/base/source_data/data_source.rb +12 -94
- data/lib/nanoc/base/source_data/identifier.rb +50 -0
- data/lib/nanoc/base/source_data/item.rb +24 -67
- data/lib/nanoc/base/source_data/item_array.rb +6 -4
- data/lib/nanoc/base/source_data/layout.rb +17 -28
- data/lib/nanoc/base/source_data/site.rb +33 -44
- data/lib/nanoc/base/store.rb +3 -5
- data/lib/nanoc/base/temp_filename_factory.rb +3 -2
- data/lib/nanoc/base/views/config.rb +19 -0
- data/lib/nanoc/base/views/item.rb +77 -0
- data/lib/nanoc/base/views/item_collection.rb +43 -0
- data/lib/nanoc/base/views/item_rep.rb +125 -0
- data/lib/nanoc/base/views/layout.rb +42 -0
- data/lib/nanoc/base/views/layout_collection.rb +26 -0
- data/lib/nanoc/base/views/mutable_config.rb +9 -0
- data/lib/nanoc/base/views/mutable_item.rb +9 -0
- data/lib/nanoc/base/views/mutable_item_collection.rb +18 -0
- data/lib/nanoc/base/views/mutable_layout.rb +9 -0
- data/lib/nanoc/base/views/mutable_layout_collection.rb +18 -0
- data/lib/nanoc/base/views/site.rb +35 -0
- data/lib/nanoc/cli.rb +3 -6
- data/lib/nanoc/cli/ansi_string_colorizer.rb +2 -0
- data/lib/nanoc/cli/cleaning_stream.rb +2 -0
- data/lib/nanoc/cli/command_runner.rb +8 -42
- data/lib/nanoc/cli/commands/check.rb +2 -2
- data/lib/nanoc/cli/commands/compile.rb +19 -34
- data/lib/nanoc/cli/commands/create-site.rb +46 -83
- data/lib/nanoc/cli/commands/deploy.rb +4 -4
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/cli/commands/show-plugins.rb +4 -6
- data/lib/nanoc/cli/error_handler.rb +4 -14
- data/lib/nanoc/cli/logger.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners.rb +1 -0
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +2 -0
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +2 -0
- data/lib/nanoc/data_sources.rb +1 -17
- data/lib/nanoc/data_sources/filesystem.rb +6 -37
- data/lib/nanoc/data_sources/filesystem_unified.rb +5 -3
- data/lib/nanoc/data_sources/filesystem_verbose.rb +5 -3
- data/lib/nanoc/data_sources/static.rb +4 -2
- data/lib/nanoc/extra.rb +1 -13
- data/lib/nanoc/extra/checking.rb +1 -0
- data/lib/nanoc/extra/checking/check.rb +4 -2
- data/lib/nanoc/extra/checking/checks.rb +1 -0
- data/lib/nanoc/extra/checking/checks/css.rb +1 -0
- data/lib/nanoc/extra/checking/checks/external_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/html.rb +1 -0
- data/lib/nanoc/extra/checking/checks/internal_links.rb +2 -0
- data/lib/nanoc/extra/checking/checks/mixed_content.rb +2 -0
- data/lib/nanoc/extra/checking/checks/stale.rb +1 -0
- data/lib/nanoc/extra/checking/dsl.rb +1 -0
- data/lib/nanoc/extra/checking/issue.rb +1 -0
- data/lib/nanoc/extra/checking/runner.rb +3 -3
- data/lib/nanoc/extra/core_ext/pathname.rb +5 -3
- data/lib/nanoc/extra/core_ext/time.rb +4 -2
- data/lib/nanoc/extra/deployer.rb +3 -1
- data/lib/nanoc/extra/deployers.rb +1 -0
- data/lib/nanoc/extra/deployers/fog.rb +2 -0
- data/lib/nanoc/extra/deployers/rsync.rb +2 -0
- data/lib/nanoc/extra/filesystem_tools.rb +3 -7
- data/lib/nanoc/extra/jruby_nokogiri_warner.rb +1 -0
- data/lib/nanoc/extra/link_collector.rb +1 -0
- data/lib/nanoc/extra/piper.rb +2 -1
- data/lib/nanoc/extra/pruner.rb +5 -3
- data/lib/nanoc/filters.rb +1 -2
- data/lib/nanoc/filters/asciidoc.rb +2 -0
- data/lib/nanoc/filters/bluecloth.rb +1 -0
- data/lib/nanoc/filters/coffeescript.rb +2 -0
- data/lib/nanoc/filters/colorize_syntax.rb +1 -12
- data/lib/nanoc/filters/erb.rb +2 -1
- data/lib/nanoc/filters/erubis.rb +2 -1
- data/lib/nanoc/filters/haml.rb +2 -1
- data/lib/nanoc/filters/handlebars.rb +2 -0
- data/lib/nanoc/filters/kramdown.rb +1 -0
- data/lib/nanoc/filters/less.rb +1 -0
- data/lib/nanoc/filters/markaby.rb +1 -0
- data/lib/nanoc/filters/maruku.rb +1 -0
- data/lib/nanoc/filters/mustache.rb +2 -0
- data/lib/nanoc/filters/pandoc.rb +1 -0
- data/lib/nanoc/filters/rainpress.rb +1 -0
- data/lib/nanoc/filters/rdiscount.rb +1 -0
- data/lib/nanoc/filters/rdoc.rb +1 -0
- data/lib/nanoc/filters/redcarpet.rb +2 -0
- data/lib/nanoc/filters/redcloth.rb +1 -0
- data/lib/nanoc/filters/relativize_paths.rb +1 -0
- data/lib/nanoc/filters/rubypants.rb +1 -0
- data/lib/nanoc/filters/sass.rb +1 -0
- data/lib/nanoc/filters/sass/sass_filesystem_importer.rb +2 -0
- data/lib/nanoc/filters/slim.rb +3 -1
- data/lib/nanoc/filters/typogruby.rb +2 -0
- data/lib/nanoc/filters/uglify_js.rb +1 -0
- data/lib/nanoc/filters/xsl.rb +2 -0
- data/lib/nanoc/filters/yui_compressor.rb +2 -0
- data/lib/nanoc/helpers/blogging.rb +30 -30
- data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
- data/lib/nanoc/helpers/capturing.rb +6 -17
- data/lib/nanoc/helpers/filtering.rb +3 -3
- data/lib/nanoc/helpers/link_to.rb +3 -3
- data/lib/nanoc/helpers/rendering.rb +11 -11
- data/lib/nanoc/helpers/xml_sitemap.rb +3 -3
- data/lib/nanoc/tasks.rb +1 -0
- data/lib/nanoc/tasks/clean.rake +1 -1
- data/lib/nanoc/version.rb +1 -1
- data/tasks/doc.rake +2 -1
- data/tasks/test.rake +7 -1
- data/test/base/checksummer_spec.rb +15 -15
- data/test/base/core_ext/array_spec.rb +10 -10
- data/test/base/core_ext/hash_spec.rb +16 -16
- data/test/base/core_ext/pathname_spec.rb +2 -2
- data/test/base/core_ext/string_spec.rb +9 -9
- data/test/base/temp_filename_factory_spec.rb +3 -7
- data/test/base/test_checksum_store.rb +5 -5
- data/test/base/test_code_snippet.rb +3 -3
- data/test/base/test_compiler.rb +29 -29
- data/test/base/test_compiler_dsl.rb +23 -23
- data/test/base/test_context.rb +4 -4
- data/test/base/test_data_source.rb +17 -7
- data/test/base/test_dependency_tracker.rb +29 -29
- data/test/base/test_directed_graph.rb +27 -27
- data/test/base/test_item.rb +23 -21
- data/test/base/test_item_array.rb +18 -18
- data/test/base/test_item_rep.rb +76 -76
- data/test/base/test_item_rep_recorder_proxy.rb +4 -4
- data/test/base/test_layout.rb +8 -16
- data/test/base/test_memoization.rb +4 -4
- data/test/base/test_notification_center.rb +6 -6
- data/test/base/test_outdatedness_checker.rb +18 -18
- data/test/base/test_plugin.rb +1 -1
- data/test/base/test_rule.rb +2 -2
- data/test/base/test_rule_context.rb +5 -5
- data/test/base/test_site.rb +62 -38
- data/test/base/test_store.rb +2 -2
- data/test/cli/commands/test_check.rb +1 -1
- data/test/cli/commands/test_compile.rb +24 -18
- data/test/cli/commands/test_create_site.rb +5 -7
- data/test/cli/commands/test_deploy.rb +1 -1
- data/test/data_sources/test_filesystem.rb +22 -67
- data/test/data_sources/test_filesystem_unified.rb +10 -23
- data/test/data_sources/test_filesystem_verbose.rb +8 -53
- data/test/data_sources/test_static.rb +9 -9
- data/test/extra/checking/checks/test_stale.rb +1 -1
- data/test/extra/core_ext/test_pathname.rb +3 -3
- data/test/extra/core_ext/test_time.rb +4 -4
- data/test/extra/test_filesystem_tools.rb +1 -1
- data/test/filters/test_handlebars.rb +3 -3
- data/test/filters/test_less.rb +6 -6
- data/test/filters/test_mustache.rb +2 -2
- data/test/filters/test_relativize_paths.rb +81 -81
- data/test/filters/test_sass.rb +7 -7
- data/test/filters/test_xsl.rb +6 -6
- data/test/helper.rb +1 -1
- data/test/helpers/test_blogging.rb +78 -99
- data/test/helpers/test_breadcrumbs.rb +12 -12
- data/test/helpers/test_capturing.rb +10 -11
- data/test/helpers/test_filtering.rb +6 -6
- data/test/helpers/test_rendering.rb +3 -3
- data/test/helpers/test_tagging.rb +7 -7
- data/test/helpers/test_xml_sitemap.rb +34 -33
- metadata +19 -43
- data/lib/nanoc/cli/commands/autocompile.rb +0 -69
- data/lib/nanoc/cli/commands/create-item.rb +0 -55
- data/lib/nanoc/cli/commands/create-layout.rb +0 -68
- data/lib/nanoc/cli/commands/sync.rb +0 -32
- data/lib/nanoc/cli/commands/update.rb +0 -63
- data/lib/nanoc/cli/commands/validate-css.rb +0 -20
- data/lib/nanoc/cli/commands/validate-html.rb +0 -20
- data/lib/nanoc/cli/commands/validate-links.rb +0 -27
- data/lib/nanoc/cli/commands/watch.rb +0 -176
- data/lib/nanoc/data_sources/deprecated/delicious.rb +0 -38
- data/lib/nanoc/data_sources/deprecated/last_fm.rb +0 -85
- data/lib/nanoc/data_sources/deprecated/twitter.rb +0 -34
- data/lib/nanoc/extra/auto_compiler.rb +0 -99
- data/lib/nanoc/extra/chick.rb +0 -117
- data/lib/nanoc/extra/file_proxy.rb +0 -36
- data/lib/nanoc/extra/validators.rb +0 -8
- data/lib/nanoc/extra/validators/links.rb +0 -18
- data/lib/nanoc/extra/validators/w3c.rb +0 -23
- data/lib/nanoc/extra/vcs.rb +0 -62
- data/lib/nanoc/extra/vcses.rb +0 -15
- data/lib/nanoc/extra/vcses/bazaar.rb +0 -21
- data/lib/nanoc/extra/vcses/dummy.rb +0 -20
- data/lib/nanoc/extra/vcses/git.rb +0 -21
- data/lib/nanoc/extra/vcses/mercurial.rb +0 -21
- data/lib/nanoc/extra/vcses/subversion.rb +0 -21
- data/lib/nanoc/filters/coderay.rb +0 -19
- data/lib/nanoc3.rb +0 -3
- data/lib/nanoc3/cli.rb +0 -3
- data/lib/nanoc3/tasks.rb +0 -3
- data/test/cli/commands/test_create_item.rb +0 -10
- data/test/cli/commands/test_create_layout.rb +0 -24
- data/test/cli/commands/test_sync.rb +0 -27
- data/test/cli/commands/test_update.rb +0 -6
- data/test/cli/commands/test_watch.rb +0 -74
- data/test/extra/test_auto_compiler.rb +0 -437
- data/test/extra/test_vcs.rb +0 -18
- data/test/extra/validators/test_links.rb +0 -4
- data/test/extra/validators/test_w3c.rb +0 -37
- data/test/filters/test_coderay.rb +0 -40
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
class SiteView
|
5
|
+
# @api private
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
end
|
9
|
+
|
10
|
+
# @api private
|
11
|
+
def unwrap
|
12
|
+
@site
|
13
|
+
end
|
14
|
+
|
15
|
+
# @api private
|
16
|
+
def layouts
|
17
|
+
@site.layouts.map { |l| Nanoc::LayoutView.new(l) }
|
18
|
+
end
|
19
|
+
|
20
|
+
# @api private
|
21
|
+
def captures_store
|
22
|
+
@site.captures_store
|
23
|
+
end
|
24
|
+
|
25
|
+
# @api private
|
26
|
+
def captures_store_compiled_items
|
27
|
+
@site.captures_store_compiled_items
|
28
|
+
end
|
29
|
+
|
30
|
+
# @api private
|
31
|
+
def compiler
|
32
|
+
@site.compiler
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/nanoc/cli.rb
CHANGED
@@ -15,6 +15,7 @@ if Nanoc.on_windows?
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
# @api private
|
18
19
|
module Nanoc::CLI
|
19
20
|
module Commands
|
20
21
|
end
|
@@ -26,10 +27,6 @@ module Nanoc::CLI
|
|
26
27
|
autoload 'StreamCleaners', 'nanoc/cli/stream_cleaners'
|
27
28
|
autoload 'ErrorHandler', 'nanoc/cli/error_handler'
|
28
29
|
|
29
|
-
# Deprecated; use CommandRunner instead
|
30
|
-
# TODO: [in nanoc 4.0] remove me
|
31
|
-
autoload 'Command', 'nanoc/cli/command_runner'
|
32
|
-
|
33
30
|
# @return [Boolean] true if debug output is enabled, false if not
|
34
31
|
#
|
35
32
|
# @since 3.2.0
|
@@ -121,8 +118,8 @@ module Nanoc::CLI
|
|
121
118
|
#
|
122
119
|
# @return [void]
|
123
120
|
def self.load_custom_commands
|
124
|
-
if Nanoc::Site.cwd_is_nanoc_site?
|
125
|
-
site = Nanoc::Site.new('.')
|
121
|
+
if Nanoc::Int::Site.cwd_is_nanoc_site?
|
122
|
+
site = Nanoc::Int::Site.new('.')
|
126
123
|
site.config[:commands_dirs].each do |path|
|
127
124
|
load_commands_at(path)
|
128
125
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Nanoc::CLI
|
4
4
|
# An output stream that passes output through stream cleaners. This can be
|
5
5
|
# used to strip ANSI color sequences, for instance.
|
6
|
+
#
|
7
|
+
# @api private
|
6
8
|
class CleaningStream
|
7
9
|
# @param [IO, StringIO] stream The stream to wrap
|
8
10
|
def initialize(stream)
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Nanoc::CLI
|
4
4
|
# A command runner subclass for nanoc commands that adds nanoc-specific
|
5
5
|
# convenience methods and error handling.
|
6
|
+
#
|
7
|
+
# @api private
|
6
8
|
class CommandRunner < ::Cri::CommandRunner
|
7
9
|
# @see http://rubydoc.info/gems/cri/Cri/CommandRunner#call-instance_method
|
8
10
|
#
|
@@ -13,42 +15,35 @@ module Nanoc::CLI
|
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
# Gets the site ({Nanoc::Site} instance) in the current directory and
|
18
|
+
# Gets the site ({Nanoc::Int::Site} instance) in the current directory and
|
17
19
|
# loads its data.
|
18
20
|
#
|
19
|
-
# @return [Nanoc::Site] The site in the current working directory
|
21
|
+
# @return [Nanoc::Int::Site] The site in the current working directory
|
20
22
|
def site
|
21
23
|
# Load site if possible
|
22
24
|
@site ||= nil
|
23
25
|
if self.is_in_site_dir? && @site.nil?
|
24
|
-
@site = Nanoc::Site.new('.')
|
26
|
+
@site = Nanoc::Int::Site.new('.')
|
25
27
|
end
|
26
28
|
|
27
29
|
@site
|
28
30
|
end
|
29
31
|
|
30
|
-
# @deprecated use `Cri::CommandDSL#runner`
|
31
|
-
#
|
32
|
-
# @see http://rubydoc.info/gems/cri/Cri/CommandDSL#runner-instance_method
|
33
|
-
def self.call(opts, args, cmd)
|
34
|
-
new(opts, args, cmd).call
|
35
|
-
end
|
36
|
-
|
37
32
|
# @return [Boolean] true if the current working directory is a nanoc site
|
38
33
|
# directory, false otherwise
|
39
34
|
def in_site_dir?
|
40
|
-
Nanoc::Site.cwd_is_nanoc_site?
|
35
|
+
Nanoc::Int::Site.cwd_is_nanoc_site?
|
41
36
|
end
|
42
37
|
alias_method :is_in_site_dir?, :in_site_dir?
|
43
38
|
|
44
39
|
# Asserts that the current working directory contains a site
|
45
|
-
# ({Nanoc::Site} instance). If no site is present, prints an error
|
40
|
+
# ({Nanoc::Int::Site} instance). If no site is present, prints an error
|
46
41
|
# message and exits.
|
47
42
|
#
|
48
43
|
# @return [void]
|
49
44
|
def require_site
|
50
45
|
if site.nil?
|
51
|
-
raise ::Nanoc::Errors::GenericTrivial, 'The current working directory does not seem to be a nanoc site.'
|
46
|
+
raise ::Nanoc::Int::Errors::GenericTrivial, 'The current working directory does not seem to be a nanoc site.'
|
52
47
|
end
|
53
48
|
end
|
54
49
|
|
@@ -72,38 +67,9 @@ module Nanoc::CLI
|
|
72
67
|
|
73
68
|
protected
|
74
69
|
|
75
|
-
# Sets the data source's VCS to the VCS with the given name. Does nothing
|
76
|
-
# when the site's data source does not support VCSes (i.e. does not
|
77
|
-
# implement #vcs=).
|
78
|
-
#
|
79
|
-
# @param [String] vcs_name The name of the VCS that should be used
|
80
|
-
#
|
81
|
-
# @return [void]
|
82
|
-
def set_vcs(vcs_name)
|
83
|
-
# Skip if not possible
|
84
|
-
return if vcs_name.nil? || site.nil?
|
85
|
-
|
86
|
-
# Find VCS
|
87
|
-
vcs_class = Nanoc::Extra::VCS.named(vcs_name.to_sym)
|
88
|
-
if vcs_class.nil?
|
89
|
-
raise Nanoc::Errors::GenericTrivial, "A VCS named #{vcs_name} was not found"
|
90
|
-
end
|
91
|
-
|
92
|
-
site.data_sources.each do |data_source|
|
93
|
-
# Skip if not possible
|
94
|
-
next unless data_source.respond_to?(:vcs=)
|
95
|
-
|
96
|
-
# Set VCS
|
97
|
-
data_source.vcs = vcs_class.new
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
70
|
# @return [Array] The compilation stack.
|
102
71
|
def stack
|
103
72
|
(site && site.compiler.stack) || []
|
104
73
|
end
|
105
74
|
end
|
106
|
-
|
107
|
-
# @deprecated Use {Nanoc::CLI::CommandRunner} instead
|
108
|
-
Command = CommandRunner
|
109
75
|
end
|
@@ -33,7 +33,7 @@ module Nanoc::CLI::Commands
|
|
33
33
|
end
|
34
34
|
|
35
35
|
unless success
|
36
|
-
raise Nanoc::Errors::GenericTrivial, 'One or more checks failed'
|
36
|
+
raise Nanoc::Int::Errors::GenericTrivial, 'One or more checks failed'
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -41,7 +41,7 @@ module Nanoc::CLI::Commands
|
|
41
41
|
|
42
42
|
def validate_options_and_arguments
|
43
43
|
if arguments.empty? && !options[:all] && !options[:deploy] && !options[:list]
|
44
|
-
raise Nanoc::Errors::GenericTrivial,
|
44
|
+
raise Nanoc::Int::Errors::GenericTrivial,
|
45
45
|
'nothing to do (pass either --all, --deploy or --list or a list of checks)'
|
46
46
|
end
|
47
47
|
end
|
@@ -22,7 +22,7 @@ option :f, :force, '(ignored)'
|
|
22
22
|
|
23
23
|
module Nanoc::CLI::Commands
|
24
24
|
class Compile < ::Nanoc::CLI::CommandRunner
|
25
|
-
extend Nanoc::Memoization
|
25
|
+
extend Nanoc::Int::Memoization
|
26
26
|
|
27
27
|
# Listens to compilation events and reacts to them. This abstract class
|
28
28
|
# does not have a real implementation; subclasses should override {#start}
|
@@ -70,11 +70,11 @@ module Nanoc::CLI::Commands
|
|
70
70
|
require 'tempfile'
|
71
71
|
setup_diffs
|
72
72
|
old_contents = {}
|
73
|
-
Nanoc::NotificationCenter.on(:will_write_rep) do |rep, snapshot|
|
73
|
+
Nanoc::Int::NotificationCenter.on(:will_write_rep) do |rep, snapshot|
|
74
74
|
path = rep.raw_path(snapshot: snapshot)
|
75
75
|
old_contents[rep] = File.file?(path) ? File.read(path) : nil
|
76
76
|
end
|
77
|
-
Nanoc::NotificationCenter.on(:rep_written) do |rep, path, _is_created, _is_modified|
|
77
|
+
Nanoc::Int::NotificationCenter.on(:rep_written) do |rep, path, _is_created, _is_modified|
|
78
78
|
unless rep.binary?
|
79
79
|
new_contents = File.file?(path) ? File.read(path) : nil
|
80
80
|
if old_contents[rep] && new_contents
|
@@ -153,7 +153,7 @@ module Nanoc::CLI::Commands
|
|
153
153
|
command_runner.options.fetch(:verbose, false)
|
154
154
|
end
|
155
155
|
|
156
|
-
# @option params [Array<Nanoc::ItemRep>] :reps The list of item representations in the site
|
156
|
+
# @option params [Array<Nanoc::Int::ItemRep>] :reps The list of item representations in the site
|
157
157
|
def initialize(params = {})
|
158
158
|
@times = {}
|
159
159
|
|
@@ -162,11 +162,11 @@ module Nanoc::CLI::Commands
|
|
162
162
|
|
163
163
|
# @see Listener#start
|
164
164
|
def start
|
165
|
-
Nanoc::NotificationCenter.on(:filtering_started) do |_rep, filter_name|
|
165
|
+
Nanoc::Int::NotificationCenter.on(:filtering_started) do |_rep, filter_name|
|
166
166
|
@times[filter_name] ||= []
|
167
167
|
@times[filter_name] << { start: Time.now }
|
168
168
|
end
|
169
|
-
Nanoc::NotificationCenter.on(:filtering_ended) do |_rep, filter_name|
|
169
|
+
Nanoc::Int::NotificationCenter.on(:filtering_ended) do |_rep, filter_name|
|
170
170
|
@times[filter_name].last[:stop] = Time.now
|
171
171
|
end
|
172
172
|
end
|
@@ -261,7 +261,7 @@ module Nanoc::CLI::Commands
|
|
261
261
|
|
262
262
|
# @see Listener#start
|
263
263
|
def start
|
264
|
-
Nanoc::NotificationCenter.on(:compilation_started) do |_rep|
|
264
|
+
Nanoc::Int::NotificationCenter.on(:compilation_started) do |_rep|
|
265
265
|
if @gc_count % 20 == 0
|
266
266
|
GC.enable
|
267
267
|
GC.start
|
@@ -287,32 +287,32 @@ module Nanoc::CLI::Commands
|
|
287
287
|
|
288
288
|
# @see Listener#start
|
289
289
|
def start
|
290
|
-
Nanoc::NotificationCenter.on(:compilation_started) do |rep|
|
290
|
+
Nanoc::Int::NotificationCenter.on(:compilation_started) do |rep|
|
291
291
|
puts "*** Started compilation of #{rep.inspect}"
|
292
292
|
end
|
293
|
-
Nanoc::NotificationCenter.on(:compilation_ended) do |rep|
|
293
|
+
Nanoc::Int::NotificationCenter.on(:compilation_ended) do |rep|
|
294
294
|
puts "*** Ended compilation of #{rep.inspect}"
|
295
295
|
puts
|
296
296
|
end
|
297
|
-
Nanoc::NotificationCenter.on(:compilation_failed) do |rep, e|
|
297
|
+
Nanoc::Int::NotificationCenter.on(:compilation_failed) do |rep, e|
|
298
298
|
puts "*** Suspended compilation of #{rep.inspect}: #{e.message}"
|
299
299
|
end
|
300
|
-
Nanoc::NotificationCenter.on(:cached_content_used) do |rep|
|
300
|
+
Nanoc::Int::NotificationCenter.on(:cached_content_used) do |rep|
|
301
301
|
puts "*** Used cached compiled content for #{rep.inspect} instead of recompiling"
|
302
302
|
end
|
303
|
-
Nanoc::NotificationCenter.on(:filtering_started) do |rep, filter_name|
|
303
|
+
Nanoc::Int::NotificationCenter.on(:filtering_started) do |rep, filter_name|
|
304
304
|
puts "*** Started filtering #{rep.inspect} with #{filter_name}"
|
305
305
|
end
|
306
|
-
Nanoc::NotificationCenter.on(:filtering_ended) do |rep, filter_name|
|
306
|
+
Nanoc::Int::NotificationCenter.on(:filtering_ended) do |rep, filter_name|
|
307
307
|
puts "*** Ended filtering #{rep.inspect} with #{filter_name}"
|
308
308
|
end
|
309
|
-
Nanoc::NotificationCenter.on(:visit_started) do |item|
|
309
|
+
Nanoc::Int::NotificationCenter.on(:visit_started) do |item|
|
310
310
|
puts "*** Started visiting #{item.inspect}"
|
311
311
|
end
|
312
|
-
Nanoc::NotificationCenter.on(:visit_ended) do |item|
|
312
|
+
Nanoc::Int::NotificationCenter.on(:visit_ended) do |item|
|
313
313
|
puts "*** Ended visiting #{item.inspect}"
|
314
314
|
end
|
315
|
-
Nanoc::NotificationCenter.on(:dependency_created) do |src, dst|
|
315
|
+
Nanoc::Int::NotificationCenter.on(:dependency_created) do |src, dst|
|
316
316
|
puts "*** Dependency created from #{src.inspect} onto #{dst.inspect}"
|
317
317
|
end
|
318
318
|
end
|
@@ -320,7 +320,7 @@ module Nanoc::CLI::Commands
|
|
320
320
|
|
321
321
|
# Prints file actions (created, updated, deleted, identical, skipped)
|
322
322
|
class FileActionPrinter < Listener
|
323
|
-
# @option params [Array<Nanoc::ItemRep>] :reps The list of item representations in the site
|
323
|
+
# @option params [Array<Nanoc::Int::ItemRep>] :reps The list of item representations in the site
|
324
324
|
def initialize(params = {})
|
325
325
|
@start_times = {}
|
326
326
|
|
@@ -329,10 +329,10 @@ module Nanoc::CLI::Commands
|
|
329
329
|
|
330
330
|
# @see Listener#start
|
331
331
|
def start
|
332
|
-
Nanoc::NotificationCenter.on(:compilation_started) do |rep|
|
332
|
+
Nanoc::Int::NotificationCenter.on(:compilation_started) do |rep|
|
333
333
|
@start_times[rep.raw_path] = Time.now
|
334
334
|
end
|
335
|
-
Nanoc::NotificationCenter.on(:rep_written) do |_rep, path, is_created, is_modified|
|
335
|
+
Nanoc::Int::NotificationCenter.on(:rep_written) do |_rep, path, is_created, is_modified|
|
336
336
|
duration = path && @start_times[path] ? Time.now - @start_times[path] : nil
|
337
337
|
action =
|
338
338
|
case
|
@@ -376,7 +376,6 @@ module Nanoc::CLI::Commands
|
|
376
376
|
time_before = Time.now
|
377
377
|
|
378
378
|
load_site
|
379
|
-
check_for_deprecated_usage
|
380
379
|
|
381
380
|
puts 'Compiling site…'
|
382
381
|
run_listeners_while do
|
@@ -436,20 +435,6 @@ module Nanoc::CLI::Commands
|
|
436
435
|
end
|
437
436
|
memoize :reps
|
438
437
|
|
439
|
-
def check_for_deprecated_usage
|
440
|
-
# Check presence of --all option
|
441
|
-
if options.key?(:all) || options.key?(:force)
|
442
|
-
$stderr.puts 'Warning: the --force option (and its deprecated --all alias) are, as of nanoc 3.2, no longer supported and have no effect.'
|
443
|
-
end
|
444
|
-
|
445
|
-
# Warn if trying to compile a single item
|
446
|
-
if arguments.size == 1
|
447
|
-
$stderr.puts '-' * 80
|
448
|
-
$stderr.puts 'Note: As of nanoc 3.2, it is no longer possible to compile a single item. When invoking the “compile” command, all items in the site will be compiled.'
|
449
|
-
$stderr.puts '-' * 80
|
450
|
-
end
|
451
|
-
end
|
452
|
-
|
453
438
|
def prune_config
|
454
439
|
site.config[:prune] || {}
|
455
440
|
end
|
@@ -7,8 +7,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` command-line option.
|
8
8
|
"
|
9
9
|
|
10
|
-
required :d, :datasource, 'specify the data source for the new site'
|
11
|
-
|
12
10
|
module Nanoc::CLI::Commands
|
13
11
|
class CreateSite < ::Nanoc::CLI::CommandRunner
|
14
12
|
class << self
|
@@ -24,18 +22,18 @@ module Nanoc::CLI::Commands
|
|
24
22
|
# A list of file extensions that nanoc will consider to be textual rather than
|
25
23
|
# binary. If an item with an extension not in this list is found, the file
|
26
24
|
# will be considered as binary.
|
27
|
-
text_extensions: #{array_to_yaml(Nanoc::Site::DEFAULT_CONFIG[:text_extensions])}
|
25
|
+
text_extensions: #{array_to_yaml(Nanoc::Int::Site::DEFAULT_CONFIG[:text_extensions])}
|
28
26
|
|
29
27
|
# The path to the directory where all generated files will be written to. This
|
30
28
|
# can be an absolute path starting with a slash, but it can also be path
|
31
29
|
# relative to the site directory.
|
32
|
-
output_dir: #{Nanoc::Site::DEFAULT_CONFIG[:output_dir]}
|
30
|
+
output_dir: #{Nanoc::Int::Site::DEFAULT_CONFIG[:output_dir]}
|
33
31
|
|
34
32
|
# A list of index filenames, i.e. names of files that will be served by a web
|
35
33
|
# server when a directory is requested. Usually, index files are named
|
36
34
|
# “index.html”, but depending on the web server, this may be something else,
|
37
35
|
# such as “default.htm”. This list is used by nanoc to generate pretty URLs.
|
38
|
-
index_filenames: #{array_to_yaml(Nanoc::Site::DEFAULT_CONFIG[:index_filenames])}
|
36
|
+
index_filenames: #{array_to_yaml(Nanoc::Int::Site::DEFAULT_CONFIG[:index_filenames])}
|
39
37
|
|
40
38
|
# Whether or not to generate a diff of the compiled content when compiling a
|
41
39
|
# site. The diff will contain the differences between the compiled content
|
@@ -60,18 +58,18 @@ data_sources:
|
|
60
58
|
-
|
61
59
|
# The type is the identifier of the data source. By default, this will be
|
62
60
|
# `filesystem_unified`.
|
63
|
-
type: #{Nanoc::Site::DEFAULT_DATA_SOURCE_CONFIG[:type]}
|
61
|
+
type: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:type]}
|
64
62
|
|
65
63
|
# The path where items should be mounted (comparable to mount points in
|
66
64
|
# Unix-like systems). This is “/” by default, meaning that items will have
|
67
65
|
# “/” prefixed to their identifiers. If the items root were “/en/”
|
68
66
|
# instead, an item at content/about.html would have an identifier of
|
69
67
|
# “/en/about/” instead of just “/about/”.
|
70
|
-
items_root: #{Nanoc::Site::DEFAULT_DATA_SOURCE_CONFIG[:items_root]}
|
68
|
+
items_root: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:items_root]}
|
71
69
|
|
72
70
|
# The path where layouts should be mounted. The layouts root behaves the
|
73
71
|
# same as the items root, but applies to layouts rather than items.
|
74
|
-
layouts_root: #{Nanoc::Site::DEFAULT_DATA_SOURCE_CONFIG[:layouts_root]}
|
72
|
+
layouts_root: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:layouts_root]}
|
75
73
|
|
76
74
|
# Whether to allow periods in identifiers. When turned off, everything
|
77
75
|
# past the first period is considered to be the extension, and when
|
@@ -292,7 +290,7 @@ EOS
|
|
292
290
|
def run
|
293
291
|
# Check arguments
|
294
292
|
if arguments.length != 1
|
295
|
-
raise Nanoc::Errors::GenericTrivial, "usage: #{command.usage}"
|
293
|
+
raise Nanoc::Int::Errors::GenericTrivial, "usage: #{command.usage}"
|
296
294
|
end
|
297
295
|
|
298
296
|
# Extract arguments and options
|
@@ -301,97 +299,62 @@ EOS
|
|
301
299
|
|
302
300
|
# Check whether site exists
|
303
301
|
if File.exist?(path)
|
304
|
-
raise Nanoc::Errors::GenericTrivial, "A site at '#{path}' already exists."
|
302
|
+
raise Nanoc::Int::Errors::GenericTrivial, "A site at '#{path}' already exists."
|
305
303
|
end
|
306
304
|
|
307
305
|
# Check whether data source exists
|
308
306
|
if Nanoc::DataSource.named(data_source).nil?
|
309
|
-
raise Nanoc::Errors::GenericTrivial, "Unrecognised data source: #{data_source}"
|
307
|
+
raise Nanoc::Int::Errors::GenericTrivial, "Unrecognised data source: #{data_source}"
|
310
308
|
end
|
311
309
|
|
312
310
|
# Setup notifications
|
313
|
-
Nanoc::NotificationCenter.on(:file_created) do |file_path|
|
311
|
+
Nanoc::Int::NotificationCenter.on(:file_created) do |file_path|
|
314
312
|
Nanoc::CLI::Logger.instance.file(:high, :create, file_path)
|
315
313
|
end
|
316
314
|
|
317
315
|
# Build entire site
|
318
316
|
FileUtils.mkdir_p(path)
|
319
317
|
FileUtils.cd(File.join(path)) do
|
320
|
-
|
321
|
-
|
322
|
-
|
318
|
+
FileUtils.mkdir_p('content')
|
319
|
+
FileUtils.mkdir_p('layouts')
|
320
|
+
FileUtils.mkdir_p('lib')
|
321
|
+
FileUtils.mkdir_p('output')
|
322
|
+
|
323
|
+
# Config
|
324
|
+
File.open('nanoc.yaml', 'w') { |io| io.write(DEFAULT_CONFIG) }
|
325
|
+
Nanoc::Int::NotificationCenter.post(:file_created, 'nanoc.yaml')
|
326
|
+
|
327
|
+
# Rules
|
328
|
+
File.open('Rules', 'w') do |io|
|
329
|
+
io.write DEFAULT_RULES
|
330
|
+
end
|
331
|
+
Nanoc::Int::NotificationCenter.post(:file_created, 'Rules')
|
332
|
+
|
333
|
+
# Home page
|
334
|
+
File.open('content/index.html', 'w') do |io|
|
335
|
+
io << '---' << "\n"
|
336
|
+
io << 'title: Home' << "\n"
|
337
|
+
io << '---' << "\n"
|
338
|
+
io << "\n"
|
339
|
+
io << DEFAULT_ITEM
|
340
|
+
end
|
341
|
+
Nanoc::Int::NotificationCenter.post(:file_created, 'content/index.html')
|
342
|
+
|
343
|
+
# Style sheet
|
344
|
+
File.open('content/stylesheet.css', 'w') do |io|
|
345
|
+
io << DEFAULT_STYLESHEET
|
346
|
+
end
|
347
|
+
Nanoc::Int::NotificationCenter.post(:file_created, 'content/stylesheet.css')
|
348
|
+
|
349
|
+
# Layout
|
350
|
+
File.open('layouts/default.html', 'w') do |io|
|
351
|
+
io << DEFAULT_LAYOUT
|
352
|
+
end
|
353
|
+
Nanoc::Int::NotificationCenter.post(:file_created, 'layouts/default.html')
|
323
354
|
end
|
324
355
|
|
325
356
|
puts "Created a blank nanoc site at '#{path}'. Enjoy!"
|
326
357
|
end
|
327
|
-
|
328
|
-
protected
|
329
|
-
|
330
|
-
# Creates a configuration file and a output directory for this site, as
|
331
|
-
# well as a rakefile that loads the standard nanoc tasks.
|
332
|
-
def site_create_minimal(_data_source)
|
333
|
-
# Create output
|
334
|
-
FileUtils.mkdir_p('output')
|
335
|
-
|
336
|
-
# Create config
|
337
|
-
File.open('nanoc.yaml', 'w') { |io| io.write(DEFAULT_CONFIG) }
|
338
|
-
Nanoc::NotificationCenter.post(:file_created, 'nanoc.yaml')
|
339
|
-
|
340
|
-
# Create rules
|
341
|
-
File.open('Rules', 'w') do |io|
|
342
|
-
io.write DEFAULT_RULES
|
343
|
-
end
|
344
|
-
Nanoc::NotificationCenter.post(:file_created, 'Rules')
|
345
|
-
end
|
346
|
-
|
347
|
-
# Sets up the site's data source, i.e. creates the bare essentials for
|
348
|
-
# this data source to work.
|
349
|
-
def site_setup
|
350
|
-
# Get site
|
351
|
-
site = Nanoc::Site.new('.')
|
352
|
-
|
353
|
-
# Set up data sources
|
354
|
-
site.data_sources.each do |data_source|
|
355
|
-
data_source.loading { data_source.setup }
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
# Populates the site with some initial data, such as a root item, a
|
360
|
-
# default layout, and so on.
|
361
|
-
def site_populate
|
362
|
-
# Get site
|
363
|
-
site = Nanoc::Site.new('.')
|
364
|
-
data_source = site.data_sources[0]
|
365
|
-
|
366
|
-
# Create home page
|
367
|
-
data_source.create_item(
|
368
|
-
DEFAULT_ITEM,
|
369
|
-
{ title: 'Home' },
|
370
|
-
'/'
|
371
|
-
)
|
372
|
-
|
373
|
-
# Create stylesheet
|
374
|
-
data_source.create_item(
|
375
|
-
DEFAULT_STYLESHEET,
|
376
|
-
{},
|
377
|
-
'/stylesheet/',
|
378
|
-
extension: '.css'
|
379
|
-
)
|
380
|
-
|
381
|
-
# Create layout
|
382
|
-
data_source.create_layout(
|
383
|
-
DEFAULT_LAYOUT,
|
384
|
-
{},
|
385
|
-
'/default/'
|
386
|
-
)
|
387
|
-
|
388
|
-
# Create code
|
389
|
-
FileUtils.mkdir_p('lib')
|
390
|
-
File.open('lib/default.rb', 'w') do |io|
|
391
|
-
io.write "\# All files in the 'lib' directory will be loaded\n"
|
392
|
-
io.write "\# before nanoc starts compiling.\n"
|
393
|
-
end
|
394
|
-
end
|
395
358
|
end
|
396
359
|
end
|
397
360
|
|