annotate src/lib/Shared.luan @ 5:aa1920665f98

discord login
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 23 Oct 2023 00:43:41 -0600
parents 8896ffd7b152
children d59ae3e468f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Time = require "luan:Time.luan"
4
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
4 local Http = require "luan:http/Http.luan"
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Shared = {}
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local started = Time.now()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
4
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
11 local function get_user()
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
12 return Http.request.cookies.user
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
13 end
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
14 Shared.get_user = get_user
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
15
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 function Shared.head()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 <meta name="viewport" content="width=device-width, initial-scale=1">
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 <style>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 @import "/site.css?s=<%=started%>";
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 </style>
4
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
22 <script src="/site.js?s=<%=started%>"></script>
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 <%
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 end
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 function Shared.header()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 <div header>
2
5ae5fbce0d75 start header
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
29 <h1><a href="/">Disearch</a></h1>
4
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
30 <% if get_user() == nil then %>
5
aa1920665f98 discord login
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
31 <a href="login1.red">login</a>
4
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
32 <% else %>
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
33 <a href="javascript:logout()">logout</a>
8896ffd7b152 start login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
34 <% end %>
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 </div>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 <hr>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 <%
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 end
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 function Shared.footer()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 <hr>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 <div footer>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 something or other in the footer
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 </div>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 <%
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 end
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 return Shared