-
Notifications
You must be signed in to change notification settings - Fork 19
/
Rakefile
68 lines (59 loc) · 1.42 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
# coding: utf-8
require 'bundler/setup'
require 'thread'
require 'launchy'
task default: :generate
desc 'preview する。 http://localhost:4000/'
task :preview do
Thread.new do
sleep 1
Launchy.open 'http://localhost:4000/'
end
sh 'bundle exec padrino start -p 4000 -h 0.0.0.0'
end
def front_formatter(datetime, event_no)
time_str = datetime.strftime("%Y-%m-%d %H:%M:%S %Z")
require 'yaml'
{
layout: 'event',
title: "すごい広島 ##{event_no}",
date: time_str,
connpass: nil,
facebook: nil,
togetter: nil,
place: 'shakehands',
categories: 'events',
}.stringify_keys.to_yaml
end
def next_event_time
require 'active_support'
require 'active_support/core_ext'
Date.today.beginning_of_week(:wednesday) + 1.week + 18.hours
end
def next_event_number
@number ||= Dir
.glob('_posts/*')
.map { |path| path.match(/event-(\d+).markdown/) }
.compact
.map { |match_object| match_object[1].to_i }
.max + 1
end
desc 'create next event file'
task :new_event do
time = next_event_time
event_no = '%03d' % next_event_number
filename = time.strftime("_posts/%Y-%m-%d-event-#{event_no}.markdown")
open(filename, 'w') do |io|
io.print front_formatter(time, next_event_number)
io.puts <<-STRING
---
# 参加者
STRING
end
end
desc 'generate site'
task :generate do
sh 'bundle exec rspec'
sh 'mkdir -p _site/img'
sh 'cp public/img/main.jpg _site/img'
end