Somehow I replaced Rakefile with oder version, oops

This commit is contained in:
Brandon Mathis 2011-08-25 10:52:43 -04:00
parent b38b613908
commit 35a158dd14

View File

@ -1,10 +1,11 @@
require "rubygems" require "rubygems"
require "bundler/setup" require "bundler/setup"
require "stringex"
## -- Rsync Deploy config -- ## ## -- Rsync Deploy config -- ##
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
ssh_user = "user@domain.com" ssh_user = "mathisweb@octopress.org"
document_root = "~/website.com/" document_root = "~/octopress.org/"
deploy_default = "rsync" deploy_default = "rsync"
# This will be configured for you when you run config_deploy # This will be configured for you when you run config_deploy
@ -51,13 +52,35 @@ end
desc "Watch the site and regenerate when it changes" desc "Watch the site and regenerate when it changes"
task :watch do task :watch do
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
system "trap 'kill $jekyllPid $compassPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; wait" puts "Starting to watch source with Jekyll and Compass."
jekyllPid = spawn("jekyll --auto")
compassPid = spawn("compass watch")
trap("INT") {
Process.kill(9, jekyllPid)
Process.kill(9, compassPid)
exit 0
}
Process.wait
end end
desc "preview the site in a web browser" desc "preview the site in a web browser"
task :preview do task :preview do
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir) raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
system "trap 'kill $jekyllPid $compassPid $rackPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; rackup --port #{server_port} & rackPid=$!; wait" puts "Starting to watch source with Jekyll and Compass. Starting Rack on port #{server_port}"
jekyllPid = spawn("jekyll --auto")
compassPid = spawn("compass watch")
rackupPid = spawn("rackup --port #{server_port}")
trap("INT") {
Process.kill(9, jekyllPid)
Process.kill(9, compassPid)
Process.kill(9, rackupPid)
exit 0
}
Process.wait
end end
# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post") # usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
@ -68,7 +91,7 @@ task :new_post, :title do |t, args|
mkdir_p "#{source_dir}/#{posts_dir}" mkdir_p "#{source_dir}/#{posts_dir}"
args.with_defaults(:title => 'new-post') args.with_defaults(:title => 'new-post')
title = args.title title = args.title
filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}.#{new_post_ext}" filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
puts "Creating new post: #{filename}" puts "Creating new post: #{filename}"
open(filename, 'w') do |post| open(filename, 'w') do |post|
system "mkdir -p #{source_dir}/#{posts_dir}/"; system "mkdir -p #{source_dir}/#{posts_dir}/";
@ -129,7 +152,7 @@ end
desc "Clean out caches: _code_cache, _gist_cache, .sass-cache" desc "Clean out caches: _code_cache, _gist_cache, .sass-cache"
task :clean do task :clean do
system "rm -rf _code_cache/** _gist_cache/** .sass-cache/** source/stylesheets/screen.css" rm_rf ["_code_cache/**", "_gist_cache/**", ".sass-cache/**", "source/stylesheets/screen.css"]
end end
desc "Move sass to sass.old, install sass theme updates, replace sass/custom with sass.old/custom" desc "Move sass to sass.old, install sass theme updates, replace sass/custom with sass.old/custom"
@ -137,11 +160,11 @@ task :update_style, :theme do |t, args|
theme = args.theme || 'classic' theme = args.theme || 'classic'
if File.directory?("sass.old") if File.directory?("sass.old")
puts "removed existing sass.old directory" puts "removed existing sass.old directory"
system "rm -r sass.old" rm_r "sass.old", :secure=>true
end end
system "mv sass sass.old" mv "sass", "sass.old"
puts "## Moved styles into sass.old/" puts "## Moved styles into sass.old/"
system "mkdir -p sass; cp -R #{themes_dir}/"+theme+"/sass/* sass/" cp_r "#{themes_dir}/"+theme+"/sass/", "sass"
cp_r "sass.old/custom/.", "sass/custom" cp_r "sass.old/custom/.", "sass/custom"
puts "## Updated Sass ##" puts "## Updated Sass ##"
end end
@ -151,15 +174,16 @@ task :update_source, :theme do |t, args|
theme = args.theme || 'classic' theme = args.theme || 'classic'
if File.directory?("#{source_dir}.old") if File.directory?("#{source_dir}.old")
puts "removed existing #{source_dir}.old directory" puts "removed existing #{source_dir}.old directory"
system "rm -r #{source_dir}.old" rm_r "#{source_dir}.old", :secure=>true
end end
system "mv #{source_dir} #{source_dir}.old" mv source_dir, "#{source_dir}.old"
puts "moved #{source_dir} into #{source_dir}.old/" puts "moved #{source_dir} into #{source_dir}.old/"
system "mkdir -p #{source_dir}; cp -R #{themes_dir}/"+theme+"/source/. #{source_dir}" mkdir_p source_dir
system "cp -Rn #{source_dir}.old/. #{source_dir}" cp_r "#{themes_dir}/"+theme+"/source/.", source_dir
system "cp -Rf #{source_dir}.old/_includes/custom/. #{source_dir}/_includes/custom/" cp_r "#{source_dir}.old/.", source_dir, :preserve=>true
system "mv -f #{source_dir}/index.html #{blog_index_dir}" if blog_index_dir != source_dir cp_r "#{source_dir}.old/_includes/custom/.", "#{source_dir}/_includes/custom/"
system "cp -f #{source_dir}.old/index.html #{source_dir}" if blog_index_dir != source_dir mv "#{source_dir}/index.html", "#{blog_index_dir}", :force=>true if blog_index_dir != source_dir
cp "#{source_dir}.old/index.html", source_dir if blog_index_dir != source_dir
puts "## Updated #{source_dir} ##" puts "## Updated #{source_dir} ##"
end end
@ -168,7 +192,19 @@ end
############## ##############
desc "Default deploy task" desc "Default deploy task"
task :deploy => "#{deploy_default}" do multitask :deploy => [:copydot, "#{deploy_default}"] do
end
desc "copy dot files for deployment"
task :copydot do
cd "#{source_dir}" do
exclusions = [".", "..", ".DS_Store"]
Dir[".*"].each do |file|
if !File.directory?(file) && !exclusions.include?(file)
cp(file, "../#{public_dir}");
end
end
end
end end
desc "Deploy website via rsync" desc "Deploy website via rsync"
@ -178,7 +214,7 @@ task :rsync do
end end
desc "deploy public directory to github pages" desc "deploy public directory to github pages"
task :push do multitask :push do
puts "## Deploying branch to Github Pages " puts "## Deploying branch to Github Pages "
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) } (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
system "cp -R #{public_dir}/* #{deploy_dir}" system "cp -R #{public_dir}/* #{deploy_dir}"