aboutsummaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorAlexandre Perrin <alexandre.perrin@netoxygen.ch>2013-09-27 10:53:43 +0200
committerAlexandre Perrin <alexandre.perrin@netoxygen.ch>2013-09-27 10:53:43 +0200
commit8bfd5ef3237f07125adde7043c19a3159879044a (patch)
tree6ac9b05d53cde0c5a6c837e8316683f652f3d5cf /Rakefile
parentfe28c0b518e47f7929772eaaab7b0118ddcfbaad (diff)
parentf0674c69366b9172e6811036bbc5b0a29dbf6025 (diff)
downloadmy_new_personal_website-8bfd5ef3237f07125adde7043c19a3159879044a.tar.xz
my_new_personal_website-8bfd5ef3237f07125adde7043c19a3159879044a.zip
Merge branch 'master' of https://github.com/imathis/octopress
Diffstat (limited to '')
-rw-r--r--Rakefile37
1 files changed, 27 insertions, 10 deletions
diff --git a/Rakefile b/Rakefile
index a57a56f6..0d5ec3b5 100644
--- a/Rakefile
+++ b/Rakefile
@@ -247,18 +247,21 @@ end
desc "deploy public directory to github pages"
multitask :push do
puts "## Deploying branch to Github Pages "
+ puts "## Pulling any updates from Github Pages "
+ cd "#{deploy_dir}" do
+ system "git pull"
+ end
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
Rake::Task[:copydot].invoke(public_dir, deploy_dir)
- puts "\n## copying #{public_dir} to #{deploy_dir}"
+ puts "\n## Copying #{public_dir} to #{deploy_dir}"
cp_r "#{public_dir}/.", deploy_dir
cd "#{deploy_dir}" do
- system "git add ."
- system "git add -u"
+ system "git add -A"
puts "\n## Commiting: Site updated at #{Time.now.utc}"
message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\""
puts "\n## Pushing generated #{deploy_dir} website"
- system "git push origin #{deploy_branch} --force"
+ system "git push origin #{deploy_branch}"
puts "\n## Github Pages deploy complete"
end
end
@@ -304,10 +307,16 @@ task :setup_github_pages, :repo do |t, args|
repo_url = args.repo
else
puts "Enter the read/write url for your repository"
- puts "(For example, 'git@github.com:your_username/your_username.github.io)"
+ puts "(For example, 'git@github.com:your_username/your_username.github.io.git)"
+ puts " or 'https://github.com/your_username/your_username.github.io')"
repo_url = get_stdin("Repository url: ")
end
- user = repo_url.match(/:([^\/]+)/)[1]
+ protocol = (repo_url.match(/(^git)@/).nil?) ? 'https' : 'git'
+ if protocol == 'git'
+ user = repo_url.match(/:([^\/]+)/)[1]
+ else
+ user = repo_url.match(/github\.com\/([^\/]+)/)[1]
+ end
branch = (repo_url.match(/\/[\w-]+\.github\.(?:io|com)/).nil?) ? 'gh-pages' : 'master'
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil?
@@ -328,10 +337,8 @@ task :setup_github_pages, :repo do |t, args|
end
end
end
- url = "http://#{user}.github.io"
- url += "/#{project}" unless project == ''
jekyll_config = IO.read('_config.yml')
- jekyll_config.sub!(/^url:.*$/, "url: #{url}")
+ jekyll_config.sub!(/^url:.*$/, "url: #{blog_url(user, project)}")
File.open('_config.yml', 'w') do |f|
f.write jekyll_config
end
@@ -351,7 +358,7 @@ task :setup_github_pages, :repo do |t, args|
f.write rakefile
end
end
- puts "\n---\n## Now you can deploy to #{url} with `rake deploy` ##"
+ puts "\n---\n## Now you can deploy to #{repo_url} with `rake deploy` ##"
end
def ok_failed(condition)
@@ -376,6 +383,16 @@ def ask(message, valid_options)
answer
end
+def blog_url(user, project)
+ url = if File.exists?('source/CNAME')
+ "http://#{IO.read('source/CNAME').strip}"
+ else
+ "http://#{user}.github.io"
+ end
+ url += "/#{project}" unless project == ''
+ url
+end
+
desc "list tasks"
task :list do
puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"