HaskerDeux

Check-in [9a429ebc79]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Hlint changes

Had to hlint on another computer... cannot get it to install on NetBSD

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | origin/issue1 | trunk | master
Files: files | file ages | folders
SHA3-256: 9a429ebc7950936b3ec6ed9fd09dddabadc1dcc508f61e7ba50b0672b729cda3
User & Date: atomicules 2020-05-15 11:56:32
Context
2020-05-15
11:56
Hlint changes

Had to hlint on another computer... cannot get it to install on NetBSD Leaf check-in: 9a429ebc79 user: atomicules tags: origin/issue1, trunk, master

08:29
Handle any case of short day: Mon, mon, MON, etc.

Just because it'll be easier for me to use lowercase. check-in: 386fcc875a user: atomicules tags: origin/issue1, trunk, master

Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to haskerdeux.hs.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
242
243
244
245
246
247
248
249
main = do 
	(date:command:argList) <- getArgs
	time <- getClockTime >>= toCalendarTime --https://wiki.haskell.org/Unix_tools/Date
	let todays_date = formatCalendarTime defaultTimeLocale "%Y-%m-%d" time
	let tomorrows_date = show (addDays 1 $ read todays_date::Data.Time.Day)
	let  todos_date | date == "today" = todays_date
	                | date == "tomorrow" = tomorrows_date
	                | (Data.List.map toLower date) `elem` ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] = parseday ((Data.List.map toLower date), todays_date)
	                | otherwise = date
	when ((command `elem` ["todos"] && Data.List.null argList) || (command `elem` ["new", "crossoff", "putoff", "delete", "nextweek"] && length argList == 1) || (command == "moveto" && length argList == 2)) $ do
		token <- login
		dispatch command (token, todos_date:argList)


parseday (future_day, todays_date) = do
	let days_map = fromList
		[ ("mon", 0)
................................................................................
login  = do
	username <- fmap fst readnetrc
	password <- fmap snd readnetrc
	home <- getHomeDirectory
	savedtoken <- doesFileExist (home ++ "/.haskerdeux-token")
	let cookies = home ++ "/haskerdeux.cookies"
	if savedtoken
		then do
			token <- readFile (home ++ "/.haskerdeux-token")
			return token
		else do
			body <- readProcess "curl" ["-s", "-L", "-c", cookies, "https://teuxdeux.com/login"] []
			token <- getauthtoken body
			writeFile (home ++ "/.haskerdeux-token") token
			let curlheader = "X-CSRF-Token: " ++ token
			let curlpostfields = "username=" ++ username ++ "&password=" ++ password ++ "&authenticity_token=" ++ token
			body <- readProcess "curl" ["-s", "-L", "-c", cookies, "-b", cookies, "-H", curlheader, "-d", curlpostfields, "https://teuxdeux.com/login"] []
			return token


relogin = do
	home <- getHomeDirectory
	removeFile (home ++ "/.haskerdeux-token")
	token <- login
	return token
	

todos (token, [todos_date]) = do
	tdsf <- curlget (token, todos_date)
	putStr $ unlines $ zipWith (\n td -> show n ++ " - " ++ td) [0..] $ Data.List.map text tdsf --numbering from LYAH


new (token, [todos_date, todo]) = do 
................................................................................
    id :: Integer,
	current_date :: String, 
	text :: String,
	done :: Bool
} deriving (Eq, Show, Data, Typeable) 

--Another data type here probably for lists








|

|







 







|
|
<













|
<
|







 







<
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
...
169
170
171
172
173
174
175
176
177

178
179
180
181
182
183
184
185
186
187
188
189
190
191

192
193
194
195
196
197
198
199
...
240
241
242
243
244
245
246

main = do 
	(date:command:argList) <- getArgs
	time <- getClockTime >>= toCalendarTime --https://wiki.haskell.org/Unix_tools/Date
	let todays_date = formatCalendarTime defaultTimeLocale "%Y-%m-%d" time
	let tomorrows_date = show (addDays 1 $ read todays_date::Data.Time.Day)
	let  todos_date | date == "today" = todays_date
	                | date == "tomorrow" = tomorrows_date
	                | Data.List.map toLower date `elem` ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] = parseday (Data.List.map toLower date, todays_date)
	                | otherwise = date
	when (((command == "todos") && Data.List.null argList) || (command `elem` ["new", "crossoff", "putoff", "delete", "nextweek"] && length argList == 1) || (command == "moveto" && length argList == 2)) $ do
		token <- login
		dispatch command (token, todos_date:argList)


parseday (future_day, todays_date) = do
	let days_map = fromList
		[ ("mon", 0)
................................................................................
login  = do
	username <- fmap fst readnetrc
	password <- fmap snd readnetrc
	home <- getHomeDirectory
	savedtoken <- doesFileExist (home ++ "/.haskerdeux-token")
	let cookies = home ++ "/haskerdeux.cookies"
	if savedtoken
		then
			readFile (home ++ "/.haskerdeux-token")

		else do
			body <- readProcess "curl" ["-s", "-L", "-c", cookies, "https://teuxdeux.com/login"] []
			token <- getauthtoken body
			writeFile (home ++ "/.haskerdeux-token") token
			let curlheader = "X-CSRF-Token: " ++ token
			let curlpostfields = "username=" ++ username ++ "&password=" ++ password ++ "&authenticity_token=" ++ token
			body <- readProcess "curl" ["-s", "-L", "-c", cookies, "-b", cookies, "-H", curlheader, "-d", curlpostfields, "https://teuxdeux.com/login"] []
			return token


relogin = do
	home <- getHomeDirectory
	removeFile (home ++ "/.haskerdeux-token")
	login



todos (token, [todos_date]) = do
	tdsf <- curlget (token, todos_date)
	putStr $ unlines $ zipWith (\n td -> show n ++ " - " ++ td) [0..] $ Data.List.map text tdsf --numbering from LYAH


new (token, [todos_date, todo]) = do 
................................................................................
    id :: Integer,
	current_date :: String, 
	text :: String,
	done :: Bool
} deriving (Eq, Show, Data, Typeable) 

--Another data type here probably for lists