From 1df70fec27ab5e4aa3dff8521767454be6b5498c Mon Sep 17 00:00:00 2001 From: FChannel <=> Date: Thu, 4 Feb 2021 12:33:42 -0800 Subject: when merging boards into a feed show the board color based on posts restrictions --- CacheDatabase.go | 4 ++ Database.go | 4 ++ client.go | 18 +++-- main.go | 9 ++- static/catalog.html | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++ static/faq.html | 2 +- static/main.html | 8 +-- static/manage.html | 10 +-- static/rules.html | 6 +- 9 files changed, 229 insertions(+), 21 deletions(-) create mode 100644 static/catalog.html diff --git a/CacheDatabase.go b/CacheDatabase.go index 21c1a8f..26d7d8d 100644 --- a/CacheDatabase.go +++ b/CacheDatabase.go @@ -273,8 +273,12 @@ func GetObjectByIDFromCache(db *sql.DB, postID string) Collection { CheckError(err, "error scan object into post struct cache") + actor = GetRemoteActor(actor.Id) + post.Actor = &actor + nColl.Actor = &actor + // var postCnt int // var imgCnt int post.Replies, _, _ = GetObjectRepliesDB(db, post) diff --git a/Database.go b/Database.go index a64ceb9..d027b43 100644 --- a/Database.go +++ b/Database.go @@ -466,8 +466,12 @@ func GetObjectByIDFromDB(db *sql.DB, postID string) Collection { CheckError(err, "error scan object into post struct") + actor = GetActorFromDB(db, actor.Id) + post.Actor = &actor + nColl.Actor = &actor + // var postCnt int // var imgCnt int post.Replies, _, _ = GetObjectRepliesDB(db, post) diff --git a/client.go b/client.go index c585209..f82c8f7 100644 --- a/client.go +++ b/client.go @@ -34,6 +34,7 @@ type Board struct{ Domain string TP string Restricted bool + Post ObjectBase } type PageData struct { @@ -85,6 +86,8 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { data.Key = *Key data.Board.Domain = Domain data.Board.ModCred, _ = GetPasswordFromSession(r) + data.Board.Actor = actor + data.Board.Post.Actor = &actor t.ExecuteTemplate(w, "layout", data) } @@ -106,12 +109,14 @@ func OutboxGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection Co returnData.Board.Summary = actor.Summary returnData.Board.InReplyTo = "" returnData.Board.To = actor.Outbox - returnData.Board.Actor.Id = actor.Id + returnData.Board.Actor = *actor returnData.Board.ModCred, _ = GetPasswordFromSession(r) returnData.Board.Domain = Domain returnData.Board.Restricted = actor.Restricted returnData.CurrentPage = page + returnData.Board.Post.Actor = actor + returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) @@ -232,13 +237,15 @@ func CatalogGet(w http.ResponseWriter, r *http.Request, db *sql.DB, collection C returnData.Board.PrefName = actor.PreferredUsername returnData.Board.InReplyTo = "" returnData.Board.To = actor.Outbox - returnData.Board.Actor.Id = actor.Id + returnData.Board.Actor = *actor returnData.Board.Summary = actor.Summary returnData.Board.ModCred, _ = GetPasswordFromSession(r) returnData.Board.Domain = Domain returnData.Board.Restricted = actor.Restricted returnData.Key = *Key + returnData.Board.Post.Actor = actor + returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) @@ -276,13 +283,12 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ returnData.Board.Name = actor.Name returnData.Board.PrefName = actor.PreferredUsername returnData.Board.To = actor.Outbox - returnData.Board.Actor.Id = actor.Id + returnData.Board.Actor = actor returnData.Board.Summary = actor.Summary returnData.Board.ModCred, _ = GetPasswordFromSession(r) returnData.Board.Domain = Domain returnData.Board.Restricted = actor.Restricted - if GetDomainURL(actor) != "" { returnData.Board.Captcha = Domain + "/" + GetRandomCaptcha(db) returnData.Board.CaptchaCode = GetCaptchaCode(returnData.Board.Captcha) @@ -301,6 +307,8 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ followActors := GetActorsFollowFromName(actor, name) followCollection := GetActorsFollowPostFromId(db, followActors, postId) + returnData.Board.Post.Actor = followCollection.Actor + DeleteRemovedPosts(db, &followCollection) DeleteTombstoneReplies(&followCollection) @@ -318,6 +326,8 @@ func PostGet(w http.ResponseWriter, r *http.Request, db *sql.DB){ returnData.Board.InReplyTo = inReplyTo collection := GetActorCollectionByID(db, inReplyTo) + returnData.Board.Post.Actor = collection.Actor + DeleteRemovedPosts(db, &collection) for i, e := range collection.OrderedItems { diff --git a/main.go b/main.go index 270977c..3dfad82 100644 --- a/main.go +++ b/main.go @@ -415,7 +415,7 @@ func main() { followActivity.Actor = &nactor followActivity.Object = &obj followActivity.Actor.Id = r.FormValue("actor") - + var mactor Actor followActivity.Object.Actor = &mactor followActivity.Object.Actor.Id = r.FormValue("follow") @@ -496,9 +496,12 @@ func main() { adminData.Title = "Manage /" + actor.Name + "/" adminData.Boards = Boards adminData.Board.Name = actor.Name - adminData.Actor = actor.Id + adminData.Board.Actor = actor adminData.Key = *Key adminData.Board.TP = TP + + adminData.Board.Post.Actor = &actor + t.ExecuteTemplate(w, "layout", adminData) } else if admin || actor.Id == Domain { @@ -529,6 +532,8 @@ func main() { adminData.Board.ModCred,_ = GetPasswordFromSession(r) adminData.Boards = Boards + + adminData.Board.Post.Actor = &actor t.ExecuteTemplate(w, "layout", adminData) } diff --git a/static/catalog.html b/static/catalog.html new file mode 100644 index 0000000..b5b361e --- /dev/null +++ b/static/catalog.html @@ -0,0 +1,189 @@ + + +
+fchan short for fchannel and is a federated image board based on activity pub. it removes the centralization aspect that so many of us have become accustom to. it is not trying to re-invent the wheel and draws likeness from other chans for ease of familiarity. you can get the source code here https://github.com/FChannel0 any help is appreciated.
+fchan short for fchannel and is a federated image board based on activity pub. it removes the need for centeralized boards. many boards can be connected and feeds shared or followed. it draws likeness from other chans for ease of familiarity. you can get the source code here https://github.com/FChannel0 and modify how you choose, any help is appreciated.
the options field when posting can be used for special options when posting. type noko in the options field to return to the thread you posting to. use sage to ignore updating the thread bump order. nokosage will do both.
diff --git a/static/main.html b/static/main.html index 7d5d236..dd9d0c0 100644 --- a/static/main.html +++ b/static/main.html @@ -19,7 +19,7 @@ } body { - {{ if .Board.Restricted }} + {{ if .Board.Post.Actor.Restricted }} background-color: #eef2fe; color: black; {{ else }} @@ -29,7 +29,7 @@ } .popup-box { - {{ if .Board.Restricted }} + {{ if .Board.Post.Actor.Restricted }} border: 4px solid #d3caf0; background-color: #eff5ff; {{ else }} @@ -43,7 +43,7 @@ } .reply { - {{ if .Board.Restricted }} + {{ if .Board.Post.Actor.Restricted }} color:#af0a0f; {{ else }} color:#000080; @@ -51,7 +51,7 @@ } .post { - {{ if .Board.Restricted }} + {{ if .Board.Post.Actor.Restricted }} background-color: #d5daf0; {{ else }} background-color: #f0e0d6; diff --git a/static/manage.html b/static/manage.html index 06288cd..570c0f5 100644 --- a/static/manage.html +++ b/static/manage.html @@ -16,7 +16,7 @@