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