Use post method for like and retweet
authorr <r@freesoftwareextremist.com>
Sat, 4 Jan 2020 18:56:47 +0000 (18:56 +0000)
committerr <r@freesoftwareextremist.com>
Sat, 4 Jan 2020 18:56:47 +0000 (18:56 +0000)
service/transport.go
static/main.css
templates/status.tmpl

index dc7e4793ef203475ac4f2a9eab2de382355257a3..d481b21e91107d8759fbb49b326a3d7cec919404 100644 (file)
@@ -167,7 +167,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
 
                w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
                w.WriteHeader(http.StatusFound)
-       }).Methods(http.MethodGet)
+       }).Methods(http.MethodPost)
 
        r.HandleFunc("/unlike/{id}", func(w http.ResponseWriter, req *http.Request) {
                ctx := getContextWithSession(context.Background(), req)
@@ -180,7 +180,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
 
                w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
                w.WriteHeader(http.StatusFound)
-       }).Methods(http.MethodGet)
+       }).Methods(http.MethodPost)
 
        r.HandleFunc("/retweet/{id}", func(w http.ResponseWriter, req *http.Request) {
                ctx := getContextWithSession(context.Background(), req)
@@ -193,7 +193,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
 
                w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
                w.WriteHeader(http.StatusFound)
-       }).Methods(http.MethodGet)
+       }).Methods(http.MethodPost)
 
        r.HandleFunc("/unretweet/{id}", func(w http.ResponseWriter, req *http.Request) {
                ctx := getContextWithSession(context.Background(), req)
@@ -206,7 +206,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
 
                w.Header().Add("Location", req.Header.Get("Referer")+"#status-"+id)
                w.WriteHeader(http.StatusFound)
-       }).Methods(http.MethodGet)
+       }).Methods(http.MethodPost)
 
        r.HandleFunc("/post", func(w http.ResponseWriter, req *http.Request) {
                ctx := getContextWithSession(context.Background(), req)
index ad03792909c675692f2f243f887da935f5687186..e82586dedc5299759c7307b1d1a13c51237194a2 100644 (file)
        min-width: 64px;
 }
 
+.status-action form {
+       display: inline-block;
+}
+
 .status-action:last-child {
        min-width: unset;
 }
index 7facba270dfbd52fb375af49bad70a6bdf796790..1661f5871647770f698585c205bab679f99a738e 100644 (file)
                                        </a>
                                        {{else}}
                                        {{if .Reblogged}}
-                                       <a class="status-retweet" href="/unretweet/{{.ID}}" title="undo retweet"> 
-                                               <img class="icon" src="/static/icons/retweeted.png" alt="undo retweet" />
-                                       </a>
+                                       <form class="status-retweet" action="/unretweet/{{.ID}}" method="post">
+                                           <input type="image" src="/static/icons/retweeted.png" alt="undo retweet" class="icon" title="undo retweet">
+                                       </form>
                                        {{else}}
-                                       <a class="status-retweet" href="/retweet/{{.ID}}" title="retweet"> 
-                                               <img class="icon" src="/static/icons/retweet.png" alt="retweet" />
-                                       </a>
+                                       <form class="status-retweet" action="/retweet/{{.ID}}" method="post">
+                                           <input type="image" src="/static/icons/retweet.png" alt="retweet" class="icon" title="retweet">
+                                       </form>
                                        {{end}}
                                        {{end}}
                                        <a class="status-action-count" href="/retweetedby/{{.ID}}" title="click to see the the list"> 
                                </div>
                                <div class="status-action">
                                        {{if .Favourited}}
-                                       <a class="status-like" href="/unlike/{{.ID}}" title="unlike"> 
-                                               <img class="icon" src="/static/icons/liked.png" alt="unlike" />
-                                       </a>
+                                       <form class="status-like" action="/unlike/{{.ID}}" method="post">
+                                           <input type="image" src="/static/icons/liked.png" alt="unlike" class="icon" title="unlike">
+                                       </form>
                                        {{else}}
-                                       <a class="status-like" href="/like/{{.ID}}" title="like"> 
-                                               <img class="icon" src="/static/icons/star-o.png" alt="like" />
-                                       </a>
+                                       <form class="status-like" action="/like/{{.ID}}" method="post">
+                                           <input type="image" src="/static/icons/star-o.png" alt="like" class="icon" title="like">
+                                       </form>
                                        {{end}}
                                        <a class="status-action-count" href="/likedby/{{.ID}}" title="click to see the the list"> 
                                                <span> {{DisplayInteractionCount .FavouritesCount}} </span>