-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
101 lines (89 loc) · 3 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
96
97
98
99
100
101
require 'yaml'
require 'digest'
def generate_gravatar_hash(email)
Digest::MD5.hexdigest(email.strip.downcase) if email
end
def generate_html_entry(person)
output = "\t<li class='left'>\n"
output += "\t\t<span class='avatar'>\n"
if person['avatar']
output += "\t\t\t<img src='#{person['avatar']}' class='round left'>\n"
else
output += "\t\t\t<img src='http://www.gravatar.com/avatar/#{generate_gravatar_hash(person['email'])}?d=identicon' class='round left'>\n"
end
output += "\t\t</span>\n"
output += "\t\t<span class='name'>#{person['name']}</span>\n"
output += "\t\t<span class='twitter'><a href='http://twitter.com/#{person['twitter']}'><i class='icon-twitter'></i></a></span>\n" if person['twitter']
output += "\t\t<span class='email'><a href='mailto:#{person['email']}'><i class='icon-envelope-alt'></i></a></span>\n" if person['email']
output += "\t</li>\n"
end
def generate_html_list(people)
output = "<ul>\n"
people.each do |person|
output += generate_html_entry(person)
end
output += "</ul>\n"
output += "<div class='clear'></div>\n"
end
task :generate do
events = YAML.load_file("events.yml")
events.each do |event|
directory = event["directory"]
organizers = YAML.load_file("events/#{directory}/organizers.yml")
attendees = YAML.load_file("events/#{directory}/attendees.yml")
File.open("site/#{directory}.html", "w") do |file|
output = "<h1>Organizer & Coaches</h1>\n"
output += generate_html_list(organizers)
output += "<h1>Attendees</h1>\n"
output += generate_html_list(attendees)
file.write <<-END.gsub(/^ {8}/, '')
<!doctype>
<html>
<head>
<title>#{event['name']} attendees</title>
<link rel='stylesheet' href='stylesheets/application.css'>
</head>
<body>
<div class="header">
<div class="wrapper">
<div class="inner">
<div class="left">
The people who attended #{event['name']} - #{event['date']}
</div>
<div class="right">
<a href="http://en.gravatar.com/">Add your avatar</a>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<div class="main">
<div class="wrapper">
<div class="inner">
#{output}
</div>
</div>
</div>
<div class="footer">
<div class="wrapper">
<div class="inner">
<a href='https://github.com/RailsGirlsSwitzerland/attendees'>Fork me on <i class="icon-github"></i></a>
</div>
</div>
</div>
</body>
</html>
END
end
system('compass compile')
end
end
# Publishes the content under site to gh-pages branch - you probably need to run `rake generate` first
task :publish do
`git checkout gh-pages`
`git checkout master -- site`
`git add .`
`git commit -am "generated pages"`
`git push origin gh-pages`
`git checkout master`
end