-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
76 lines (57 loc) · 1.31 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
require 'sinatra'
require './constants'
require 'pony'
get '/' do
@page_title = set_title('Home')
erb :index
end
get '/registry' do
@page_title = set_title('Registry')
erb :registry
end
get '/travel' do
@page_title = set_title('Travel')
erb :travel
end
get '/hotels' do
@page_title = set_title('Hotels')
erb :hotels
end
get '/rsvp' do
@page_title = set_title('RSVP')
erb :rsvp
end
post '/rsvp' do
Pony.mail({
to: 'Robby Grossman <[email protected]>',
from: 'Wedding Response <[email protected]>',
subject: 'Wedding Response Received',
body: params_to_email_body(params),
via: :smtp,
via_options: {
address: 'smtp.sendgrid.net',
port: '587',
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
authentication: :plain,
domain: 'robbyandkristin.com'
}
})
redirect '/rsvp-success'
end
get '/rsvp-success' do
@page_title = set_title('RSVP Recorded!')
erb :'rsvp-success'
end
get '/javascripts/jquery.function.js' do
erb :'javascripts/jquery.function.js', layout: false
end
###########
def set_title(page_name)
"#{GROOM_FIRST_NAME} & #{BRIDE_FIRST_NAME} - #{page_name}"
end
def params_to_email_body(params)
params.inject('') do |result, kv|
result += "#{kv[0]}: #{kv[1]}\n"
end
end