This is my new blog CMS https://jlelse.blog
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

2 months ago
  1. package main
  2. import (
  3. "encoding/json"
  4. "net/http"
  5. )
  6. func serveNodeInfoDiscover(w http.ResponseWriter, r *http.Request) {
  7. b, _ := json.Marshal(map[string]interface{}{
  8. "links": []map[string]interface{}{
  9. {
  10. "href": appConfig.Server.PublicAddress + "/nodeinfo",
  11. "rel": "http://nodeinfo.diaspora.software/ns/schema/2.1",
  12. },
  13. },
  14. })
  15. w.Header().Set(contentType, contentTypeJSONUTF8)
  16. _, _ = writeMinified(w, contentTypeJSON, b)
  17. }
  18. func serveNodeInfo(w http.ResponseWriter, r *http.Request) {
  19. localPosts, _ := countPosts(&postsRequestConfig{
  20. status: statusPublished,
  21. })
  22. b, _ := json.Marshal(map[string]interface{}{
  23. "version": "2.1",
  24. "software": map[string]interface{}{
  25. "name": "goblog",
  26. "repository": "https://git.jlel.se/jlelse/GoBlog",
  27. },
  28. "usage": map[string]interface{}{
  29. "users": map[string]interface{}{
  30. "total": len(appConfig.Blogs),
  31. },
  32. "localPosts": localPosts,
  33. },
  34. "protocols": []string{
  35. "activitypub",
  36. "micropub",
  37. "webmention",
  38. },
  39. "metadata": map[string]interface{}{},
  40. })
  41. w.Header().Set(contentType, contentTypeJSONUTF8)
  42. _, _ = writeMinified(w, contentTypeJSON, b)
  43. }