-
Notifications
You must be signed in to change notification settings - Fork 40
/
web.rb
110 lines (99 loc) · 2.57 KB
/
web.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
require 'sinatra'
require 'json'
require './draminate'
get '/txt' do
Random.srand
draminate
end
get '/txt/:version/:seed' do
Random.srand(params[:seed].to_i(36))
draminate params[:version]
end
get '/json' do
seed = Random.new_seed
version = current_version
Random.srand(seed)
{seed: seed.to_s(36), drama: draminate, version: version}.to_json
end
get '/json/:version/:seed' do
seed = params[:seed].to_i(36)
Random.srand(seed)
{seed: seed.to_s(36), drama: draminate(params[:version]), version: params[:version]}.to_json
end
get '/' do
seed = Random.new_seed
Random.srand(seed)
erb :drama, locals: {seed: seed.to_s(36), version: current_version, drama: draminate, permalink: false}
end
get '/:version/:seed' do
seed = params[:seed].to_i(36)
Random.srand(seed)
erb :drama, locals: {seed: seed.to_s(36), drama: draminate(params[:version]), version: params[:version], permalink: true}
end
get '/:legacy_seed' do
seed = params[:legacy_seed].to_i
version = '6b51081190f6f87d32aa32a52e3c273a7798cebf' # The last version to use this seed format.
Random.srand(seed)
erb :drama, locals: {seed: seed.to_s(36), drama: draminate(version), version: version, permalink: true}
end
__END__
@@drama
<!doctype html>
<html>
<head>
<title>MC Drama Generator</title>
<meta charset="utf-8">
<meta name="description" content="<%= drama %>">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="theme-color" content="#111111">
<meta property="og:title" content="MC Drama Generator">
<meta property="og:type" content="website">
<% if permalink %>
<meta property="og:url" content="http://ftb-drama.herokuapp.com/<%= version %>/<%= seed %>">
<meta property="og:description" content="<%= drama %>">
<% else %>
<meta property="og:url" content="http://ftb-drama.herokuapp.com/">
<% end %>
</head>
<body>
<style>
* {
text-align: center;
}
.drama {
font-size: 32px;
min-height: 10ex;
display: flex;
flex-direction: column;
justify-content: center;
}
body {
color: #111;
background-color: #eee;
font-family: "Roboto", "lucida grande", tahoma, verdana, arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
body {
color: #eee;
background-color: #111;
}
}
a {
color: #79C;
text-decoration: none;
}
a:visited {
color: #88B;
}
a:hover {
color: white;
}
</style>
<div class='drama'><%= drama %></div>
<a href='/'>Get more drama!</a> <br>
<a href='/<%= version %>/<%= seed %>'>Permalink</a> <br><br>
<a href='https://github.com/Gaelan/MCDrama'>GitHub</a> |
<a href='https://twitter.com/MCDramaLlama'>Twitter</a> |
<a href='https://reddit.com/r/mcdramagen'>Subreddit</a>
</body>
</html>