Mercurial Hosting > disearch
diff src/lib/Shared.luan @ 4:8896ffd7b152
start login
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 22 Oct 2023 23:53:59 -0600 |
parents | 5ae5fbce0d75 |
children | aa1920665f98 |
line wrap: on
line diff
--- a/src/lib/Shared.luan Sat Oct 21 22:52:41 2023 -0600 +++ b/src/lib/Shared.luan Sun Oct 22 23:53:59 2023 -0600 @@ -1,18 +1,25 @@ local Luan = require "luan:Luan.luan" local error = Luan.error local Time = require "luan:Time.luan" +local Http = require "luan:http/Http.luan" local Shared = {} local started = Time.now() +local function get_user() + return Http.request.cookies.user +end +Shared.get_user = get_user + function Shared.head() %> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> @import "/site.css?s=<%=started%>"; </style> + <script src="/site.js?s=<%=started%>"></script> <% end @@ -20,7 +27,11 @@ %> <div header> <h1><a href="/">Disearch</a></h1> - <span>login</span> +<% if get_user() == nil then %> + <a href="login.red">login</a> +<% else %> + <a href="javascript:logout()">logout</a> +<% end %> </div> <hr> <%