aboutsummaryrefslogtreecommitdiff
path: root/renderer
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2019-12-26 09:11:24 +0000
committerr <r@freesoftwareextremist.com>2019-12-26 09:44:05 +0000
commitac4ff88adb9a2526555757f8d4e65c69cafb3788 (patch)
tree9277e726f3c152aa72c01167744ba9465ded4cbd /renderer
parentc34bde2d52bf71ff7de7d92f659e820fe4ea315b (diff)
downloadbloat-ac4ff88adb9a2526555757f8d4e65c69cafb3788.tar.gz
bloat-ac4ff88adb9a2526555757f8d4e65c69cafb3788.zip
Add liked by and retweeted by page
Diffstat (limited to 'renderer')
-rw-r--r--renderer/model.go29
-rw-r--r--renderer/renderer.go28
2 files changed, 47 insertions, 10 deletions
diff --git a/renderer/model.go b/renderer/model.go
index 4dfac84..20d11d8 100644
--- a/renderer/model.go
+++ b/renderer/model.go
@@ -21,6 +21,19 @@ type CommonData struct {
NavbarData *NavbarData
}
+type ErrorData struct {
+ *CommonData
+ Error string
+}
+
+type HomePageData struct {
+ *CommonData
+}
+
+type SigninData struct {
+ *CommonData
+}
+
type TimelineData struct {
*CommonData
Title string
@@ -59,6 +72,20 @@ type AboutData struct {
}
type EmojiData struct {
+ *CommonData
Emojis []*mastodon.Emoji
- CommonData *CommonData
+}
+
+type LikedByData struct {
+ *CommonData
+ Users []*mastodon.Account
+ HasNext bool
+ NextLink string
+}
+
+type RetweetedByData struct {
+ *CommonData
+ Users []*mastodon.Account
+ HasNext bool
+ NextLink string
}
diff --git a/renderer/renderer.go b/renderer/renderer.go
index 48c0879..061737c 100644
--- a/renderer/renderer.go
+++ b/renderer/renderer.go
@@ -12,15 +12,17 @@ import (
)
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)
+ RenderErrorPage(ctx context.Context, writer io.Writer, data *ErrorData)
+ RenderHomePage(ctx context.Context, writer io.Writer, data *HomePageData) (err error)
+ RenderSigninPage(ctx context.Context, writer io.Writer, data *SigninData) (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)
+ RenderLikedByPage(ctx context.Context, writer io.Writer, data *LikedByData) (err error)
+ RenderRetweetedByPage(ctx context.Context, writer io.Writer, data *RetweetedByData) (err error)
}
type renderer struct {
@@ -44,17 +46,17 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
}, nil
}
-func (r *renderer) RenderErrorPage(ctx context.Context, writer io.Writer, err error) {
- r.template.ExecuteTemplate(writer, "error.tmpl", err)
+func (r *renderer) RenderErrorPage(ctx context.Context, writer io.Writer, errorData *ErrorData) {
+ r.template.ExecuteTemplate(writer, "error.tmpl", errorData)
return
}
-func (r *renderer) RenderHomePage(ctx context.Context, writer io.Writer) (err error) {
- return r.template.ExecuteTemplate(writer, "homepage.tmpl", nil)
+func (r *renderer) RenderHomePage(ctx context.Context, writer io.Writer, homePageData *HomePageData) (err error) {
+ return r.template.ExecuteTemplate(writer, "homepage.tmpl", homePageData)
}
-func (r *renderer) RenderSigninPage(ctx context.Context, writer io.Writer) (err error) {
- return r.template.ExecuteTemplate(writer, "signin.tmpl", nil)
+func (r *renderer) RenderSigninPage(ctx context.Context, writer io.Writer, signinData *SigninData) (err error) {
+ return r.template.ExecuteTemplate(writer, "signin.tmpl", signinData)
}
func (r *renderer) RenderTimelinePage(ctx context.Context, writer io.Writer, data *TimelineData) (err error) {
@@ -81,6 +83,14 @@ func (r *renderer) RenderEmojiPage(ctx context.Context, writer io.Writer, data *
return r.template.ExecuteTemplate(writer, "emoji.tmpl", data)
}
+func (r *renderer) RenderLikedByPage(ctx context.Context, writer io.Writer, data *LikedByData) (err error) {
+ return r.template.ExecuteTemplate(writer, "likedby.tmpl", data)
+}
+
+func (r *renderer) RenderRetweetedByPage(ctx context.Context, writer io.Writer, data *RetweetedByData) (err error) {
+ return r.template.ExecuteTemplate(writer, "retweetedby.tmpl", data)
+}
+
func EmojiFilter(content string, emojis []mastodon.Emoji) string {
var replacements []string
for _, e := range emojis {