-
Notifications
You must be signed in to change notification settings - Fork 0
/
zinweb.rb
58 lines (48 loc) · 1.06 KB
/
zinweb.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
# zinweb.rb
require 'erb'
require 'mail'
require 'pony'
set :views, File.dirname(__FILE__) + '/views'
get "/" do
erb :index
end
get "/twitter/?" do
erb :twitter
end
get '/qrcard/?' do
erb :qrcard
end
get '/thanks/?' do
erb :thanks
end
post '/inq/?' do
name = params[:name]
mail = params[:mail]
body = params[:body]
smtp_settings = {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN']
}
Pony.mail(
:to => '[email protected]',
:from => "#{name} <#{mail}>",
:subject => "#{name} says Hi!",
:body => "#{body}",
:via => :smtp, :via_options => smtp_settings
)
puts "#{name} from #{mail} said #{body}"
redirect '/thanks', 302
end
TEAM = %w(sebastian sergio alejandro juan felipe nicolas)
get "/team/:name" do
name = params[:name]
if TEAM.include? name
erb "team/#{name}".to_sym
else
halt 404
end
end