-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
75 lines (61 loc) · 1.93 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require "rubygems"
require "bundler"
Bundler.require
require "time"
task :default => [:runserver]
ARTICLE_FILE_DATE_FORMAT = "%Y-%m-%d"
ARTICLE_POST_DATE_FORMAT = "%b %d, %Y %H:%M"
NOW = Time.now.strftime(ARTICLE_FILE_DATE_FORMAT)
desc "Run development server"
task :runserver do
system "bundle exec middleman serve"
end
namespace :new do
# rake new:article["hello world uğur","2016 june 20"]
# rake new:article["Do you know how write Django code ?","Jun 6 2019 10:30"]
desc "Post new Article"
task :article, [:title, :date] do |t, args|
article_title = args.title ? args.title : "new-article"
article_date = args.date ? Time.parse(args.date) : Time.now
article_file = "source/blog/#{article_date.strftime(ARTICLE_FILE_DATE_FORMAT)}-#{article_title.to_url}.html.markdown.erb"
output = []
output << "---"
output << "title: \"#{article_title}\""
output << "date: #{article_date.strftime(ARTICLE_POST_DATE_FORMAT)}"
output << "# category: news"
output << "# tags: tag1,tag2"
output << "author: \"Uğur Özyılmazel\""
output << "opengraph_image: \"#{article_date.strftime(ARTICLE_FILE_DATE_FORMAT)}-og-IMAGE.jpg\""
output << "# published: false"
output << "---"
output << ""
output << "Article summary..."
output << "READ_MORE"
output << ""
File.write article_file, output.join("\n")
puts "Blog post is ready to cook: #{article_file}"
end
end
desc "Deploy to gh-pages with bump"
task :deploy, [:bump] do |_, args|
args.with_defaults(bump: 'patch')
now = Time.now.strftime("%Y-%m-%d-%H-%M")
system %{
cd build/ &&
git pull &&
cd ../ &&
bumpversion #{args.bump} &&
git push &&
bundle exec middleman build --clean --verbose &&
cd build/ &&
git add . &&
git commit -m "release #{now}" &&
git push &&
cd ../
}
puts "Deployed..."
end
desc "Build site"
task :build do
system "bundle exec middleman build --clean --verbose"
end