From 7116705959bad9244893434039a0da9b500f5043 Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Sun, 7 Nov 2021 00:59:12 -0300 Subject: last commit of the night --- routes/post.go | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'routes') diff --git a/routes/post.go b/routes/post.go index 41706c0..ace9c6b 100644 --- a/routes/post.go +++ b/routes/post.go @@ -3,6 +3,7 @@ package routes import ( "regexp" + "github.com/FChannel0/FChannel-Server/activitypub" "github.com/FChannel0/FChannel-Server/config" "github.com/FChannel0/FChannel-Server/db" "github.com/FChannel0/FChannel-Server/util" @@ -102,3 +103,65 @@ func PostGet(ctx *fiber.Ctx) error { "page": returnData, }, "layouts/main") } + +func CatalogGet(ctx *fiber.Ctx) error { + // TODO: + collection := ctx.Locals("collection").(activitypub.Collection) + + // TODO: implement this in template functions + // "showArchive": func() bool { + // col, err := db.GetActorCollectionDBTypeLimit(collection.Actor.Id, "Archive", 1) + // if err != nil { + // // TODO: figure out what to do here + // panic(err) + // } + // + // if len(col.OrderedItems) > 0 { + // return true + // } + // return false + //}, + + actor := collection.Actor + + var returnData PageData + returnData.Board.Name = actor.Name + returnData.Board.PrefName = actor.PreferredUsername + returnData.Board.InReplyTo = "" + returnData.Board.To = actor.Outbox + returnData.Board.Actor = *actor + returnData.Board.Summary = actor.Summary + returnData.Board.ModCred, _ = getPassword(ctx) + returnData.Board.Domain = config.Domain + returnData.Board.Restricted = actor.Restricted + returnData.Key = config.Key + returnData.ReturnTo = "catalog" + + returnData.Board.Post.Actor = actor.Id + + var err error + returnData.Instance, err = db.GetActorFromDB(config.Domain) + if err != nil { + return err + } + + 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.Boards = db.Boards + + returnData.Posts = collection.OrderedItems + + returnData.Themes = &config.Themes + returnData.ThemeCookie = getThemeCookie(ctx) + + return ctx.Render("ncatalog", fiber.Map{ + "page": returnData, + }, "layouts/main") +} -- cgit v1.2.3