-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathapp.rb
78 lines (73 loc) · 2.28 KB
/
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
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
#!/usr/bin/env ruby
require 'sinatra/base'
require 'httparty'
require 'haml'
require 'yaml'
WAIFU = YAML.load_file File.expand_path(".", "lists/waifu.yml")
HUSBANDO = YAML.load_file File.expand_path(".", "lists/husbando.yml")
IMOUTO = YAML.load_file File.expand_path(".", "lists/imouto.yml")
SHIPGIRL = YAML.load_file File.expand_path(".", "lists/kancolle.yml")
TOUHOU = YAML.load_file File.expand_path(".", "lists/touhou.yml")
VOCALOID = YAML.load_file File.expand_path(".", "lists/vocaloid.yml")
IDOL = YAML.load_file File.expand_path(".", "lists/idol.yml")
class WaifuApp < Sinatra::Base
get '/' do
@waifu = WAIFU.sample
@tweet = URI::encode("My waifu is #{@waifu['name']}! Who is yours? Find out at")
haml :waifu, layout: :layout
end
get '/:list' do
case params[:list]
when /waifu/i
@waifu = WAIFU.sample
@type = "waifu"
when /husbando/i
@waifu = HUSBANDO.sample
@type = "husbando"
when /imouto/i
@waifu = IMOUTO.sample
@type = "imouto"
when /shipgirl/i
@waifu = SHIPGIRL.sample
@type = "shipgirl"
when /touhou/i
@waifu = TOUHOU.sample
@type = "touhou"
when /vocaloid/i
@waifu = VOCALOID.sample
@type = "vocaloid"
when /idol/i
@waifu = IDOL.sample
@type = "idol"
else
@waifu = WAIFU.sample
@type = "waifu"
end
@tweet = URI::encode("My #{@type} is #{@waifu['name']}! Who is yours? Find it out at")
haml :list, layout: :layout
end
get '/otp/' do
@partner_a = WAIFU.sample
@partner_b = HUSBANDO.sample
@tweet = URI::encode("My OTP is #{@partner_a['name']} x #{@partner_b['name']}! Which is yours? Find out at")
haml :otp, layout: :layout
end
get '/otp/:type' do
case params[:type]
when /yaoi/i
@partner_a = HUSBANDO.sample
@partner_b = HUSBANDO.sample
@type = "yaoi OTP"
when /yuri/i
@partner_a = WAIFU.sample
@partner_b = WAIFU.sample
@type = "yuri OTP"
else
@partner_a = WAIFU.sample
@partner_b = HUSBANDO.sample
@type = "OTP"
end
@tweet = URI::encode("My #{@type} is #{@partner_a['name']} x #{@partner_b['name']}! Which is yours? Find out at")
haml :otps, layout: :layout
end
end