aboutsummaryrefslogtreecommitdiff
path: root/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'renderer')
-rw-r--r--renderer/model.go88
-rw-r--r--renderer/renderer.go24
2 files changed, 25 insertions, 87 deletions
diff --git a/renderer/model.go b/renderer/model.go
index be777f6..dfa46b1 100644
--- a/renderer/model.go
+++ b/renderer/model.go
@@ -5,19 +5,12 @@ import (
"web/model"
)
-type NavbarTemplateData struct {
+type NavbarData struct {
User *mastodon.Account
NotificationCount int
}
-func NewNavbarTemplateData(notificationCount int, user *mastodon.Account) *NavbarTemplateData {
- return &NavbarTemplateData{
- NotificationCount: notificationCount,
- User: user,
- }
-}
-
-type TimelinePageTemplateData struct {
+type TimelineData struct {
Title string
Statuses []*mastodon.Status
HasNext bool
@@ -25,91 +18,36 @@ type TimelinePageTemplateData struct {
HasPrev bool
PrevLink string
PostContext model.PostContext
- NavbarData *NavbarTemplateData
-}
-
-func NewTimelinePageTemplateData(title string, statuses []*mastodon.Status, hasNext bool, nextLink string, hasPrev bool,
- prevLink string, postContext model.PostContext, navbarData *NavbarTemplateData) *TimelinePageTemplateData {
- return &TimelinePageTemplateData{
- Title: title,
- Statuses: statuses,
- HasNext: hasNext,
- NextLink: nextLink,
- HasPrev: hasPrev,
- PrevLink: prevLink,
- PostContext: postContext,
- NavbarData: navbarData,
- }
+ NavbarData *NavbarData
}
-type ThreadPageTemplateData struct {
+type ThreadData struct {
Statuses []*mastodon.Status
PostContext model.PostContext
ReplyMap map[string][]mastodon.ReplyInfo
- NavbarData *NavbarTemplateData
+ NavbarData *NavbarData
}
-func NewThreadPageTemplateData(statuses []*mastodon.Status, postContext model.PostContext, replyMap map[string][]mastodon.ReplyInfo, navbarData *NavbarTemplateData) *ThreadPageTemplateData {
- return &ThreadPageTemplateData{
- Statuses: statuses,
- PostContext: postContext,
- ReplyMap: replyMap,
- NavbarData: navbarData,
- }
-}
-
-type NotificationPageTemplateData struct {
+type NotificationData 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,
- }
+ NavbarData *NavbarData
}
-type UserPageTemplateData struct {
+type UserData struct {
User *mastodon.Account
Statuses []*mastodon.Status
HasNext bool
NextLink string
- NavbarData *NavbarTemplateData
-}
-
-func NewUserPageTemplateData(user *mastodon.Account, statuses []*mastodon.Status, hasNext bool, nextLink string, navbarData *NavbarTemplateData) *UserPageTemplateData {
- return &UserPageTemplateData{
- User: user,
- Statuses: statuses,
- HasNext: hasNext,
- NextLink: nextLink,
- NavbarData: navbarData,
- }
+ NavbarData *NavbarData
}
-type AboutPageTemplateData struct {
- NavbarData *NavbarTemplateData
+type AboutData struct {
+ NavbarData *NavbarData
}
-func NewAboutPageTemplateData(navbarData *NavbarTemplateData) *AboutPageTemplateData {
- return &AboutPageTemplateData{
- NavbarData: navbarData,
- }
-}
-
-type EmojiPageTemplateData struct {
- NavbarData *NavbarTemplateData
+type EmojiData struct {
Emojis []*mastodon.Emoji
-}
-
-func NewEmojiPageTemplateData(navbarData *NavbarTemplateData, emojis []*mastodon.Emoji) *EmojiPageTemplateData {
- return &EmojiPageTemplateData{
- NavbarData: navbarData,
- Emojis: emojis,
- }
+ NavbarData *NavbarData
}
diff --git a/renderer/renderer.go b/renderer/renderer.go
index 4415b0b..48c0879 100644
--- a/renderer/renderer.go
+++ b/renderer/renderer.go
@@ -15,12 +15,12 @@ type Renderer interface {
RenderErrorPage(ctx context.Context, writer io.Writer, err error)
RenderHomePage(ctx context.Context, writer io.Writer) (err error)
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)
- RenderUserPage(ctx context.Context, writer io.Writer, data *UserPageTemplateData) (err error)
- RenderAboutPage(ctx context.Context, writer io.Writer, data *AboutPageTemplateData) (err error)
- RenderEmojiPage(ctx context.Context, writer io.Writer, data *EmojiPageTemplateData) (err error)
+ RenderTimelinePage(ctx context.Context, writer io.Writer, data *TimelineData) (err error)
+ RenderThreadPage(ctx context.Context, writer io.Writer, data *ThreadData) (err error)
+ RenderNotificationPage(ctx context.Context, writer io.Writer, data *NotificationData) (err error)
+ RenderUserPage(ctx context.Context, writer io.Writer, data *UserData) (err error)
+ RenderAboutPage(ctx context.Context, writer io.Writer, data *AboutData) (err error)
+ RenderEmojiPage(ctx context.Context, writer io.Writer, data *EmojiData) (err error)
}
type renderer struct {
@@ -57,27 +57,27 @@ func (r *renderer) RenderSigninPage(ctx context.Context, writer io.Writer) (err
return r.template.ExecuteTemplate(writer, "signin.tmpl", nil)
}
-func (r *renderer) RenderTimelinePage(ctx context.Context, writer io.Writer, data *TimelinePageTemplateData) (err error) {
+func (r *renderer) RenderTimelinePage(ctx context.Context, writer io.Writer, data *TimelineData) (err error) {
return r.template.ExecuteTemplate(writer, "timeline.tmpl", data)
}
-func (r *renderer) RenderThreadPage(ctx context.Context, writer io.Writer, data *ThreadPageTemplateData) (err error) {
+func (r *renderer) RenderThreadPage(ctx context.Context, writer io.Writer, data *ThreadData) (err error) {
return r.template.ExecuteTemplate(writer, "thread.tmpl", data)
}
-func (r *renderer) RenderNotificationPage(ctx context.Context, writer io.Writer, data *NotificationPageTemplateData) (err error) {
+func (r *renderer) RenderNotificationPage(ctx context.Context, writer io.Writer, data *NotificationData) (err error) {
return r.template.ExecuteTemplate(writer, "notification.tmpl", data)
}
-func (r *renderer) RenderUserPage(ctx context.Context, writer io.Writer, data *UserPageTemplateData) (err error) {
+func (r *renderer) RenderUserPage(ctx context.Context, writer io.Writer, data *UserData) (err error) {
return r.template.ExecuteTemplate(writer, "user.tmpl", data)
}
-func (r *renderer) RenderAboutPage(ctx context.Context, writer io.Writer, data *AboutPageTemplateData) (err error) {
+func (r *renderer) RenderAboutPage(ctx context.Context, writer io.Writer, data *AboutData) (err error) {
return r.template.ExecuteTemplate(writer, "about.tmpl", data)
}
-func (r *renderer) RenderEmojiPage(ctx context.Context, writer io.Writer, data *EmojiPageTemplateData) (err error) {
+func (r *renderer) RenderEmojiPage(ctx context.Context, writer io.Writer, data *EmojiData) (err error) {
return r.template.ExecuteTemplate(writer, "emoji.tmpl", data)
}