2009-10-23 02:25:15 +02:00
|
|
|
#!/usr/bin/env ruby
|
2009-11-18 00:26:23 +01:00
|
|
|
require File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'middleman')
|
2011-02-05 19:32:04 +01:00
|
|
|
require "thor"
|
|
|
|
require "thor/group"
|
2009-10-23 02:25:15 +02:00
|
|
|
|
2011-02-05 19:32:04 +01:00
|
|
|
module Middleman
|
|
|
|
class Generator < ::Thor::Group
|
|
|
|
include Thor::Actions
|
2009-10-23 02:25:15 +02:00
|
|
|
|
2011-02-16 18:36:10 +01:00
|
|
|
argument :location, :type => :string, :desc => "New project location"
|
|
|
|
|
|
|
|
class_option :template, :aliases => "-T", :default => "default", :desc => 'Optionally use a pre-defined project template: html5, default'
|
|
|
|
|
2009-10-23 02:25:15 +02:00
|
|
|
def self.source_root
|
2011-02-16 18:36:10 +01:00
|
|
|
File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'templates')
|
2009-10-23 02:25:15 +02:00
|
|
|
end
|
|
|
|
|
2011-02-05 19:32:04 +01:00
|
|
|
class_option :css_dir, :default => "stylesheets", :desc => 'The path to the css files'
|
|
|
|
class_option :js_dir, :default => "javascripts", :desc => 'The path to the javascript files'
|
|
|
|
class_option :images_dir, :default => "images", :desc => 'The path to the image files'
|
|
|
|
|
|
|
|
def create_project
|
2011-02-16 18:36:10 +01:00
|
|
|
if options[:template] == "html5"
|
|
|
|
template "html5boilerplate/config.tt", File.join(location, "config.rb")
|
|
|
|
directory "html5boilerplate/public", File.join(location, "public")
|
|
|
|
empty_directory File.join(location, "views")
|
|
|
|
else
|
|
|
|
template "default/config.tt", File.join(location, "config.rb")
|
2011-04-08 20:48:47 +02:00
|
|
|
template "default/config.ru", File.join(location, "config.ru")
|
2011-02-16 18:36:10 +01:00
|
|
|
directory "default/views", File.join(location, "views")
|
|
|
|
empty_directory File.join(location, "public", options[:css_dir])
|
|
|
|
empty_directory File.join(location, "public", options[:js_dir])
|
|
|
|
empty_directory File.join(location, "public", options[:images_dir])
|
|
|
|
end
|
2011-02-05 19:32:04 +01:00
|
|
|
end
|
2009-10-23 02:25:15 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-02-16 18:36:10 +01:00
|
|
|
Middleman::Generator.start
|