This repository was archived by the owner on Aug 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexternal.cr
More file actions
91 lines (80 loc) · 2.2 KB
/
external.cr
File metadata and controls
91 lines (80 loc) · 2.2 KB
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
require "runcobo"
class StackCoin::Api::External
def self.run!
Runcobo.start
end
end
class StackCoin::Api::External::Auth < BaseAction
get "/auth"
query NamedTuple(one_time_key: String?)
call do |context|
if one_time_key = params[:one_time_key]
result = Core::SessionStore.upgrade_one_time_to_real_session(one_time_key)
if result.is_a?(Core::SessionStore::Result::NewSession)
cookie = Core::SessionStore::Session.to_cookie(result.new_session_id)
context.response.cookies << cookie
context = render_plain("redirecting")
context.response.status_code = 303
context.response.headers["Location"] = "/"
context
else
render_plain(result.message)
end
else
render_plain("~") # TODO maybe redirect to login?
end
end
end
class StackCoin::Api::External::Default < BaseAction
get "/"
get "/*"
call do |context|
context = render_plain(<<-HTML
<html>
<head>
<link rel="preconnect" href="https://rsms.me/">
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
<style>
:root {
font-family: Inter, sans-serif;
font-feature-settings: 'liga' 1, 'calt' 1;
}
@supports (font-variation-settings: normal) {
:root { font-family: InterVariable, sans-serif; }
}
body {
margin: 2rem;
font-size: 1.4rem;
}
.no-func {
color: gray;
font-style: italic;
}
img {
width: 30rem;
max-width: 100%;
}
main {
max-width: 40rem;
margin: 0 auto;
}
</style>
</head>
<body>
<a href="/">
<p align="center">
<img src="https://i.imgur.com/ou12BG6.png">
</p>
</a>
<main>
<p>stackcoin</p>
<p class="no-func">this website has no functionality, at the moment</p>
</main>
</body>
</html>
HTML
)
context.response.content_type = "text/html"
context
end
end