-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
95 lines (77 loc) · 2.22 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# frozen_string_literal: true
require "yaml"
require "./lib/post_creator"
task default: :new
def ask(message)
print message
STDIN.gets.chomp
end
def post_metadata(post_path)
if File.exists?(post_path)
File.open(post_path, 'r') do |file|
lines = file.readlines
i, j, _ = lines.each_with_index.find_all { |line, i| line =~ /---/ }.map { |_, i| i }
header = lines[i + 1...j].join
YAML.load(header)
end
end
end
def metadata
FileList.new('_posts/*.md').map { |f| post_metadata(f) }
end
####################
desc "List all tags currently used."
task :tags do
puts metadata.map { |md| md["tags"] }.flatten.compact.uniq.sort
end
MONTHLY_MEETUP = "Monthly Online Meetup".freeze
namespace :new do
desc "Create a new generic announcement"
task :announcement, [:title] do |_, args|
PostCreator.new(title: args.title, layout: "announcement").create
end
desc "Create announcment for monthly meetup"
task :monthly_meetup, [:title] do |_, args|
PostCreator.new(
title: [MONTHLY_MEETUP, args.title].join("—"),
layout: "announcement",
).create
end
desc "Create announcment for monthly meetup"
task :discussion, [:title] do |_, args|
PostCreator.new(
title: "Online Meetup—Discussion:#{args.title}",
layout: "announcement",
).create
end
desc "Create announcment for monthly meetup specific to hack night"
task :hack_night do
PostCreator.new(
title: [MONTHLY_MEETUP, "Hack Night"].join("—"),
layout: "announcement",
body: HACK_NIGHT,
).create
end
desc "Create announcment for monthly meetup specific to lightning talks"
task :lightning_talks do
PostCreator.new(
title: [MONTHLY_MEETUP, "Lightning Talks"].join("—"),
layout: "announcement",
body: LIGHTNING_TALKS,
).create
end
desc "Create a new video post"
task :video, [:title] do |_, args|
PostCreator.new(title: args.title, layout: "video").create
end
end
HACK_NIGHT = <<~BODY
{% include time.html %}
{% include location_online.html %}
{% include hacknight.html %}
BODY
LIGHTNING_TALKS = <<~BODY
{% include time.html %}
{% include location_online.html %}
{% include signup_lightning_talks.html %}
BODY