-
Notifications
You must be signed in to change notification settings - Fork 8
/
website.rb
80 lines (65 loc) · 1.98 KB
/
website.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
69
70
71
72
73
74
75
76
77
78
79
80
# encoding: utf-8
require "bundler/setup"
require "sinatra/base"
require "haml"
require "date"
require "rest-client"
require "json"
require "sinatra/ghetto_i18n"
module RubyConf
class Website < Sinatra::Application
register Sinatra::GhettoI18n
set :public, File.expand_path("../public", __FILE__)
set :haml, :format => :html5
set :languages, "en" => "English", "es" => "Español"
home do
haml :home
end
get "sponsors" do
haml :sponsors
end
get "speakers" do
haml :speakers
end
get "agenda" do
json = RestClient.get "https://eventioz.com/events/rubyconf-uruguay-2011/agenda.json"
agenda_json = JSON.parse json
@agenda = {}
agenda_json.each_with_index do |talk, index|
presentation = talk.fetch("presentation")
date_time = DateTime.parse presentation.fetch("starts_at")
date = date_time.to_date.to_s
time = date_time.strftime("%H:%M")
title, summary = presentation.fetch("description").split("\n")
summary = summary.join("\n") if summary.is_a?(Array)
@agenda[date] ||= []
@agenda[date] << { :index => index, :title => title, :summary => summary, :time => time }
end
haml :agenda
end
get "where" do
haml :where
end
get "events" do
haml :events
end
get 'tw/:id' do
redirect "/"
end
def speaker_twitter(user)
"Twitter: " + link_to("@#{user}", "http://twitter.com/#{user}")
end
def twitter(text="sígannos en twitter", user="rubyconfuruguay")
link_to text, "http://twitter.com/#{user}", :class => "twitter"
end
def email(text="envíennos un email", address="[email protected]")
link_to text, "mailto:#{address}", :class => "email"
end
def link_to(text, url=nil, options={}, &block)
url, text = text, capture_haml(&block) if url.nil?
capture_haml do
haml_tag :a, text, options.merge(:href => url)
end
end
end
end