//go:generate tmpl bind ./... package main import ( _ "embed" "html/template" "github.com/nbd-wtf/go-nostr" "github.com/tylermmorton/tmpl" ) type TemplateID int const ( Profile TemplateID = iota Note LongForm TelegramInstantView Other ) var ( //go:embed templates/head_common.html tmplHeadCommon string HeadCommonTemplate = tmpl.MustCompile(&HeadCommonPartial{}) ) //tmpl:bind head_common.html type HeadCommonPartial struct { IsProfile bool } func (*HeadCommonPartial) TemplateText() string { return tmplHeadCommon } var ( //go:embed templates/top.html tmplTop string TopTemplate = tmpl.MustCompile(&TopPartial{}) ) //tmpl:bind top.html type TopPartial struct{} func (*TopPartial) TemplateText() string { return tmplTop } var ( //go:embed templates/details.html tmplDetails string DetailsTemplate = tmpl.MustCompile(&DetailsPartial{}) ) //tmpl:bind details.html type DetailsPartial struct { HideDetails bool CreatedAt string EventJSON string Nevent string Kind int KindNIP string KindDescription string } func (*DetailsPartial) TemplateText() string { return tmplDetails } var ( //go:embed templates/clients.html tmplClients string ClientsTemplate = tmpl.MustCompile(&ClientsPartial{}) ) //tmpl:bind clients.html type ClientsPartial struct { Clients []ClientReference } func (*ClientsPartial) TemplateText() string { return tmplClients } var ( //go:embed templates/footer.html tmplFooter string FooterTemplate = tmpl.MustCompile(&FooterPartial{}) ) //tmpl:bind footer.html type FooterPartial struct{} func (*FooterPartial) TemplateText() string { return tmplFooter } var ( //go:embed templates/telegram_instant_view.html tmplTelegramInstantView string TelegramInstantViewTemplate = tmpl.MustCompile(&TelegramInstantViewPage{}) ) type TelegramInstantViewPage struct { Video string VideoType string Image string Summary template.HTML Content template.HTML Description string Subject string Metadata nostr.ProfileMetadata AuthorLong string CreatedAt string } func (*TelegramInstantViewPage) TemplateText() string { return tmplTelegramInstantView } var ( //go:embed templates/homepage.html tmplHomePage string HomePageTemplate = tmpl.MustCompile(&HomePage{}) ) type HomePage struct { HeadCommonPartial `tmpl:"head_common"` TopPartial `tmpl:"top"` FooterPartial `tmpl:"footer"` Host string Npubs []string LastNotes []string } func (*HomePage) TemplateText() string { return tmplHomePage } var ( //go:embed templates/archive.html tmplArchive string ArchiveTemplate = tmpl.MustCompile(&ArchivePage{}) ) type ArchivePage struct { HeadCommonPartial `tmpl:"head_common"` TopPartial `tmpl:"top"` FooterPartial `tmpl:"footer"` Title string PathPrefix string Data []string ModifiedAt string PaginationUrl string NextPage string PrevPage string } func (*ArchivePage) TemplateText() string { return tmplArchive } var ( //go:embed templates/other.html tmplOther string OtherTemplate = tmpl.MustCompile(&OtherPage{}) ) type OtherPage struct { HeadCommonPartial `tmpl:"head_common"` TopPartial `tmpl:"top"` DetailsPartial `tmpl:"details"` FooterPartial `tmpl:"footer"` IsParameterizedReplaceable bool Naddr string Npub string Kind int KindDescription string } func (*OtherPage) TemplateText() string { return tmplOther } var ( //go:embed templates/note.html tmplNote string NoteTemplate = tmpl.MustCompile(&NotePage{}) ) type NotePage struct { HeadCommonPartial `tmpl:"head_common"` TopPartial `tmpl:"top"` DetailsPartial `tmpl:"details"` ClientsPartial `tmpl:"clients"` FooterPartial `tmpl:"footer"` AuthorLong string Content template.HTML CreatedAt string Description string Image string Metadata nostr.ProfileMetadata Nevent string Npub string NpubShort string Oembed string ParentLink template.HTML Proxy string SeenOn []string Style string Subject string TextImageURL string Title string TitleizedContent string TwitterTitle string Video string VideoType string } func (*NotePage) TemplateText() string { return tmplNote } var ( //go:embed templates/profile.html tmplProfile string ProfileTemplate = tmpl.MustCompile(&ProfilePage{}) ) type ProfilePage struct { HeadCommonPartial `tmpl:"head_common"` TopPartial `tmpl:"top"` DetailsPartial `tmpl:"details"` ClientsPartial `tmpl:"clients"` FooterPartial `tmpl:"footer"` AuthorRelays []string Content string CreatedAt string Domain string LastNotes []LastNotesItem Metadata nostr.ProfileMetadata NormalizedAuthorWebsiteURL string RenderedAuthorAboutText template.HTML Nevent string Npub string IsReply string Proxy string Title string } func (*ProfilePage) TemplateText() string { return tmplProfile }