Villefort 0.1.1.10 → 0.1.1.11
raw patch · 9 files changed
+73/−95 lines, 9 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Villefort.Definitions: [dataBasePath] :: VConfig -> Maybe String
+ Villefort.Config: defColors :: [[Char]]
+ Villefort.Definitions: [colors] :: VConfig -> [String]
+ Villefort.Todo: getTheme :: (MonadReader VConfig m, MonadIO m) => m String
- Villefort.Definitions: VConfig :: ![[String]] -> [[String]] -> [[String]] -> Weekly -> Int -> Bool -> Maybe String -> Bool -> VConfig
+ Villefort.Definitions: VConfig :: ![[String]] -> [[String]] -> [[String]] -> Weekly -> [String] -> Int -> Bool -> Bool -> VConfig
- Villefort.Todo: getHeader :: IO String
+ Villefort.Todo: getHeader :: (MonadReader VConfig m, MonadIO m) => m String
Files
- README.md +3/−4
- Villefort.cabal +1/−1
- src/Villefort/Config.hs +10/−8
- src/Villefort/Definitions.hs +1/−3
- src/Villefort/Server.hs +25/−22
- src/Villefort/Stats.hs +4/−4
- src/Villefort/Summary.hs +2/−2
- src/Villefort/Todo.hs +16/−8
- templates/header +11/−43
README.md view
@@ -1,10 +1,9 @@ # Villefort Villefort is a time managment system written in Haskell. -## Version 1.1.6 -Now has --- accurate due rankings --- total on today page +## Version 1.1.11 +You can define your own colors. +[default config](https://gist.github.com/Chrisr850/3ca20d75c3ac8aaa585c3140e959fdb1) ## How to copy data between versions of Villefort. Install the new version through cabal
Villefort.cabal view
@@ -1,5 +1,5 @@ name: Villefort-version: 0.1.1.10+version: 0.1.1.11 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
@@ -4,13 +4,14 @@ import Villefort.Definitions import Villefort.Database def = VConfig {- daily = [[]],- monthly =[[]],- yearly =[[]],- weekly = defWeekly,- port = 3002,- noCustom = False,- showDatabase = False+ daily = [[]], --daily tasks+ monthly =[[]], -- not implemented+ yearly =[[]], -- not implemented+ weekly = defWeekly, -- tasks to run on a given week day+ port = 3002, -- port+ noCustom = False, -- flag for debugging stops launching custom executable+ showDatabase = False, -- optionally prints database+ colors = defColors -- Colors to use first is closest task } defWeekly = Weekly {@@ -23,4 +24,5 @@ sunday = [return []] } --- ghc -o /home/chris/.villefort/villefort /home/chris/.villefort/villefort.hs+defColors = ["#0d47a1","#1565c0","#1976d2","#1e88e5","#2196f3","#42a5f5","#64b5f6","#90caf9"]+-- ghc -o /home/chris/.villefort/villefort /home/chris/.villefort/villefort.s
src/Villefort/Definitions.hs view
@@ -5,9 +5,9 @@ monthly :: [[String]], yearly :: [[String]], weekly :: Weekly,+ colors :: [String], port :: Int, noCustom :: Bool,- dataBasePath :: Maybe String, showDatabase :: Bool } @@ -20,5 +20,3 @@ saturday :: [IO[String]], sunday ::[IO[String]] }--
src/Villefort/Server.hs view
@@ -12,7 +12,6 @@ import Villefort.Stats import Villefort.Definitions import Paths_Villefort-import Villefort.Daily import Villefort.Ml import Villefort.Time import Villefort.Summary@@ -22,9 +21,8 @@ import Control.Monad.Reader import System.Process import System.Directory-import System.FilePath import System.Posix.Process-import Paths_Villefort+ getWeeks ::(MonadReader VConfig m,MonadIO m) => m [[[Char]]] getWeeks = do rawSql <- makeQuery "select id, Title from weeks where state = 1 order by Title"@@ -71,21 +69,21 @@ readDate :: IO D readDate = do datePath <- getDataFileName "data/date"- raw <- S.readFile datePath- let date = unpackStringToDate raw+ rawDate <- S.readFile datePath+ let date = unpackStringToDate rawDate return date writeDay :: IO () writeDay = do- day <- show <$> getDay+ newDay <- show <$> getDay datePath <- getDataFileName "data/day"- writeFile datePath day+ writeFile datePath newDay readDay :: IO Int readDay = do datePath <- getDataFileName "data/day"- raw <- S.readFile datePath- let int = read raw :: Int+ rawDay <- S.readFile datePath+ let int = read rawDay :: Int return int checkDay :: D -> D ->Bool@@ -95,6 +93,7 @@ checkYear :: D -> D -> Bool checkYear oldDate currentDate = (year oldDate) == (year currentDate) +runDaily :: VConfig -> D -> D -> IO () runDaily vconf oldDate currentDate= if (checkDay oldDate currentDate) then putStrLn "same-day"@@ -123,22 +122,24 @@ mapM_ add stmts else return () where add = (\x -> if Prelude.null x then return () else runReaderT ( addDaily x) conf)- ++selector :: (Num a, Eq a) => VConfig -> a -> [IO [String]] selector conf x- | x == 0 = monday lookup- | x == 1 = tuesday lookup- | x == 2 = wednesday lookup- | x == 3 = thursday lookup- | x == 4 = friday lookup- | x == 5 = saturday lookup- | otherwise = sunday lookup - where lookup = weekly conf+ | x == 0 = monday lookconf+ | x == 1 = tuesday lookconf+ | x == 2 = wednesday lookconf+ | x == 3 = thursday lookconf+ | x == 4 = friday lookconf+ | x == 5 = saturday lookconf+ | otherwise = sunday lookconf+ where lookconf = weekly conf --man :: IO ()+man :: VConfig -> IO () man conf = do oldDate <- readDate currentDate <- getDateD@@ -150,13 +151,14 @@ writeDay threadDelay 18000000 -+dailyCheck :: VConfig -> IO b dailyCheck conf = forever$ man conf +villefort :: VConfig -> IO () villefort conf = do args <- getArgs case args of- ["--custom",x] -> putStrLn "custom" >> launch conf + ["--custom",_] -> putStrLn "custom" >> launch conf ["--recompile"] -> putStrLn "recompiling" >> recompile _ -> putStrLn "straight starting " >> do if noCustom conf@@ -169,10 +171,11 @@ let execPath = dir ++ "/villefort" sourcePath = dir ++"/villefort.hs" (_,_,_,pid) <- createProcess (proc "/usr/bin/ghc" ["-o",execPath,sourcePath])- waitForProcess pid+ _ <-+ waitForProcess pid return ()- checkCustomBuild = do+ dir <- getAppUserDataDirectory "villefort" let path = dir ++ "/villefort" putStrLn path
src/Villefort/Stats.hs view
@@ -47,8 +47,8 @@ let bot = " ], color: " ++ color ++ " }); </script>" return (header ++ (Prelude.concat q )++ bot) -colors :: [String]-colors = ["'#F44336'"+statsColors :: [String]+statsColors = ["'#F44336'" ,"'#E91E63'" ,"'#9C27B0'" ,"'#673AB7'"@@ -71,6 +71,6 @@ getColor :: IO String getColor = do- number <- randomRIO (0, (length $ colors)-1) :: IO Int- return (colors !! number)+ number <- randomRIO (0, (length $ statsColors)-1) :: IO Int+ return (statsColors !! number)
src/Villefort/Summary.hs view
@@ -7,12 +7,12 @@ import Villefort.Definitions f :: [[String]] -> Int-f x = sum $ map (\x -> read $ x !! 1 :: Int) x+f row = sum $ map (\x -> read $ x !! 1 :: Int) row getSummary :: (MonadReader VConfig m, MonadIO m) => m String getSummary = do dat <- getDone- header <- liftIO $ getHeader+ header <- getHeader return ( header ++ (makeTable ["Subject","Time"] $ dat ++ [["Total", show$ f dat]])) --2017-07-26
src/Villefort/Todo.hs view
@@ -6,7 +6,7 @@ import Villefort.Definitions import Control.Monad.IO.Class import Data.List.Split-import Data.ByteString.Lazy hiding (map,length,take,readFile)+import Data.ByteString.Lazy hiding (map,length,take,readFile,zip) import Paths_Villefort import Database.HDBC import Control.Monad.Reader@@ -110,17 +110,25 @@ getTodos :: (MonadReader VConfig m, MonadIO m) => m String getTodos = do tasks <- qetTasks'- --do liftIO $ putStrLn $ show tasks modals <-liftIO $ sequence $ genModal' <$> tasks- header <- liftIO $ getHeader+ header <- getHeader+ theme <- getTheme let body = Prelude.concat modals- return (header ++ body)+ return (header ++ theme ++ body) -getHeader :: IO String+getTheme :: (MonadReader VConfig m, MonadIO m) => m String+getTheme = do+ userConfig <- ask+ let userColor = colors userConfig+ let mix = zip [0 ..] userColor + return $ "<style>" ++ (mconcat $ map genSelector mix) ++ "</style>"+ where genSelector x = ".btn-due" ++ show (fst x) ++ "{ \n background:" ++ (snd x ) ++ "; \n color: #ffffff; }\n"+ ++getHeader :: (MonadReader VConfig m, MonadIO m) => m String getHeader = do- headerPath <-getDataFileName "templates/header"- header <- liftIO $ readFile headerPath- return header+ headerPath <- liftIO $ getDataFileName "templates/header"+ liftIO $ readFile headerPath -- | Delete a done task from database sets state = 0 but it's record is still maintained in the database for the stats page.
templates/header view
@@ -7,41 +7,15 @@ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>- <style>- .btn-due7{- background: #750787;- color: #ffffff;- }- .btn-due6{- background: #750787;- color: #ffffff;- }- .btn-due5{-background: #008026;- color: #ffffff;- }- .btn-due4{-background: #004DFF;- color: #ffffff;- }- .btn-due3{-background: #008026;- color: #ffffff;- }- .btn-due2{-background: #FFED00;- color: #ffffff;- }- .btn-due1{-background: #FF8C00;- color: #ffffff;- }- .btn-due0{- background: #E40303;- color: #ffffff;- }- - </style>+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>+<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>+<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">+ <script+ src="https://code.jquery.com/jquery-1.10.2.min.js"+ integrity="sha256-C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg="+ crossorigin="anonymous"></script>+ <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">+ > <div class="page"> <h1>Villefort</h1>@@ -67,19 +41,13 @@ </br> </div> -<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">- <script- src="https://code.jquery.com/jquery-1.10.2.min.js"- integrity="sha256-C6CB9UYIS9UJeqinPHWTHVqh/E1uhG5Twh+Y5qFQmYg="- crossorigin="anonymous"></script>+ <style> .page { padding-left:20%; } </style> -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>-<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>- <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">+ <script> $(document).ready(function() { $("#due").datepicker();