octopress and gitcafe
ocotpress 支持 github,不过 github 的 pages 貌似被墙了,且速度慢。gitcafe 速度还不错,也支持 pages,刚好可以切换过去。我只是简单粗暴的修改了几个文件。
1diff --git a/.gitignore b/.gitignore
2index 85ed25d..5858b25 100644
3--- a/.gitignore
4+++ b/.gitignore
5@@ -12,3 +12,4 @@ source/stylesheets/screen.css
6 vendor
7 node_modules
8 .themes/fabric/
9+gitcafe
10diff --git a/Rakefile b/Rakefile
11index 53072e5..62061e0 100644
12--- a/Rakefile
13+++ b/Rakefile
14@@ -27,6 +27,9 @@ new_post_ext = "markdown" # default new post file extension when using the n
15 new_page_ext = "markdown" # default new page file extension when using the new_page task
16 server_port = "4000" # port for preview server eg. localhost:4000
17
18+gitcafe_dir = "gitcafe"
19+gitcafe_branch = "gitcafe-pages"
20+
21
22 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 them
23 task :install, :theme do |t, args|
24@@ -219,7 +214,7 @@ end
25 ##############
26
27 desc "Default deploy task"
28-task :deploy do
29+task :deploy_old do
30 # Check if preview posts exist, which should not be published
31 if File.exists?(".preview-mode")
32 puts "## Found posts in preview mode, regenerating files ..."
33@@ -231,6 +226,31 @@ task :deploy do
34 Rake::Task["#{deploy_default}"].execute
35 end
36
37+desc "deploy gitcafe"
38+task :deploy do
39+ # Check if preview posts exist, which should not be published
40+ if File.exists?(".preview-mode")
41+ puts "## Found posts in preview mode, regenerating files ..."
42+ File.delete(".preview-mode")
43+ #Rake::Task[:generate].execute # 这个地方每次都会 generate 我一般喜欢先 generate 本地看好没问题之后再 deploy,所以就注释掉了
44+ end
45+
46+ puts "## Deploying branch to Gitcafe Pages "
47+ puts "\n## copying #{public_dir} to #{gitcafe_dir}"
48+ cp_r "#{public_dir}/.", gitcafe_dir
49+ cd "#{gitcafe_dir}" do
50+ system "git add ."
51+ system "git add -u"
52+ puts "\n## Commiting: Site updated at #{Time.now.utc}"
53+ message = "Site updated at #{Time.now.utc}"
54+ system "git commit -m \"#{message}\""
55+ puts "\n## Pushing generated #{gitcafe_dir} website"
56+ system "git push origin #{gitcafe_branch} --force"
57+ puts "\n## Gcafe Pages deploy complete"
58+ end
59+end
60+
61+
62 desc "Generate website and deploy"
63 task :gen_deploy => [:integrate, :generate, :deploy] do
64 end
然后需要在 octopus 根目录 clone 一下你的 gitcafe 项目到 gitcafe 目录
1$ git clone [email protected]:wd/wd gitcafe
2....
然后就可以试试看 rake generate
, rake preview
, rake deploy
了。