diff --git a/db.go b/db.go index 6d23618..33ca177 100644 --- a/db.go +++ b/db.go @@ -195,3 +195,18 @@ func getHostsTotal(db *sql.DB, since string, search string) (int, error) { return totali, nil } + +func getRejectedHostsTotal(db *sql.DB) (int, error) { + total := "0" + query := "SELECT count(url) FROM instances WHERE rejected = 1" + + row := db.QueryRow(query) + row.Scan(&total) + + totali, err := strconv.Atoi(total) + if err != nil { + return 0, err + } + + return totali, nil +} diff --git a/main.go b/main.go index 3572001..43aaa5e 100644 --- a/main.go +++ b/main.go @@ -145,9 +145,23 @@ func serve() { defer db.Close() r := gin.Default() + r.LoadHTMLGlob("templates/*") r.GET("/", func(c *gin.Context) { - c.String(200, "index") + filteredInstancesCount, err := getHostsTotal(db, "", "") + if err != nil { + panic(err) + } + + rejectedInstancesCount, err := getRejectedHostsTotal(db) + if err != nil { + panic(err) + } + + c.HTML(http.StatusOK, "index.tmpl", gin.H{ + "FilteredInstancesCount": filteredInstancesCount, + "RejectedInstancesCount": rejectedInstancesCount, + }) }) r.GET("/instances", func(c *gin.Context) { diff --git a/templates/index.tmpl b/templates/index.tmpl new file mode 100644 index 0000000..acd6aaf --- /dev/null +++ b/templates/index.tmpl @@ -0,0 +1,53 @@ + +
+ +By using global index of instances and auto-subscribing there are problem by removing from your instance following because it comes back after next sync.
+This filter is middleware to collect removed instances and list global index without them
+ +Source code is available on g.arns.lt/zordsdavini/peertube-instance-index-filter
+Contact on Fediverse: @zordsdavini@s.arns.lt
+ +Filtered instances | +{{ .FilteredInstancesCount }} | +
---|---|
Rejected instances | +{{ .RejectedInstancesCount }} | +
App can be called directly and do management in console. For now it is the only way.
+ +peertube-instance-index-filter -command index -url https://instances.joinpeertube.org/api/v1/instances/hosts -instance-url https://instances.joinpeertube.org/api/v1/instances
- add url to index of hosts. Later it will be used to collect instancespeertube-instance-index-filter -command collect
- collect instances from index of hosts urlspeertube-instance-index-filter -command reject -host www.example.com
- reject instance from index to exclude it from global index?start=3&count=100&since=2024-01-10
. Sorted by descending creation date. Also it can be used as search by host: ?search=www.example.com
?start=3&count=100&since=2024-01-10
. Sorted by descending creation date. This should be given to Peertube instanceAdded docker files as example. See /docker
folder.
./instances-joinpeertube.db
is prepared datebase from instances.joinpeertube.org on 2025-06-20. It can be copied to ./instances.db
to be used.
GPLv3
+ +