Skip to content

Instantly share code, notes, and snippets.

@fullstackplus
Created June 30, 2014 06:07
Show Gist options
  • Save fullstackplus/2035999f0d916e2ca335 to your computer and use it in GitHub Desktop.
Save fullstackplus/2035999f0d916e2ca335 to your computer and use it in GitHub Desktop.
App.rb for a new Nesta site
module Nesta
class App
post '/contact' do
configure_options
Pony.mail(
:from => params[:name] + "<" + params[:email] + ">",
:to => '[email protected]',
:subject => params[:name] + " has contacted you",
:body => params[:message]
)
redirect '/thank-you'
end
def configure_options
Pony.options = {
:via => :smtp,
:via_options => {
:address => 'smtp.sendgrid.net',
:port => '587',
:domain => 'heroku.com',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
}
end
get '*' do
set_common_variables
parts = params[:splat].map { |p| p.sub(/\/$/, '') }
@page = Nesta::Page.find_by_path(File.join(parts))
raise Sinatra::NotFound if @page.nil?
@title = @page.title
set_from_page(:description, :keywords)
haml(@page.template, layout: @page.layout)
#http://nestacms.com/docs/design/templating-engines
#erb(@page.template, :layout => @page.layout)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment