packages feed

Villefort-0.1.2.16: README.md

# Villefort
Villefort is a time management system written in Haskell.

## Version 1.2.15
- New Task Data type with better scheduling options
- Running tasks is now fault tolerant. If one task fails the tasks after it still run.
- You can now store aribitrary vars in the task database

### New Task Data Type
```haskell
data Date = Date {year :: String, -- | The specific date you want a task to be on
                  month :: String,
                  day :: String }
            | Offset {offset :: Int}   -- | The number of days in the future you want the task to be due on 
            | Today -- | Make the task due today
          deriving (Show,Eq)

-- | Villefort's internal representation of Tasks
data Task = Task {title :: String,
                 description :: String,
                 subject :: String,
                 due :: Date} deriving (Show,Eq)

```
Example

```haskell
cs121n :: IO Task
cs121n = pure $ Task {
  title = "cs121 notes",
  description = "Type up cs121 lecture notes",
  subject = "cs121",
  due = Today}
```
### Storing Vars in the Database
```haskell
module Main where

import Villefort.Server (villefort)
import Villefort.Config (defaultConfig,defWeekly)
import Villefort.Definitions
import Villefort.Database
import Control.Monad.Reader
import System.Random

main :: IO ()
main =  check >> villefort conf

conf = defaultConfig {
    database= "dotfiles/todo.db"
    ,weekly = schedule    
  }

-- | checks if vars exists and if they don't initialize them with their default vals
check :: IO ()
check = do
  isBack <- runReaderT (isVar "back" ) conf
  if isBack then pure () else runReaderT (updateVar "back" (show 5.0)) conf
  isCrunch <- runReaderT (isVar "crunch" ) conf
  if isBack then pure () else runReaderT (updateVar "crunch" (show 5.0)) conf


schedule = defWeekly {
   monday = [a121cn
            ,eng301n
            ,a121chw            
            ,back
            ],
   tuesday = [cs101n
             ,cs121n
             ],
   wednesday = [a121cn
               ,eng301n
               ,a121chw
               ,back
               ],
   thursday = [cs101n
              ,cs101hw
              ,crunches
              ],
   friday  =  [eng301n
              ,a121chw
              ,back
              ],
   saturday = [crunches]
   }

cs121hw :: IO Task
cs121hw = pure $ Task {title="cs121 hw",
                       description="Do cs121hw for Friday",
                       subject="cs211",
                       due =Offset 4}
cs101hw :: IO Task          
cs101hw = pure $ Task { title ="cs101 hw",
                        description ="Do cs101hw for Friday",
                        subject = "cs101",
                        due = Offset 7} 
cs101n :: IO Task
cs101n = pure $ Task {
  title = "cs101 notes",
  description = "Type up cs101 lecture notes",
  subject = "cs101",
  due = Today}

cs121n :: IO Task
cs121n = pure $ defTask {
  title = "cs121 notes",
  description = "Type up cs121 lecture notes",
  subject = "cs121"}

eng301n :: IO Task
eng301n = pure $ defTask {
  title = "eng301 notes",
  description = "Type up eng301 lecture notes",
  subject = "eng301"
  }

a121chw :: IO Task
a121chw = pure $ defTask {
  title = "a121c hw",
  description = "Do a121c homework",
  subject = "a121c"
  }
  
a121cn :: IO Task
a121cn = pure $ defTask {
  title = "a121c notes",
  description = "Type up a121c lecture notes",
  subject = "a121c"
  }

cs101 :: IO Task
cs101 = pure $ Task {
  title = "cs101 hw",
  description = "Do cs101hw for Friday",
  subject = "cs101",
  due = Offset 7}
  
back     = exercise "back" 1
crunches = exercise "crunch" 1

exercise var increment = do
  res <- flip runReaderT conf $ getVar var
  putStrLn $ show res
  let num = read res :: Double
  flip runReaderT conf (updateVar var ( show ( num+increment)))
  listB <- gener num
  return $ Task var ("do " ++ show listB++ " " ++ var)   "exercise" Today

gener :: Double -> IO [Int]
gener level = do
  dubs <-  mapM gen $ replicate 5 level :: IO [Double]
  return $ map floor dubs
  where gen x =  randomRIO (x-(x/3),x+(x/3))
```


[default config](https://github.com/alicereuter/Villefort/blob/master/src/Villefort/Config.hs)

# Home screen
![alt text](https://raw.githubusercontent.com/alicereuter/Villefort/master/data/screen.png)
# Add new todos
![alt text](https://raw.githubusercontent.com/alicereuter/Villefort/master/data/screen01.png)
# Stats page 

![alt text](https://raw.githubusercontent.com/alicereuter/Villefort/master/data/screen02.png)

# To install 
1. Install cabal (https://www.haskell.org/platform/)
2. In terminal or command prompt run `cabal install Villefort`.
3. and then `cabal run Villefort`.
4. You will be able to see the home screen by typing localhost:3002 into your favorite browser.

## Configure your villefort
create a custom main method in ~.villefort/villefort.hs. Below is an example.


Use ```Villefort --recompile``` to recompile Villefort with your custom config. Recompilation requires ghc to be in your $PATH.
The next time you run villefort it will run with your custom config. The default Config is found in Villefort.Config. 

## How to copy data between versions of Villefort.
1. Install the new version through cabal.
2. Navigate to ~/.cabal .
3. Navigate to share/ .
4. Navigate into your architecture folder mine is x86_64-linux-ghc-7.10.3.
5. You should now see different versions of Villefort.

Villefort-0.1.2.12/
```
    |-- data/
    |   |-- date
    |   |-- day
    |   |-- todo.db
    |-- templates/
    |-- js.js
```
Villefort-0.1.2.13/
```
	|-- data/
	|   |-- date
	|   |-- day
	|   |-- todo.db
	|-- templates/
	|-- js.js
```
Just copy the data/todo.db from the old version into data/todo.db of the new version.
Remember to rebuild Villefort so that your custom build uses the new version of Villefort.

    Villefort --recompile