1
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local Time = require "luan:Time.luan"
|
4
|
4 local Http = require "luan:http/Http.luan"
|
1
|
5
|
|
6
|
|
7 local Shared = {}
|
|
8
|
|
9 local started = Time.now()
|
|
10
|
4
|
11 local function get_user()
|
|
12 return Http.request.cookies.user
|
|
13 end
|
|
14 Shared.get_user = get_user
|
|
15
|
1
|
16 function Shared.head()
|
|
17 %>
|
|
18 <meta name="viewport" content="width=device-width, initial-scale=1">
|
|
19 <style>
|
|
20 @import "/site.css?s=<%=started%>";
|
|
21 </style>
|
4
|
22 <script src="/site.js?s=<%=started%>"></script>
|
1
|
23 <%
|
|
24 end
|
|
25
|
|
26 function Shared.header()
|
|
27 %>
|
|
28 <div header>
|
2
|
29 <h1><a href="/">Disearch</a></h1>
|
4
|
30 <% if get_user() == nil then %>
|
5
|
31 <a href="login1.red">login</a>
|
4
|
32 <% else %>
|
9
|
33 <span right pulldown>
|
|
34 <script>document.write(`<img src="https://cdn.discordapp.com/avatars/${localStorage.user_id}/${localStorage.user_avatar}.png" onclick="clickMenu(this)">`)</script>
|
|
35 <div pulldown_menu>
|
|
36 <span username><script>document.write(localStorage.user_name)</script></span>
|
11
|
37 <a href="/servers.html">Your Servers</a>
|
9
|
38 <a href="javascript:logout()">Log out</a>
|
|
39 </div>
|
|
40 </span>
|
4
|
41 <% end %>
|
1
|
42 </div>
|
|
43 <hr>
|
|
44 <%
|
|
45 end
|
|
46
|
|
47 function Shared.footer()
|
|
48 %>
|
|
49 <hr>
|
|
50 <div footer>
|
|
51 something or other in the footer
|
|
52 </div>
|
|
53 <%
|
|
54 end
|
|
55
|
6
|
56 function Shared.discord_redirect_uri()
|
|
57 local request = Http.request
|
8
|
58 return request.scheme.."://"..request.headers["Host"].."/login2.html"
|
6
|
59 end
|
|
60
|
1
|
61 return Shared
|