forked from oguzzkilic/js.gelistiriciyiz.biz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
68 lines (55 loc) · 1.74 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
# -*- encoding: utf-8 -*-
require "bundler/setup"
require "date"
require "time"
require "stringex"
require "yaml"
Dir.glob('*.rake').each { |r| import r }
FILE_DATE_FORMAT = "%Y-%m-%d"
POST_DATE_FORMAT = "%b %d, %Y %H:%M"
NOW = Time.now.strftime(FILE_DATE_FORMAT)
task :default => ["preview"]
desc "Ön izleme / geliştirme sunucusu"
task :preview do
system "middleman"
end
desc "Test için build"
task :build do
system "rm -rf build/"
system "middleman build --verbose"
end
desc "Deploy"
task :deploy do
system "rm -rf build/"
system "middleman deploy"
end
desc "Yeni yazı ekle"
task :post, [:post_title, :post_date] do |t, args|
main_config = YAML.load_file('config.yaml')
main_author = main_config['site']['main_author']
begin
custom_config = YAML.load_file('config_custom.yaml')
main_author = custom_config['main_author']
rescue Exception => e
end
post_title = args[:post_title] ? args[:post_title] : "yeni-post"
post_time = args[:post_date] ? Time.parse(args[:post_date]) : Time.now
post_file = "source/posts/#{post_time.strftime(FILE_DATE_FORMAT)}-#{post_title.to_url}.md"
output = []
output << "---"
output << "title: \"#{post_title}\""
output << "date: #{post_time.strftime(POST_DATE_FORMAT)}"
output << "# tags: tag1,tag2"
output << "# subtitle: "
output << "# published: false"
output << "# cover: "
output << "author:"
output << " name: #{main_author['name']}"
output << " email: #{main_author['email']}"
output << " link: #{main_author['link']}"
output << " bio: #{main_author['bio']}"
output << " twitter: #{main_author['twitter']}" if main_author['twitter']
output << "---"
File.write post_file, output.join("\n")
puts "Yeni post edit edilmek için hazır: #{post_file}"
end