Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 52d207bd5f
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (33 sloc) 1.076 kB
require 'rubygems'
require 'sinatra'
require 'nokogiri'
require 'open-uri'
require 'omniauth/oauth'
enable :sessions
APP_ID = "YOUR-FACEBOOK-APP-ID"
APP_SECRET = "YOUR-FACEBOOK-APP-SECRET"
BASE_URL = "http://www.irishrail.ie/your_journey/ajax/ajaxRefreshResults.asp?station="
use OmniAuth::Builder do
provider :facebook, APP_ID, APP_SECRET, { :scope => 'email, status_update, publish_stream', :iframe => true,
:client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
end
OmniAuth.config.full_host = 'YOURCANVASURL'
get '/' do
erb :index
end
post '/' do
erb :index
end
get '/train' do
@station = URI.escape(params[:station])
doc = Nokogiri::HTML(open("#{BASE_URL}#{@station}"))
@trains = []
doc.search('tr').each {|t| @trains << t if t.content =~ /DART/}
erb :train
end
post '/auth/facebook/callback' do
session['fb_auth'] = request.env['omniauth.auth']
session['fb_token'] = session['fb_auth']['credentials']['token']
session['fb_error'] = nil
redirect '/'
end
Jump to Line
Something went wrong with that request. Please try again.