Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 266 lines (241 sloc) 11.017 kb
091ef1c6 » dbloete
2010-05-26 Use Bundler for dependency management
1 require "rubygems"
8698a276 » imathis
2011-05-30 Cleaned out public from repository, updated gitignore, added syntax
2 require "bundler/setup"
091ef1c6 » dbloete
2010-05-26 Use Bundler for dependency management
3
a2ab1d48 » imathis
2011-06-22 1. Reordered configs in Rakefile based on importance.
4 ## -- Rsync Deploy config -- ##
5 # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
ea349cdf » imathis
2011-06-29 Moved themes to .themes to get it out of the way. Updated Rakefile to…
6 ssh_user = "user@domain.com"
7 document_root = "~/website.com/"
8 deploy_default = "rsync"
9
10 # This will be configured for you when you run config_deploy
11 deploy_branch = "gh-pages"
a2ab1d48 » imathis
2011-06-22 1. Reordered configs in Rakefile based on importance.
12
59521e3d » imathis
2011-08-16 added blog_index_dir configuration and improved update_source
13 ## -- Misc Configs -- ##
a2ab1d48 » imathis
2011-06-22 1. Reordered configs in Rakefile based on importance.
14
59521e3d » imathis
2011-08-16 added blog_index_dir configuration and improved update_source
15 public_dir = "public" # compiled site directory
16 source_dir = "source" # source file directory
17 blog_index_dir = 'source' # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog')
18 deploy_dir = "_deploy" # deploy directory (for Github pages deployment)
19 stash_dir = "_stash" # directory to stash posts for speedy generation
20 posts_dir = "_posts" # directory for blog files
21 themes_dir = ".themes" # directory for blog files
22 new_post_ext = "markdown" # default new post file extension when using the new_post task
23 new_page_ext = "markdown" # default new page file extension when using the new_page task
24 server_port = "4000" # port for preview server eg. localhost:4000
399fe77f » imathis
2009-11-24 updated rakefile to support github user pages, and github project pag…
25
cc8985df » imathis
2009-10-31 fixed a few issues with the rakefile, and updated the readme
26
17c59fb1 » imathis
2011-07-19 Moved plugins to root directory. I'm ditching the idea of shipping pl…
27 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]"
d8b796ac » imathis
2011-06-07 Another massive commit:
28 task :install, :theme do |t, args|
29 # copy theme into working Jekyll directories
30 theme = args.theme || 'classic'
17c59fb1 » imathis
2011-07-19 Moved plugins to root directory. I'm ditching the idea of shipping pl…
31 puts "## Copying "+theme+" theme into ./#{source_dir} and ./sass"
9e6a9518 » imathis
2011-07-11 Updated install rake task (now properly copies directory contents) Th…
32 mkdir_p source_dir
33 cp_r "#{themes_dir}/#{theme}/source/.", source_dir
34 mkdir_p "sass"
35 cp_r "#{themes_dir}/#{theme}/sass/.", "sass"
36 mkdir_p "#{source_dir}/#{posts_dir}"
37 mkdir_p public_dir
d8b796ac » imathis
2011-06-07 Another massive commit:
38 end
39
14ba4cfd » imathis
2011-06-11 1. Reduced dependencies and updated the gemfile
40 #######################
41 # Working with Jekyll #
42 #######################
eefe29e5 » imathis
2010-03-10 now Octopress uses partials
43
a128d499 » imathis
2011-06-22 1. Improved Deployment and setup tasks in Rakefile
44 desc "Generate jekyll site"
45 task :generate do
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
46 raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
a128d499 » imathis
2011-06-22 1. Improved Deployment and setup tasks in Rakefile
47 puts "## Generating Site with Jekyll"
48 system "jekyll"
49 end
50
14ba4cfd » imathis
2011-06-11 1. Reduced dependencies and updated the gemfile
51 desc "Watch the site and regenerate when it changes"
52 task :watch do
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
53 raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
54 system "trap 'kill $jekyllPid $compassPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; wait"
af719fb4 » imathis
2009-11-25 fixed default deploy task
55 end
56
14ba4cfd » imathis
2011-06-11 1. Reduced dependencies and updated the gemfile
57 desc "preview the site in a web browser"
58 task :preview do
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
59 raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
60 system "trap 'kill $jekyllPid $compassPid $rackPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; rackup --port #{server_port} & rackPid=$!; wait"
145f8104 » imathis
2009-11-05 updated rake file, reorganized stylesheets, added google site search,…
61 end
62
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
63 # usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
ce662172 » imathis
2011-06-27 Improved the post and init_deploy rake tasks
64 desc "Begin a new post in #{source_dir}/#{posts_dir}"
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
65 task :new_post, :title do |t, args|
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
66 raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
92247251 » kent
2011-07-16 Updated path to plugins.
67 require './plugins/titlecase.rb'
ebd5fb00 » imathis
2011-08-25 sleeps wait, cleaned up rake preview and rake watch a bit
68 mkdir_p "#{source_dir}/#{posts_dir}"
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
69 args.with_defaults(:title => 'new-post')
70 title = args.title
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
71 filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}.#{new_post_ext}"
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
72 puts "Creating new post: #{filename}"
73 open(filename, 'w') do |post|
ebd5fb00 » imathis
2011-08-25 sleeps wait, cleaned up rake preview and rake watch a bit
74 system "mkdir -p #{source_dir}/#{posts_dir}/";
a6262dcb » imathis
2009-12-07 added a rake task for creating a new post
75 post.puts "---"
e4c2d579 » imathis
2011-04-17 irrisponsibly massive commit
76 post.puts "layout: post"
98cfd74d » imathis
2011-07-19 In new_post and new_page rake tasks: adding quotes around title attri…
77 post.puts "title: \"#{title.gsub(/&/,'&').titlecase}\""
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
78 post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
79 post.puts "comments: true"
17c59fb1 » imathis
2011-07-19 Moved plugins to root directory. I'm ditching the idea of shipping pl…
80 post.puts "categories: "
a6262dcb » imathis
2009-12-07 added a rake task for creating a new post
81 post.puts "---"
82 end
83 end
84
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
85 # usage rake new_page[my-new-page] or rake new_page[my-new-page.html] or rake new_page (defaults to "new-page.markdown")
9189548e » ballou88
2011-07-26 Changed description of new_page rake task, to what it does
86 desc "Create a new page in #{source_dir}/(filename)/index.#{new_page_ext}"
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
87 task :new_page, :filename do |t, args|
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
88 raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
89 require './plugins/titlecase.rb'
90 args.with_defaults(:filename => 'new-page')
91 page_dir = source_dir
cc1cfa56 » imathis
2011-07-19 fixed regular expression for new_page rake task
92 if args.filename =~ /(^.+\/)?([\w_-]+)(\.)?(.+)?/
6006ac8a » imathis
2011-07-19 new_page rake task now creates pages as page_name/index.[default_form…
93 page_dir += $4 ? "/#{$1}" : "/#{$1}#{$2}/"
94 name = $4 ? $2 : "index"
95 extension = $4 || "#{new_page_ext}"
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
96 filename = "#{name}.#{extension}"
97 mkdir_p page_dir
98 file = page_dir + filename
99 puts "Creating new page: #{file}"
100 open(file, 'w') do |page|
101 page.puts "---"
102 page.puts "layout: page"
6006ac8a » imathis
2011-07-19 new_page rake task now creates pages as page_name/index.[default_form…
103 page.puts "title: \"#{$2.gsub(/[-_]/, ' ').titlecase}\""
4a403231 » imathis
2011-07-19 Changed rake task 'post' to 'new_post' and updated the yaml front mat…
104 page.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
105 page.puts "comments: true"
106 page.puts "sharing: true"
107 page.puts "footer: true"
108 page.puts "---"
109 end
110 else
111 puts "Syntax error: #{args.filename} contains unsupported characters"
112 end
113 end
114
2f415171 » rwdaigle
2010-01-23 Update to rakefile to allow working on a single post at a time (and s…
115 # usage rake isolate[my-post]
116 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."
117 task :isolate, :filename do |t, args|
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
118 stash_dir = "#{source_dir}/#{stash_dir}"
2f415171 » rwdaigle
2010-01-23 Update to rakefile to allow working on a single post at a time (and s…
119 FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
120 Dir.glob("#{source_dir}/#{posts_dir}/*.*") do |post|
2f415171 » rwdaigle
2010-01-23 Update to rakefile to allow working on a single post at a time (and s…
121 FileUtils.mv post, stash_dir unless post.include?(args.filename)
122 end
123 end
124
125 desc "Move all stashed posts back into the posts directory, ready for site generation."
126 task :integrate do
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
127 FileUtils.mv Dir.glob("#{source_dir}/#{stash_dir}/*.*"), "#{source_dir}/#{posts_dir}/"
2f415171 » rwdaigle
2010-01-23 Update to rakefile to allow working on a single post at a time (and s…
128 end
129
21813059 » imathis
2011-06-17 1. Replaced Rdiscount in favor of Kramdown (better html5 support) for…
130 desc "Clean out caches: _code_cache, _gist_cache, .sass-cache"
131 task :clean do
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
132 system "rm -rf _code_cache/** _gist_cache/** .sass-cache/** source/stylesheets/screen.css"
21813059 » imathis
2011-06-17 1. Replaced Rdiscount in favor of Kramdown (better html5 support) for…
133 end
134
19df7e84 » imathis
2011-07-19 added source_update and sass_update rake tasks, for easily updating a…
135 desc "Move sass to sass.old, install sass theme updates, replace sass/custom with sass.old/custom"
136 task :update_style, :theme do |t, args|
137 theme = args.theme || 'classic'
6244feae » lukearmstrong
2011-07-28 Fixed rake update_source and rake update_style
138 if File.directory?("sass.old")
139 puts "removed existing sass.old directory"
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
140 system "rm -r sass.old"
6244feae » lukearmstrong
2011-07-28 Fixed rake update_source and rake update_style
141 end
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
142 system "mv sass sass.old"
19df7e84 » imathis
2011-07-19 added source_update and sass_update rake tasks, for easily updating a…
143 puts "## Moved styles into sass.old/"
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
144 system "mkdir -p sass; cp -R #{themes_dir}/"+theme+"/sass/* sass/"
19df7e84 » imathis
2011-07-19 added source_update and sass_update rake tasks, for easily updating a…
145 cp_r "sass.old/custom/.", "sass/custom"
146 puts "## Updated Sass ##"
147 end
148
149 desc "Move source to source.old, install source theme updates, replace source/_includes/navigation.html with source.old's navigation"
150 task :update_source, :theme do |t, args|
151 theme = args.theme || 'classic'
6244feae » lukearmstrong
2011-07-28 Fixed rake update_source and rake update_style
152 if File.directory?("#{source_dir}.old")
153 puts "removed existing #{source_dir}.old directory"
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
154 system "rm -r #{source_dir}.old"
6244feae » lukearmstrong
2011-07-28 Fixed rake update_source and rake update_style
155 end
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
156 system "mv #{source_dir} #{source_dir}.old"
19df7e84 » imathis
2011-07-19 added source_update and sass_update rake tasks, for easily updating a…
157 puts "moved #{source_dir} into #{source_dir}.old/"
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
158 system "mkdir -p #{source_dir}; cp -R #{themes_dir}/"+theme+"/source/. #{source_dir}"
159 system "cp -Rn #{source_dir}.old/. #{source_dir}"
160 system "cp -Rf #{source_dir}.old/_includes/custom/. #{source_dir}/_includes/custom/"
161 system "mv -f #{source_dir}/index.html #{blog_index_dir}" if blog_index_dir != source_dir
162 system "cp -f #{source_dir}.old/index.html #{source_dir}" if blog_index_dir != source_dir
19df7e84 » imathis
2011-07-19 added source_update and sass_update rake tasks, for easily updating a…
163 puts "## Updated #{source_dir} ##"
164 end
165
14ba4cfd » imathis
2011-06-11 1. Reduced dependencies and updated the gemfile
166 ##############
167 # Deploying #
168 ##############
169
ea349cdf » imathis
2011-06-29 Moved themes to .themes to get it out of the way. Updated Rakefile to…
170 desc "Default deploy task"
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
171 task :deploy => "#{deploy_default}" do
ea349cdf » imathis
2011-06-29 Moved themes to .themes to get it out of the way. Updated Rakefile to…
172 end
173
14ba4cfd » imathis
2011-06-11 1. Reduced dependencies and updated the gemfile
174 desc "Deploy website via rsync"
ea349cdf » imathis
2011-06-29 Moved themes to .themes to get it out of the way. Updated Rakefile to…
175 task :rsync do
d8b796ac » imathis
2011-06-07 Another massive commit:
176 puts "## Deploying website via Rsync"
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
177 ok_failed system("rsync -avz --delete #{public_dir}/ #{ssh_user}:#{document_root}")
82d0251d » imathis
2009-10-18 improved starting point
178 end
179
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
180 desc "deploy public directory to github pages"
b38b6139 » imathis
2011-08-25 Added warning if users try to add posts, pages, or generate their site
181 task :push do
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
182 puts "## Deploying branch to Github Pages "
183 (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
a12b0b7f » imathis
2011-07-26 updated push rake task to copy contents of public directory into _deploy
184 system "cp -R #{public_dir}/* #{deploy_dir}"
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
185 puts "\n## copying #{public_dir} to #{deploy_dir}"
186 cd "#{deploy_dir}" do
187 system "git add ."
188 system "git add -u"
189 puts "\n## Commiting: Site updated at #{Time.now.utc}"
190 message = "Site updated at #{Time.now.utc}"
191 system "git commit -m '#{message}'"
192 puts "\n## Pushing generated #{deploy_dir} website"
ea349cdf » imathis
2011-06-29 Moved themes to .themes to get it out of the way. Updated Rakefile to…
193 system "git push origin #{deploy_branch}"
b9b9eb09 » imathis
2011-06-21 improved rake tasks for deployment, updated .gitignore
194 puts "\n## Github Pages deploy complete"
195 end
54766a0c » imathis
2009-11-24 updated rakefile to support github pages deployments
196 end
197
1f9b596b » imathis
2011-07-16 1. Added rake task for simple configuration of subdirectory deployment.
198 desc "Update configurations to support publishing to root or sub directory"
199 task :set_root_dir, :dir do |t, args|
200 puts ">>> !! Please provide a directory, eg. rake config_dir[publishing/subdirectory]" unless args.dir
201 if args.dir
202 if args.dir == "/"
203 dir = ""
204 else
205 dir = "/" + args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
206 end
207 rakefile = IO.read(__FILE__)
208 rakefile.sub!(/public_dir(\s*)=(\s*)(["'])[\w\-\/]*["']/, "public_dir\\1=\\2\\3public#{dir}\\3")
209 File.open(__FILE__, 'w') do |f|
210 f.write rakefile
211 end
212 compass_config = IO.read('config.rb')
213 compass_config.sub!(/http_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_path\\1=\\2\\3#{dir}/\\3")
214 compass_config.sub!(/http_images_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_images_path\\1=\\2\\3#{dir}/images\\3")
215 compass_config.sub!(/http_fonts_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_fonts_path\\1=\\2\\3#{dir}/fonts\\3")
216 compass_config.sub!(/css_dir(\s*)=(\s*)(["'])[\w\-\/]*["']/, "css_dir\\1=\\2\\3public#{dir}/stylesheets\\3")
217 File.open('config.rb', 'w') do |f|
218 f.write compass_config
219 end
220 jekyll_config = IO.read('_config.yml')
221 jekyll_config.sub!(/^destination:.+$/, "destination: public#{dir}")
12aed03e » imathis
2011-07-22 updated rakefile and config to support url mapping in previous commit
222 jekyll_config.sub!(/^subscribe_rss:\s*\/.+$/, "subscribe_rss: #{dir}/atom.xml")
223 jekyll_config.sub!(/^root:.*$/, "root: /#{dir.sub(/^\//, '')}")
1f9b596b » imathis
2011-07-16 1. Added rake task for simple configuration of subdirectory deployment.
224 File.open('_config.yml', 'w') do |f|
225 f.write jekyll_config
226 end
12aed03e » imathis
2011-07-22 updated rakefile and config to support url mapping in previous commit
227 rm_rf public_dir
228 mkdir_p "#{public_dir}#{dir}"
229 puts "## Site's root directory is now '/#{dir.sub(/^\//, '')}' ##"
1f9b596b » imathis
2011-07-16 1. Added rake task for simple configuration of subdirectory deployment.
230 end
231 end
232
233 desc "Setup _deploy folder and deploy branch"
ea349cdf » imathis
2011-06-29 Moved themes to .themes to get it out of the way. Updated Rakefile to…
234 task :config_deploy, :branch do |t, args|
ce662172 » imathis
2011-06-27 Improved the post and init_deploy rake tasks
235 puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch
236 puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment"
6f4c842b » imathis
2011-06-27 fixed a bug in init_deploy task
237 cd "#{deploy_dir}" do
a128d499 » imathis
2011-06-22 1. Improved Deployment and setup tasks in Rakefile
238 system "git symbolic-ref HEAD refs/heads/#{args.branch}"
239 system "rm .git/index"
240 system "git clean -fdx"
ce662172 » imathis
2011-06-27 Improved the post and init_deploy rake tasks
241 system "echo 'My Octopress Page is coming soon …' > index.html"
a128d499 » imathis
2011-06-22 1. Improved Deployment and setup tasks in Rakefile
242 system "git add ."
ea349cdf » imathis
2011-06-29 Moved themes to .themes to get it out of the way. Updated Rakefile to…
243 system "git commit -m 'Octopress init'"
244 rakefile = IO.read(__FILE__)
245 rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{args.branch}\\3")
246 rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
247 File.open(__FILE__, 'w') do |f|
248 f.write rakefile
249 end
a128d499 » imathis
2011-06-22 1. Improved Deployment and setup tasks in Rakefile
250 end
ee7b9dd9 » imathis
2011-07-11 Changed _plugins folder to plugins and updated rake tasks accordingly
251 puts "## Deployment configured. Now you can deploy to the #{args.branch} branch with `rake deploy` ##"
a128d499 » imathis
2011-06-22 1. Improved Deployment and setup tasks in Rakefile
252 end
82d0251d » imathis
2009-10-18 improved starting point
253
a128d499 » imathis
2011-06-22 1. Improved Deployment and setup tasks in Rakefile
254 def ok_failed(condition)
255 if (condition)
256 puts "OK"
257 else
258 puts "FAILED"
259 end
260 end
82d0251d » imathis
2009-10-18 improved starting point
261
14ba4cfd » imathis
2011-06-11 1. Reduced dependencies and updated the gemfile
262 desc "list tasks"
263 task :list do
a817f997 » marutanm
2011-08-11 fix rake-list
264 puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).join(', ')}"
14ba4cfd » imathis
2011-06-11 1. Reduced dependencies and updated the gemfile
265 puts "(type rake -T for more detail)\n\n"
9bd71339 » gisikw
2010-08-03 Fixed 'rake preview on fails vanilla install' bug
266 end
Something went wrong with that request. Please try again.