gdritter repos new-inf-blog / aeec4b9
Use POST on a /delete URL instead of DELETE (which does not work) Getty Ritter 5 years ago
3 changed file(s) with 11 addition(s) and 12 deletion(s). Collapse all Expand all
2525
2626 instance SQL.ToField User where
2727 toField = SQL.toField . userName
28
2928
3029 -- | A 'PostRef' is just the information needed to identify a post
3130 -- internally, including when it was posted and its title and slug
107107 DB.runDB (DB.submitPost (User u) rp) c
108108 Web.redirect (postURL oldPost)
109109
110 ("DELETE", [y, m, s]) ->
111 case user of
112 Nothing -> Web.redirect "/"
113 Just _ -> do
114 Log.warn [ "deleting post!" ]
115 flip DB.runDB c $ do
116 post <- DB.postByDateAndSlug y m s
117 DB.deletePost (postToRawPost post)
118 Web.redirect "/"
119
120110 ("GET", [y, m, s, "edit"]) ->
121111 case user of
122112 Nothing -> do
126116 oldPost <- DB.runDB (DB.postByDateAndSlug y m s) c
127117 contents <- Template.edit (postURL oldPost) (postToRawPost oldPost)
128118 Web.ok user (T.fromStrict (postTitle oldPost)) contents
119
120 ("POST", [y, m, s, "delete"]) ->
121 case user of
122 Nothing -> Web.redirect "/"
123 Just _ -> do
124 Log.warn [ "deleting post:", show (y, m, s) ]
125 flip DB.runDB c $ do
126 post <- DB.postByDateAndSlug y m s
127 DB.deletePost (postToRawPost post)
128 Web.redirect "/"
129129
130130 ("GET", [y, m, s, "delete"]) ->
131131 case user of
22 <p>Are you sure you want to delete this post?</p>
33 <p>
44 <a href="{{post_url}}">No</a>
5 <form name="delpost" action="{{post_url}}" method="DELETE">
5 <form name="delpost" action="{{post_url}}/delete" method="POST">
66 <input type="submit" value="yes" />
77 </form>
88 </p>