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