50 lines
868 B
Go
50 lines
868 B
Go
package templates
|
|
|
|
import (
|
|
"html/template"
|
|
"lishwist/http/props/htmlx"
|
|
)
|
|
|
|
type AccountLink struct {
|
|
Alert bool
|
|
}
|
|
|
|
type CopyList struct {
|
|
Domain string
|
|
Reference string
|
|
}
|
|
|
|
type User struct {
|
|
Name string
|
|
CopyList *CopyList
|
|
}
|
|
|
|
type NavCollapse struct {
|
|
User *User
|
|
AccountLink *AccountLink
|
|
Links []htmlx.Link
|
|
}
|
|
|
|
func DefaultNavCollapse() NavCollapse {
|
|
return NavCollapse{Links: []htmlx.Link{{Href: "/", Name: "Home"}}}
|
|
}
|
|
|
|
func UserNavCollapse(username string, accountAlert bool) NavCollapse {
|
|
return NavCollapse{
|
|
Links: []htmlx.Link{{Href: "/", Name: "Home"}},
|
|
User: &User{Name: username},
|
|
AccountLink: &AccountLink{Alert: accountAlert},
|
|
}
|
|
}
|
|
|
|
var Template *template.Template
|
|
|
|
func init() {
|
|
Template = load()
|
|
}
|
|
|
|
func load() *template.Template {
|
|
t := template.Must(template.ParseGlob("templates/*.gotmpl"))
|
|
return t
|
|
}
|