mirror of
https://gitea.phreedom.club/localhost_frssoft/bloat.git
synced 2025-05-01 09:34:21 +00:00
Add notification support
This commit is contained in:
parent
51a4b16af5
commit
f68d72ae0e
13 changed files with 271 additions and 29 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue