From 4e3848cadbb3fd89b94a7ef24838173939d198db Mon Sep 17 00:00:00 2001 From: knotteye Date: Thu, 1 Jul 2021 17:56:04 -0500 Subject: Add a list of local boards and server news --- client.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'client.go') diff --git a/client.go b/client.go index dd40f3d..fcb496b 100644 --- a/client.go +++ b/client.go @@ -47,6 +47,7 @@ type PageData struct { Instance Actor InstanceIndex []ObjectBase ReturnTo string + NewsItems []NewsItem } type AdminPage struct { @@ -73,8 +74,15 @@ type Removed struct { Board string } + +type NewsItem struct { + Title string + Content string + Time int +} + func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { - t := template.Must(template.ParseFiles("./static/main.html", "./static/index.html")) + t := template.Must(template.New("").Funcs(template.FuncMap{"mod": func(i, j int) bool { return i%j == 0 }}).ParseFiles("./static/main.html", "./static/index.html")) actor := GetActorFromDB(db, Domain) @@ -90,8 +98,9 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { data.Board.Post.Actor = actor.Id data.Board.Restricted = actor.Restricted data.InstanceIndex = GetCollectionFromReq("https://fchan.xyz/followers").Items + data.NewsItems = getNewsFromDB(db) - t.ExecuteTemplate(w, "layout", data) + t.ExecuteTemplate(w, "layout", data) } func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Collection){ -- cgit v1.2.3