24 lines
913 B
Go
24 lines
913 B
Go
package components
|
|
|
|
import (
|
|
"dk/internal/auth"
|
|
"dk/internal/csrf"
|
|
"dk/internal/router"
|
|
"fmt"
|
|
)
|
|
|
|
// GenerateTopNav generates the top navigation HTML based on authentication status
|
|
func GenerateTopNav(ctx router.Ctx) string {
|
|
if auth.IsAuthenticated(ctx) {
|
|
return fmt.Sprintf(`<form action="/logout" method="post" class="logout">
|
|
%s
|
|
<button class="img-button" type="submit"><img src="/assets/images/button_logout.gif" alt="Log Out" title="Log Out"></button>
|
|
</form>
|
|
<a href="/help"><img src="/assets/images/button_help.gif" alt="Help" title="Help"></a>`, csrf.HiddenField(ctx))
|
|
} else {
|
|
return `<a href="/login"><img src="/assets/images/button_login.gif" alt="Log In" title="Log In"></a>
|
|
<a href="/register"><img src="/assets/images/button_register.gif" alt="Register" title="Register"></a>
|
|
<a href="/help"><img src="/assets/images/button_help.gif" alt="Help" title="Help"></a>`
|
|
}
|
|
}
|