diff options
author | knotteye <knotteye@airmail.cc> | 2021-07-02 14:20:16 -0500 |
---|---|---|
committer | knotteye <knotteye@airmail.cc> | 2021-07-02 14:20:16 -0500 |
commit | faae38726dd804e3246514d88f93794c23a0cdb2 (patch) | |
tree | 4671606919340098b81c398e8478ba616a0432b1 /client.go | |
parent | ad5f4e9ff7e7ab0abab4a964cbf1626d0cdc3365 (diff) |
show only the last 3 news items on index, link to a page with all news items
Diffstat (limited to 'client.go')
-rw-r--r-- | client.go | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -102,7 +102,7 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { data.Board.Restricted = actor.Restricted data.BoardRemainer = make([]int, (len(data.Boards) % 3)+1) data.InstanceIndex = GetCollectionFromReq("https://fchan.xyz/followers").Items - data.NewsItems = getNewsFromDB(db) + data.NewsItems = getNewsFromDB(db, 3) t.ExecuteTemplate(w, "layout", data) } @@ -138,6 +138,27 @@ func NewsGet(w http.ResponseWriter, r *http.Request, db *sql.DB, timestamp int) t.ExecuteTemplate(w, "layout", data) } +func AllNewsGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { + t := template.Must(template.New("").Funcs(template.FuncMap{"unixtoreadable": func(u int) string { return time.Unix(int64(u), 0).Format("Jan 02, 2006") }}).ParseFiles("./static/main.html", "./static/anews.html")) + + actor := GetActorFromDB(db, Domain) + + var data PageData + data.PreferredUsername = actor.PreferredUsername + data.Title = actor.PreferredUsername + " News" + data.Boards = Boards + data.Board.Name = "" + data.Key = *Key + data.Board.Domain = Domain + data.Board.ModCred, _ = GetPasswordFromSession(r) + data.Board.Actor = actor + data.Board.Post.Actor = actor.Id + data.Board.Restricted = actor.Restricted + data.NewsItems = getNewsFromDB(db, 0) + + t.ExecuteTemplate(w, "layout", data) +} + func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Collection){ t := template.Must(template.ParseFiles("./static/main.html", "./static/nposts.html", "./static/top.html", "./static/bottom.html", "./static/posts.html")) |