Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Follow-up to previous commit - remove all trailing slashes from apiurls
And add to the put and delete where needed. This is better and more consistent. Also works. Odd that things magically broke |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/issue1 | trunk | master |
Files: | files | file ages | folders |
SHA3-256: |
06a6b89ac275066a738820011cfd6f32 |
User & Date: | atomicules 2020-03-14 15:15:59 |
2020-05-14
| ||
06:16 |
Add `nextweek` command to move todos to "next" Monday
I.e. whatever day of the week the todo is on it'll be moved to the next Monday. | |
2020-03-14
| ||
15:15 |
Follow-up to previous commit - remove all trailing slashes from apiurls
And add to the put and delete where needed. This is better and more consistent. Also works. Odd that things magically broke | |
15:09 |
Always reference cookie files from home dir; API url changes
I forgot to commit the cookie changes awhile back so they've got caught up in a commit fixing the API urls. The cookie stuff just makes sense. Previously the cookie files were stored in the same directory we were running haskerdeux from, which could lead to multiple files. Makes sense to reference one location (home directory). The API changes I found when this stopped working: https://atomicules.co.uk/2017/08/27/Remind-to-Teuxdeux.html Which is friggin' annoying as I almost forgot about Mothering Sunday. Anyway, it seems some of the URLs haven't so much changed, but now don't like trailing slashes in some cases. - new, post, can't have trailing slash Yay for consistency! Hmm... actually I might tweak this further on a following commit as the puts don't make sense to me. check-in: 4af11b69a0 user: atomicules tags: master, origin/issue1, trunk | |
Changes to haskerdeux.hs.
︙ | ︙ | |||
100 101 102 103 104 105 106 | curldelete (token, [date, apiurl, okresponse]) number = do home <- getHomeDirectory let cookies = home ++ "/haskerdeux.cookies" tdsf <- curlget (token, date) let itemid = Main.id $ tdsf!!(read number::Int) let curlheader = "X-CSRF-Token: " ++ token | | | | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | curldelete (token, [date, apiurl, okresponse]) number = do home <- getHomeDirectory let cookies = home ++ "/haskerdeux.cookies" tdsf <- curlget (token, date) let itemid = Main.id $ tdsf!!(read number::Int) let curlheader = "X-CSRF-Token: " ++ token body <- readProcess "curl" ["-s", "-XDELETE", apiurl++"/"++show itemid, "-c", cookies, "-b", cookies, "-H", curlheader] [] let ok = not ("Invalid CSRF Token" `isInfixOf` body) if ok then if "done_updated_at" `isInfixOf` body then putStrLn okresponse else putStrLn "Uh Oh! Didn't work!" else do token <- relogin curldelete (token, [date, apiurl, okresponse]) number curlput (token, [date, json, apiurl, okresponse]) number = do home <- getHomeDirectory let cookies = home ++ "/haskerdeux.cookies" tdsf <- curlget (token, date) let itemid = Main.id $ tdsf!!(read number::Int) let curlheader = "X-CSRF-Token: " ++ token body <- readProcess "curl" ["-s", "-XPUT", apiurl++"/"++show itemid, "-L", "-c", cookies, "-b", cookies, "-H", curlheader, "-H", "Content-Type: application/json", "-d", json] [] let ok = not ("Invalid CSRF Token" `isInfixOf` body) if ok then if "done_updated_at" `isInfixOf` body then putStrLn okresponse else putStrLn "Uh Oh! Didn't work!" else do |
︙ | ︙ | |||
178 179 180 181 182 183 184 | new (token, [todos_date, todo]) = do let encodedtodo = Network.URI.Encode.encode todo curlpost (token, [todos_date, "text", todo, "https://teuxdeux.com/api/v1/todos", "Added!"]) Nothing crossoff (token, [todos_date, number]) = | | | | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | new (token, [todos_date, todo]) = do let encodedtodo = Network.URI.Encode.encode todo curlpost (token, [todos_date, "text", todo, "https://teuxdeux.com/api/v1/todos", "Added!"]) Nothing crossoff (token, [todos_date, number]) = curlput (token, [todos_date, "{ \"done\": true }", "https://teuxdeux.com/api/v1/todos", "Crossed Off!"]) number putoff (token, [todos_date, number]) = do let tomorrows_date = show (addDays 1 $ read todos_date::Data.Time.Day) curlpost (token, [todos_date, "current_date", tomorrows_date, "https://teuxdeux.com/api/v1/todos/reposition", "Put Off!"]) (Just number) moveto (token, [todos_date, number, new_date]) = --TODO: Need to figure out moving to bottom of a list curlpost (token, [todos_date, "current_date", new_date, "https://teuxdeux.com/api/v1/todos/reposition", "Moved!"]) (Just number) remove (token, [todos_date, number]) = curldelete (token, [todos_date, "https://teuxdeux.com/api/v1/todos", "Deleted!"]) number --Thanks to http://www.amateurtopologist.com/blog/2010/11/05/a-haskell-newbies-guide-to-text-json/ and http://hpaste.org/41263/parsing_json_with_textjson data Teuxdeux = Teuxdeux { id :: Integer, current_date :: String, text :: String, done :: Bool } deriving (Eq, Show, Data, Typeable) --Another data type here probably for lists |