cleanup cli class
This commit is contained in:
parent
2682bbf6ea
commit
d264a49a76
|
@ -110,7 +110,7 @@ module Middleman::Base
|
||||||
if !::Tilt.mappings.has_key?(template_engine.to_s)
|
if !::Tilt.mappings.has_key?(template_engine.to_s)
|
||||||
matched_mime = mime_type(File.extname(request_path))
|
matched_mime = mime_type(File.extname(request_path))
|
||||||
matched_mime = "application/octet-stream" if matched_mime.nil?
|
matched_mime = "application/octet-stream" if matched_mime.nil?
|
||||||
content_type matched_mime, :charset => 'utf-8'
|
content_type matched_mime
|
||||||
status 200
|
status 200
|
||||||
send_file File.join(settings.views, request_path)
|
send_file File.join(settings.views, request_path)
|
||||||
false
|
false
|
||||||
|
@ -216,12 +216,10 @@ module Middleman::Base
|
||||||
result = render(engine, path, render_options, locals)
|
result = render(engine, path, render_options, locals)
|
||||||
|
|
||||||
if result
|
if result
|
||||||
content_type mime_type(File.extname(request_path)), :charset => 'utf-8'
|
content_type mime_type(File.extname(request_path))
|
||||||
status 200
|
status 200
|
||||||
body result
|
body result
|
||||||
end
|
end
|
||||||
# rescue
|
|
||||||
# status(404)
|
|
||||||
ensure
|
ensure
|
||||||
settings.set :layout, old_layout
|
settings.set :layout, old_layout
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,20 +6,38 @@ module Middleman
|
||||||
check_unknown_options!
|
check_unknown_options!
|
||||||
default_task :server
|
default_task :server
|
||||||
|
|
||||||
class_option "help", :type => :boolean, :default => false, :aliases => "-h"
|
class_option "help",
|
||||||
|
:type => :boolean,
|
||||||
|
:default => false,
|
||||||
|
:aliases => "-h"
|
||||||
def initialize(*)
|
def initialize(*)
|
||||||
super
|
super
|
||||||
help_check if options[:help]
|
help_check if options[:help]
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "init NAME [options]", "Create new Middleman project directory NAME"
|
desc "init NAME [options]", "Create new project NAME"
|
||||||
available_templates = Middleman::Templates.registered_names.join(", ")
|
available_templates = Middleman::Templates.registered_names.join(", ")
|
||||||
method_option "template", :aliases => "-T", :default => "default", :desc => "Optionally use a pre-defined project template: #{available_templates}"
|
method_option "template",
|
||||||
method_option "css_dir", :default => "stylesheets", :desc => 'The path to the css files'
|
:aliases => "-T",
|
||||||
method_option "js_dir", :default => "javascripts", :desc => 'The path to the javascript files'
|
:default => "default",
|
||||||
method_option "images_dir", :default => "images", :desc => 'The path to the image files'
|
:desc => "Use a project template: #{available_templates}"
|
||||||
method_option "rack", :type => :boolean, :default => false, :desc => 'Include a config.ru file'
|
method_option "css_dir",
|
||||||
method_option "bundler", :type => :boolean, :default => false, :desc => 'Create a Gemfile and use Bundler to manage gems'
|
:default => "stylesheets",
|
||||||
|
:desc => 'The path to the css files'
|
||||||
|
method_option "js_dir",
|
||||||
|
:default => "javascripts",
|
||||||
|
:desc => 'The path to the javascript files'
|
||||||
|
method_option "images_dir",
|
||||||
|
:default => "images",
|
||||||
|
:desc => 'The path to the image files'
|
||||||
|
method_option "rack",
|
||||||
|
:type => :boolean,
|
||||||
|
:default => false,
|
||||||
|
:desc => 'Include a config.ru file'
|
||||||
|
method_option "bundler",
|
||||||
|
:type => :boolean,
|
||||||
|
:default => false,
|
||||||
|
:desc => 'Create a Gemfile and use Bundler to manage gems'
|
||||||
def init(name)
|
def init(name)
|
||||||
key = options[:template].to_sym
|
key = options[:template].to_sym
|
||||||
unless Middleman::Templates.registered_templates.has_key?(key)
|
unless Middleman::Templates.registered_templates.has_key?(key)
|
||||||
|
@ -30,42 +48,48 @@ module Middleman
|
||||||
thor_group.new([name], options).invoke_all
|
thor_group.new([name], options).invoke_all
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "server [-p 4567] [-e development]", "Starts the Middleman preview server"
|
desc "server [options]", "Start the preview server"
|
||||||
method_option "environment", :aliases => "-e", :default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development', :desc => "The environment Middleman will run under"
|
method_option "environment",
|
||||||
method_option "port", :aliases => "-p", :default => "4567", :desc => "The port Middleman will listen on"
|
:aliases => "-e",
|
||||||
|
:default => ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development',
|
||||||
method_option "disable-watcher", :default => false, :type => :boolean, :desc => "Don't use config.rb watcher (also disables livereload)"
|
:desc => "The environment Middleman will run under"
|
||||||
method_option "livereload", :default => false, :type => :boolean, :desc => "Whether to enable Livereload or not"
|
method_option "port",
|
||||||
method_option "livereload-port", :default => "35729", :desc => "The port Livereload will listen on"
|
:aliases => "-p",
|
||||||
|
:default => "4567",
|
||||||
|
:desc => "The port Middleman will listen on"
|
||||||
def server
|
def server
|
||||||
v1_check
|
v1_check
|
||||||
|
|
||||||
if options["livereload"]
|
|
||||||
livereload_options = {:port => options["livereload-port"]}
|
|
||||||
end
|
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
:port => options[:port],
|
:port => options[:port],
|
||||||
:environment => options[:environment]
|
:environment => options[:environment]
|
||||||
}
|
}
|
||||||
|
|
||||||
if options["disable-watcher"]
|
Middleman::Guard.start(params)
|
||||||
Middleman.start_server(params)
|
|
||||||
else
|
|
||||||
Middleman::Guard.start(params, livereload_options)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "build", "Builds the static site for deployment"
|
desc "build", "Builds the static site for deployment"
|
||||||
method_option :relative, :type => :boolean, :aliases => "-r", :default => false, :desc => 'Override the config.rb file and force relative urls'
|
method_option :relative,
|
||||||
method_option :clean, :type => :boolean, :aliases => "-c", :default => false, :desc => 'Builds a clean project removing any orpahand files or directories'
|
:type => :boolean,
|
||||||
method_option :glob, :type => :string, :aliases => "-g", :default => nil, :desc => 'Build a subset of the project'
|
:aliases => "-r",
|
||||||
|
:default => false,
|
||||||
|
:desc => 'Force relative urls'
|
||||||
|
method_option :clean,
|
||||||
|
:type => :boolean,
|
||||||
|
:aliases => "-c",
|
||||||
|
:default => false,
|
||||||
|
:desc => 'Removes orpahand files or directories from build'
|
||||||
|
method_option :glob,
|
||||||
|
:type => :string,
|
||||||
|
:aliases => "-g",
|
||||||
|
:default => nil,
|
||||||
|
:desc => 'Build a subset of the project'
|
||||||
def build
|
def build
|
||||||
v1_check
|
v1_check
|
||||||
thor_group = Middleman::Builder.new([], options).invoke_all
|
thor_group = Middleman::Builder.new([], options).invoke_all
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "migrate", "Migrates an older Middleman project to the 2.0 structure"
|
desc "migrate", "Migrates an older project to the 2.0 structure"
|
||||||
def migrate
|
def migrate
|
||||||
return if File.exists?("source")
|
return if File.exists?("source")
|
||||||
`mv public source`
|
`mv public source`
|
||||||
|
@ -73,7 +97,7 @@ module Middleman
|
||||||
`rm -rf views`
|
`rm -rf views`
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "version", "Show Middleman version"
|
desc "version", "Show version"
|
||||||
def version
|
def version
|
||||||
require 'middleman/version'
|
require 'middleman/version'
|
||||||
say "Middleman #{Middleman::VERSION}"
|
say "Middleman #{Middleman::VERSION}"
|
||||||
|
@ -92,6 +116,5 @@ module Middleman
|
||||||
help self.class.send(:retrieve_task_name, ARGV.dup)
|
help self.class.send(:retrieve_task_name, ARGV.dup)
|
||||||
exit 0
|
exit 0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -12,7 +12,7 @@ module Middleman
|
||||||
# Deprecation Warning
|
# Deprecation Warning
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.start(options={}, livereload={})
|
def self.start(options={})
|
||||||
options_hash = ""
|
options_hash = ""
|
||||||
options.each do |k,v|
|
options.each do |k,v|
|
||||||
options_hash << ", :#{k} => '#{v}'"
|
options_hash << ", :#{k} => '#{v}'"
|
||||||
|
|
|
@ -28,7 +28,6 @@ Gem::Specification.new do |s|
|
||||||
s.add_dependency("sinatra", ["~> 1.3.1"])
|
s.add_dependency("sinatra", ["~> 1.3.1"])
|
||||||
s.add_dependency("rack-test", ["~> 0.6.1"])
|
s.add_dependency("rack-test", ["~> 0.6.1"])
|
||||||
s.add_dependency("uglifier", ["~> 1.0.0"])
|
s.add_dependency("uglifier", ["~> 1.0.0"])
|
||||||
s.add_dependency("slim", ["~> 1.0.2"])
|
|
||||||
s.add_dependency("haml", ["~> 3.1.0"])
|
s.add_dependency("haml", ["~> 3.1.0"])
|
||||||
s.add_dependency("sass", ["~> 3.1.7"])
|
s.add_dependency("sass", ["~> 3.1.7"])
|
||||||
s.add_dependency("compass", ["~> 0.11.3"])
|
s.add_dependency("compass", ["~> 0.11.3"])
|
||||||
|
@ -49,6 +48,7 @@ Gem::Specification.new do |s|
|
||||||
# Development and test
|
# Development and test
|
||||||
s.add_development_dependency("coffee-filter", ["~> 0.1.1"])
|
s.add_development_dependency("coffee-filter", ["~> 0.1.1"])
|
||||||
s.add_development_dependency("liquid", ["~> 2.2.0"])
|
s.add_development_dependency("liquid", ["~> 2.2.0"])
|
||||||
|
s.add_development_dependency("slim", ["~> 1.0.2"])
|
||||||
s.add_development_dependency("cucumber", ["~> 1.0.2"])
|
s.add_development_dependency("cucumber", ["~> 1.0.2"])
|
||||||
s.add_development_dependency("rake", ["~> 0.9.2"])
|
s.add_development_dependency("rake", ["~> 0.9.2"])
|
||||||
s.add_development_dependency("rspec", ["~> 2.6.0"])
|
s.add_development_dependency("rspec", ["~> 2.6.0"])
|
||||||
|
|
Loading…
Reference in a new issue