Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 162 lines (140 sloc) 5.57 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
eefe29e @imathis now Octopress uses partials
imathis authored
4 port = "4000" # preview project port eg. http://localhost:4000
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
5 site = "public" # compiled site directory
eefe29e @imathis now Octopress uses partials
imathis authored
6 source = "source" # source file directory
7 stash = "_stash" # directory to stash posts for speedy generation
8 posts = "_posts" # directory for blog files
9 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
10
11 ## -- Rsync Deploy config -- ##
cc8985d @imathis fixed a few issues with the rakefile, and updated the readme
imathis authored
12 ssh_user = "user@host.com" # for rsync deployment
13 document_root = "~/document_root/" # for rsync deployment
14 ## ---- ##
15
399fe77 @imathis updated rakefile to support github user pages, and github project pag…
imathis authored
16 ## -- Github Pages deploy config -- ##
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
17 # Read http://pages.github.com for guidance
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
18 # You can deploy to github pages with `rake push_github` or change the default push task below to :push_github
399fe77 @imathis updated rakefile to support github user pages, and github project pag…
imathis authored
19 # If you're not using this, you can remove it
20 source_branch = "source" # this compiles to your deploy branch
de113ec @imathis changed default github pages deploy branch to master
imathis authored
21 deploy_branch = "master" # For user pages, use "master" for project pages use "gh-pages"
399fe77 @imathis updated rakefile to support github user pages, and github project pag…
imathis authored
22 ## ---- ##
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
23
82d0251 @imathis improved starting point
imathis authored
24 def ok_failed(condition)
25 if (condition)
26 puts "OK"
27 else
28 puts "FAILED"
29 end
30 end
31
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
32 ## if you're deploying with github, change the default deploy to push_github
33 desc "default push task"
34 task :push => [:push_rsync] do
eefe29e @imathis now Octopress uses partials
imathis authored
35 end
36
37 desc "Generate and deploy task"
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
38 task :deploy => [:integrate, :generate, :clean_debug, :push] do
af719fb @imathis fixed default deploy task
imathis authored
39 end
40
145f810 @imathis updated rake file, reorganized stylesheets, added google site search,…
imathis authored
41 desc "generate website in output directory"
eefe29e @imathis now Octopress uses partials
imathis authored
42 task :generate => [:generate_site, :generate_style] do
76b8b8c @imathis fixed rake preview and updated sass to sass3 syntax
imathis authored
43 puts ">>> Site Generating Complete! <<<\n\n>>> Refresh your browser <<<"
145f810 @imathis updated rake file, reorganized stylesheets, added google site search,…
imathis authored
44 end
45
a6262dc @imathis added a rake task for creating a new post
imathis authored
46 # usage rake post[my-new-post] or rake post['my new post'] or rake post (defaults to "new-post")
47 desc "Begin a new post in #{source}/_posts"
48 task :post, :filename do |t, args|
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
49 require './_plugins/titlecase.rb'
a6262dc @imathis added a rake task for creating a new post
imathis authored
50 args.with_defaults(:filename => 'new-post')
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
51 open("#{source}/_posts/#{Time.now.strftime('%Y-%m-%d')}-#{args.filename.downcase.gsub(/[ _]/, '-')}.#{post_format}", 'w') do |post|
a6262dc @imathis added a rake task for creating a new post
imathis authored
52 post.puts "---"
53 post.puts "title: \"#{args.filename.gsub(/[-_]/, ' ').titlecase}\""
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
54 post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
55 post.puts "layout: post"
a6262dc @imathis added a rake task for creating a new post
imathis authored
56 post.puts "---"
57 end
58 end
59
2f41517 @rwdaigle Update to rakefile to allow working on a single post at a time (and s…
rwdaigle authored
60 # usage rake isolate[my-post]
61 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."
62 task :isolate, :filename do |t, args|
63 stash_dir = "#{source}/#{stash}"
64 FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
65 Dir.glob("#{source}/#{posts}/*.*") do |post|
66 FileUtils.mv post, stash_dir unless post.include?(args.filename)
67 end
68 end
69
70 desc "Move all stashed posts back into the posts directory, ready for site generation."
71 task :integrate do
72 FileUtils.mv Dir.glob("#{source}/#{stash}/*.*"), "#{source}/#{posts}/"
73 end
74
82d0251 @imathis improved starting point
imathis authored
75 desc "list tasks"
145f810 @imathis updated rake file, reorganized stylesheets, added google site search,…
imathis authored
76 task :list do
6c9f156 @imathis updated rakefile, added some basic twitter files
imathis authored
77 puts "Tasks: #{(Rake::Task.tasks - [Rake::Task[:list]]).to_sentence}"
82d0251 @imathis improved starting point
imathis authored
78 puts "(type rake -T for more detail)\n\n"
79 end
80
81 desc "remove files in output directory"
82 task :clean do
6c9f156 @imathis updated rakefile, added some basic twitter files
imathis authored
83 puts ">>> Removing output <<<"
82d0251 @imathis improved starting point
imathis authored
84 Dir["#{site}/*"].each { |f| rm_rf(f) }
85 end
86
cc8985d @imathis fixed a few issues with the rakefile, and updated the readme
imathis authored
87 task :clean_debug do
6c9f156 @imathis updated rakefile, added some basic twitter files
imathis authored
88 puts ">>> Removing debug pages <<<"
3e69c6b @imathis fixed the deploy rake task so it will delete the debug pages
imathis authored
89 Dir["#{site}/test"].each { |f| rm_rf(f) }
cc8985d @imathis fixed a few issues with the rakefile, and updated the readme
imathis authored
90 end
91
145f810 @imathis updated rake file, reorganized stylesheets, added google site search,…
imathis authored
92 desc "Generate styles only"
93 task :generate_style do
6c9f156 @imathis updated rakefile, added some basic twitter files
imathis authored
94 puts ">>> Generating styles <<<"
e112b7e @dbloete Fix compass/sass deprecation warnings
dbloete authored
95 system "compass compile"
145f810 @imathis updated rake file, reorganized stylesheets, added google site search,…
imathis authored
96 end
97
98 desc "Generate site files only"
416667c @imathis added disqus comment support
imathis authored
99 task :generate_site => [:clean, :generate_style] do
24c5fed @imathis udpated thirdparty integration, it is now conditionally added, update…
imathis authored
100 puts "\n\n>>> Generating site files <<<"
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
101 system "jekyll"
dafeb04 @imathis updated rakefile to use FSSM in `rake watch`, generate a sitemap, and…
imathis authored
102 end
103
104 desc "Watch the site and regenerate when it changes"
105 task :watch do
8698a27 @imathis Cleaned out public from repository, updated gitignore, added syntax
imathis authored
106 system "trap 'kill $jekyllPid $guardPid $compassPid' Exit; jekyll --auto & jekyllPid=$!; compass watch & compassPid=$!; guard & guardPid=$!; wait"
dafeb04 @imathis updated rakefile to use FSSM in `rake watch`, generate a sitemap, and…
imathis authored
107 end
108
399fe77 @imathis updated rakefile to support github user pages, and github project pag…
imathis authored
109 desc "generate and deploy website via rsync"
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
110 multitask :push_rsync do
111 puts ">>> Deploying website via Rsync <<<"
e0a0d09 @imathis paramaterized feed, rsync deployment, and unified layouts
imathis authored
112 ok_failed system("rsync -avz --delete #{site}/ #{ssh_user}:#{document_root}")
82d0251 @imathis improved starting point
imathis authored
113 end
114
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
115 desc "deploy website to github user pages"
116 multitask :push_github do
b12b037 @imathis improved rake file feedback during deploy
imathis authored
117 puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
118 require 'git'
119 repo = Git.open('.')
b12b037 @imathis improved rake file feedback during deploy
imathis authored
120 puts "\n>>> Checking out #{deploy_branch} branch <<<\n"
3a69742 @imathis fixed source_branch variable name in github deploy script
imathis authored
121 repo.branch("#{deploy_branch}").checkout
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
122 (Dir["*"] - ["#{site}"]).each { |f| rm_rf(f) }
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
123 Dir["#{site}/*"].each {|f| mv(f, ".")}
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
124 rm_rf("#{site}")
125 puts "\n>>> Moving generated /#{site} files <<<\n"
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
126 Dir["**/*"].each {|f| repo.add(f) }
127 repo.status.deleted.each {|f, s| repo.remove(f)}
b12b037 @imathis improved rake file feedback during deploy
imathis authored
128 puts "\n>>> Commiting: Site updated at #{Time.now.utc} <<<\n"
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
129 message = ENV["MESSAGE"] || "Site updated at #{Time.now.utc}"
130 repo.commit(message)
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
131 puts "\n>>> Pushing generated /#{site} files to #{deploy_branch} branch <<<\n"
eff018e @imathis trying one more thing with the rake task auto push
imathis authored
132 repo.push
b12b037 @imathis improved rake file feedback during deploy
imathis authored
133 puts "\n>>> Github Pages deploy complete <<<\n"
399fe77 @imathis updated rakefile to support github user pages, and github project pag…
imathis authored
134 repo.branch("#{source_branch}").checkout
54766a0 @imathis updated rakefile to support github pages deployments
imathis authored
135 end
136
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
137 desc "start up a web server on the output files"
138 task :start_server => :stop_server do
139 print "Starting serve..."
140 system("serve #{site} #{port} > /dev/null 2>&1 &")
141 sleep 1
142 pid = `ps auxw | awk '/bin\\/serve #{site} #{port}/ { print $2 }'`.strip
143 ok_failed !pid.empty?
144 system "open http://localhost:#{port}" unless pid.empty?
82d0251 @imathis improved starting point
imathis authored
145 end
146
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
147 desc "stop the web server"
148 task :stop_server do
149 pid = `ps auxw | awk '/bin\\/serve #{site} #{port}/ { print $2 }'`.strip
82d0251 @imathis improved starting point
imathis authored
150 if pid.empty?
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
151 puts "Adsf is not running"
82d0251 @imathis improved starting point
imathis authored
152 else
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
153 print "Stoping adsf..."
82d0251 @imathis improved starting point
imathis authored
154 ok_failed system("kill -9 #{pid}")
155 end
156 end
157
158 desc "preview the site in a web browser"
e4c2d57 @imathis irrisponsibly massive commit
imathis authored
159 task :preview do
160 system "trap 'kill $servePid $jekyllPid $guardPid' Exit; serve #{site} #{port} > /dev/null 2>&1 & servePid=$!; jekyll --auto & jekyllPid=$!; guard & guardPid=$!; compass compile; open http://localhost:#{port}; wait"
9bd7133 @gisikw Fixed 'rake preview on fails vanilla install' bug
gisikw authored
161 end
Something went wrong with that request. Please try again.