51 lines
908 B
Go
51 lines
908 B
Go
package templates
|
|
|
|
import (
|
|
"html/template"
|
|
|
|
"github.com/Teajey/hmc"
|
|
)
|
|
|
|
type AccountLink struct {
|
|
Alert bool
|
|
}
|
|
|
|
type CopyList struct {
|
|
Domain string
|
|
Reference string
|
|
}
|
|
|
|
type User struct {
|
|
Name string
|
|
CopyList *CopyList
|
|
}
|
|
|
|
type NavCollapse struct {
|
|
User *User `json:",omitempty"`
|
|
AccountLink *AccountLink `json:",omitempty"`
|
|
Links []hmc.Link
|
|
}
|
|
|
|
func DefaultNavCollapse() NavCollapse {
|
|
return NavCollapse{Links: []hmc.Link{{Href: "/", Label: "Home"}}}
|
|
}
|
|
|
|
func UserNavCollapse(username string, accountAlert bool) NavCollapse {
|
|
return NavCollapse{
|
|
Links: []hmc.Link{{Href: "/", Label: "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
|
|
}
|