mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-11-16 06:05:00 -05:00
Fix: task set_root_dir now works properly and outputs rewritten configuration on success
This commit is contained in:
parent
50e6a1ed04
commit
4dfdfb80c2
39
Rakefile
39
Rakefile
@ -411,30 +411,37 @@ end
|
||||
|
||||
desc "Update configurations to support publishing to root or sub directory"
|
||||
task :set_root_dir, :dir do |t, args|
|
||||
if args.dir
|
||||
dir = args.dir
|
||||
else
|
||||
dir = get_stdin("Please provide a directory: ")
|
||||
path = args.dir || nil
|
||||
if path.nil?
|
||||
path = get_stdin("Please provide a directory: ")
|
||||
end
|
||||
if dir
|
||||
if dir == "/"
|
||||
dir = ""
|
||||
if path
|
||||
if path == "/"
|
||||
path = ""
|
||||
else
|
||||
dir = "/" + args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
|
||||
path = "/" + path.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
|
||||
end
|
||||
# update personal configuration
|
||||
site_configs = configurator.read_configuration('site.yml')
|
||||
site_configs[:destination] = "public#{dir}"
|
||||
site_configs[:subscribe_rss] = "#{dir}/atom.xml"
|
||||
site_configs[:root] = "/#{dir.sub(/^\//, '')}"
|
||||
site_configs = configurator.read_config('site.yml')
|
||||
site_configs[:destination] = "public#{path}"
|
||||
root = "/#{path.sub(/^\//, '')}"
|
||||
url = $1 if site_configs[:url] =~ /(https?:\/\/[^\/]+)/i
|
||||
site_configs[:url] = url + path
|
||||
site_configs[:subscribe_rss] = "#{path}/atom.xml"
|
||||
site_configs[:root] = "#{root}"
|
||||
configurator.write_config('site.yml', site_configs)
|
||||
|
||||
rm_rf configuration[:destination]
|
||||
mkdir_p site_configs[:destination]
|
||||
puts "\n========================================================"
|
||||
puts "Site's root directory is now '/#{dir.sub(/^\//, '')}'"
|
||||
puts "Don't forget to update your url in _config.yml"
|
||||
puts "\n========================================================"
|
||||
puts "\nYour _config/site.yml has been updated to the following"
|
||||
output = <<-EOF
|
||||
|
||||
url: #{url + path}
|
||||
destination: public#{path}
|
||||
subscribe_rss: #{path}/atom.xml
|
||||
root: #{root}
|
||||
EOF
|
||||
puts output.yellow
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user