From 97ce6d91545ec10f35d692ccbf60536d83f5debf Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Fri, 2 Jul 2021 02:05:58 -0700 Subject: added anchor links for index.html and public instance indexing tweak --- client.go | 9 ++++++--- main.go | 49 ++++++++++++++++++++++++++++--------------------- static/faq.html | 20 ++++++++++---------- static/index.html | 4 ++-- 4 files changed, 46 insertions(+), 36 deletions(-) diff --git a/client.go b/client.go index 49c7d0c..6e185cc 100644 --- a/client.go +++ b/client.go @@ -1,6 +1,5 @@ package main -import "fmt" import "net/http" import "html/template" import "database/sql" @@ -36,7 +35,8 @@ type Board struct{ type PageData struct { Title string - Message string + Message string + MessageHTML template.HTML Board Board Pages []int CurrentPage int @@ -81,7 +81,8 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { var data PageData data.Title = "Welcome to " + actor.PreferredUsername - data.Message = fmt.Sprintf("%s is a federated image board based on activitypub. The current version of the code running the server is still a work in progress, expect a bumpy ride for the time being. Get the server code here https://github.com/FChannel0", Domain) + data.Message = actor.PreferredUsername + " is a federated image board based on activitypub. The current version of the code running the server is still a work in progress, expect a bumpy ride for the time being. Get the server code here https://github.com/FChannel0" + data.MessageHTML = template.HTML(actor.PreferredUsername + " is a federated image board based on activitypub. The current version of the code running the server is still a work in progress, expect a bumpy ride for the time being. Get the server code here https://github.com/FChannel0") data.Boards = Boards data.Board.Name = "" data.Key = *Key @@ -92,6 +93,8 @@ func IndexGet(w http.ResponseWriter, r *http.Request, db *sql.DB) { data.Board.Restricted = actor.Restricted data.InstanceIndex = GetCollectionFromReq("https://fchan.xyz/followers").Items + + t.ExecuteTemplate(w, "layout", data) } diff --git a/main.go b/main.go index 9dac9e2..2874396 100644 --- a/main.go +++ b/main.go @@ -1115,29 +1115,9 @@ func main() { return } - followers := GetCollectionFromID("https://fchan.xyz/followers") - var alreadyIndex = false - for _, e := range followers.Items { - if e.Id == actor { - alreadyIndex = true - } - } - - // delay to give instance time to boot up - time.Sleep(15 * time.Second) - - checkActor := GetActor(actor) - if checkActor.Id == actor { - if !alreadyIndex { - query := `insert into follower (id, follower) values ($1, $2)` - - _, err := db.Exec(query, "https://fchan.xyz", actor) - - CheckError(err, "Error with add to index query") - } - } + go AddInstanceToIndexDB(db, actor) }) fmt.Println("Server for " + Domain + " running on port " + Port) @@ -2449,6 +2429,32 @@ func AddInstanceToIndex(actor string) { } } +func AddInstanceToIndexDB(db *sql.DB, actor string) { + + time.Sleep(15 * time.Second) + + followers := GetCollectionFromID("https://fchan.xyz/followers") + + var alreadyIndex = false + for _, e := range followers.Items { + if e.Id == actor { + alreadyIndex = true + } + } + + checkActor := GetActor(actor) + + if checkActor.Id == actor { + if !alreadyIndex { + query := `insert into follower (id, follower) values ($1, $2)` + + _, err := db.Exec(query, "https://fchan.xyz", actor) + + CheckError(err, "Error with add to index query") + } + } +} + func GetCollectionFromReq(path string) Collection { req, err := http.NewRequest("GET", path, nil) @@ -2474,3 +2480,4 @@ func GetCollectionFromReq(path string) Collection { return respCollection } + diff --git a/static/faq.html b/static/faq.html index 9ce691a..ed7fed2 100644 --- a/static/faq.html +++ b/static/faq.html @@ -12,32 +12,32 @@
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.
-you can identify yourself with a tripcode by adding a hash mark (#) after your name followed by your unique identifying string, example anon#myunique.
-use a greater than symbols (>) to quote strings of text. use double (>>) followed by the url id of the post you are referencing (this will be changed later for better use).
-click on "No." next to a post to view its thread.
-max file size is 7MB. the supported file types are "image/gif","image/jpeg","image/png","image/webp","image/apng","video/mp4","video/ogg","video/webm","audio/mpeg","audio/ogg","audio/wav","audio/wave","audio/x-wav". these were choosen based on browser support for embeding.
-a version of the client with no javascript will be made eventually. current version requires it, because of basic functionality needed. no libraries or frameworks for javascript is used besides ECMAScript, just basic selection of DOM elements and modifying their styling. maybe someone would be willing to make a client that uses no javascript.
-sequential numbers have run their course. random base 16 (now base 36) is better.
-coming soon(tm).
-v0.0.5b
+v0.0.5c
{{.Message}}
+{{.MessageHTML}}
{{ .Id }} | +{{ .Id }} |