mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
add middleman.rb option
This commit is contained in:
parent
0f785a448a
commit
e886eeaa3e
3 changed files with 19 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
|
* Add the option of naming `config.rb` as `middleman.rb`.
|
||||||
* Builder extracted from Thor. `after_build` hook now passes an instance of a Builder instead of the Thor CLI.
|
* Builder extracted from Thor. `after_build` hook now passes an instance of a Builder instead of the Thor CLI.
|
||||||
* New FileWatcher API.
|
* New FileWatcher API.
|
||||||
* Remove the `partials_dir` setting. Partials should live next to content, or be addressed with absolute paths.
|
* Remove the `partials_dir` setting. Partials should live next to content, or be addressed with absolute paths.
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Middleman::Cli
|
||||||
def init(target='.')
|
def init(target='.')
|
||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
|
||||||
repo = if shortname?(options[:template])
|
repo_path, repo_branch = if shortname?(options[:template])
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
|
@ -35,17 +35,21 @@ module Middleman::Cli
|
||||||
begin
|
begin
|
||||||
data = ::JSON.parse(uri.read)
|
data = ::JSON.parse(uri.read)
|
||||||
data['links']['github']
|
data['links']['github']
|
||||||
|
data['links']['github'].split('#')
|
||||||
rescue ::OpenURI::HTTPError
|
rescue ::OpenURI::HTTPError
|
||||||
puts "Template `#{options[:template]}` not found in Middleman Directory."
|
puts "Template `#{options[:template]}` not found in Middleman Directory."
|
||||||
puts 'Did you mean to use a full `user/repo` path?'
|
puts 'Did you mean to use a full `user/repo` path?'
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
repository_path(options[:template])
|
repo_name, repo_branch = options[:template].split('#')
|
||||||
|
[repository_path(repo_name), repo_branch]
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.mktmpdir do |dir|
|
Dir.mktmpdir do |dir|
|
||||||
run("git clone #{repo} #{dir}")
|
cmd = repo_branch ? "clone -b #{repo_branch}" : 'clone'
|
||||||
|
|
||||||
|
run("git #{cmd} #{repo_path} #{dir}")
|
||||||
|
|
||||||
source_paths << dir
|
source_paths << dir
|
||||||
|
|
||||||
|
|
|
@ -256,10 +256,17 @@ module Middleman
|
||||||
|
|
||||||
def evaluate_configuration
|
def evaluate_configuration
|
||||||
# Check for and evaluate local configuration in `config.rb`
|
# Check for and evaluate local configuration in `config.rb`
|
||||||
local_config = File.join(root, 'config.rb')
|
config_rb = File.join(root, 'config.rb')
|
||||||
if File.exist? local_config
|
if File.exist? config_rb
|
||||||
logger.debug '== Reading: Local config'
|
logger.debug '== Reading: Local config: config.rb'
|
||||||
config_context.instance_eval File.read(local_config), local_config, 1
|
config_context.instance_eval File.read(config_rb), config_rb, 1
|
||||||
|
else
|
||||||
|
# Check for and evaluate local configuration in `middleman.rb`
|
||||||
|
middleman_rb = File.join(root, 'middleman.rb')
|
||||||
|
if File.exist? middleman_rb
|
||||||
|
logger.debug '== Reading: Local middleman: middleman.rb'
|
||||||
|
config_context.instance_eval File.read(middleman_rb), middleman_rb, 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
env_config = File.join(root, 'environments', "#{config[:environment]}.rb")
|
env_config = File.join(root, 'environments', "#{config[:environment]}.rb")
|
||||||
|
|
Loading…
Reference in a new issue