forked from mmwtsn/hipchat-emotodex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
43 lines (36 loc) · 782 Bytes
/
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
# Load Rubygems
require 'bundler'
Bundler.require
# Load and include helper methods
require './helpers'
include Helpers
configure do
# If cache is not set, create new Redis instance
uri = URI.parse(ENV["REDISTOGO_URL"]) # Required for Heroku
CACHE ||= Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
# Ensure value exists in cache before proceeding
unless emoticons_in(CACHE)
update(CACHE)
end
end
# Display Emoticons
get '/' do
# Format emoticon data and make them available to the view
@emoticons = render_emoticons(CACHE)
erb :index
end
# Update Emoticons
get '/refresh/?' do
update(CACHE)
redirect '/'
end
# 404
not_found do
status 404
erb 404.to_s.to_sym
end
# 500
error do
status 500
erb 500.to_s.to_sym
end