1
1
mirror of https://github.com/srid/ema.git synced 2024-12-01 23:23:42 +03:00
This commit is contained in:
Sridhar Ratnakumar 2022-07-15 10:41:28 -04:00
parent f8f143fd5c
commit bd0bbd51fc

View File

@ -88,8 +88,7 @@ instance EmaSite Route where
forM_ (Map.toList $ modelDays model) $ \(date, mood) -> do forM_ (Map.toList $ modelDays model) $ \(date, mood) -> do
H.li $ do H.li $ do
let url = Ema.routeUrl rp $ Route_Date date let url = Ema.routeUrl rp $ Route_Date date
H.a ! A.href (H.toValue url) $ H.a ! A.href (H.toValue url) $ show date
show date
": " ": "
show mood show mood
Route_Date d -> do Route_Date d -> do
@ -113,12 +112,14 @@ First add a sample Csv file under `./data/moods.csv` containing:
Now change the `siteInput` function to replace `mempty` with the contents of this Csv file loaded as `Model`: Now change the `siteInput` function to replace `mempty` with the contents of this Csv file loaded as `Model`:
```haskell ```haskell
import Data.Csv qualified as Csv
instance EmaSite Route where instance EmaSite Route where
siteInput _ _ = do siteInput _ _ = do
s <- readFileLBS "data/moods.csv" s <- readFileLBS "data/moods.csv"
case toList <$> Csv.decode Csv.NoHeader s of case toList <$> Csv.decode Csv.NoHeader s of
Left err -> throw $ userError err Left err -> throw $ userError err
Right (moods :: [(Date, Mood)]) -> Right moods ->
pure $ pure $ Model $ Map.fromList moods pure $ pure $ Model $ Map.fromList moods
``` ```