Compare commits

..

No commits in common. "b3fe5c17ed6db5aba74b37eed29b1789ede7c265" and "8a69473bafff97f9ea6e06a50b178a605ca86b6d" have entirely different histories.

2 changed files with 18 additions and 21 deletions

View File

@ -1,6 +1,11 @@
# ekster
a [Microsub](https://indieweb.org/Microsub) server
a microsub server
## Warning!
Very alpha: no warranty.
## Installing and running ekster
@ -14,7 +19,7 @@ you need a Go environment. Use these commands to install the programs.
go get -u p83.nl/go/ekster/cmd/eksterd
go get -u p83.nl/go/ekster/cmd/ek
`eksterd` uses [Redis](https://redis.io/) as the database to temporarily save
`eksterd` uses [Redis](https://redis.io/) as the database, to temporarily save
the items and feeds. The more permanent information is saved in `backend.json`.
#### Running eksterd
@ -157,7 +162,3 @@ Micropub client.
`ekster` will check every 10 minutes, if the token is still valid. This could
be retrieved automatically, but this doesn't happen at the moment.
## Other Microsub projects
* <https://indieweb.org/Microsub>
* Aperture: [code](https://github.com/aaronparecki/Aperture), [hosted](https://aperture.p3k.io)

View File

@ -31,10 +31,6 @@ var (
entryRegex = regexp.MustCompile("^entry\\[\\d+\\]$")
)
const (
OutputContentType = "application/json; charset=utf-8"
)
type microsubHandler struct {
backend microsub.Microsub
}
@ -67,7 +63,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
jw := json.NewEncoder(w)
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
err = jw.Encode(map[string][]microsub.Channel{
"channels": channels,
})
@ -82,7 +78,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
jw := json.NewEncoder(w)
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
jw.SetIndent("", " ")
jw.SetEscapeHTML(false)
err = jw.Encode(timeline)
@ -98,7 +94,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
jw := json.NewEncoder(w)
jw.SetIndent("", " ")
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
err = jw.Encode(timeline)
if err != nil {
http.Error(w, err.Error(), 500)
@ -112,7 +108,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
jw := json.NewEncoder(w)
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
err = jw.Encode(map[string][]microsub.Feed{
"items": following,
})
@ -144,7 +140,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), 500)
return
}
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
fmt.Fprintln(w, "[]")
return
}
@ -156,7 +152,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), 500)
return
}
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
err = jw.Encode(channel)
if err != nil {
http.Error(w, err.Error(), 500)
@ -168,7 +164,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), 500)
return
}
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
err = jw.Encode(channel)
if err != nil {
http.Error(w, err.Error(), 500)
@ -184,7 +180,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), 500)
return
}
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
jw := json.NewEncoder(w)
err = jw.Encode(feed)
if err != nil {
@ -199,7 +195,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), 500)
return
}
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
fmt.Fprintln(w, "[]")
} else if action == "search" {
query := values.Get("query")
@ -209,7 +205,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
jw := json.NewEncoder(w)
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
err = jw.Encode(map[string][]microsub.Feed{
"results": feeds,
})
@ -249,7 +245,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, fmt.Sprintf("unknown method in timeline %s\n", method), 500)
return
}
w.Header().Add("Content-Type", OutputContentType)
w.Header().Add("Content-Type", "application/json")
fmt.Fprintln(w, "[]")
} else {
http.Error(w, fmt.Sprintf("unknown action %s\n", action), 500)