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} 60 61type KnotsParams struct { 62 User *auth.User 63 Registrations []db.Registration 64} 65 66func Knots(w io.Writer, p KnotsParams) error { 67 return parse("knots.html").Execute(w, p) 68} 69 70type KnotParams struct { 71 User *auth.User 72 Registration *db.Registration 73 Members []string 74 IsOwner bool 75} 76 77func Knot(w io.Writer, p KnotParams) error { 78 return parse("knot.html").Execute(w, p) 79} 80 81type NewRepoParams struct { 82 User *auth.User 83} 84 85func NewRepo(w io.Writer, p NewRepoParams) error { 86 return parse("new-repo.html").Execute(w, p) 87}