packages feed

Villefort 0.1.1.14 → 0.1.1.15

raw patch · 7 files changed

+66/−29 lines, 7 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Villefort.Daily: n :: (MonadReader VConfig m, MonadIO m) => m String
+ Villefort.Daily: genTabs :: (MonadReader VConfig m, MonadIO m) => m String
- Villefort.Definitions: VConfig :: ![[String]] -> [[String]] -> [[String]] -> Weekly -> [String] -> Int -> Bool -> Bool -> String -> VConfig
+ Villefort.Definitions: VConfig :: [IO [String]] -> [[String]] -> [[String]] -> Weekly -> [String] -> Int -> Bool -> Bool -> String -> VConfig
- Villefort.Definitions: [daily] :: VConfig -> ![[String]]
+ Villefort.Definitions: [daily] :: VConfig -> [IO [String]]

Files

Main.hs view
@@ -1,6 +1,11 @@ module Main where  import Villefort+import Villefort.Definitions  main :: IO ()-main = villefort def+main = villefort def {+  port = 3000,+  noCustom = True,+  database = "/home/chris/.cabal/share/x86_64-linux-ghc-7.10.3/Villefort-0.1.1.14/data/todo.db"+                     }
README.md view
@@ -1,9 +1,9 @@ # Villefort
 Villefort is a time managment system written in Haskell.
 
-## Version 1.1.14
-Now you can compare new weekly tab.
-Fixed weekly bug.
+## Version 1.1.15
+- generally cleaned up code base
+- made daily into the IO monad so it matches the weekly tasks
 
 [default config](https://github.com/Chrisr850/Villefort/blob/master/src/Villefort/Config.hs)
 
@@ -22,23 +22,53 @@ 4. You will be able to see the homescreen by typing localhost:3002 into your favorite browser.
 
 ## Configure your villefort
-create a custom main method in ~.villefort/villefort.hs example
+create a custom main method in ~.villefort/villefort.hs. Below is an example.
 
+
 ```haskell
 module Main where
 
 import Villefort
-
+import Villefort.Definitions
+import System.Random
+import System.IO.Strict as S
 
 main :: IO ()
 main = villefort def {
-           -- description			Title	       Subject
-  daily = [[ "","check calendar","admin"]] -- tasks to run daily
+  daily = [floss,
+           calendar ],
   weekly = defWeekly {
-      friday = [return ["Freaky Friday","Friday","Admin"] -- tasks to run every friday
-      },
-  port = 3001
-    }
+    monday = [more,
+             dailyRef],
+    tuesday = [dailyRef],
+    wednesday = [more,
+                dailyRef],
+    thursday  = [dailyRef],
+    friday = [more,
+              scan,
+              dailyRef]
+ 
+    },
+    showDatabase = True
+ }
+
+floss    = pure ["","floss","wellness"]
+calendar = pure ["","check calendar","admin"]
+scan     = pure ["scan class notes","scan","admin"] 
+dailyRef = pure ["write a daily reflection on each class","reflect","admin"]
+
+more = do
+  z <- S.readFile  "/home/chris/.villefort/push"  -- readfile to get # push ups
+  let num = read z :: Double
+  writeFile "/home/chris/.villefort/push" (show (num+0.3))
+  sets <- pushUps num
+  return $ [show sets,"push ups","fit"]
+
+pushUps level = do
+  dubs <-  mapM gen $ replicate 5 level :: IO [Double]
+  return $ map floor dubs
+  where gen x =  randomRIO (x-(x/3),x+(x/3))
+ 
 ```
 
 Then run ```Villefort --recompile```
Villefort.cabal view
@@ -1,5 +1,5 @@ name:                Villefort-version:             0.1.1.14+version:             0.1.1.15 synopsis: Villefort is a task manager and time tracker written in haskell. description: Villefort is a browser based time tracker. homepage:            https://github.com/Chrisr850/Villefort#readme
src/Villefort/Config.hs view
@@ -5,7 +5,7 @@ import Villefort.Database  def = VConfig {-  daily = [[]], --daily tasks+  daily = [return []], --daily tasks   monthly =[[]], -- not implemented   yearly =[[]], --  not implemented   weekly = defWeekly, -- tasks to run on a given week day
src/Villefort/Daily.hs view
@@ -21,9 +21,8 @@   (_,numWeek,_) <- liftIO $ toWeekDate <$> getDate   let addWeek = ( ("<h1> Week " ++ show numWeek ++ "</h1> ") ++ )   z <-  (header ++ ) <$> addWeek <$> mconcat <$> mapM getSummaryDay  dates-  d <- n+  d <- genTabs   return $ z ++ d-             getSummaryDay :: (MonadReader VConfig m, MonadIO m) => Day -> m String getSummaryDay day = do@@ -44,24 +43,24 @@   t z   where t  = (\x -> getSubWeek (show $ x !! 0) (show $ x !! 1)) -n :: (MonadReader VConfig m, MonadIO m) => m String-n = do+genTabs :: (MonadReader VConfig m, MonadIO m) => m String+genTabs = do   z <- p   t <- st+  f <- liftIO $ getDatesOfPrevWeek+  n <- liftIO $ getDatesOfThisWeek   let q =  sortBy ( compare  `on` head) $ z ++ t--  return $ makeTable ["Subject","Last week","This week"] $ spec q+  return $ makeTable ["Subject","Last week"++ show f,"This week" ++ show n] $ spec q   spec :: [[String]] -> [[String]] spec (x:y:z) = if head x ==  head y                   then [[head x] ++ tail x ++ tail y] ++ spec (y:z)                        else spec (y:z)-+                             spec (x:y:[]) = if head x ==  (head y)                   then [[head x], tail x ++ (tail y)] ++ spec [y]                        else spec [y]  spec (x:[]) = [x] spec [] = []-
src/Villefort/Definitions.hs view
@@ -1,7 +1,7 @@ module Villefort.Definitions where  data VConfig  = VConfig {-  daily :: ![[String]],+  daily :: [IO [String]],   monthly :: [[String]],   yearly :: [[String]],   weekly :: Weekly,
src/Villefort/Server.hs view
@@ -99,8 +99,12 @@   if (checkDay oldDate currentDate) then     putStrLn "same-day"   else-    putStrLn "adding-daily" >> putStrLn (show ( daily vconf)) >> runReaderT ( mapM_ addDaily (daily vconf)) vconf -               +    putStrLn "adding-daily" >> do+    dailies <- sequence (daily vconf)+    mapM_ add dailies+    where add = (\x -> if Prelude.null x then return () else runReaderT ( addDaily x) vconf)++     runMonthly :: D -> D -> IO () runMonthly oldDate currentDate = if(checkMonth oldDate currentDate) then   putStrLn "same-month"@@ -175,8 +179,9 @@   _ <-     waitForProcess pid   return ()-checkCustomBuild = do +checkCustomBuild :: IO ()+checkCustomBuild = do   dir <- getAppUserDataDirectory "villefort"   let path = dir ++ "/villefort"   putStrLn path@@ -242,11 +247,9 @@       to <- liftIO $ runReaderT weeklyStats conf       html $ pack to -    get "/arst" $ do-      z <- liftIO $ runReaderT n conf-      html $ pack z            get "/stat" $ do       page <- liftIO $runReaderT  genStats conf       html $ pack page+