Skip to content
Newer
Older
100644 143 lines (122 sloc) 5.03 KB
091ef1c @dbloete Use Bundler for dependency management
dbloete authored
1 require "rubygems"
8698a27 @imathis Cleaned out public from repository, updated gitignore, added syntax
imathis authored
2 require "bundler/setup"
091ef1c @dbloete Use Bundler for dependency management
dbloete authored
3
a2ab1d4 @imathis 1. Reordered configs in Rakefile based on importance.
imathis authored
4 ## -- Rsync Deploy config -- ##
5 # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
6 ssh_user = "mathisweb@imathis.com"
7 document_root = "~/dev.octopress.org/"
8
9 ## -- Misc Configs, you probably have no reason to changes these -- ##
10
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
11 public_dir = "public" # compiled site directory
12 source_dir = "source" # source file directory
13 deploy_dir = "_deploy" # deploy directory (for Github pages deployment)
14 stash_dir = "_stash" # directory to stash posts for speedy generation
15 posts_dir = "_posts" # directory for blog files
eefe29e @imathis now Octopress uses partials
imathis authored
16 post_format = "markdown" # file format for new posts when using the post rake task
399fe77 @imathis updated rakefile to support github user pages, and github project pag…
imathis authored
17
cc8985d @imathis fixed a few issues with the rakefile, and updated the readme
imathis authored
18
d8b796a @imathis Another massive commit:
imathis authored
19 desc "Initial setup for Octopress: copies the default theme into the path of Jekyll's generator. rake install defaults to rake install[classic] to install a different theme run rake install[some_theme_name]"
20 task :install, :theme do |t, args|
21 # copy theme into working Jekyll directories
22 theme = args.theme || 'classic'
ce66217 @imathis Improved the post and init_deploy rake tasks
imathis authored
23 puts "## Copying "+theme+" theme into ./#{source_dir} ./sass and ./_plugins "
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
24 system "mkdir -p #{source_dir}; cp -R themes/"+theme+"/source/ #{source_dir}/"
913fa10 @imathis 1. Moved _plugins into themes/classic/_plugins
imathis authored
25 system "mkdir -p sass; cp -R themes/"+theme+"/sass/ sass/"
26 system "mkdir -p _plugins; cp -R themes/"+theme+"/_plugins/ _plugins/"
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
27 system "mkdir -p #{source_dir}/#{posts_dir}";
d8b796a @imathis Another massive commit:
imathis authored
28 end
29
14ba4cf @imathis 1. Reduced dependencies and updated the gemfile
imathis authored
30 #######################
31 # Working with Jekyll #
32 #######################
eefe29e @imathis now Octopress uses partials
imathis authored
33
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
34 desc "Generate jekyll site"
35 task :generate do
36 puts "## Generating Site with Jekyll"
37 system "jekyll"
38 end
39
14ba4cf @imathis 1. Reduced dependencies and updated the gemfile
imathis authored
40 desc "Watch the site and regenerate when it changes"
41 task :watch do
42 system "trap 'kill $jekyllPid $compassPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; wait"
af719fb @imathis fixed default deploy task
imathis authored
43 end
44
14ba4cf @imathis 1. Reduced dependencies and updated the gemfile
imathis authored
45 desc "preview the site in a web browser"
46 task :preview do
47 system "trap 'kill $jekyllPid $compassPid' Exit; jekyll --auto --server & jekyllPid=$!; compass watch & compassPid=$!; wait"
145f810 @imathis updated rake file, reorganized stylesheets, added google site search,…
imathis authored
48 end
49
a6262dc @imathis added a rake task for creating a new post
imathis authored
50 # usage rake post[my-new-post] or rake post['my new post'] or rake post (defaults to "new-post")
ce66217 @imathis Improved the post and init_deploy rake tasks
imathis authored
51 desc "Begin a new post in #{source_dir}/#{posts_dir}"
a6262dc @imathis added a rake task for creating a new post
imathis authored
52 task :post, :filename do |t, args|
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
53 require './_plugins/titlecase.rb'
a6262dc @imathis added a rake task for creating a new post
imathis authored
54 args.with_defaults(:filename => 'new-post')
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
55 open("#{source_dir}/_posts/#{Time.now.strftime('%Y-%m-%d')}-#{args.filename.downcase.gsub(/[ _]/, '-')}.#{post_format}", 'w') do |post|
56 system "mkdir -p #{source_dir}/#{posts_dir}";
a6262dc @imathis added a rake task for creating a new post
imathis authored
57 post.puts "---"
2181305 @imathis 1. Replaced Rdiscount in favor of Kramdown (better html5 support) for…
imathis authored
58 post.puts "title: #{args.filename.gsub(/[-_]/, ' ').titlecase}"
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
59 post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
60 post.puts "layout: post"
353ccfd @imathis 1. Added Category support
imathis authored
61 post.puts "categories: []"
a6262dc @imathis added a rake task for creating a new post
imathis authored
62 post.puts "---"
63 end
64 end
65
2f41517 @rwdaigle Update to rakefile to allow working on a single post at a time (and s…
rwdaigle authored
66 # usage rake isolate[my-post]
67 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."
68 task :isolate, :filename do |t, args|
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
69 stash_dir = "#{source_dir}/#{stash_dir}"
2f41517 @rwdaigle Update to rakefile to allow working on a single post at a time (and s…
rwdaigle authored
70 FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
71 Dir.glob("#{source_dir}/#{posts_dir}/*.*") do |post|
2f41517 @rwdaigle Update to rakefile to allow working on a single post at a time (and s…
rwdaigle authored
72 FileUtils.mv post, stash_dir unless post.include?(args.filename)
73 end
74 end
75
76 desc "Move all stashed posts back into the posts directory, ready for site generation."
77 task :integrate do
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
78 FileUtils.mv Dir.glob("#{source_dir}/#{stash_dir}/*.*"), "#{source_dir}/#{posts_dir}/"
2f41517 @rwdaigle Update to rakefile to allow working on a single post at a time (and s…
rwdaigle authored
79 end
80
2181305 @imathis 1. Replaced Rdiscount in favor of Kramdown (better html5 support) for…
imathis authored
81 desc "Clean out caches: _code_cache, _gist_cache, .sass-cache"
82 task :clean do
83 system "rm -rf _code_cache/** _gist_cache/** .sass-cache/**"
84 end
85
14ba4cf @imathis 1. Reduced dependencies and updated the gemfile
imathis authored
86 ##############
87 # Deploying #
88 ##############
89
90 desc "Deploy website via rsync"
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
91 task :sync do
d8b796a @imathis Another massive commit:
imathis authored
92 puts "## Deploying website via Rsync"
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
93 ok_failed system("rsync -avz --delete #{public_dir}/ #{ssh_user}:#{document_root}")
82d0251 @imathis improved starting point
imathis authored
94 end
95
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
96 desc "deploy public directory to github pages"
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
97 task :push do
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
98 puts "## Deploying branch to Github Pages "
99 (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
100 system "cp -R #{public_dir}/ #{deploy_dir}"
101 puts "\n## copying #{public_dir} to #{deploy_dir}"
102 cd "#{deploy_dir}" do
103 system "git add ."
104 system "git add -u"
105 puts "\n## Commiting: Site updated at #{Time.now.utc}"
106 message = "Site updated at #{Time.now.utc}"
107 system "git commit -m '#{message}'"
108 puts "\n## Pushing generated #{deploy_dir} website"
109 system "git push"
110 puts "\n## Github Pages deploy complete"
111 end
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
112 end
113
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
114 desc "setup _deploy folder and deploy branch"
115 task :init_deploy, :branch do |t, args|
ce66217 @imathis Improved the post and init_deploy rake tasks
imathis authored
116 puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch
117 puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment"
6f4c842 @imathis fixed a bug in init_deploy task
imathis authored
118 cd "#{deploy_dir}" do
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
119 system "git symbolic-ref HEAD refs/heads/#{args.branch}"
120 system "rm .git/index"
121 system "git clean -fdx"
ce66217 @imathis Improved the post and init_deploy rake tasks
imathis authored
122 system "echo 'My Octopress Page is coming soon …' > index.html"
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
123 system "git add ."
ce66217 @imathis Improved the post and init_deploy rake tasks
imathis authored
124 system "git commit -m 'My Octopress site is coming soon'"
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
125 system "git push origin #{args.branch}"
126 end
127 end
82d0251 @imathis improved starting point
imathis authored
128
a128d49 @imathis 1. Improved Deployment and setup tasks in Rakefile
imathis authored
129 def ok_failed(condition)
130 if (condition)
131 puts "OK"
132 else
133 puts "FAILED"
134 end
135 end
82d0251 @imathis improved starting point
imathis authored
136
14ba4cf @imathis 1. Reduced dependencies and updated the gemfile
imathis authored
137 desc "list tasks"
138 task :list do
139 puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).to_sentence}"
140 puts "(type rake -T for more detail)\n\n"
9bd7133 @gisikw Fixed 'rake preview on fails vanilla install' bug
gisikw authored
141 end
b9b9eb0 @imathis improved rake tasks for deployment, updated .gitignore
imathis authored
142
Something went wrong with that request. Please try again.