lib/nanoc/cli/commands/create-site.rb in nanoc-4.0.0b2 vs lib/nanoc/cli/commands/create-site.rb in nanoc-4.0.0b3
- old
+ new
@@ -1,13 +1,9 @@
-# encoding: utf-8
-
usage 'create-site [options] path'
aliases :create_site, :cs
summary 'create a site'
-description "
-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.
-"
+description "Create a new site at the given path. The site will use the `filesystem` data source."
flag nil, :force, "Force creation of new site. Disregards previous existence of site in destination"
module Nanoc::CLI::Commands
class CreateSite < ::Nanoc::CLI::CommandRunner
class << self
@@ -60,12 +56,11 @@
# hashes; each array element represents a single data source. By default,
# there is only a single data source that reads data from the “content/” and
# “layout/” directories in the site directory.
data_sources:
-
- # The type is the identifier of the data source. By default, this will be
- # `filesystem_unified`.
+ # The type is the identifier of the data source.
type: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:type]}
# The path where items should be mounted (comparable to mount points in
# Unix-like systems). This is “/” by default, meaning that items will have
# “/” prefixed to their identifiers. If the items root were “/en/”
@@ -75,22 +70,17 @@
# The path where layouts should be mounted. The layouts root behaves the
# same as the items root, but applies to layouts rather than items.
layouts_root: #{Nanoc::Int::Site::DEFAULT_DATA_SOURCE_CONFIG[:layouts_root]}
- # Whether to allow periods in identifiers. When turned off, everything
- # past the first period is considered to be the extension, and when
- # turned on, only the characters past the last period are considered to
- # be the extension. For example, a file named “content/about.html.erb”
- # will have the identifier “/about/” when turned off, but when turned on
- # it will become “/about.html/” instead.
- allow_periods_in_identifiers: false
-
# The encoding to use for input files. If your input files are not in
# UTF-8 (which they should be!), change this.
encoding: utf-8
+ # The kind of identifier to use for items and layouts. The default is
+ # “full”, meaning that identifiers include file extensions. This can also
+ # be “legacy”, primarily used by older nanoc sites.
identifier_type: full
# Configuration for the “check” command, which run unit tests on the site.
checks:
# Configuration for the “internal_links” checker, which checks whether all
@@ -289,28 +279,20 @@
</body>
</html>
EOS
def run
- # Check arguments
+ # Extract arguments
if arguments.length != 1
raise Nanoc::Int::Errors::GenericTrivial, "usage: #{command.usage}"
end
+ path = arguments[0]
- # Extract arguments and options
- path = arguments[0]
- data_source = options[:datasource] || 'filesystem_unified'
-
# Check whether site exists
if File.exist?(path) && (!File.directory?(path) || !(Dir.entries(path) - %w{ . .. }).empty?) && !options[:force]
raise Nanoc::Int::Errors::GenericTrivial,
"The site was not created because '#{path}' already exists. " +
"Re-run the command using --force to create the site anyway."
- end
-
- # Check whether data source exists
- if Nanoc::DataSource.named(data_source).nil?
- raise Nanoc::Int::Errors::GenericTrivial, "Unrecognised data source: #{data_source}"
end
# Setup notifications
Nanoc::Int::NotificationCenter.on(:file_created) do |file_path|
Nanoc::CLI::Logger.instance.file(:high, :create, file_path)