mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-24 16:38:49 -05:00
Merge branch '2.1' into site-2.1
This commit is contained in:
commit
47b13260cf
66
Rakefile
66
Rakefile
@ -221,7 +221,6 @@ task :deploy do
|
||||
File.delete(".preview-mode")
|
||||
Rake::Task[:generate].execute
|
||||
end
|
||||
|
||||
Rake::Task[:copydot].invoke(source_dir, public_dir)
|
||||
Rake::Task["#{deploy_default}"].execute
|
||||
end
|
||||
@ -249,21 +248,29 @@ end
|
||||
|
||||
desc "deploy public directory to github pages"
|
||||
multitask :push do
|
||||
if File.directory?(deploy_dir)
|
||||
puts "## Deploying branch to Github Pages "
|
||||
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
|
||||
Rake::Task[:copydot].invoke(public_dir, deploy_dir)
|
||||
puts "Attempting pull, to sync local deployment repository"
|
||||
cd "#{deploy_dir}" do
|
||||
system "git pull origin #{deploy_branch}"
|
||||
end
|
||||
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"
|
||||
puts "\n## Commiting: Site updated at #{Time.now.utc}"
|
||||
message = "Site updated at #{Time.now.utc}"
|
||||
puts "\n## Commiting: #{message}"
|
||||
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
|
||||
else
|
||||
puts "This project isn't configured for deploying to Github Pages\nPlease run `rake setup_github_pages[your-deployment-repo-url]`."
|
||||
end
|
||||
end
|
||||
|
||||
desc "Update configurations to support publishing to root or sub directory"
|
||||
@ -311,6 +318,8 @@ task :setup_github_pages, :repo do |t, args|
|
||||
user = repo_url.match(/:([^\/]+)/)[1]
|
||||
branch = (repo_url.match(/\/[\w-]+.github.com/).nil?) ? 'gh-pages' : 'master'
|
||||
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
|
||||
url = "http://#{user}.github.com"
|
||||
url += "/#{project}" unless project == ''
|
||||
unless `git remote -v`.match(/origin.+?octopress.git/).nil?
|
||||
# If octopress is still the origin remote (from cloning) rename it to octopress
|
||||
system "git remote rename origin octopress"
|
||||
@ -325,34 +334,65 @@ task :setup_github_pages, :repo do |t, args|
|
||||
puts "Master branch renamed to 'source' for committing your blog source files"
|
||||
else
|
||||
unless !public_dir.match("#{project}").nil?
|
||||
system "rake set_root_dir[#{project}]"
|
||||
Rake::Task[:set_root_dir].invoke(project)
|
||||
end
|
||||
end
|
||||
end
|
||||
url = "http://#{user}.github.com"
|
||||
url += "/#{project}" unless project == ''
|
||||
jekyll_config = IO.read('_config.yml')
|
||||
jekyll_config.sub!(/^url:.*$/, "url: #{url}")
|
||||
File.open('_config.yml', 'w') do |f|
|
||||
f.write jekyll_config
|
||||
end
|
||||
|
||||
# Configure deployment repository
|
||||
rm_rf deploy_dir
|
||||
mkdir deploy_dir
|
||||
cd "#{deploy_dir}" do
|
||||
system "git init"
|
||||
system "git remote add origin #{repo_url}"
|
||||
puts "Attempting to pull from repository"
|
||||
system "git pull origin #{branch}"
|
||||
unless File.exist?('index.html')
|
||||
system "echo 'My Octopress Page is coming soon …' > index.html"
|
||||
system "git add ."
|
||||
system "git commit -m \"Octopress init\""
|
||||
system "git branch -m gh-pages" unless branch == 'master'
|
||||
system "git remote add origin #{repo_url}"
|
||||
end
|
||||
end
|
||||
|
||||
# Configure deployment setup in Rakefile
|
||||
rakefile = IO.read(__FILE__)
|
||||
rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{branch}\\3")
|
||||
rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
|
||||
File.open(__FILE__, 'w') do |f|
|
||||
f.write rakefile
|
||||
end
|
||||
|
||||
# Configure published url
|
||||
jekyll_config = IO.read('_config.yml')
|
||||
current_url = /^url:\s?(.*$)/.match(jekyll_config)[1]
|
||||
has_cname = File.exists?("#{source_dir}/CNAME")
|
||||
if current_url == 'http://yoursite.com'
|
||||
jekyll_config.sub!(/^url:.*$/, "url: #{url}")
|
||||
File.open('_config.yml', 'w') do |f|
|
||||
f.write jekyll_config
|
||||
end
|
||||
puts "\n---\n## Now you can deploy to #{url} with `rake deploy` ##"
|
||||
current_url = url
|
||||
end
|
||||
|
||||
puts "\n========================================================"
|
||||
if has_cname
|
||||
cname = IO.read("#{source_dir}/CNAME").chomp
|
||||
current_short_url = /\/{2}(.*$)/.match(current_url)[1]
|
||||
if cname != current_short_url
|
||||
puts "!! WARNING: Your CNAME points to #{cname} but your _config.yml url is set to #{current_short_url} !!"
|
||||
puts "For help with setting up a CNAME follow the guide at http://help.github.com/pages/#custom_domains"
|
||||
else
|
||||
puts "Github Pages will host your site at http://#{cname}"
|
||||
end
|
||||
else
|
||||
puts "Github Pages will host your site at #{url}."
|
||||
puts "To host at \"your-site.com\", configure a CNAME: `echo \"your-domain.com\" > #{source_dir}/CNAME`"
|
||||
puts "Then change the url in _config.yml from #{current_url} to http://your-domain.com"
|
||||
puts "Finally, follow the guide at http://help.github.com/pages/#custom_domains for help pointing your domain to Github Pages"
|
||||
end
|
||||
puts "Deploy to #{repo_url} with `rake deploy`"
|
||||
puts "========================================================"
|
||||
end
|
||||
|
||||
def ok_failed(condition)
|
||||
|
@ -10,6 +10,7 @@ module BacktickCodeBlock
|
||||
@lang = nil
|
||||
@url = nil
|
||||
@title = nil
|
||||
input.encode!("UTF-8")
|
||||
input.gsub(/^`{3} *([^\n]+)?\n(.+?)\n`{3}/m) do
|
||||
@options = $1 || ''
|
||||
str = $2
|
||||
|
Loading…
Reference in New Issue
Block a user