aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/service.go9
-rw-r--r--service/transport.go15
2 files changed, 24 insertions, 0 deletions
diff --git a/service/service.go b/service/service.go
index ce689fd..1666959 100644
--- a/service/service.go
+++ b/service/service.go
@@ -305,6 +305,15 @@ func (s *service) ThreadPage(c *client, id string, reply bool) (err error) {
return s.renderer.Render(rCtx, c, renderer.ThreadPage, data)
}
+func (svc *service) StatusPopup(c *client, id string) (err error) {
+ status, err := c.GetStatus(ctx, id)
+ if err != nil {
+ return
+ }
+ rCtx := getRendererContext(c)
+ return svc.renderer.Render(rCtx, c, renderer.StatusPopup, status)
+}
+
func (s *service) LikedByPage(c *client, id string) (err error) {
likers, err := c.GetFavouritedBy(ctx, id, nil)
if err != nil {
diff --git a/service/transport.go b/service/transport.go
index 096b44e..9841650 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -64,6 +64,15 @@ func writeJson(c *client, data interface{}) error {
})
}
+func serveJsonError(w http.ResponseWriter, err error) {
+ var d = make(map[string]interface{})
+ d["error"] = err.Error()
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusInternalServerError)
+ json.NewEncoder(w).Encode(d)
+ return
+}
+
func redirect(c *client, url string) {
c.Header().Add("Location", url)
c.WriteHeader(http.StatusFound)
@@ -632,6 +641,11 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
return writeJson(c, count)
}, CSRF, JSON)
+ fStatus := handle(func(c *client) error {
+ id, _ := mux.Vars(c.Req)["id"]
+ return s.StatusPopup(c, id)
+ }, SESSION, JSON)
+
r.HandleFunc("/", rootPage).Methods(http.MethodGet)
r.HandleFunc("/nav", navPage).Methods(http.MethodGet)
r.HandleFunc("/signin", signinPage).Methods(http.MethodGet)
@@ -678,6 +692,7 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
r.HandleFunc("/fluoride/unlike/{id}", fUnlike).Methods(http.MethodPost)
r.HandleFunc("/fluoride/retweet/{id}", fRetweet).Methods(http.MethodPost)
r.HandleFunc("/fluoride/unretweet/{id}", fUnretweet).Methods(http.MethodPost)
+ r.HandleFunc("/fluoride/status/{id}", fStatus).Methods(http.MethodGet)
r.PathPrefix("/static").Handler(http.StripPrefix("/static",
http.FileServer(http.Dir(staticDir))))