diff options
author | FChannel <> | 2021-07-03 18:39:34 -0700 |
---|---|---|
committer | FChannel <> | 2021-07-03 18:39:34 -0700 |
commit | cf86acee94652ac7cd8e8f313e6abf6c9901c398 (patch) | |
tree | e8e9d1157e2d64eb8d8f3baa1f8694bd3e7e108d /client.go | |
parent | ab6edbbe8044d5a3c7d9456bd15e3a74af35111a (diff) |
add some styling to news pull request
Diffstat (limited to 'client.go')
-rw-r--r-- | client.go | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -79,12 +79,15 @@ type Removed struct { type NewsItem struct { Title string - Content string + Content template.HTML Time int } func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { - t := template.Must(template.New("").Funcs(template.FuncMap{"mod": func(i, j int) bool { return i%j == 0 }, "unixtoreadable": func(u int) string { return time.Unix(int64(u), 0).Format("Jan 02, 2006") }}).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 }, + "sub": func (i, j int) int { return i - j }, + "unixtoreadable": func(u int) string { return time.Unix(int64(u), 0).Format("Jan 02, 2006") }}).ParseFiles("./static/main.html", "./static/index.html")) actor := GetActorFromDB(db, Domain) @@ -113,7 +116,9 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { } func NewsGet(w http.ResponseWriter, r *http.Request, db *sql.DB, timestamp int) { - 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/news.html")) + t := template.Must(template.New("").Funcs(template.FuncMap{ + "sub": func (i, j int) int { return i - j }, + "unixtoreadable": func(u int) string { return time.Unix(int64(u), 0).Format("Jan 02, 2006") }}).ParseFiles("./static/main.html", "./static/news.html")) actor := GetActorFromDB(db, Domain) @@ -144,7 +149,10 @@ func NewsGet(w http.ResponseWriter, r *http.Request, db *sql.DB, timestamp int) } 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")) + t := template.Must(template.New("").Funcs(template.FuncMap{ + "mod": func(i, j int) bool { return i%j == 0 }, + "sub": func (i, j int) int { return i - j }, + "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) @@ -165,8 +173,9 @@ func AllNewsGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { } func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Collection){ + t := template.Must(template.New("").Funcs(template.FuncMap{ + "sub": func (i, j int) int { return i - j }}).ParseFiles("./static/main.html", "./static/nposts.html", "./static/top.html", "./static/bottom.html", "./static/posts.html")) - t := template.Must(template.ParseFiles("./static/main.html", "./static/nposts.html", "./static/top.html", "./static/bottom.html", "./static/posts.html")) actor := collection.Actor @@ -214,9 +223,8 @@ func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Co } func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Collection){ - - t := template.Must(template.ParseFiles("./static/main.html", "./static/ncatalog.html", "./static/top.html")) - + t := template.Must(template.New("").Funcs(template.FuncMap{ + "sub": func (i, j int) int { return i - j }}).ParseFiles("./static/main.html", "./static/ncatalog.html", "./static/top.html")) actor := collection.Actor var returnData PageData @@ -249,8 +257,8 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C } func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ - - t := template.Must(template.ParseFiles("./static/main.html", "./static/npost.html", "./static/top.html", "./static/bottom.html", "./static/posts.html")) + t := template.Must(template.New("").Funcs(template.FuncMap{ + "sub": func (i, j int) int { return i - j }}).ParseFiles("./static/main.html", "./static/npost.html", "./static/top.html", "./static/bottom.html", "./static/posts.html")) path := r.URL.Path actor := GetActorFromPath(db, path, "/") @@ -322,10 +330,11 @@ func GetBoardCollection(db *sql.DB) []Board { if boardActor.Id == "" { boardActor = FingerActor(e.Id) } - board.Name = "/" + boardActor.Name + "/" + board.Name = boardActor.Name board.PrefName = boardActor.PreferredUsername board.Location = "/" + boardActor.Name board.Actor = boardActor + board.Restricted = boardActor.Restricted collection = append(collection, board) } |