mirror of
https://git.freesoftwareextremist.com/bloat
synced 2024-12-22 09:10:42 +00:00
Refactor renderer and templates
This commit is contained in:
parent
3c6653a77b
commit
55987a4c1b
27 changed files with 262 additions and 242 deletions
|
@ -54,10 +54,7 @@ type Status struct {
|
|||
ShowReplies bool `json:"show_replies"`
|
||||
ReplyMap map[string][]ReplyInfo `json:"reply_map"`
|
||||
ReplyNumber int `json:"reply_number"`
|
||||
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
||||
MaskNSFW bool `json:"mask_nsfw"`
|
||||
RetweetedByID string `json:"retweeted_by_id"`
|
||||
DarkMode bool `json:"dark_mode"`
|
||||
}
|
||||
|
||||
// Context hold information for mastodon context.
|
||||
|
|
|
@ -5,12 +5,17 @@ import (
|
|||
"mastodon"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
MaskNSFW bool
|
||||
FluorideMode bool
|
||||
ThreadInNewTab bool
|
||||
DarkMode bool
|
||||
}
|
||||
|
||||
type HeaderData struct {
|
||||
Title string
|
||||
NotificationCount int
|
||||
CustomCSS string
|
||||
FluorideMode bool
|
||||
DarkMode bool
|
||||
}
|
||||
|
||||
type NavbarData struct {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package renderer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -44,22 +43,26 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
type TemplateData struct {
|
||||
Data interface{}
|
||||
Ctx *Context
|
||||
}
|
||||
|
||||
type Renderer interface {
|
||||
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)
|
||||
RenderFollowingPage(ctx context.Context, writer io.Writer, data *FollowingData) (err error)
|
||||
RenderFollowersPage(ctx context.Context, writer io.Writer, data *FollowersData) (err error)
|
||||
RenderSearchPage(ctx context.Context, writer io.Writer, data *SearchData) (err error)
|
||||
RenderSettingsPage(ctx context.Context, writer io.Writer, data *SettingsData) (err error)
|
||||
RenderSigninPage(ctx *Context, writer io.Writer, data *SigninData) (err error)
|
||||
RenderErrorPage(ctx *Context, writer io.Writer, data *ErrorData)
|
||||
RenderTimelinePage(ctx *Context, writer io.Writer, data *TimelineData) (err error)
|
||||
RenderThreadPage(ctx *Context, writer io.Writer, data *ThreadData) (err error)
|
||||
RenderNotificationPage(ctx *Context, writer io.Writer, data *NotificationData) (err error)
|
||||
RenderUserPage(ctx *Context, writer io.Writer, data *UserData) (err error)
|
||||
RenderAboutPage(ctx *Context, writer io.Writer, data *AboutData) (err error)
|
||||
RenderEmojiPage(ctx *Context, writer io.Writer, data *EmojiData) (err error)
|
||||
RenderLikedByPage(ctx *Context, writer io.Writer, data *LikedByData) (err error)
|
||||
RenderRetweetedByPage(ctx *Context, writer io.Writer, data *RetweetedByData) (err error)
|
||||
RenderFollowingPage(ctx *Context, writer io.Writer, data *FollowingData) (err error)
|
||||
RenderFollowersPage(ctx *Context, writer io.Writer, data *FollowersData) (err error)
|
||||
RenderSearchPage(ctx *Context, writer io.Writer, data *SearchData) (err error)
|
||||
RenderSettingsPage(ctx *Context, writer io.Writer, data *SettingsData) (err error)
|
||||
}
|
||||
|
||||
type renderer struct {
|
||||
|
@ -76,6 +79,7 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
|
|||
"FormatTimeRFC3339": FormatTimeRFC3339,
|
||||
"FormatTimeRFC822": FormatTimeRFC822,
|
||||
"GetIcon": GetIcon,
|
||||
"WithContext": WithContext,
|
||||
}).ParseGlob(templateGlobPattern)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -85,65 +89,61 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (r *renderer) RenderErrorPage(ctx context.Context, writer io.Writer, errorData *ErrorData) {
|
||||
r.template.ExecuteTemplate(writer, "error.tmpl", errorData)
|
||||
func (r *renderer) RenderSigninPage(ctx *Context, writer io.Writer, signinData *SigninData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "signin.tmpl", WithContext(signinData, ctx))
|
||||
}
|
||||
|
||||
func (r *renderer) RenderErrorPage(ctx *Context, writer io.Writer, errorData *ErrorData) {
|
||||
r.template.ExecuteTemplate(writer, "error.tmpl", WithContext(errorData, ctx))
|
||||
return
|
||||
}
|
||||
|
||||
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) RenderTimelinePage(ctx *Context, writer io.Writer, data *TimelineData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "timeline.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
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) RenderThreadPage(ctx *Context, writer io.Writer, data *ThreadData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "thread.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
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) RenderNotificationPage(ctx *Context, writer io.Writer, data *NotificationData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "notification.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
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) RenderUserPage(ctx *Context, writer io.Writer, data *UserData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "user.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
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) RenderAboutPage(ctx *Context, writer io.Writer, data *AboutData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "about.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
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) RenderEmojiPage(ctx *Context, writer io.Writer, data *EmojiData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "emoji.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
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) RenderLikedByPage(ctx *Context, writer io.Writer, data *LikedByData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "likedby.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
func (r *renderer) RenderEmojiPage(ctx context.Context, writer io.Writer, data *EmojiData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "emoji.tmpl", data)
|
||||
func (r *renderer) RenderRetweetedByPage(ctx *Context, writer io.Writer, data *RetweetedByData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "retweetedby.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
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) RenderFollowingPage(ctx *Context, writer io.Writer, data *FollowingData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "following.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
func (r *renderer) RenderRetweetedByPage(ctx context.Context, writer io.Writer, data *RetweetedByData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "retweetedby.tmpl", data)
|
||||
func (r *renderer) RenderFollowersPage(ctx *Context, writer io.Writer, data *FollowersData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "followers.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
func (r *renderer) RenderFollowingPage(ctx context.Context, writer io.Writer, data *FollowingData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "following.tmpl", data)
|
||||
func (r *renderer) RenderSearchPage(ctx *Context, writer io.Writer, data *SearchData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "search.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
func (r *renderer) RenderFollowersPage(ctx context.Context, writer io.Writer, data *FollowersData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "followers.tmpl", data)
|
||||
}
|
||||
|
||||
func (r *renderer) RenderSearchPage(ctx context.Context, writer io.Writer, data *SearchData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "search.tmpl", data)
|
||||
}
|
||||
|
||||
func (r *renderer) RenderSettingsPage(ctx context.Context, writer io.Writer, data *SettingsData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "settings.tmpl", data)
|
||||
func (r *renderer) RenderSettingsPage(ctx *Context, writer io.Writer, data *SettingsData) (err error) {
|
||||
return r.template.ExecuteTemplate(writer, "settings.tmpl", WithContext(data, ctx))
|
||||
}
|
||||
|
||||
func EmojiFilter(content string, emojis []mastodon.Emoji) string {
|
||||
|
@ -222,3 +222,7 @@ func GetIcon(name string, darkMode bool) (icon string) {
|
|||
icon, _ = icons[name]
|
||||
return
|
||||
}
|
||||
|
||||
func WithContext(data interface{}, ctx *Context) TemplateData {
|
||||
return TemplateData{data, ctx}
|
||||
}
|
||||
|
|
|
@ -73,12 +73,9 @@ func (s *authService) GetUserToken(ctx context.Context, sessionID string, c *mod
|
|||
return
|
||||
}
|
||||
|
||||
func (s *authService) ServeHomePage(ctx context.Context, client io.Writer) (err error) {
|
||||
return s.Service.ServeHomePage(ctx, client)
|
||||
}
|
||||
|
||||
func (s *authService) ServeErrorPage(ctx context.Context, client io.Writer, err error) {
|
||||
s.Service.ServeErrorPage(ctx, client, err)
|
||||
func (s *authService) ServeErrorPage(ctx context.Context, client io.Writer, c *model.Client, err error) {
|
||||
c, _ = s.getClient(ctx)
|
||||
s.Service.ServeErrorPage(ctx, client, c, err)
|
||||
}
|
||||
|
||||
func (s *authService) ServeSigninPage(ctx context.Context, client io.Writer) (err error) {
|
||||
|
|
|
@ -37,20 +37,12 @@ func (s *loggingService) GetUserToken(ctx context.Context, sessionID string, c *
|
|||
return s.Service.GetUserToken(ctx, sessionID, c, code)
|
||||
}
|
||||
|
||||
func (s *loggingService) ServeHomePage(ctx context.Context, client io.Writer) (err error) {
|
||||
defer func(begin time.Time) {
|
||||
s.logger.Printf("method=%v, took=%v, err=%v\n",
|
||||
"ServeHomePage", time.Since(begin), err)
|
||||
}(time.Now())
|
||||
return s.Service.ServeHomePage(ctx, client)
|
||||
}
|
||||
|
||||
func (s *loggingService) ServeErrorPage(ctx context.Context, client io.Writer, err error) {
|
||||
func (s *loggingService) ServeErrorPage(ctx context.Context, client io.Writer, c *model.Client, err error) {
|
||||
defer func(begin time.Time) {
|
||||
s.logger.Printf("method=%v, err=%v, took=%v\n",
|
||||
"ServeErrorPage", err, time.Since(begin))
|
||||
}(time.Now())
|
||||
s.Service.ServeErrorPage(ctx, client, err)
|
||||
s.Service.ServeErrorPage(ctx, client, c, err)
|
||||
}
|
||||
|
||||
func (s *loggingService) ServeSigninPage(ctx context.Context, client io.Writer) (err error) {
|
||||
|
|
|
@ -26,10 +26,9 @@ var (
|
|||
)
|
||||
|
||||
type Service interface {
|
||||
ServeHomePage(ctx context.Context, client io.Writer) (err error)
|
||||
GetAuthUrl(ctx context.Context, instance string) (url string, sessionID string, err error)
|
||||
GetUserToken(ctx context.Context, sessionID string, c *model.Client, token string) (accessToken string, err error)
|
||||
ServeErrorPage(ctx context.Context, client io.Writer, err error)
|
||||
ServeErrorPage(ctx context.Context, client io.Writer, c *model.Client, err error)
|
||||
ServeSigninPage(ctx context.Context, client io.Writer) (err error)
|
||||
ServeTimelinePage(ctx context.Context, client io.Writer, c *model.Client, timelineType string, maxID string, sinceID string, minID string) (err error)
|
||||
ServeThreadPage(ctx context.Context, client io.Writer, c *model.Client, id string, reply bool) (err error)
|
||||
|
@ -79,6 +78,15 @@ func NewService(clientName string, clientScope string, clientWebsite string,
|
|||
}
|
||||
}
|
||||
|
||||
func getRendererContext(s model.Settings) *renderer.Context {
|
||||
return &renderer.Context{
|
||||
MaskNSFW: s.MaskNSFW,
|
||||
ThreadInNewTab: s.ThreadInNewTab,
|
||||
FluorideMode: s.FluorideMode,
|
||||
DarkMode: s.DarkMode,
|
||||
}
|
||||
}
|
||||
|
||||
func (svc *service) GetAuthUrl(ctx context.Context, instance string) (
|
||||
redirectUrl string, sessionID string, err error) {
|
||||
var instanceURL string
|
||||
|
@ -202,20 +210,7 @@ func (svc *service) GetUserToken(ctx context.Context, sessionID string, c *model
|
|||
return res.AccessToken, nil
|
||||
}
|
||||
|
||||
func (svc *service) ServeHomePage(ctx context.Context, client io.Writer) (err error) {
|
||||
commonData, err := svc.getCommonData(ctx, client, nil, "home")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
data := &renderer.HomePageData{
|
||||
CommonData: commonData,
|
||||
}
|
||||
|
||||
return svc.renderer.RenderHomePage(ctx, client, data)
|
||||
}
|
||||
|
||||
func (svc *service) ServeErrorPage(ctx context.Context, client io.Writer, err error) {
|
||||
func (svc *service) ServeErrorPage(ctx context.Context, client io.Writer, c *model.Client, err error) {
|
||||
var errStr string
|
||||
if err != nil {
|
||||
errStr = err.Error()
|
||||
|
@ -231,7 +226,15 @@ func (svc *service) ServeErrorPage(ctx context.Context, client io.Writer, err er
|
|||
Error: errStr,
|
||||
}
|
||||
|
||||
svc.renderer.RenderErrorPage(ctx, client, data)
|
||||
var s model.Settings
|
||||
if c != nil {
|
||||
s = c.Session.Settings
|
||||
} else {
|
||||
s = *model.NewSettings()
|
||||
}
|
||||
rCtx := getRendererContext(s)
|
||||
|
||||
svc.renderer.RenderErrorPage(rCtx, client, data)
|
||||
}
|
||||
|
||||
func (svc *service) ServeSigninPage(ctx context.Context, client io.Writer) (err error) {
|
||||
|
@ -244,7 +247,8 @@ func (svc *service) ServeSigninPage(ctx context.Context, client io.Writer) (err
|
|||
CommonData: commonData,
|
||||
}
|
||||
|
||||
return svc.renderer.RenderSigninPage(ctx, client, data)
|
||||
rCtx := getRendererContext(*model.NewSettings())
|
||||
return svc.renderer.RenderSigninPage(rCtx, client, data)
|
||||
}
|
||||
|
||||
func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
||||
|
@ -279,14 +283,8 @@ func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
|||
}
|
||||
|
||||
for i := range statuses {
|
||||
statuses[i].ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
||||
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||
statuses[i].DarkMode = c.Session.Settings.DarkMode
|
||||
if statuses[i].Reblog != nil {
|
||||
statuses[i].Reblog.RetweetedByID = statuses[i].ID
|
||||
statuses[i].Reblog.ThreadInNewTab = c.Session.Settings.ThreadInNewTab
|
||||
statuses[i].Reblog.MaskNSFW = c.Session.Settings.MaskNSFW
|
||||
statuses[i].Reblog.DarkMode = c.Session.Settings.DarkMode
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +317,6 @@ func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
|||
postContext := model.PostContext{
|
||||
DefaultVisibility: c.Session.Settings.DefaultVisibility,
|
||||
Formats: svc.postFormats,
|
||||
DarkMode: c.Session.Settings.DarkMode,
|
||||
}
|
||||
|
||||
commonData, err := svc.getCommonData(ctx, client, c, timelineType+" timeline ")
|
||||
|
@ -337,8 +334,9 @@ func (svc *service) ServeTimelinePage(ctx context.Context, client io.Writer,
|
|||
PostContext: postContext,
|
||||
CommonData: commonData,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderTimelinePage(ctx, client, data)
|
||||
err = svc.renderer.RenderTimelinePage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -404,8 +402,6 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *mo
|
|||
for i := range statuses {
|
||||
statuses[i].ShowReplies = true
|
||||
statuses[i].ReplyMap = replyMap
|
||||
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||
statuses[i].DarkMode = c.Session.Settings.DarkMode
|
||||
addToReplyMap(replyMap, statuses[i].InReplyToID, statuses[i].ID, i+1)
|
||||
}
|
||||
|
||||
|
@ -420,8 +416,9 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *mo
|
|||
ReplyMap: replyMap,
|
||||
CommonData: commonData,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderThreadPage(ctx, client, data)
|
||||
err = svc.renderer.RenderThreadPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -448,8 +445,6 @@ func (svc *service) ServeNotificationPage(ctx context.Context, client io.Writer,
|
|||
for i := range notifications {
|
||||
if notifications[i].Status != nil {
|
||||
notifications[i].Status.CreatedAt = notifications[i].CreatedAt
|
||||
notifications[i].Status.MaskNSFW = c.Session.Settings.MaskNSFW
|
||||
notifications[i].Status.DarkMode = c.Session.Settings.DarkMode
|
||||
switch notifications[i].Type {
|
||||
case "reblog", "favourite":
|
||||
notifications[i].Status.HideAccountInfo = true
|
||||
|
@ -482,9 +477,10 @@ func (svc *service) ServeNotificationPage(ctx context.Context, client io.Writer,
|
|||
HasNext: hasNext,
|
||||
NextLink: nextLink,
|
||||
CommonData: commonData,
|
||||
DarkMode: c.Session.Settings.DarkMode,
|
||||
}
|
||||
err = svc.renderer.RenderNotificationPage(ctx, client, data)
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderNotificationPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -512,15 +508,6 @@ func (svc *service) ServeUserPage(ctx context.Context, client io.Writer, c *mode
|
|||
return
|
||||
}
|
||||
|
||||
for i := range statuses {
|
||||
statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||
statuses[i].DarkMode = c.Session.Settings.DarkMode
|
||||
if statuses[i].Reblog != nil {
|
||||
statuses[i].Reblog.MaskNSFW = c.Session.Settings.MaskNSFW
|
||||
statuses[i].Reblog.DarkMode = c.Session.Settings.DarkMode
|
||||
}
|
||||
}
|
||||
|
||||
if len(pg.MaxID) > 0 {
|
||||
hasNext = true
|
||||
nextLink = "/user/" + id + "?max_id=" + pg.MaxID
|
||||
|
@ -537,10 +524,10 @@ func (svc *service) ServeUserPage(ctx context.Context, client io.Writer, c *mode
|
|||
HasNext: hasNext,
|
||||
NextLink: nextLink,
|
||||
CommonData: commonData,
|
||||
DarkMode: c.Session.Settings.DarkMode,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderUserPage(ctx, client, data)
|
||||
err = svc.renderer.RenderUserPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -557,7 +544,9 @@ func (svc *service) ServeAboutPage(ctx context.Context, client io.Writer, c *mod
|
|||
data := &renderer.AboutData{
|
||||
CommonData: commonData,
|
||||
}
|
||||
err = svc.renderer.RenderAboutPage(ctx, client, data)
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderAboutPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -580,8 +569,9 @@ func (svc *service) ServeEmojiPage(ctx context.Context, client io.Writer, c *mod
|
|||
Emojis: emojis,
|
||||
CommonData: commonData,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderEmojiPage(ctx, client, data)
|
||||
err = svc.renderer.RenderEmojiPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -604,8 +594,9 @@ func (svc *service) ServeLikedByPage(ctx context.Context, client io.Writer, c *m
|
|||
CommonData: commonData,
|
||||
Users: likers,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderLikedByPage(ctx, client, data)
|
||||
err = svc.renderer.RenderLikedByPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -628,8 +619,9 @@ func (svc *service) ServeRetweetedByPage(ctx context.Context, client io.Writer,
|
|||
CommonData: commonData,
|
||||
Users: retweeters,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderRetweetedByPage(ctx, client, data)
|
||||
err = svc.renderer.RenderRetweetedByPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -668,8 +660,9 @@ func (svc *service) ServeFollowingPage(ctx context.Context, client io.Writer, c
|
|||
HasNext: hasNext,
|
||||
NextLink: nextLink,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderFollowingPage(ctx, client, data)
|
||||
err = svc.renderer.RenderFollowingPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -708,8 +701,9 @@ func (svc *service) ServeFollowersPage(ctx context.Context, client io.Writer, c
|
|||
HasNext: hasNext,
|
||||
NextLink: nextLink,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderFollowersPage(ctx, client, data)
|
||||
err = svc.renderer.RenderFollowersPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -731,11 +725,6 @@ func (svc *service) ServeSearchPage(ctx context.Context, client io.Writer, c *mo
|
|||
hasNext = len(results.Accounts) == 20
|
||||
case "statuses":
|
||||
hasNext = len(results.Statuses) == 20
|
||||
for i := range results.Statuses {
|
||||
results.Statuses[i].MaskNSFW = c.Session.Settings.MaskNSFW
|
||||
results.Statuses[i].DarkMode = c.Session.Settings.DarkMode
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if hasNext {
|
||||
|
@ -761,8 +750,9 @@ func (svc *service) ServeSearchPage(ctx context.Context, client io.Writer, c *mo
|
|||
HasNext: hasNext,
|
||||
NextLink: nextLink,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderSearchPage(ctx, client, data)
|
||||
err = svc.renderer.RenderSearchPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -780,8 +770,9 @@ func (svc *service) ServeSettingsPage(ctx context.Context, client io.Writer, c *
|
|||
CommonData: commonData,
|
||||
Settings: &c.Session.Settings,
|
||||
}
|
||||
rCtx := getRendererContext(c.Session.Settings)
|
||||
|
||||
err = svc.renderer.RenderSettingsPage(ctx, client, data)
|
||||
err = svc.renderer.RenderSettingsPage(rCtx, client, data)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -837,8 +828,6 @@ func (svc *service) getCommonData(ctx context.Context, client io.Writer, c *mode
|
|||
}
|
||||
|
||||
data.HeaderData.NotificationCount = notificationCount
|
||||
data.HeaderData.FluorideMode = c.Session.Settings.FluorideMode
|
||||
data.HeaderData.DarkMode = c.Session.Settings.DarkMode
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -41,7 +41,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
r.HandleFunc("/signin", func(w http.ResponseWriter, req *http.Request) {
|
||||
err := s.ServeSigninPage(ctx, w)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -50,7 +50,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
instance := req.FormValue("instance")
|
||||
url, sessionID, err := s.GetAuthUrl(ctx, instance)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
token := req.URL.Query().Get("code")
|
||||
_, err := s.GetUserToken(ctx, "", nil, token)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeTimelinePage(ctx, w, nil, timelineType, maxID, sinceID, minID)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -103,7 +103,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
reply := req.URL.Query().Get("reply")
|
||||
err := s.ServeThreadPage(ctx, w, nil, id, len(reply) > 1)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -114,7 +114,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeLikedByPage(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -125,7 +125,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeRetweetedByPage(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -139,7 +139,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeFollowingPage(ctx, w, nil, id, maxID, minID)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -153,7 +153,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeFollowersPage(ctx, w, nil, id, maxID, minID)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -165,7 +165,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
_, err := s.Like(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
_, err := s.UnLike(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
_, err := s.Retweet(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
_, err := s.UnRetweet(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -239,13 +239,13 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
id, _ := mux.Vars(req)["id"]
|
||||
count, err := s.Like(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = serveJson(w, count)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodPost)
|
||||
|
@ -255,13 +255,13 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
id, _ := mux.Vars(req)["id"]
|
||||
count, err := s.UnLike(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = serveJson(w, count)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodPost)
|
||||
|
@ -271,13 +271,13 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
id, _ := mux.Vars(req)["id"]
|
||||
count, err := s.Retweet(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = serveJson(w, count)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodPost)
|
||||
|
@ -287,13 +287,13 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
id, _ := mux.Vars(req)["id"]
|
||||
count, err := s.UnRetweet(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
err = serveJson(w, count)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodPost)
|
||||
|
@ -303,7 +303,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := req.ParseMultipartForm(4 << 20)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
id, err := s.PostTweet(ctx, w, nil, content, replyToID, format, visibility, isNSFW, files)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeNotificationPage(ctx, w, nil, maxID, minID)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -351,7 +351,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeUserPage(ctx, w, nil, id, maxID, minID)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -363,7 +363,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.Follow(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.UnFollow(ctx, w, nil, id)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeAboutPage(ctx, w, nil)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -401,7 +401,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeEmojiPage(ctx, w, nil)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -418,14 +418,14 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
if len(offsetStr) > 1 {
|
||||
offset, err = strconv.Atoi(offsetStr)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
err = s.ServeSearchPage(ctx, w, nil, q, qType, offset)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -435,7 +435,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
|
||||
err := s.ServeSettingsPage(ctx, w, nil)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
}).Methods(http.MethodGet)
|
||||
|
@ -455,12 +455,12 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
|||
ThreadInNewTab: threadInNewTab,
|
||||
MaskNSFW: maskNSFW,
|
||||
FluorideMode: fluorideMode,
|
||||
DarkMode: darkMode,
|
||||
DarkMode: darkMode,
|
||||
}
|
||||
|
||||
err := s.SaveSettings(ctx, w, nil, settings)
|
||||
if err != nil {
|
||||
s.ServeErrorPage(ctx, w, err)
|
||||
s.ServeErrorPage(ctx, w, nil, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> About </div>
|
||||
|
||||
<div>
|
||||
|
@ -15,4 +16,5 @@
|
|||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Emojis </div>
|
||||
|
||||
<div class="emoji-list-container">
|
||||
|
@ -12,5 +13,4 @@
|
|||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
|
||||
|
||||
{{end}}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
<div class="page-title"> Error </div>
|
||||
|
||||
<div class="error-text"> {{.Error}} </div>
|
||||
<div>
|
||||
<a href="/timeline/home">Home</a>
|
||||
<a href="/signin">Sign In</a>
|
||||
<a href="/timeline/home">Home</a>
|
||||
<a href="/signin">Sign In</a>
|
||||
</div>
|
||||
{{template "footer.tmpl"}}
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Followers </div>
|
||||
|
||||
{{template "userlist.tmpl" .Users}}
|
||||
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||
<div class="pagination">
|
||||
{{if .HasNext}}
|
||||
<a href="{{.NextLink}}">next</a>
|
||||
|
@ -10,3 +11,4 @@
|
|||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Following </div>
|
||||
|
||||
{{template "userlist.tmpl" .Users}}
|
||||
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||
<div class="pagination">
|
||||
{{if .HasNext}}
|
||||
<a href="{{.NextLink}}">next</a>
|
||||
|
@ -10,3 +11,4 @@
|
|||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{with .Data}}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
@ -8,8 +9,9 @@
|
|||
{{if .CustomCSS}}
|
||||
<link rel="stylesheet" href="{{.CustomCSS}}">
|
||||
{{end}}
|
||||
{{if .FluorideMode}}
|
||||
{{if $.Ctx.FluorideMode}}
|
||||
<script src="/static/fluoride.js"></script>
|
||||
{{end}}
|
||||
</head>
|
||||
<body {{if .DarkMode}}class="dark"{{end}}>
|
||||
<body {{if $.Ctx.DarkMode}}class="dark"{{end}}>
|
||||
{{end}}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
<div class="page-title"> Home </div>
|
||||
<a href="/signin"> Signin </a>
|
||||
{{template "footer.tmpl"}}
|
|
@ -1,7 +1,9 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Liked By </div>
|
||||
|
||||
{{template "userlist.tmpl" .Users}}
|
||||
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{with .Data}}
|
||||
<div class="user-info">
|
||||
<div class="user-info-img-container">
|
||||
<a class="img-link" href="/timeline/home" title="home">
|
||||
|
@ -25,3 +26,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Notifications </div>
|
||||
|
||||
{{range .Notifications}}
|
||||
|
@ -14,7 +15,7 @@
|
|||
<div>
|
||||
<div class="notification-info-text">
|
||||
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||
<img class="icon" src="{{GetIcon "user-plus" .DarkMode}}" alt="followed" />
|
||||
<img class="icon" src="{{GetIcon "user-plus" $.Ctx.DarkMode}}" alt="followed" />
|
||||
<span> followed you </span>
|
||||
</div>
|
||||
<div class="notification-follow-uname">
|
||||
|
@ -24,7 +25,7 @@
|
|||
</div>
|
||||
|
||||
{{else if eq .Type "mention"}}
|
||||
{{template "status" .Status}}
|
||||
{{template "status" (WithContext .Status $.Ctx)}}
|
||||
|
||||
{{else if eq .Type "reblog"}}
|
||||
<div class="notification-retweet-container">
|
||||
|
@ -36,10 +37,10 @@
|
|||
<div>
|
||||
<div class="notification-info-text">
|
||||
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||
<img class="icon" src="{{GetIcon "retweeted" .DarkMode}}" alt="retweeted" />
|
||||
<img class="icon" src="{{GetIcon "retweeted" $.Ctx.DarkMode}}" alt="retweeted" />
|
||||
<span> retweeted your post </span>
|
||||
</div>
|
||||
{{template "status" .Status}}
|
||||
{{template "status" (WithContext .Status $.Ctx)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -53,10 +54,10 @@
|
|||
<div>
|
||||
<div class="notification-info-text">
|
||||
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||
<img class="icon" src="{{GetIcon "liked" .DarkMode}}" alt="liked" />
|
||||
<img class="icon" src="{{GetIcon "liked" $.Ctx.DarkMode}}" alt="liked" />
|
||||
<span> liked your post </span>
|
||||
</div>
|
||||
{{template "status" .Status}}
|
||||
{{template "status" (WithContext .Status $.Ctx)}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
@ -68,4 +69,6 @@
|
|||
<a href="{{.NextLink}}">next</a>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{with .Data}}
|
||||
<form class="post-form" action="/post" method="POST" enctype="multipart/form-data">
|
||||
{{if .ReplyContext}}
|
||||
<input type="hidden" name="reply_to_id" value="{{.ReplyContext.InReplyToID}}" />
|
||||
|
@ -6,7 +7,7 @@
|
|||
<label for="post-content" class="post-form-title"> New post </label>
|
||||
{{end}}
|
||||
<a class="post-form-emoji-link" href="/emojis" target="_blank" title="emoji reference">
|
||||
<img class="icon post-emoji" src="{{GetIcon "smile-o" .DarkMode}}" alt="emojis" />
|
||||
<img class="icon post-emoji" src="{{GetIcon "smile-o" $.Ctx.DarkMode}}" alt="emojis" />
|
||||
</a>
|
||||
<div class="post-form-content-container">
|
||||
<textarea id="post-content" name="content" class="post-content" cols="50" rows="5">{{if .ReplyContext}}{{.ReplyContext.ReplyContent}}{{end}}</textarea>
|
||||
|
@ -42,4 +43,5 @@
|
|||
</div>
|
||||
<button type="submit"> Post </button>
|
||||
</form>
|
||||
{{end}}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Retweeted By </div>
|
||||
|
||||
{{template "userlist.tmpl" .Users}}
|
||||
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Search </div>
|
||||
|
||||
<div>
|
||||
|
@ -21,12 +22,12 @@
|
|||
|
||||
{{if eq .Type "statuses"}}
|
||||
{{range .Statuses}}
|
||||
{{template "status.tmpl" .}}
|
||||
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
{{if eq .Type "accounts"}}
|
||||
{{template "userlist.tmpl" .Users}}
|
||||
{{template "userlist.tmpl" (WithContext .Users $.Ctx)}}
|
||||
{{end}}
|
||||
|
||||
<div class="pagination">
|
||||
|
@ -34,4 +35,6 @@
|
|||
<a href="{{.NextLink}}">next</a>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Settings </div>
|
||||
|
||||
<form id="settings-form" action="/settings" method="POST">
|
||||
|
@ -36,3 +37,4 @@
|
|||
</form>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
<div class="page-title"> Signin </div>
|
||||
|
||||
<form class="signin-form" action="/signin" method="post">
|
||||
|
@ -8,3 +9,4 @@
|
|||
</form>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{with .Data}}
|
||||
<div id="status-{{.ID}}" class="status-container-container">
|
||||
{{if .Reblog}}
|
||||
<div class="retweet-info">
|
||||
|
@ -5,12 +6,13 @@
|
|||
<img class="status-profile-img" src="{{.Account.AvatarStatic}}" alt="avatar" />
|
||||
</a>
|
||||
<span class="status-dname"> {{EmojiFilter .Account.DisplayName .Account.Emojis}} </span>
|
||||
<img class="icon" src="{{GetIcon "retweeted" .DarkMode}}" alt="retweeted" />
|
||||
<img class="icon" src="{{GetIcon "retweeted" $.Ctx.DarkMode}}" alt="retweeted" />
|
||||
retweeted
|
||||
</div>
|
||||
{{template "status" .Reblog}}
|
||||
{{template "status" (WithContext .Reblog $.Ctx)}}
|
||||
{{else}}
|
||||
{{block "status" .}}
|
||||
{{block "status" (WithContext . $.Ctx)}}
|
||||
{{with $s := .Data}}
|
||||
<div class="status-container status-{{.ID}}" data-id="{{.ID}}">
|
||||
{{if not .HideAccountInfo}}
|
||||
<div class="status-profile-img-container">
|
||||
|
@ -28,17 +30,17 @@
|
|||
</a>
|
||||
<a class="status-visibility">
|
||||
{{if eq .Visibility "public"}}
|
||||
<img class="icon" src="{{GetIcon "globe" .DarkMode}}" alt="Public" title="Public" />
|
||||
<img class="icon" src="{{GetIcon "globe" $.Ctx.DarkMode}}" alt="Public" title="Public" />
|
||||
{{else if eq .Visibility "unlisted"}}
|
||||
<img class="icon" src="{{GetIcon "unlock-alt" .DarkMode}}" alt="Unlisted" title="Unlisted" />
|
||||
<img class="icon" src="{{GetIcon "unlock-alt" $.Ctx.DarkMode}}" alt="Unlisted" title="Unlisted" />
|
||||
{{else if eq .Visibility "private"}}
|
||||
<img class="icon" src="{{GetIcon "lock" .DarkMode}}" alt="Private" title="Private" />
|
||||
<img class="icon" src="{{GetIcon "lock" $.Ctx.DarkMode}}" alt="Private" title="Private" />
|
||||
{{else if eq .Visibility "direct"}}
|
||||
<img class="icon" src="{{GetIcon "envelope" .DarkMode}}" alt="Direct" title="Direct" />
|
||||
<img class="icon" src="{{GetIcon "envelope" $.Ctx.DarkMode}}" alt="Direct" title="Direct" />
|
||||
{{end}}
|
||||
</a>
|
||||
<a class="remote-link" href="{{.URL}}" target="_blank" title="source">
|
||||
<img class="icon" src="{{GetIcon "link" .DarkMode}}" alt="source" />
|
||||
<img class="icon" src="{{GetIcon "link" $.Ctx.DarkMode}}" alt="source" />
|
||||
</a>
|
||||
</div>
|
||||
{{end}}
|
||||
|
@ -46,7 +48,7 @@
|
|||
{{if .InReplyToID}}
|
||||
<div class="status-reply-to">
|
||||
<a class="status-reply-to-link" href="{{if not .ShowReplies}}/thread/{{.InReplyToID}}{{end}}#status-{{.InReplyToID}}">
|
||||
<img class="icon" src="{{GetIcon "mail-forward" .DarkMode}}" alt="reply to" /> reply to {{.Pleroma.InReplyToAccountAcct}}
|
||||
<img class="icon" src="{{GetIcon "mail-forward" $.Ctx.DarkMode}}" alt="reply to" /> reply to {{.Pleroma.InReplyToAccountAcct}}
|
||||
</a>
|
||||
</div>
|
||||
{{if index .ReplyMap .ID}} <span class="status-reply-info-divider"> - </span> {{end}}
|
||||
|
@ -66,7 +68,7 @@
|
|||
{{if eq .Type "image"}}
|
||||
<a class="img-link" href="{{.URL}}" target="_blank">
|
||||
<img class="status-image" src="{{.URL}}" alt="status-image" />
|
||||
{{if (and $.MaskNSFW $.Sensitive)}}
|
||||
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
|
||||
<div class="status-nsfw-overlay"></div>
|
||||
{{end}}
|
||||
</a>
|
||||
|
@ -81,7 +83,7 @@
|
|||
<source src="{{.URL}}">
|
||||
<p> Your browser doesn't support HTML5 video </p>
|
||||
</video>
|
||||
{{if (and $.MaskNSFW $.Sensitive)}}
|
||||
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
|
||||
<div class="status-nsfw-overlay"></div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
@ -93,27 +95,27 @@
|
|||
<div class="status-action-container">
|
||||
<div class="status-action">
|
||||
<a class="status-you" href="/thread/{{.ID}}?reply=true#status-{{.ID}}" title="reply">
|
||||
<img class="icon" src="{{GetIcon "reply" .DarkMode}}" alt="reply" />
|
||||
<img class="icon" src="{{GetIcon "reply" $.Ctx.DarkMode}}" alt="reply" />
|
||||
</a>
|
||||
<a class="status-reply-count" href="/thread/{{.ID}}#status-{{.ID}}" {{if .ThreadInNewTab}}target="_blank"{{end}}>
|
||||
<a class="status-reply-count" href="/thread/{{.ID}}#status-{{.ID}}" {{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
|
||||
{{DisplayInteractionCount .RepliesCount}}
|
||||
</a>
|
||||
</div>
|
||||
<div class="status-action">
|
||||
{{if or (eq .Visibility "private") (eq .Visibility "direct")}}
|
||||
<a class="status-retweet" title="this status cannot be retweeted">
|
||||
<img class="icon" src="{{GetIcon "retweet" .DarkMode}}" alt="retweet" />
|
||||
<img class="icon" src="{{GetIcon "retweet" $.Ctx.DarkMode}}" alt="retweet" />
|
||||
</a>
|
||||
{{else}}
|
||||
{{if .Reblogged}}
|
||||
<form class="status-retweet" data-action="unretweet" action="/unretweet/{{.ID}}" method="post">
|
||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||
<input type="image" src="{{GetIcon "retweeted" .DarkMode}}" alt="undo retweet" class="icon" title="undo retweet">
|
||||
<input type="image" src="{{GetIcon "retweeted" $.Ctx.DarkMode}}" alt="undo retweet" class="icon" title="undo retweet">
|
||||
</form>
|
||||
{{else}}
|
||||
<form class="status-retweet" data-action="retweet" action="/retweet/{{.ID}}" method="post">
|
||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||
<input type="image" src="{{GetIcon "retweet" .DarkMode}}" alt="retweet" class="icon" title="retweet">
|
||||
<input type="image" src="{{GetIcon "retweet" $.Ctx.DarkMode}}" alt="retweet" class="icon" title="retweet">
|
||||
</form>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
@ -125,12 +127,12 @@
|
|||
{{if .Favourited}}
|
||||
<form class="status-like" data-action="unlike" action="/unlike/{{.ID}}" method="post">
|
||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||
<input type="image" src="{{GetIcon "liked" .DarkMode}}" alt="unlike" class="icon" title="unlike">
|
||||
<input type="image" src="{{GetIcon "liked" $.Ctx.DarkMode}}" alt="unlike" class="icon" title="unlike">
|
||||
</form>
|
||||
{{else}}
|
||||
<form class="status-like" data-action="like" action="/like/{{.ID}}" method="post">
|
||||
<input type="hidden" name="retweeted_by_id" value="{{.RetweetedByID}}" />
|
||||
<input type="image" src="{{GetIcon "star-o" .DarkMode}}" alt="like" class="icon" title="like">
|
||||
<input type="image" src="{{GetIcon "star-o" $.Ctx.DarkMode}}" alt="like" class="icon" title="like">
|
||||
</form>
|
||||
{{end}}
|
||||
<a class="status-like-count" href="/likedby/{{.ID}}" title="click to see the the list">
|
||||
|
@ -138,7 +140,7 @@
|
|||
</a>
|
||||
</div>
|
||||
<div class="status-action">
|
||||
<a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}" {{if .ThreadInNewTab}}target="_blank"{{end}}>
|
||||
<a class="status-time" href="{{if not .ShowReplies}}/thread/{{.ID}}{{end}}#status-{{.ID}}" {{if $.Ctx.ThreadInNewTab}}target="_blank"{{end}}>
|
||||
<time datetime="{{FormatTimeRFC3339 .CreatedAt}}" title="{{FormatTimeRFC822 .CreatedAt}}"> {{TimeSince .CreatedAt}} </time>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -147,4 +149,6 @@
|
|||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with $s := .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> Thread </div>
|
||||
|
||||
{{range .Statuses}}
|
||||
|
||||
{{template "status.tmpl" .}}
|
||||
{{if $.PostContext.ReplyContext}}{{if eq .ID $.PostContext.ReplyContext.InReplyToID}}
|
||||
{{template "postform.tmpl" $.PostContext}}
|
||||
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
||||
{{if $s.PostContext.ReplyContext}}{{if eq .ID $s.PostContext.ReplyContext.InReplyToID}}
|
||||
{{template "postform.tmpl" (WithContext $s.PostContext $.Ctx)}}
|
||||
{{end}}{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> {{.Title}} </div>
|
||||
|
||||
|
||||
{{template "postform.tmpl" .PostContext}}
|
||||
{{template "postform.tmpl" (WithContext .PostContext $.Ctx)}}
|
||||
|
||||
{{range .Statuses}}
|
||||
{{template "status.tmpl" .}}
|
||||
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
||||
{{end}}
|
||||
|
||||
<div class="pagination">
|
||||
|
@ -17,4 +17,6 @@
|
|||
<a href="{{.NextLink}}">next</a>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
{{end}}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{{template "header.tmpl" .HeaderData}}
|
||||
{{template "navigation.tmpl" .NavbarData}}
|
||||
{{with .Data}}
|
||||
{{template "header.tmpl" (WithContext .HeaderData $.Ctx)}}
|
||||
{{template "navigation.tmpl" (WithContext .NavbarData $.Ctx)}}
|
||||
<div class="page-title"> User </div>
|
||||
|
||||
<div class="user-info-container">
|
||||
|
@ -14,7 +15,7 @@
|
|||
<span class="status-dname"> {{EmojiFilter .User.DisplayName .User.Emojis}} </span>
|
||||
<span class="status-uname"> {{.User.Acct}} </span>
|
||||
<a class="remote-link" href="{{.User.URL}}" target="_blank" title="remote profile">
|
||||
<img class="icon" src="{{GetIcon "link" .DarkMode}}" alt="link" />
|
||||
<img class="icon" src="{{GetIcon "link" $.Ctx.DarkMode}}" alt="link" />
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -48,7 +49,7 @@
|
|||
</div>
|
||||
|
||||
{{range .Statuses}}
|
||||
{{template "status.tmpl" .}}
|
||||
{{template "status.tmpl" (WithContext . $.Ctx)}}
|
||||
{{end}}
|
||||
|
||||
<div class="pagination">
|
||||
|
@ -58,4 +59,4 @@
|
|||
</div>
|
||||
|
||||
{{template "footer.tmpl"}}
|
||||
|
||||
{{end}}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{{with .Data}}
|
||||
<div class="user-list-container">
|
||||
{{range .}}
|
||||
<div class="user-list-item">
|
||||
|
@ -15,3 +16,4 @@
|
|||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in a new issue