Add a logout button
Add a button that only shows when users are logged in, allowing them to log out.
This commit is contained in:
parent
4e0a23ee95
commit
6398e97498
|
@ -43,7 +43,7 @@ local function get_site_home(req, loggedin)
|
||||||
loggedin = loggedin
|
loggedin = loggedin
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
local function get_author_home(req)
|
local function get_author_home(req, loggedin)
|
||||||
--print("Looking at author home...")
|
--print("Looking at author home...")
|
||||||
local host = http_request_get_host(req)
|
local host = http_request_get_host(req)
|
||||||
local subdomain = host:match("([^\\.]+)")
|
local subdomain = host:match("([^\\.]+)")
|
||||||
|
@ -120,11 +120,11 @@ local function index_get(req)
|
||||||
--author home page
|
--author home page
|
||||||
local cachepath = string.format("%s.%s",subdomain,config.domain)
|
local cachepath = string.format("%s.%s",subdomain,config.domain)
|
||||||
text = cache.render(cachepath, function()
|
text = cache.render(cachepath, function()
|
||||||
return get_author_home(req)
|
return get_author_home(req, author ~= nil)
|
||||||
end)
|
end)
|
||||||
elseif host ~= config.domain and author == subdomain then
|
elseif host ~= config.domain and author == subdomain then
|
||||||
--author's home page for the author, don't cache, display unlisted
|
--author's home page for the author, don't cache, display unlisted
|
||||||
text = get_author_home(req)
|
text = get_author_home(req, author ~= nil)
|
||||||
end
|
end
|
||||||
assert(text)
|
assert(text)
|
||||||
http_response(req,200,text)
|
http_response(req,200,text)
|
||||||
|
|
|
@ -5,7 +5,19 @@
|
||||||
<a href="https://<%= author %>.<%= domain %>"><%= author %></a>.<a href="https://<%= domain %>"><%= domain %></a>
|
<a href="https://<%= author %>.<%= domain %>"><%= author %></a>.<a href="https://<%= domain %>"><%= domain %></a>
|
||||||
</h1>
|
</h1>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a href="/_paste" class="button">New paste</a>
|
<div class="row">
|
||||||
|
<a href="/_paste" class="button column column-0">New paste</a>
|
||||||
|
<% if not loggedin then %>
|
||||||
|
<a href="/_login" class="button column column-0">Log in</a>
|
||||||
|
<% else %>
|
||||||
|
<a href="/_logout" class="button column column-0">Log out</a>
|
||||||
|
<% end %>
|
||||||
|
<span class="column column-0"></span>
|
||||||
|
<form action="https://<%= domain %>/_search" method="get" class="search column row">
|
||||||
|
<input class="column" type="text" name="q" placeholder="+greentext -dotr +hits>20"/>
|
||||||
|
<input class="column column-0 button button-clear" type="submit" value="🔎"/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<%= bio %>
|
<%= bio %>
|
||||||
|
|
|
@ -8,12 +8,13 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a href="/_paste" class="button column column-0">New paste</a>
|
<a href="/_paste" class="button column column-0">New paste</a>
|
||||||
<% if loggedin then %>
|
<% if not loggedin then %>
|
||||||
<a href="/_login" class="button column column-0">Log in</a>
|
<a href="/_login" class="button column column-0">Log in</a>
|
||||||
|
<a href="/_claim" class="button column column-0">Register</a>
|
||||||
<% else %>
|
<% else %>
|
||||||
<a href="/_logout" class="button column column-0">Log out</a>
|
<a href="/_logout" class="button column column-0">Log out</a>
|
||||||
|
<span class="column column-0"></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="/_claim" class="button column column-0">Register</a>
|
|
||||||
<form action="https://<%= domain %>/_search" method="get" class="search column row">
|
<form action="https://<%= domain %>/_search" method="get" class="search column row">
|
||||||
<input class="column" type="text" name="q" placeholder="+greentext -dotr +hits>20"/>
|
<input class="column" type="text" name="q" placeholder="+greentext -dotr +hits>20"/>
|
||||||
<input class="column column-0 button button-clear" type="submit" value="🔎"/>
|
<input class="column column-0 button button-clear" type="submit" value="🔎"/>
|
||||||
|
|
Loading…
Reference in New Issue