aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFChannel <>2021-07-02 02:05:58 -0700
committerFChannel <>2021-07-02 02:05:58 -0700
commit97ce6d91545ec10f35d692ccbf60536d83f5debf (patch)
treeda65fbb40a3e936255d6af0b1313743b172bc2d3
parenta122d62f78e5f1fd66efc28994809d720a2841ab (diff)
added anchor links for index.html and public instance indexing tweak
-rw-r--r--client.go9
-rw-r--r--main.go49
-rw-r--r--static/faq.html20
-rw-r--r--static/index.html4
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 <a href='https://github.com/FChannel0'>https://github.com/FChannel0</a>")
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 @@
<h4>What is fchan</h4>
<p>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.</p>
- <h4>Options</h4>
+ <h4 id="options">Options</h4>
<p>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.</p>
- <h4>Tripcode</h4>
+ <h4 id="tripcode">Tripcode</h4>
<p>you can identify yourself with a tripcode by adding a hash mark (#) after your name followed by your unique identifying string, example anon#myunique.</p>
- <h4>Quote</h4>
+ <h4 id="quote">Quote</h4>
<p>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).</p>
- <h4>No. Link</h4>
+ <h4 id="link">No. Link</h4>
<p>click on "No." next to a post to view its thread.</p>
- <h4>Uploading files</h4>
+ <h4 id="upload">Uploading files</h4>
<p>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.</p>
- <h4>JavaScript why?</h4>
+ <h4 id="javascript">JavaScript why?</h4>
<p>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.</p>
- <h4>Why are the posts not sequential numbers?</h4>
+ <h4 id="seqnum">Why are the posts not sequential numbers?</h4>
<p>sequential numbers have run their course. random base 16 (now base 36) is better.</p>
- <h4>Activitypub specific examples</h4>
+ <h4 id="pubexamp">Activitypub specific examples</h4>
<p>coming soon(tm).</p>
- <h4>Server Version</h4>
- <p>v0.0.5b</p>
+ <h4 id="version">Server Version</h4>
+ <p>v0.0.5c</p>
</div>
<div style="width: 500px; margin:0 auto; margin-top: 50px; text-align: center;">
<a href="/">[Home]</a><a href="/static/rules.html">[Rules]</a><a href="/static/faq.html">[FAQ]</a>
diff --git a/static/index.html b/static/index.html
index 502e527..ab0bea0 100644
--- a/static/index.html
+++ b/static/index.html
@@ -20,7 +20,7 @@
{{ define "content" }}
<div style="text-align: center; max-width: 800px; margin: 0 auto;">
<h1>{{ .Title }}</h1>
- <p style="text-align: justify">{{.Message}}</p>
+ <p style="text-align: justify">{{.MessageHTML}}</p>
<div style="margin-top:50px;">
<table align="center" style="text-align: left;">
@@ -30,7 +30,7 @@
{{ range .InstanceIndex }}
<tr>
- <td>{{ .Id }}</td>
+ <td><a href="{{ .Id }}">{{ .Id }}</a></td>
</tr>
{{ end }}
</table>