From 5b52d269faa2ce2014d0feba603a2122361cf4eb Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Fri, 29 Apr 2022 10:36:43 -0700 Subject: general layout organization --- routes/outbox.go | 73 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'routes/outbox.go') diff --git a/routes/outbox.go b/routes/outbox.go index 1277011..4b874df 100644 --- a/routes/outbox.go +++ b/routes/outbox.go @@ -41,36 +41,6 @@ func OutboxGet(ctx *fiber.Ctx) error { } } - var returnData PageData - - returnData.Board.Name = actor.Name - returnData.Board.PrefName = actor.PreferredUsername - returnData.Board.Summary = actor.Summary - returnData.Board.InReplyTo = "" - returnData.Board.To = actor.Outbox - returnData.Board.Actor = actor - returnData.Board.ModCred, _ = getPassword(ctx) - returnData.Board.Domain = config.Domain - returnData.Board.Restricted = actor.Restricted - returnData.CurrentPage = page - returnData.ReturnTo = "feed" - - returnData.Board.Post.Actor = actor.Id - - capt, err := db.GetRandomCaptcha() - if err != nil { - return err - } - returnData.Board.Captcha = config.Domain + "/" + capt - returnData.Board.CaptchaCode = util.GetCaptchaCode(returnData.Board.Captcha) - - returnData.Title = "/" + actor.Name + "/ - " + actor.PreferredUsername - - returnData.Key = config.Key - - returnData.Boards = db.Boards - returnData.Posts = collection.OrderedItems - var offset = 15 var pages []int pageLimit := (float64(collection.TotalItems) / float64(offset)) @@ -83,13 +53,46 @@ func OutboxGet(ctx *fiber.Ctx) error { pages = append(pages, int(i)) } - returnData.Pages = pages - returnData.TotalPage = len(returnData.Pages) - 1 + var data PageData + data.Board.Name = actor.Name + data.Board.PrefName = actor.PreferredUsername + data.Board.Summary = actor.Summary + data.Board.InReplyTo = "" + data.Board.To = actor.Outbox + data.Board.Actor = actor + data.Board.ModCred, _ = getPassword(ctx) + data.Board.Domain = config.Domain + data.Board.Restricted = actor.Restricted + data.CurrentPage = page + data.ReturnTo = "feed" + + data.Board.Post.Actor = actor.Id + + capt, err := db.GetRandomCaptcha() + if err != nil { + return err + } + data.Board.Captcha = config.Domain + "/" + capt + data.Board.CaptchaCode = util.GetCaptchaCode(data.Board.Captcha) + + data.Title = "/" + actor.Name + "/ - " + actor.PreferredUsername + + data.Key = config.Key + + data.Boards = db.Boards + data.Posts = collection.OrderedItems + + data.Pages = pages + data.TotalPage = len(data.Pages) - 1 + + data.Meta.Description = data.Board.Summary + data.Meta.Url = data.Board.Actor.Id + data.Meta.Title = data.Title - returnData.Themes = &config.Themes - returnData.ThemeCookie = getThemeCookie(ctx) + data.Themes = &config.Themes + data.ThemeCookie = getThemeCookie(ctx) return ctx.Render("nposts", fiber.Map{ - "page": returnData, + "page": data, }, "layouts/main") } -- cgit v1.2.3