Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 60 lines (53 sloc) 1.61 KB
#!/usr/bin/env ruby
require 'rubygems'
require 'jekyll'
require 'glynn'
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
options = {}
case ARGV.size
when 0
when 1
options['destination'] = ARGV[0]
when 2
options['source'] = ARGV[0]
options['destination'] = ARGV[1]
when 4
options['source'] = ARGV[0]
options['destination'] = ARGV[1]
options['ftp_username'] = ARGV[2]
options['ftp_password'] = ARGV[3]
end
options = Jekyll.configuration(options)
ftp_port = (options['ftp_port'] || 21).to_i
ftp_disable_passive = options['ftp_disable_passive'] || false
puts "Building site: #{options['source']} -> #{options['destination']}"
jekyll = Glynn::Jekyll.new
jekyll.build
puts "Successfully generated site"
puts "Sending site over FTP (host: #{options['ftp_host']}, port: #{ftp_port})"
begin
if options['ftp_username'].nil?
print "FTP Username: "
username = $stdin.gets.chomp
else
username = options['ftp_username']
end
if options['ftp_password'].nil?
print "FTP Password: "
# We hide the entered characters before to ask for the password
system "stty -echo"
password = $stdin.gets.chomp
system "stty echo"
else
password = options['ftp_password']
end
rescue NoMethodError, Interrupt
# When the process is exited, we display the characters again
# And we exit
system "stty echo"
exit
end
ftp = Glynn::Ftp.new(options['ftp_host'], ftp_port, {:username => username, :password => password, :disable_passive => ftp_disable_passive})
puts "\r\nConnected to server. Sending site"
ftp.sync(options['destination'], options['ftp_dir'])
puts "Successfully sent site"
Jump to Line
Something went wrong with that request. Please try again.