-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
76 lines (67 loc) · 1.51 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
# encoding: UTF-8
require 'sinatra'
require 'haml'
require 'mail'
set :haml, :format => :html5, :escape_html => true
configure :production do
before do
cache_control :public, :max_age => 24*3600
Mail.defaults do
delivery_method :smtp, {
:address => "smtp.sendgrid.net",
:port => "25",
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => ENV['SENDGRID_DOMAIN']
}
end
end
end
configure :development do
before do
cache_control :no_store
Mail.defaults do
delivery_method :test
end
end
end
before do
content_type :html, :charset => 'utf-8'
@title = "Mon7 Consulting"
@menu = [
['/', 'Mon7 Consulting'],
['/projekt', 'Tidigare projekt'],
['/tjanster', 'Tjänster'],
['/kontakt', 'Kontakt'],
]
end
get '/' do
last_modified File.mtime "./views/index.haml"
haml :index
end
get '/:page' do |page|
pass unless File.exists? "./views/#{page}.haml"
last_modified File.mtime "./views/#{page}.haml"
@title = page.capitalize.gsub(/_/, ' ') + " - " + @title
haml page.to_sym
end
get '/mail' do
subj = "#{params[:subject]} #{params[:company]}" if params[:company]
subj = "#{params[:subject]}}"
body = params.inspect
Mail.deliver do
from '[email protected]'
to '[email protected]'
subject subj
body body
end
redirect '/felrapport_skickat' unless params[:company]
redirect '/mail_skickat'
end
get 'mail_skickat' do
haml :mail_skickat
end
not_found do
haml :not_found
end