-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.rb
49 lines (39 loc) · 1.1 KB
/
server.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
require 'sinatra'
require 'sinatra/json'
require 'haml'
require 'sass'
require 'config'
require 'helpers'
require 'twitter'
require 'meeting_info_finder'
require 'meeting_date_calculator'
## VIEWS
get '/' do
@next_meeting = MeetingInfoFinder.new('./data/meetings.yml')
.find(MeetingDateCalculator.next)
@mailing_list = "http://groups.google.com/group/columbusclojure"
@twitter_url = "https://twitter.com/ColumbusClojure"
haml :welcome
end
get '/tweets', :provides => 'json' do
headers \
"Access-Control-Allow-Origin" => "*"
twitter_client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_ACCESS_TOKEN']
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
end
tweets = twitter_client.user_timeline("ColumbusClojure", count: 6).map(&:attrs)
json tweets
end
get '/ping' do
"Pinged at #{Time.now}"
end
not_found do
redirect '/'
end
## STYLESHEETS
get '/:stylesheet.css' do |stylesheet|
sass stylesheet.to_sym
end