From def01cb4441a08a4dca4b4be4d44c8684857f648 Mon Sep 17 00:00:00 2001 From: Rob Slifka Date: Wed, 21 Aug 2013 16:42:03 -0700 Subject: Use source/CNAME (if it exists) to set _config.yml url property --- Rakefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index f3ada93d..f16a5f40 100644 --- a/Rakefile +++ b/Rakefile @@ -337,7 +337,11 @@ task :setup_github_pages, :repo do |t, args| end end end - url = "http://#{user}.github.io" + url = if File.exists?('source/CNAME') + "http://#{IO.read('source/CNAME').strip}" + else + "http://#{user}.github.io" + end url += "/#{project}" unless project == '' jekyll_config = IO.read('_config.yml') jekyll_config.sub!(/^url:.*$/, "url: #{url}") -- cgit v1.2.1 From f56cbb55891c9214d66a9eaace4120d0901c62b4 Mon Sep 17 00:00:00 2001 From: Rob Slifka Date: Wed, 21 Aug 2013 20:58:45 -0700 Subject: Extract method --- Rakefile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index f16a5f40..8e07281a 100644 --- a/Rakefile +++ b/Rakefile @@ -337,14 +337,8 @@ task :setup_github_pages, :repo do |t, args| end end end - url = if File.exists?('source/CNAME') - "http://#{IO.read('source/CNAME').strip}" - else - "http://#{user}.github.io" - end - 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 @@ -389,6 +383,15 @@ 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 == '' +end + desc "list tasks" task :list do puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}" -- cgit v1.2.1 From 7f19c78cd53369cac01c1b107e9147c72de6d22a Mon Sep 17 00:00:00 2001 From: Rob Slifka Date: Thu, 22 Aug 2013 22:01:41 -0700 Subject: Improved readability --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 8e07281a..ce6ba4ad 100644 --- a/Rakefile +++ b/Rakefile @@ -338,7 +338,7 @@ task :setup_github_pages, :repo do |t, args| end end jekyll_config = IO.read('_config.yml') - jekyll_config.sub!(/^url:.*$/, "url: #{blog_url(user,project)}") + jekyll_config.sub!(/^url:.*$/, "url: #{blog_url(user, project)}") File.open('_config.yml', 'w') do |f| f.write jekyll_config end -- cgit v1.2.1