diff src/lib/Shared.luan @ 3:fc3ee39d7764

login
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 19 Jun 2022 20:47:31 -0600
parents 6a1e2749571d
children a17e400ddaa1
line wrap: on
line diff
--- a/src/lib/Shared.luan	Thu Jun 16 20:52:24 2022 -0600
+++ b/src/lib/Shared.luan	Sun Jun 19 20:47:31 2022 -0600
@@ -1,6 +1,10 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
+local Http = require "luan:http/Http.luan"
 local Forum = require "site:/lib/Forum.luan"
+local User = require "site:/lib/User.luan"
+local Logging = require "luan:logging/Logging.luan"
+local logger = Logging.logger "Shared"
 
 
 local Shared = {}
@@ -15,9 +19,16 @@
 end
 
 function Shared.header()
+	local user = User.current()
 %>
 		<div header>
 			<a href="/"><%=Forum.title%></a>
+			-
+<%	if user == nil then %>
+			<a href="/login.html">login</a>
+<%	else %>
+			<a href="/account.html"><%=user.name_html%></a>
+<%	end %>
 		</div>
 <%
 end
@@ -30,4 +41,8 @@
 <%
 end
 
+function Shared.base_url()
+	return Http.request.scheme.."://"..Http.request.headers["host"]
+end
+
 return Shared