diff options
author | KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> | 2021-10-27 18:18:06 -0300 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | d2277b1f9b17e61456cd312ef54542e1cfa81a40 (patch) | |
tree | 3f7f4b6dffe95c0f9909921dd47700e733b4ee47 /routes/index.go | |
parent | 9f8195162295d2a789462e6b13394174a5745100 (diff) |
restructuring, part 1 of many
Diffstat (limited to 'routes/index.go')
-rw-r--r-- | routes/index.go | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/routes/index.go b/routes/index.go index ccd398b..df10d9f 100644 --- a/routes/index.go +++ b/routes/index.go @@ -1,7 +1,51 @@ package routes -import "github.com/gofiber/fiber/v2" +import ( + "github.com/FChannel0/FChannel-Server/config" + "github.com/FChannel0/FChannel-Server/db" + "github.com/gofiber/fiber/v2" +) func Index(c *fiber.Ctx) error { - return c.SendString("index") + actor, err := db.GetActor(config.Domain) + if err != nil { + return err + } + + var data PageData + data.Title = "Welcome to " + actor.PreferredUsername + data.PreferredUsername = actor.PreferredUsername + data.Boards = Boards + data.Board.Name = "" + data.Key = *Key + data.Board.Domain = config.Domain + data.Board.ModCred, _ = GetPasswordFromCtx(c) + data.Board.Actor = actor + data.Board.Post.Actor = actor.Id + data.Board.Restricted = actor.Restricted + //almost certainly there is a better algorithm for this but the old one was wrong + //and I suck at math. This works at least. + data.BoardRemainer = make([]int, 3-(len(data.Boards)%3)) + if len(data.BoardRemainer) == 3 { + data.BoardRemainer = make([]int, 0) + } + + col := GetCollectionFromReq("https://fchan.xyz/followers") + + if len(col.Items) > 0 { + data.InstanceIndex = col.Items + } + + data.NewsItems, err = db.GetNewsFromDB(3) + if err != nil { + return err + } + + data.Themes = &Themes + + data.ThemeCookie = getThemeCookie(c) + + return c.Render("index", fiber.Map{ + "page": data, + }, "layouts/main") } |