aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/service.go8
-rw-r--r--service/transport.go15
2 files changed, 23 insertions, 0 deletions
diff --git a/service/service.go b/service/service.go
index 8297764..c56114c 100644
--- a/service/service.go
+++ b/service/service.go
@@ -378,6 +378,14 @@ func (s *service) QuickReplyPage(c *client, id string) (err error) {
return s.renderer.Render(c.rctx, c.w, renderer.QuickReplyPage, data)
}
+func (svc *service) StatusPopup(c *client, id string) (err error) {
+ status, err := c.GetStatus(c.ctx, id)
+ if err != nil {
+ return
+ }
+ return svc.renderer.Render(c.rctx, c.w, renderer.StatusPopup, status)
+}
+
func (s *service) LikedByPage(c *client, id string) (err error) {
likers, err := c.GetFavouritedBy(c.ctx, id, nil)
if err != nil {
diff --git a/service/transport.go b/service/transport.go
index 615fe2a..02e6106 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -54,6 +54,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.w.Header().Add("Location", url)
c.w.WriteHeader(http.StatusFound)
@@ -640,6 +649,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.r)["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)
@@ -690,6 +704,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))))