-
Notifications
You must be signed in to change notification settings - Fork 0
/
activity.rb
68 lines (55 loc) · 1.66 KB
/
activity.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
require 'rubygems'
require 'sinatra'
require 'erb'
require 'yaml'
require 'nokogiri'
require 'open-uri'
require 'feed_tools'
require 'parsers/delicious'
require 'parsers/twitter'
require 'parsers/github'
require 'cache'
configure do
@@settings = YAML::load(File.read('settings.yml'))
@@cache = Cache.new
end
get '/' do
erb :activity
end
post '/delicious' do
if @@cache.expired? 'delicious' or params['reload']
@feeds = delicious_feeds @@settings['delicious']
@@cache.write('delicious', erb(:delicious) )
end
@@cache.read('delicious') + "<span>#{params['reload']}</span>"
end
post '/twitter' do
if @@cache.expired? 'twitter' or params['reload']
@messages = twitter_messages @@settings['twitter'], @@settings['twitter_messagges_count']
@@cache.write('twitter', erb(:twitter) )
end
@@cache.read('twitter')
end
post '/github' do
if @@cache.expired? 'github' or params['reload']
@commits = github @@settings['github_user_name'], @@settings['github_token']
@@cache.write('github', erb(:github) )
end
@@cache.read('github')
end
get '/js/jquery.js' do
headers 'Content-Type' => 'text/javascript; charset=utf-8'
File.read( File.join( File.dirname( __FILE__ ), 'js', 'jquery.js' ) )
end
get '/js/activity.js' do
headers 'Content-Type' => 'text/javascript; charset=utf-8'
File.read( File.join( File.dirname( __FILE__ ), 'js', 'activity.js' ) )
end
get '/css/activity.css' do
headers 'Content-Type' => 'text/css; charset=utf-8'
File.read(File.join(File.dirname(__FILE__), 'css', 'activity.css' ) )
end
get '/img/loader.gif' do
headers 'Content-Type' => 'image/jpeg;'
File.read(File.join(File.dirname(__FILE__), 'img', 'loader.gif' ) )
end