diff options
Diffstat (limited to 'renderer')
-rw-r--r-- | renderer/model.go | 54 | ||||
-rw-r--r-- | renderer/renderer.go | 5 |
2 files changed, 47 insertions, 12 deletions
diff --git a/renderer/model.go b/renderer/model.go index 6f6acc4..4529386 100644 --- a/renderer/model.go +++ b/renderer/model.go @@ -4,22 +4,34 @@ import ( "mastodon" ) +type NavbarTemplateData struct { + NotificationCount int +} + +func NewNavbarTemplateData(notificationCount int) *NavbarTemplateData { + return &NavbarTemplateData{ + NotificationCount: notificationCount, + } +} + type TimelinePageTemplateData struct { - Statuses []*mastodon.Status - HasNext bool - NextLink string - HasPrev bool - PrevLink string + Statuses []*mastodon.Status + HasNext bool + NextLink string + HasPrev bool + PrevLink string + NavbarData *NavbarTemplateData } func NewTimelinePageTemplateData(statuses []*mastodon.Status, hasNext bool, nextLink string, hasPrev bool, - prevLink string) *TimelinePageTemplateData { + prevLink string, navbarData *NavbarTemplateData) *TimelinePageTemplateData { return &TimelinePageTemplateData{ - Statuses: statuses, - HasNext: hasNext, - NextLink: nextLink, - HasPrev: hasPrev, - PrevLink: prevLink, + Statuses: statuses, + HasNext: hasNext, + NextLink: nextLink, + HasPrev: hasPrev, + PrevLink: prevLink, + NavbarData: navbarData, } } @@ -29,14 +41,32 @@ type ThreadPageTemplateData struct { PostReply bool ReplyToID string ReplyContent string + NavbarData *NavbarTemplateData } -func NewThreadPageTemplateData(status *mastodon.Status, context *mastodon.Context, postReply bool, replyToID string, replyContent string) *ThreadPageTemplateData { +func NewThreadPageTemplateData(status *mastodon.Status, context *mastodon.Context, postReply bool, replyToID string, replyContent string, navbarData *NavbarTemplateData) *ThreadPageTemplateData { return &ThreadPageTemplateData{ Status: status, Context: context, PostReply: postReply, ReplyToID: replyToID, ReplyContent: replyContent, + NavbarData: navbarData, + } +} + +type NotificationPageTemplateData struct { + Notifications []*mastodon.Notification + HasNext bool + NextLink string + NavbarData *NavbarTemplateData +} + +func NewNotificationPageTemplateData(notifications []*mastodon.Notification, hasNext bool, nextLink string, navbarData *NavbarTemplateData) *NotificationPageTemplateData { + return &NotificationPageTemplateData{ + Notifications: notifications, + HasNext: hasNext, + NextLink: nextLink, + NavbarData: navbarData, } } diff --git a/renderer/renderer.go b/renderer/renderer.go index c3d3526..394d74f 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -17,6 +17,7 @@ type Renderer interface { RenderSigninPage(ctx context.Context, writer io.Writer) (err error) RenderTimelinePage(ctx context.Context, writer io.Writer, data *TimelinePageTemplateData) (err error) RenderThreadPage(ctx context.Context, writer io.Writer, data *ThreadPageTemplateData) (err error) + RenderNotificationPage(ctx context.Context, writer io.Writer, data *NotificationPageTemplateData) (err error) } type renderer struct { @@ -60,6 +61,10 @@ func (r *renderer) RenderThreadPage(ctx context.Context, writer io.Writer, data return r.template.ExecuteTemplate(writer, "thread.tmpl", data) } +func (r *renderer) RenderNotificationPage(ctx context.Context, writer io.Writer, data *NotificationPageTemplateData) (err error) { + return r.template.ExecuteTemplate(writer, "notification.tmpl", data) +} + func WithEmojis(content string, emojis []mastodon.Emoji) string { var emojiNameContentPair []string for _, e := range emojis { |