...
|
...
|
@@ -12,13 +12,14 @@ deploy_branch = "gh-pages"
|
12
|
12
|
|
13
|
13
|
## -- Misc Configs, you probably have no reason to changes these -- ##
|
14
|
14
|
|
15
|
|
-public_dir = "public" # compiled site directory
|
16
|
|
-source_dir = "source" # source file directory
|
17
|
|
-deploy_dir = "_deploy" # deploy directory (for Github pages deployment)
|
18
|
|
-stash_dir = "_stash" # directory to stash posts for speedy generation
|
19
|
|
-posts_dir = "_posts" # directory for blog files
|
20
|
|
-themes_dir = ".themes" # directory for blog files
|
21
|
|
-post_format = "markdown" # file format for new posts when using the post rake task
|
|
15
|
+public_dir = "public" # compiled site directory
|
|
16
|
+source_dir = "source" # source file directory
|
|
17
|
+deploy_dir = "_deploy" # deploy directory (for Github pages deployment)
|
|
18
|
+stash_dir = "_stash" # directory to stash posts for speedy generation
|
|
19
|
+posts_dir = "_posts" # directory for blog files
|
|
20
|
+themes_dir = ".themes" # directory for blog files
|
|
21
|
+new_post_ext = "markdown" # default new post file extension when using the new_post task
|
|
22
|
+new_page_ext = "markdown" # default new page file extension when using the new_page task
|
22
|
23
|
|
23
|
24
|
|
24
|
25
|
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]"
|
...
|
...
|
@@ -54,22 +55,55 @@ task :preview do
|
54
|
54
|
system "trap 'kill $jekyllPid $compassPid' Exit; jekyll --auto --server & jekyllPid=$!; compass watch & compassPid=$!; wait"
|
55
|
55
|
end
|
56
|
56
|
|
57
|
|
-# usage rake post[my-new-post] or rake post['my new post'] or rake post (defaults to "new-post")
|
|
57
|
+# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
|
58
|
58
|
desc "Begin a new post in #{source_dir}/#{posts_dir}"
|
59
|
|
-task :post, :filename do |t, args|
|
|
59
|
+task :new_post, :title do |t, args|
|
60
|
60
|
require './plugins/titlecase.rb'
|
61
|
|
- args.with_defaults(:filename => 'new-post')
|
62
|
|
- open("#{source_dir}/_posts/#{Time.now.strftime('%Y-%m-%d')}-#{args.filename.downcase.gsub(/[ _]/, '-')}.#{post_format}", 'w') do |post|
|
|
61
|
+ args.with_defaults(:title => 'new-post')
|
|
62
|
+ title = args.title
|
|
63
|
+ filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/&/,'and').gsub(/[,\.'":\(\)\[\]]/,'').gsub(/\W/, '-')}.#{new_post_ext}"
|
|
64
|
+ puts "Creating new post: #{filename}"
|
|
65
|
+ open(filename, 'w') do |post|
|
63
|
66
|
system "mkdir -p #{source_dir}/#{posts_dir}";
|
64
|
67
|
post.puts "---"
|
65
|
|
- post.puts "title: #{args.filename.gsub(/[-_]/, ' ').titlecase}"
|
66
|
|
- post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
|
67
|
68
|
post.puts "layout: post"
|
|
69
|
+ post.puts "title: #{title.gsub(/&/,'&').titlecase}"
|
|
70
|
+ post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
|
|
71
|
+ post.puts "comments: true"
|
68
|
72
|
post.puts "categories: "
|
69
|
73
|
post.puts "---"
|
70
|
74
|
end
|
71
|
75
|
end
|
72
|
76
|
|
|
77
|
+# usage rake new_page[my-new-page] or rake new_page[my-new-page.html] or rake new_page (defaults to "new-page.markdown")
|
|
78
|
+desc "Begin a new post in #{source_dir}/#{posts_dir}"
|
|
79
|
+task :new_page, :filename do |t, args|
|
|
80
|
+ require './plugins/titlecase.rb'
|
|
81
|
+ args.with_defaults(:filename => 'new-page')
|
|
82
|
+ page_dir = source_dir
|
|
83
|
+ if args.filename =~ /(^.+\/)?(\w+)(\.)?(.+)?/
|
|
84
|
+ page_dir += "/#{$1}"
|
|
85
|
+ name = $2
|
|
86
|
+ extension = $4 || new_page_ext
|
|
87
|
+ filename = "#{name}.#{extension}"
|
|
88
|
+ mkdir_p page_dir
|
|
89
|
+ file = page_dir + filename
|
|
90
|
+ puts "Creating new page: #{file}"
|
|
91
|
+ open(file, 'w') do |page|
|
|
92
|
+ page.puts "---"
|
|
93
|
+ page.puts "layout: page"
|
|
94
|
+ page.puts "title: #{name.gsub(/[-_]/, ' ').titlecase}"
|
|
95
|
+ page.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
|
|
96
|
+ page.puts "comments: true"
|
|
97
|
+ page.puts "sharing: true"
|
|
98
|
+ page.puts "footer: true"
|
|
99
|
+ page.puts "---"
|
|
100
|
+ end
|
|
101
|
+ else
|
|
102
|
+ puts "Syntax error: #{args.filename} contains unsupported characters"
|
|
103
|
+ end
|
|
104
|
+end
|
|
105
|
+
|
73
|
106
|
# usage rake isolate[my-post]
|
74
|
107
|
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."
|
75
|
108
|
task :isolate, :filename do |t, args|
|