mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-26 01:18:51 -05:00
Merge branch '2.1' into site-2.1
This commit is contained in:
commit
58e7489c4b
46
Rakefile
46
Rakefile
@ -55,6 +55,21 @@ task :generate do
|
|||||||
system "jekyll"
|
system "jekyll"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# usage rake generate_only[my-post]
|
||||||
|
desc "Generate only the specified post (much faster)"
|
||||||
|
task :generate_only, :filename do |t, args|
|
||||||
|
if args.filename
|
||||||
|
filename = args.filename
|
||||||
|
else
|
||||||
|
filename = get_stdin("Enter a post file name: ")
|
||||||
|
end
|
||||||
|
puts "## Stashing other posts"
|
||||||
|
Rake::Task["isolate"].invoke(filename)
|
||||||
|
Rake::Task["generate"].execute
|
||||||
|
puts "## Restoring stashed posts"
|
||||||
|
Rake::Task["integrate"].execute
|
||||||
|
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)
|
||||||
@ -62,12 +77,10 @@ task :watch do
|
|||||||
system "compass compile --css-dir #{source_dir}/stylesheets"
|
system "compass compile --css-dir #{source_dir}/stylesheets"
|
||||||
jekyllPid = Process.spawn("jekyll --auto")
|
jekyllPid = Process.spawn("jekyll --auto")
|
||||||
compassPid = Process.spawn("compass watch")
|
compassPid = Process.spawn("compass watch")
|
||||||
|
|
||||||
trap("INT") {
|
trap("INT") {
|
||||||
[jekyllPid, compassPid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
|
[jekyllPid, compassPid].each { |pid| Process.kill(9, pid) rescue Errno::ESRCH }
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
[jekyllPid, compassPid].each { |pid| Process.wait(pid) }
|
[jekyllPid, compassPid].each { |pid| Process.wait(pid) }
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -157,10 +170,15 @@ end
|
|||||||
# usage rake isolate[my-post]
|
# usage rake isolate[my-post]
|
||||||
desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much quicker."
|
desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much quicker."
|
||||||
task :isolate, :filename do |t, args|
|
task :isolate, :filename do |t, args|
|
||||||
|
if args.filename
|
||||||
|
filename = args.filename
|
||||||
|
else
|
||||||
|
filename = get_stdin("Enter a post file name: ")
|
||||||
|
end
|
||||||
stash_dir = "#{source_dir}/#{stash_dir}"
|
stash_dir = "#{source_dir}/#{stash_dir}"
|
||||||
FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
|
FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
|
||||||
Dir.glob("#{source_dir}/#{posts_dir}/*.*") do |post|
|
Dir.glob("#{source_dir}/#{posts_dir}/*.*") do |post|
|
||||||
FileUtils.mv post, stash_dir unless post.include?(args.filename)
|
FileUtils.mv post, stash_dir unless post.include?(filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -172,6 +190,14 @@ end
|
|||||||
desc "Clean out caches: .pygments-cache, .gist-cache, .sass-cache"
|
desc "Clean out caches: .pygments-cache, .gist-cache, .sass-cache"
|
||||||
task :clean do
|
task :clean do
|
||||||
rm_rf [".pygments-cache/**", ".gist-cache/**", ".sass-cache/**", "source/stylesheets/screen.css"]
|
rm_rf [".pygments-cache/**", ".gist-cache/**", ".sass-cache/**", "source/stylesheets/screen.css"]
|
||||||
|
puts "## Cleaned Sass, Pygments and Gist caches, removed generated stylesheets ##"
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Update theme source and style"
|
||||||
|
task :update, :theme do |t, args|
|
||||||
|
theme = args.theme || 'classic'
|
||||||
|
Rake::Task[:update_source].invoke(theme)
|
||||||
|
Rake::Task[:update_style].invoke(theme)
|
||||||
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"
|
||||||
@ -217,6 +243,7 @@ task :update_source, :theme do |t, args|
|
|||||||
puts "## Updated #{source_dir} ##"
|
puts "## Updated #{source_dir} ##"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# Deploying #
|
# Deploying #
|
||||||
##############
|
##############
|
||||||
@ -277,9 +304,13 @@ end
|
|||||||
|
|
||||||
desc "Update configurations to support publishing to root or sub directory"
|
desc "Update configurations to support publishing to root or sub directory"
|
||||||
task :set_root_dir, :dir do |t, args|
|
task :set_root_dir, :dir do |t, args|
|
||||||
puts ">>> !! Please provide a directory, eg. rake config_dir[publishing/subdirectory]" unless args.dir
|
|
||||||
if args.dir
|
if args.dir
|
||||||
if args.dir == "/"
|
dir = args.dir
|
||||||
|
else
|
||||||
|
dir = get_stdin("Please provide a directory: ")
|
||||||
|
end
|
||||||
|
if dir
|
||||||
|
if dir == "/"
|
||||||
dir = ""
|
dir = ""
|
||||||
else
|
else
|
||||||
dir = "/" + args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
|
dir = "/" + args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
|
||||||
@ -306,7 +337,10 @@ task :set_root_dir, :dir do |t, args|
|
|||||||
end
|
end
|
||||||
rm_rf public_dir
|
rm_rf public_dir
|
||||||
mkdir_p "#{public_dir}#{dir}"
|
mkdir_p "#{public_dir}#{dir}"
|
||||||
puts "## Site's root directory is now '/#{dir.sub(/^\//, '')}' ##"
|
puts "\n========================================================"
|
||||||
|
puts "Site's root directory is now '/#{dir.sub(/^\//, '')}'"
|
||||||
|
puts "Don't forget to update your url in _config.yml"
|
||||||
|
puts "\n========================================================"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user