-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
149 lines (122 loc) · 3.82 KB
/
app.rb
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
require 'bundler/setup'
Bundler.require(:default)
configure do
set :haml, :format => :html5
Compass.configuration do |config|
config.project_path = File.dirname(__FILE__)
config.sass_dir = 'views'
end
set :scss, Compass.sass_engine_options
end
configure :development do
require 'sinatra/reloader'
end
helpers do
def file_digest(file)
File.read("#{file}.md5")
end
def asset_path(file)
"/#{file}?#{file_digest('public/' + file)}"
end
end
# Haml file-not-found exception bubbling up from the depths.
error Errno::ENOENT do
halt(404)
end
# 2013
get '/2013/?' do
@title = :home
haml :"2013/home", :layout => :"2013/layout"
end
get '/2013/:page_name' do
page_name = params[:page_name]
@title = page_name
haml :"2013/#{page_name}", :layout => :"2013/layout"
end
# 2014
get '/2014/?' do
page_name = params[:page_name]
@title = page_name
haml :"2014/home", :layout => :"2014/layout"
end
get '/2014/:page_name' do
page_name = params[:page_name]
@title = page_name
haml :"2014/#{page_name}", :layout => :"2014/layout"
end
# 2015
get '/2015' do
@title = :home
@speaker = %w( keithpitty.jpg laurenvoswinkel.jpg philiparndt.jpg konstantingredeskoul.png johndalton.jpg shevauncoker.jpg seanmarcia.jpg josspaling.jpg erikmichaelsober.jpg johnbarton.jpg amywibowo.jpg
scottfeinberg.jpg sabrinaleandro.jpg ).sample
haml :"2015/home", :layout => :"2015/layout"
end
# 2016
get '/2017' do
@title = :home
@speaker = %w( keithpitty.jpg laurenvoswinkel.jpg philiparndt.jpg konstantingredeskoul.png johndalton.jpg shevauncoker.jpg seanmarcia.jpg josspaling.jpg erikmichaelsober.jpg johnbarton.jpg amywibowo.jpg
scottfeinberg.jpg sabrinaleandro.jpg ).sample
haml :"2017/home", :layout => :"2017/layout"
end
get '/2016' do
@title = :home
@speaker = %w( keithpitty.jpg laurenvoswinkel.jpg philiparndt.jpg konstantingredeskoul.png johndalton.jpg shevauncoker.jpg seanmarcia.jpg josspaling.jpg erikmichaelsober.jpg johnbarton.jpg amywibowo.jpg
scottfeinberg.jpg sabrinaleandro.jpg ).sample
haml :"2016/home", :layout => :"2016/layout"
end
get '/2015/:page_name' do
page_name = params[:page_name]
@title = page_name
haml :"2015/#{page_name}", :layout => :"2015/layout"
end
get '/2016/:page_name' do
page_name = params[:page_name]
@title = page_name
haml :"2016/#{page_name}", :layout => :"2016/layout"
end
# Generic
get '/' do
status_code 302
redirect '/2016'
end
post '/subscribe' do
content_type :json
CreateSend.api_key '64e1e3a9ca79765e3a439a2fd4588dc8'
begin
CreateSend::Subscriber.add "da0ee77746e2f89b40a3bdff230c415d", params[:email], "", [], true
rescue CreateSend::BadRequest => br
puts "Bad request error: #{br}"
puts "Error Code: #{br.data.Code}"
puts "Error Message: #{br.data.Message}"
rescue Exception => e
puts "Error: #{e}"
end
{success: true}.to_json
end
# post '/talk-proposal' do
# if params[:honeypot].empty?
# puts '***************'
# puts "Sending proposal from #{params[:name]} | #{params[:email]}"
# puts '***************'
# Pony.mail(to: '[email protected]',
# from: params[:email],
# subject: "Lightning talk proposal from #{params[:name]}",
# body: haml(:"2014/email", layout: false),
# via: :smtp,
# via_options: {
# address: 'smtp.sendgrid.net',
# port: '587',
# domain: ENV['SENDGRID_DOMAIN'],
# user_name: ENV['SENDGRID_USERNAME'],
# password: ENV['SENDGRID_PASSWORD'],
# authentication: :plain,
# enable_starttls_auto: true
# })
# end
#
# { success: true }.to_json
# end
get "/:year/stylesheets/main.css" do
content_type 'text/css', :charset => 'utf-8'
scss :"#{params[:year]}/styles/main"
end