Somehow I replaced Rakefile with oder version, oops
This commit is contained in:
parent
b38b613908
commit
35a158dd14
72
Rakefile
72
Rakefile
@ -1,10 +1,11 @@
|
||||
require "rubygems"
|
||||
require "bundler/setup"
|
||||
require "stringex"
|
||||
|
||||
## -- Rsync Deploy config -- ##
|
||||
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
|
||||
ssh_user = "user@domain.com"
|
||||
document_root = "~/website.com/"
|
||||
ssh_user = "mathisweb@octopress.org"
|
||||
document_root = "~/octopress.org/"
|
||||
deploy_default = "rsync"
|
||||
|
||||
# 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"
|
||||
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)
|
||||
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
|
||||
|
||||
desc "preview the site in a web browser"
|
||||
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)
|
||||
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
|
||||
|
||||
# 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}"
|
||||
args.with_defaults(:title => 'new-post')
|
||||
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}"
|
||||
open(filename, 'w') do |post|
|
||||
system "mkdir -p #{source_dir}/#{posts_dir}/";
|
||||
@ -129,7 +152,7 @@ end
|
||||
|
||||
desc "Clean out caches: _code_cache, _gist_cache, .sass-cache"
|
||||
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
|
||||
|
||||
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'
|
||||
if File.directory?("sass.old")
|
||||
puts "removed existing sass.old directory"
|
||||
system "rm -r sass.old"
|
||||
rm_r "sass.old", :secure=>true
|
||||
end
|
||||
system "mv sass sass.old"
|
||||
mv "sass", "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"
|
||||
puts "## Updated Sass ##"
|
||||
end
|
||||
@ -151,15 +174,16 @@ task :update_source, :theme do |t, args|
|
||||
theme = args.theme || 'classic'
|
||||
if File.directory?("#{source_dir}.old")
|
||||
puts "removed existing #{source_dir}.old directory"
|
||||
system "rm -r #{source_dir}.old"
|
||||
rm_r "#{source_dir}.old", :secure=>true
|
||||
end
|
||||
system "mv #{source_dir} #{source_dir}.old"
|
||||
mv source_dir, "#{source_dir}.old"
|
||||
puts "moved #{source_dir} into #{source_dir}.old/"
|
||||
system "mkdir -p #{source_dir}; cp -R #{themes_dir}/"+theme+"/source/. #{source_dir}"
|
||||
system "cp -Rn #{source_dir}.old/. #{source_dir}"
|
||||
system "cp -Rf #{source_dir}.old/_includes/custom/. #{source_dir}/_includes/custom/"
|
||||
system "mv -f #{source_dir}/index.html #{blog_index_dir}" if blog_index_dir != source_dir
|
||||
system "cp -f #{source_dir}.old/index.html #{source_dir}" if blog_index_dir != source_dir
|
||||
mkdir_p source_dir
|
||||
cp_r "#{themes_dir}/"+theme+"/source/.", source_dir
|
||||
cp_r "#{source_dir}.old/.", source_dir, :preserve=>true
|
||||
cp_r "#{source_dir}.old/_includes/custom/.", "#{source_dir}/_includes/custom/"
|
||||
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} ##"
|
||||
end
|
||||
|
||||
@ -168,7 +192,19 @@ end
|
||||
##############
|
||||
|
||||
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
|
||||
|
||||
desc "Deploy website via rsync"
|
||||
@ -178,7 +214,7 @@ task :rsync do
|
||||
end
|
||||
|
||||
desc "deploy public directory to github pages"
|
||||
task :push do
|
||||
multitask :push do
|
||||
puts "## Deploying branch to Github Pages "
|
||||
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
|
||||
system "cp -R #{public_dir}/* #{deploy_dir}"
|
||||
|
Loading…
Reference in New Issue
Block a user