Class: Nanoc3::CLI::Commands::CreateSite

  • Cri::Command
    • Nanoc3::CLI::Commands::CreateSite

Constants

DEFAULT_ITEM
"<h1>A Brand New nanoc Site</h1>\n\n<p>You&#8217;ve just created a new nanoc site. The page you are looking at right now is the home page for your site (and it&#8217;s probably the only page).</p>\n\n<p>To get started, consider replacing this default homepage with your own customized homepage. Some pointers on how to do so:</p>\n\n<ul>\n <li><p><strong>Change this page&#8217;s content</strong> by editing &#8220;content.html&#8221; file in the &#8220;content&#8221; directory. This is the actual page content, and therefore doesn&#8217;t include the header, sidebar or style information (those are part of the layout).</p></li>\n <li><p><strong>Change the layout</strong>, which is the &#8220;default.txt&#8221; file in the &#8220;layouts/default&#8221; directory, and create something unique (and hopefully less bland).</p></li>\n</ul>\n\n<p>If you need any help with customizing your nanoc web site, be sure to check out the documentation (see sidebar), and be sure to subscribe to the discussion group (also see sidebar). Enjoy!</p>\n"
DEFAULT_LAYOUT
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n <head>\n <title>A Brand New nanoc Site - <%= @item[:title] %></title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\" media=\"screen\">\n </head>\n <body>\n <div id=\"main\">\n<%= yield %>\n </div>\n <div id=\"sidebar\">\n <h2>Documentation</h2>\n <ul>\n <li><a href=\"http://nanoc.stoneship.org/help/tutorial/\">Tutorial</a></li>\n <li><a href=\"http://nanoc.stoneship.org/help/manual/\">Manual</a></li>\n </ul>\n <h2>Community</h2>\n <ul>\n <li><a href=\"http://groups.google.com/group/nanoc/\">Discussion Group</a></li>\n <li><a href=\"http://groups.google.com/group/nanoc-es/\">Spanish Discussion Group</a></li>\n <li><a href=\"http://projects.stoneship.org/trac/nanoc/\">Wiki</a></li>\n </ul>\n </div>\n </body>\n</html>\n"
DEFAULT_STYLESHEET
"* {\n margin: 0;\n padding: 0;\n\n font-family: Georgia, Palatino, Times, 'Times New Roman', sans-serif;\n}\n\nbody {\n background: #fff;\n}\n\na {\n text-decoration: none;\n}\n\na:link,\na:visited {\n color: #f30;\n}\n\na:hover {\n color: #f90;\n}\n\n#main {\n position: absolute;\n\n top: 40px;\n left: 280px;\n\n width: 500px;\n}\n\n#main h1 {\n font-size: 40px;\n font-weight: normal;\n\n line-height: 40px;\n\n letter-spacing: -1px;\n}\n\n#main p {\n margin: 20px 0;\n \n font-size: 15px;\n \n line-height: 20px;\n}\n\n#main ul {\n margin: 20px;\n}\n\n#main li {\n list-style-type: square;\n\n font-size: 15px;\n \n line-height: 20px;\n}\n\n#sidebar {\n position: absolute;\n\n top: 40px;\n left: 20px;\n width: 200px;\n\n padding: 20px 20px 0 0;\n\n border-right: 1px solid #ccc;\n\n text-align: right;\n}\n\n#sidebar h2 {\n text-transform: uppercase;\n\n font-size: 13px;\n\n color: #333;\n\n letter-spacing: 1px;\n\n line-height: 20px;\n}\n\n#sidebar ul {\n list-style-type: none;\n\n margin: 20px 0;\n}\n\n#sidebar li {\n font-size: 14px;\n\n line-height: 20px;\n}\n"

Public Visibility

Public Instance Method Summary

#aliases
#long_desc
#name
#option_definitions
#run(options, arguments)
#short_desc
#usage

Public Instance Method Details

aliases

public aliases
[View source]


159
160
161
# File 'lib/nanoc3/cli/commands/create_site.rb', line 159

def aliases
  [ 'cs' ]
end

long_desc

public long_desc
[View source]


167
168
169
170
171
# File 'lib/nanoc3/cli/commands/create_site.rb', line 167

def long_desc
  'Create a new site at the given path. The site will use the ' +
  'filesystem_compact data source by default, but this can be ' +
  'changed using the --datasource commandline option.'
end

name

public name
[View source]


155
156
157
# File 'lib/nanoc3/cli/commands/create_site.rb', line 155

def name
  'create_site'
end

option_definitions

public option_definitions
[View source]


177
178
179
180
181
182
183
184
185
# File 'lib/nanoc3/cli/commands/create_site.rb', line 177

def option_definitions
  [
    # --datasource
    {
      :long => 'datasource', :short => 'd', :argument => :required,
      :desc => 'specify the data source for the new site'
    }
  ]
end

run

public run(options, arguments)
[View source]


187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/nanoc3/cli/commands/create_site.rb', line 187

def run(options, arguments)
  # Check arguments
  if arguments.length != 1
    $stderr.puts "usage: #{usage}"
    exit 1
  end

  # Extract arguments and options
  path        = arguments[0]
  data_source = options[:datasource] || 'filesystem_compact'

  # Check whether site exists
  if File.exist?(path)
    $stderr.puts "A site at '#{path}' already exists."
    exit 1
  end

  # Check whether data source exists
  if Nanoc3::DataSource.named(data_source).nil?
    $stderr.puts "Unrecognised data source: #{data_source}"
    exit 1
  end

  # Setup notifications
  Nanoc3::NotificationCenter.on(:file_created) do |file_path|
    Nanoc3::CLI::Logger.instance.file(:high, :create, file_path)
  end

  # Build entire site
  FileUtils.mkdir_p(path)
  FileUtils.cd(File.join(path)) do
    site_create_minimal(data_source)
    site_setup
    site_populate
  end

  puts "Created a blank nanoc site at '#{path}'. Enjoy!"
end

short_desc

public short_desc
[View source]


163
164
165
# File 'lib/nanoc3/cli/commands/create_site.rb', line 163

def short_desc
  'create a site'
end

usage

public usage
[View source]


173
174
175
# File 'lib/nanoc3/cli/commands/create_site.rb', line 173

def usage
  "nanoc3 create_site [path]"
end
Generated on Sunday, August 09 2009 at 01:43:13 PM by YARD 0.2.3.2 (ruby-1.8.7).