nanoc3 3.2.0a4 → 3.2.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.md +20 -2
- data/README.md +7 -3
- data/bin/nanoc3 +1 -3
- data/lib/nanoc3.rb +1 -13
- data/lib/nanoc3/base/compilation/filter.rb +21 -0
- data/lib/nanoc3/base/compilation/item_rep_recorder_proxy.rb +1 -3
- data/lib/nanoc3/base/compilation/outdatedness_checker.rb +1 -1
- data/lib/nanoc3/base/compilation/rule_memory_calculator.rb +0 -2
- data/lib/nanoc3/base/compilation/rules_collection.rb +37 -13
- data/lib/nanoc3/base/directed_graph.rb +3 -3
- data/lib/nanoc3/base/memoization.rb +6 -9
- data/lib/nanoc3/base/source_data/code_snippet.rb +2 -1
- data/lib/nanoc3/base/source_data/configuration.rb +7 -3
- data/lib/nanoc3/base/source_data/item.rb +52 -10
- data/lib/nanoc3/base/source_data/layout.rb +28 -1
- data/lib/nanoc3/base/source_data/site.rb +14 -3
- data/lib/nanoc3/cli.rb +98 -6
- data/lib/nanoc3/cli/{base.rb → command.rb} +117 -153
- data/lib/nanoc3/cli/commands/autocompile.rb +20 -48
- data/lib/nanoc3/cli/commands/compile.rb +32 -48
- data/lib/nanoc3/cli/commands/create_item.rb +21 -37
- data/lib/nanoc3/cli/commands/create_layout.rb +18 -36
- data/lib/nanoc3/cli/commands/create_site.rb +15 -34
- data/lib/nanoc3/cli/commands/debug.rb +17 -31
- data/lib/nanoc3/cli/commands/info.rb +14 -29
- data/lib/nanoc3/cli/commands/nanoc.rb +37 -0
- data/lib/nanoc3/cli/commands/update.rb +21 -44
- data/lib/nanoc3/cli/commands/view.rb +18 -44
- data/lib/nanoc3/cli/commands/watch.rb +16 -31
- data/lib/nanoc3/data_sources/filesystem.rb +25 -6
- data/lib/nanoc3/data_sources/filesystem_unified.rb +5 -5
- data/lib/nanoc3/extra/auto_compiler.rb +1 -0
- data/lib/nanoc3/extra/file_proxy.rb +0 -1
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/filters/asciidoc.rb +16 -36
- data/lib/nanoc3/filters/bluecloth.rb +2 -2
- data/lib/nanoc3/filters/coderay.rb +2 -2
- data/lib/nanoc3/filters/colorize_syntax.rb +18 -5
- data/lib/nanoc3/filters/erb.rb +2 -2
- data/lib/nanoc3/filters/erubis.rb +2 -2
- data/lib/nanoc3/filters/haml.rb +2 -2
- data/lib/nanoc3/filters/kramdown.rb +2 -2
- data/lib/nanoc3/filters/less.rb +32 -1
- data/lib/nanoc3/filters/markaby.rb +2 -2
- data/lib/nanoc3/filters/maruku.rb +2 -2
- data/lib/nanoc3/filters/mustache.rb +2 -2
- data/lib/nanoc3/filters/rainpress.rb +2 -2
- data/lib/nanoc3/filters/rdiscount.rb +4 -3
- data/lib/nanoc3/filters/rdoc.rb +10 -6
- data/lib/nanoc3/filters/redcarpet.rb +2 -2
- data/lib/nanoc3/filters/redcloth.rb +2 -2
- data/lib/nanoc3/filters/rubypants.rb +2 -2
- data/lib/nanoc3/filters/sass.rb +44 -52
- data/lib/nanoc3/filters/slim.rb +2 -2
- data/lib/nanoc3/filters/typogruby.rb +2 -2
- data/lib/nanoc3/filters/uglify_js.rb +42 -0
- data/nanoc3.gemspec +1 -1
- data/tasks/test.rake +6 -0
- data/test/base/core_ext/array_spec.rb +0 -2
- data/test/base/core_ext/hash_spec.rb +0 -2
- data/test/base/core_ext/pathname_spec.rb +0 -2
- data/test/base/core_ext/string_spec.rb +0 -2
- data/test/base/test_checksum_store.rb +0 -2
- data/test/base/test_code_snippet.rb +0 -2
- data/test/base/test_compiler.rb +2 -4
- data/test/base/test_compiler_dsl.rb +1 -3
- data/test/base/test_context.rb +0 -2
- data/test/base/test_data_source.rb +0 -2
- data/test/base/test_dependency_tracker.rb +0 -2
- data/test/base/test_directed_graph.rb +0 -2
- data/test/base/test_filter.rb +0 -2
- data/test/base/test_item.rb +19 -4
- data/test/base/test_item_rep.rb +0 -2
- data/test/base/test_layout.rb +19 -4
- data/test/base/test_memoization.rb +39 -2
- data/test/base/test_notification_center.rb +0 -2
- data/test/base/test_outdatedness_checker.rb +31 -2
- data/test/base/test_plugin.rb +0 -2
- data/test/base/test_rule.rb +0 -2
- data/test/base/test_rule_context.rb +0 -2
- data/test/base/test_site.rb +30 -3
- data/test/cli/commands/test_compile.rb +24 -3
- data/test/cli/commands/test_create_item.rb +5 -3
- data/test/cli/commands/test_create_layout.rb +4 -4
- data/test/cli/commands/test_create_site.rb +5 -5
- data/test/cli/commands/test_help.rb +3 -3
- data/test/cli/commands/test_info.rb +2 -3
- data/test/cli/commands/test_update.rb +0 -2
- data/test/cli/test_cli.rb +40 -0
- data/test/cli/test_logger.rb +0 -2
- data/test/data_sources/test_filesystem.rb +0 -2
- data/test/data_sources/test_filesystem_unified.rb +32 -58
- data/test/data_sources/test_filesystem_verbose.rb +0 -2
- data/test/extra/core_ext/test_enumerable.rb +0 -2
- data/test/extra/core_ext/test_time.rb +0 -2
- data/test/extra/deployers/test_rsync.rb +0 -2
- data/test/extra/test_auto_compiler.rb +5 -7
- data/test/extra/test_file_proxy.rb +0 -2
- data/test/extra/test_vcs.rb +0 -2
- data/test/extra/validators/test_links.rb +0 -2
- data/test/extra/validators/test_w3c.rb +0 -2
- data/test/filters/test_asciidoc.rb +0 -2
- data/test/filters/test_bluecloth.rb +0 -2
- data/test/filters/test_coderay.rb +0 -2
- data/test/filters/test_colorize_syntax.rb +49 -2
- data/test/filters/test_erb.rb +0 -2
- data/test/filters/test_erubis.rb +0 -2
- data/test/filters/test_haml.rb +0 -2
- data/test/filters/test_kramdown.rb +0 -2
- data/test/filters/test_less.rb +59 -5
- data/test/filters/test_markaby.rb +0 -2
- data/test/filters/test_maruku.rb +0 -2
- data/test/filters/test_mustache.rb +0 -2
- data/test/filters/test_rainpress.rb +0 -2
- data/test/filters/test_rdiscount.rb +0 -2
- data/test/filters/test_rdoc.rb +0 -2
- data/test/filters/test_redcarpet.rb +0 -2
- data/test/filters/test_redcloth.rb +0 -2
- data/test/filters/test_relativize_paths.rb +77 -24
- data/test/filters/test_rubypants.rb +0 -2
- data/test/filters/test_sass.rb +136 -10
- data/test/filters/test_slim.rb +0 -2
- data/test/filters/test_typogruby.rb +0 -2
- data/test/filters/test_uglify_js.rb +30 -0
- data/test/gem_loader.rb +11 -0
- data/test/helper.rb +3 -0
- data/test/helpers/test_blogging.rb +0 -2
- data/test/helpers/test_breadcrumbs.rb +0 -2
- data/test/helpers/test_capturing.rb +0 -2
- data/test/helpers/test_filtering.rb +0 -2
- data/test/helpers/test_html_escape.rb +0 -2
- data/test/helpers/test_link_to.rb +0 -2
- data/test/helpers/test_rendering.rb +0 -2
- data/test/helpers/test_tagging.rb +0 -2
- data/test/helpers/test_text.rb +0 -2
- data/test/helpers/test_xml_sitemap.rb +0 -2
- data/test/tasks/test_clean.rb +0 -2
- metadata +11 -9
- data/lib/nanoc3/cli/commands.rb +0 -16
- data/lib/nanoc3/cli/commands/help.rb +0 -71
- data/tasks/clean.rake +0 -11
@@ -1,59 +1,31 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def long_desc
|
20
|
-
'Start the autocompiler web server. Unless specified, the web ' +
|
21
|
-
'server will run on port 3000 and listen on all IP addresses. ' +
|
22
|
-
'Running the autocompiler requires \'mime/types\' and \'rack\'.'
|
23
|
-
end
|
3
|
+
usage 'autocompile [options]'
|
4
|
+
summary 'start the autocompiler'
|
5
|
+
aliases :aco
|
6
|
+
description <<-EOS
|
7
|
+
Start the autocompiler web server. Unless specified, the web server will run
|
8
|
+
on port 3000 and listen on all IP addresses. Running the autocompiler requires
|
9
|
+
the 'mime/types' and 'rack' gems.
|
10
|
+
EOS
|
11
|
+
|
12
|
+
option :H, :handler, 'specify the handler to use (webrick/mongrel/...)'
|
13
|
+
option :o, :host, 'specify the host to listen on (default: 0.0.0.0)'
|
14
|
+
option :p, :port, 'specify the port to listen on (default: 3000)'
|
15
|
+
|
16
|
+
run do |opts, args, cmd|
|
17
|
+
Nanoc3::CLI::Commands::AutoCompile.call(opts, args, cmd)
|
18
|
+
end
|
24
19
|
|
25
|
-
|
26
|
-
"nanoc3 autocompile [options]"
|
27
|
-
end
|
20
|
+
module Nanoc3::CLI::Commands
|
28
21
|
|
29
|
-
|
30
|
-
[
|
31
|
-
# --handler
|
32
|
-
{
|
33
|
-
:long => 'handler', :short => 'H', :argument => :required,
|
34
|
-
:desc => 'specify the handler to use (webrick/mongrel/...)'
|
35
|
-
},
|
36
|
-
# --host
|
37
|
-
{
|
38
|
-
:long => 'host', :short => 'o', :argument => :required,
|
39
|
-
:desc => 'specify the host to listen on (default: 0.0.0.0)'
|
40
|
-
},
|
41
|
-
# --port
|
42
|
-
{
|
43
|
-
:long => 'port', :short => 'p', :argument => :required,
|
44
|
-
:desc => 'specify the port to listen on (default: 3000)'
|
45
|
-
}
|
46
|
-
]
|
47
|
-
end
|
22
|
+
class AutoCompile < ::Nanoc3::CLI::Command
|
48
23
|
|
49
|
-
def run
|
24
|
+
def run
|
50
25
|
require 'rack'
|
51
26
|
|
52
|
-
# Warn
|
53
|
-
warn 'WARNING: As of nanoc 3.2, the autocompiler is deprecated. Consider using the new and much faster “nanoc watch” command that recompiles the site on change rather than on request.'
|
54
|
-
|
55
27
|
# Make sure we are in a nanoc site directory
|
56
|
-
|
28
|
+
self.require_site
|
57
29
|
|
58
30
|
# Set options
|
59
31
|
options_for_rack = {
|
@@ -1,52 +1,37 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
usage 'compile [options]'
|
4
|
+
summary 'compile items of this site'
|
5
|
+
description <<-EOS
|
6
|
+
Compile all items of the current site.
|
4
7
|
|
5
|
-
|
8
|
+
The compile command will show all items of the site as they are processed. The time spent compiling the item will be printed, as well as a status message, which can be one of the following:
|
6
9
|
|
7
|
-
|
8
|
-
'compile'
|
9
|
-
end
|
10
|
+
CREATED - The compiled item did not yet exist and has been created
|
10
11
|
|
11
|
-
|
12
|
-
[]
|
13
|
-
end
|
12
|
+
UPDATED - The compiled item did already exist and has been modified
|
14
13
|
|
15
|
-
|
16
|
-
'compile items of this site'
|
17
|
-
end
|
14
|
+
IDENTICAL - The item was deemed outdated and has been recompiled, but the compiled version turned out to be identical to the already existing version
|
18
15
|
|
19
|
-
|
20
|
-
'Compile all items of the current site.' +
|
21
|
-
"\n\n" +
|
22
|
-
'By default, only item that are outdated will be compiled. This can ' +
|
23
|
-
'speed up the compilation process quite a bit, but items that include ' +
|
24
|
-
'content from other items may have to be recompiled manually.'
|
25
|
-
end
|
16
|
+
SKIP - The item was deemed not outdated and was therefore not recompiled
|
26
17
|
|
27
|
-
|
28
|
-
"nanoc3 compile [options]"
|
29
|
-
end
|
18
|
+
EOS
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
# --all
|
34
|
-
{
|
35
|
-
:long => 'all', :short => 'a', :argument => :forbidden,
|
36
|
-
:desc => '(ignored)'
|
37
|
-
},
|
38
|
-
# --force
|
39
|
-
{
|
40
|
-
:long => 'force', :short => 'f', :argument => :forbidden,
|
41
|
-
:desc => '(ignored)'
|
42
|
-
}
|
43
|
-
]
|
44
|
-
end
|
20
|
+
option :a, :all, '(ignored)'
|
21
|
+
option :f, :force, '(ignored)'
|
45
22
|
|
46
|
-
|
23
|
+
run do |opts, args, cmd|
|
24
|
+
Nanoc3::CLI::Commands::Compile.call(opts, args, cmd)
|
25
|
+
end
|
26
|
+
|
27
|
+
module Nanoc3::CLI::Commands
|
28
|
+
|
29
|
+
class Compile < ::Nanoc3::CLI::Command
|
30
|
+
|
31
|
+
def run
|
47
32
|
# Make sure we are in a nanoc site directory
|
48
33
|
puts "Loading site data..."
|
49
|
-
|
34
|
+
self.require_site
|
50
35
|
|
51
36
|
# Check presence of --all option
|
52
37
|
if options.has_key?(:all) || options.has_key?(:force)
|
@@ -73,10 +58,10 @@ module Nanoc3::CLI::Commands
|
|
73
58
|
setup_diffs
|
74
59
|
|
75
60
|
# Compile
|
76
|
-
|
61
|
+
self.site.compile
|
77
62
|
|
78
63
|
# Find reps
|
79
|
-
reps =
|
64
|
+
reps = self.site.items.map { |i| i.reps }.flatten
|
80
65
|
|
81
66
|
# Show skipped reps
|
82
67
|
reps.select { |r| !r.compiled? }.each do |rep|
|
@@ -100,8 +85,6 @@ module Nanoc3::CLI::Commands
|
|
100
85
|
end
|
101
86
|
end
|
102
87
|
|
103
|
-
private
|
104
|
-
|
105
88
|
def setup_notifications
|
106
89
|
# File notifications
|
107
90
|
Nanoc3::NotificationCenter.on(:will_write_rep) do |rep, snapshot|
|
@@ -115,16 +98,16 @@ module Nanoc3::CLI::Commands
|
|
115
98
|
|
116
99
|
# Debug notifications
|
117
100
|
Nanoc3::NotificationCenter.on(:compilation_started) do |rep|
|
118
|
-
puts "*** Started compilation of #{rep.inspect}" if
|
101
|
+
puts "*** Started compilation of #{rep.inspect}" if self.debug?
|
119
102
|
end
|
120
103
|
Nanoc3::NotificationCenter.on(:compilation_ended) do |rep|
|
121
|
-
puts "*** Ended compilation of #{rep.inspect}" if
|
104
|
+
puts "*** Ended compilation of #{rep.inspect}" if self.debug?
|
122
105
|
end
|
123
106
|
Nanoc3::NotificationCenter.on(:compilation_failed) do |rep|
|
124
|
-
puts "*** Suspended compilation of #{rep.inspect} due to unmet dependencies" if
|
107
|
+
puts "*** Suspended compilation of #{rep.inspect} due to unmet dependencies" if self.debug?
|
125
108
|
end
|
126
109
|
Nanoc3::NotificationCenter.on(:cached_content_used) do |rep|
|
127
|
-
puts "*** Used cached compiled content for #{rep.inspect} instead of recompiling" if
|
110
|
+
puts "*** Used cached compiled content for #{rep.inspect} instead of recompiling" if self.debug?
|
128
111
|
end
|
129
112
|
|
130
113
|
# Timing notifications
|
@@ -135,11 +118,12 @@ module Nanoc3::CLI::Commands
|
|
135
118
|
@rep_times[rep.raw_path] = Time.now - @rep_times[rep.raw_path]
|
136
119
|
end
|
137
120
|
Nanoc3::NotificationCenter.on(:filtering_started) do |rep, filter_name|
|
138
|
-
@filter_times[filter_name]
|
121
|
+
@filter_times[filter_name] ||= []
|
122
|
+
@filter_times[filter_name] << Time.now
|
139
123
|
start_filter_progress(rep, filter_name)
|
140
124
|
end
|
141
125
|
Nanoc3::NotificationCenter.on(:filtering_ended) do |rep, filter_name|
|
142
|
-
@filter_times[filter_name]
|
126
|
+
@filter_times[filter_name] << Time.now - @filter_times[filter_name].pop
|
143
127
|
stop_filter_progress(rep, filter_name)
|
144
128
|
end
|
145
129
|
end
|
@@ -155,7 +139,7 @@ module Nanoc3::CLI::Commands
|
|
155
139
|
end
|
156
140
|
|
157
141
|
def generate_diff_for(rep, snapshot)
|
158
|
-
return if
|
142
|
+
return if !self.site.config[:enable_output_diff]
|
159
143
|
return if !File.file?(rep.raw_path(:snapshot => snapshot))
|
160
144
|
return if rep.binary?
|
161
145
|
|
@@ -1,43 +1,27 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
'create a item'
|
17
|
-
end
|
18
|
-
|
19
|
-
def long_desc
|
20
|
-
'Create a new item in the current site. The first data source in the site configuration will be used.'
|
21
|
-
end
|
3
|
+
usage 'create_item [options] identifier'
|
4
|
+
summary 'create an item'
|
5
|
+
aliases :ci
|
6
|
+
description <<-EOS
|
7
|
+
Create a new item in the current site. The first data source in the site
|
8
|
+
configuration will be used.
|
9
|
+
EOS
|
10
|
+
|
11
|
+
option :c, :vcs, 'specify the VCS to use'
|
12
|
+
|
13
|
+
run do |opts, args, cmd|
|
14
|
+
Nanoc3::CLI::Commands::CreateItem.call(opts, args, cmd)
|
15
|
+
end
|
22
16
|
|
23
|
-
|
24
|
-
"nanoc3 create_item [options] identifier"
|
25
|
-
end
|
17
|
+
module Nanoc3::CLI::Commands
|
26
18
|
|
27
|
-
|
28
|
-
[
|
29
|
-
# --vcs
|
30
|
-
{
|
31
|
-
:long => 'vcs', :short => 'c', :argument => :required,
|
32
|
-
:desc => 'select the VCS to use'
|
33
|
-
}
|
34
|
-
]
|
35
|
-
end
|
19
|
+
class CreateItem < ::Nanoc3::CLI::Command
|
36
20
|
|
37
|
-
def run
|
21
|
+
def run
|
38
22
|
# Check arguments
|
39
23
|
if arguments.length != 1
|
40
|
-
$stderr.puts "usage: #{usage}"
|
24
|
+
$stderr.puts "usage: #{command.usage}"
|
41
25
|
exit 1
|
42
26
|
end
|
43
27
|
|
@@ -45,13 +29,13 @@ module Nanoc3::CLI::Commands
|
|
45
29
|
identifier = arguments[0].cleaned_identifier
|
46
30
|
|
47
31
|
# Make sure we are in a nanoc site directory
|
48
|
-
|
32
|
+
self.require_site
|
49
33
|
|
50
34
|
# Set VCS if possible
|
51
|
-
|
35
|
+
self.set_vcs(options[:vcs])
|
52
36
|
|
53
37
|
# Check whether item is unique
|
54
|
-
if
|
38
|
+
if !self.site.items.find { |i| i.identifier == identifier }.nil?
|
55
39
|
$stderr.puts "An item already exists at #{identifier}. Please " +
|
56
40
|
"pick a unique name for the item you are creating."
|
57
41
|
exit 1
|
@@ -63,7 +47,7 @@ module Nanoc3::CLI::Commands
|
|
63
47
|
end
|
64
48
|
|
65
49
|
# Create item
|
66
|
-
data_source =
|
50
|
+
data_source = self.site.data_sources[0]
|
67
51
|
data_source.create_item(
|
68
52
|
"Hi, I'm a new item!\n",
|
69
53
|
{ :title => "A New Item" },
|
@@ -1,40 +1,22 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def short_desc
|
16
|
-
'create a layout'
|
17
|
-
end
|
18
|
-
|
19
|
-
def long_desc
|
20
|
-
'Create a new layout in the current site. The first data source in the site configuration will be used.'
|
21
|
-
end
|
3
|
+
usage 'create_layout [options] identifier'
|
4
|
+
aliases 'cl'
|
5
|
+
summary 'create a layout'
|
6
|
+
description <<-EOS
|
7
|
+
Create a new layout in the current site. The first data source in the site
|
8
|
+
configuration will be used.
|
9
|
+
EOS
|
10
|
+
|
11
|
+
run do |opts, args, cmd|
|
12
|
+
Nanoc3::CLI::Commands::CreateLayout.call(opts, args, cmd)
|
13
|
+
end
|
22
14
|
|
23
|
-
|
24
|
-
"nanoc3 create_layout [options] identifier"
|
25
|
-
end
|
15
|
+
module Nanoc3::CLI::Commands
|
26
16
|
|
27
|
-
|
28
|
-
[
|
29
|
-
# --vcs
|
30
|
-
{
|
31
|
-
:long => 'vcs', :short => 'c', :argument => :required,
|
32
|
-
:desc => 'select the VCS to use'
|
33
|
-
}
|
34
|
-
]
|
35
|
-
end
|
17
|
+
class CreateLayout < ::Nanoc3::CLI::Command
|
36
18
|
|
37
|
-
def run
|
19
|
+
def run
|
38
20
|
# Check arguments
|
39
21
|
if arguments.length != 1
|
40
22
|
$stderr.puts "usage: #{usage}"
|
@@ -45,13 +27,13 @@ module Nanoc3::CLI::Commands
|
|
45
27
|
identifier = arguments[0].cleaned_identifier
|
46
28
|
|
47
29
|
# Make sure we are in a nanoc site directory
|
48
|
-
|
30
|
+
self.require_site
|
49
31
|
|
50
32
|
# Set VCS if possible
|
51
|
-
|
33
|
+
self.set_vcs(options[:vcs])
|
52
34
|
|
53
35
|
# Check whether layout is unique
|
54
|
-
if
|
36
|
+
if !self.site.layouts.find { |l| l.identifier == identifier }.nil?
|
55
37
|
$stderr.puts "A layout already exists at #{identifier}. Please " +
|
56
38
|
"pick a unique name for the layout you are creating."
|
57
39
|
exit 1
|
@@ -70,7 +52,7 @@ module Nanoc3::CLI::Commands
|
|
70
52
|
end
|
71
53
|
|
72
54
|
# Create layout
|
73
|
-
data_source =
|
55
|
+
data_source = self.site.data_sources[0]
|
74
56
|
data_source.create_layout(
|
75
57
|
"<html>\n" +
|
76
58
|
" <head>\n" +
|
@@ -1,8 +1,21 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
usage 'create_site [options] path'
|
4
|
+
aliases 'cs'
|
5
|
+
summary 'create a site'
|
6
|
+
description <<-EOS
|
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
|
+
EOS
|
9
|
+
|
10
|
+
required :d, :datasource, 'specify the data source for the new site'
|
11
|
+
|
12
|
+
run do |opts, args, cmd|
|
13
|
+
Nanoc3::CLI::Commands::CreateSite.call(opts, args, cmd)
|
14
|
+
end
|
15
|
+
|
3
16
|
module Nanoc3::CLI::Commands
|
4
17
|
|
5
|
-
class CreateSite <
|
18
|
+
class CreateSite < ::Nanoc3::CLI::Command
|
6
19
|
|
7
20
|
class << self
|
8
21
|
|
@@ -270,39 +283,7 @@ EOS
|
|
270
283
|
</html>
|
271
284
|
EOS
|
272
285
|
|
273
|
-
def
|
274
|
-
'create_site'
|
275
|
-
end
|
276
|
-
|
277
|
-
def aliases
|
278
|
-
[ 'cs' ]
|
279
|
-
end
|
280
|
-
|
281
|
-
def short_desc
|
282
|
-
'create a site'
|
283
|
-
end
|
284
|
-
|
285
|
-
def long_desc
|
286
|
-
'Create a new site at the given path. The site will use the ' +
|
287
|
-
'filesystem_unified data source by default, but this can be ' +
|
288
|
-
'changed using the --datasource commandline option.'
|
289
|
-
end
|
290
|
-
|
291
|
-
def usage
|
292
|
-
"nanoc3 create_site [options] path"
|
293
|
-
end
|
294
|
-
|
295
|
-
def option_definitions
|
296
|
-
[
|
297
|
-
# --datasource
|
298
|
-
{
|
299
|
-
:long => 'datasource', :short => 'd', :argument => :required,
|
300
|
-
:desc => 'specify the data source for the new site'
|
301
|
-
}
|
302
|
-
]
|
303
|
-
end
|
304
|
-
|
305
|
-
def run(options, arguments)
|
286
|
+
def run
|
306
287
|
# Check arguments
|
307
288
|
if arguments.length != 1
|
308
289
|
$stderr.puts "usage: #{usage}"
|