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>
|
|
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
|
1
|
60 return Shared
|