Merge branch 'missing-files' into new-microsub-package
All checks were successful
the build was successful
All checks were successful
the build was successful
This commit is contained in:
commit
b3fe5c17ed
13
README.md
13
README.md
|
|
@ -1,11 +1,6 @@
|
||||||
# ekster
|
# ekster
|
||||||
|
|
||||||
a microsub server
|
a [Microsub](https://indieweb.org/Microsub) server
|
||||||
|
|
||||||
|
|
||||||
## Warning!
|
|
||||||
|
|
||||||
Very alpha: no warranty.
|
|
||||||
|
|
||||||
## Installing and running ekster
|
## Installing and running ekster
|
||||||
|
|
||||||
|
|
@ -19,7 +14,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/eksterd
|
||||||
go get -u p83.nl/go/ekster/cmd/ek
|
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`.
|
the items and feeds. The more permanent information is saved in `backend.json`.
|
||||||
|
|
||||||
#### Running eksterd
|
#### Running eksterd
|
||||||
|
|
@ -162,3 +157,7 @@ Micropub client.
|
||||||
`ekster` will check every 10 minutes, if the token is still valid. This could
|
`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.
|
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)
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,10 @@ var (
|
||||||
entryRegex = regexp.MustCompile("^entry\\[\\d+\\]$")
|
entryRegex = regexp.MustCompile("^entry\\[\\d+\\]$")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
OutputContentType = "application/json; charset=utf-8"
|
||||||
|
)
|
||||||
|
|
||||||
type microsubHandler struct {
|
type microsubHandler struct {
|
||||||
backend microsub.Microsub
|
backend microsub.Microsub
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +67,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
err = jw.Encode(map[string][]microsub.Channel{
|
err = jw.Encode(map[string][]microsub.Channel{
|
||||||
"channels": channels,
|
"channels": channels,
|
||||||
})
|
})
|
||||||
|
|
@ -78,7 +82,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
jw.SetIndent("", " ")
|
jw.SetIndent("", " ")
|
||||||
jw.SetEscapeHTML(false)
|
jw.SetEscapeHTML(false)
|
||||||
err = jw.Encode(timeline)
|
err = jw.Encode(timeline)
|
||||||
|
|
@ -94,7 +98,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
jw.SetIndent("", " ")
|
jw.SetIndent("", " ")
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
err = jw.Encode(timeline)
|
err = jw.Encode(timeline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -108,7 +112,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
err = jw.Encode(map[string][]microsub.Feed{
|
err = jw.Encode(map[string][]microsub.Feed{
|
||||||
"items": following,
|
"items": following,
|
||||||
})
|
})
|
||||||
|
|
@ -140,7 +144,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
fmt.Fprintln(w, "[]")
|
fmt.Fprintln(w, "[]")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +156,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
err = jw.Encode(channel)
|
err = jw.Encode(channel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -164,7 +168,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
err = jw.Encode(channel)
|
err = jw.Encode(channel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
@ -180,7 +184,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
err = jw.Encode(feed)
|
err = jw.Encode(feed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -195,7 +199,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
fmt.Fprintln(w, "[]")
|
fmt.Fprintln(w, "[]")
|
||||||
} else if action == "search" {
|
} else if action == "search" {
|
||||||
query := values.Get("query")
|
query := values.Get("query")
|
||||||
|
|
@ -205,7 +209,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
jw := json.NewEncoder(w)
|
jw := json.NewEncoder(w)
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
err = jw.Encode(map[string][]microsub.Feed{
|
err = jw.Encode(map[string][]microsub.Feed{
|
||||||
"results": feeds,
|
"results": feeds,
|
||||||
})
|
})
|
||||||
|
|
@ -245,7 +249,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, fmt.Sprintf("unknown method in timeline %s\n", method), 500)
|
http.Error(w, fmt.Sprintf("unknown method in timeline %s\n", method), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", OutputContentType)
|
||||||
fmt.Fprintln(w, "[]")
|
fmt.Fprintln(w, "[]")
|
||||||
} else {
|
} else {
|
||||||
http.Error(w, fmt.Sprintf("unknown action %s\n", action), 500)
|
http.Error(w, fmt.Sprintf("unknown action %s\n", action), 500)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user