this repo has no description
1package pages 2 3import ( 4 "embed" 5 "html/template" 6 "io" 7 "sync" 8 9 "github.com/sotangled/tangled/appview/auth" 10 "github.com/sotangled/tangled/appview/db" 11) 12 13//go:embed *.html 14var files embed.FS 15 16var ( 17 cache = make(map[string]*template.Template) 18 mutex sync.Mutex 19) 20 21func parse(file string) *template.Template { 22 mutex.Lock() 23 defer mutex.Unlock() 24 25 if tmpl, found := cache[file]; found { 26 return tmpl 27 } 28 29 tmpl := template.Must( 30 template.New("layout.html").ParseFS(files, "layout.html", file), 31 ) 32 33 cache[file] = tmpl 34 return tmpl 35} 36 37type LoginParams struct { 38} 39 40func Login(w io.Writer, p LoginParams) error { 41 return parse("login.html").Execute(w, p) 42} 43 44type TimelineParams struct { 45 User *auth.User 46} 47 48func Timeline(w io.Writer, p TimelineParams) error { 49 return parse("timeline.html").Execute(w, p) 50} 51 52type SettingsParams struct { 53 User *auth.User 54 PubKeys []db.PublicKey 55} 56 57func Settings(w io.Writer, p SettingsParams) error { 58 return parse("settings.html").Execute(w, p) 59}