-
Notifications
You must be signed in to change notification settings - Fork 6
/
Generate101.hs
38 lines (32 loc) · 1.15 KB
/
Generate101.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module Main where
import Data.Aeson
import qualified Data.ByteString.Lazy as BS
import OneOhOne
-- IMPORTANT: Always add new talks at the top of the list!
-- The use of reverse then makes sure that the old entries
-- get to keep their old id numbers that are zipped in
talks :: IO [(Int, Talk)]
talks = do
f <- BS.readFile "_101.json"
case eitherDecode' f of
Left err -> error err
Right ts -> return $ reverse $ zip [(0::Int)..] $ reverse ts
{-
-- aeson-pretty in .cabal file
-- {-# LANGUAGE OverloadedStrings #-}
-- import Data.Aeson.Encode.Pretty
prettyEncode :: [Talk] -> FilePath -> IO ()
prettyEncode ts file = do
let ord = ["tag", "date", "speaker", "institute", "speakerurl", "insturl", "title", "url", "abstract", "location", "locationurl", "description", "material"]
let cfg = defConfig {confIndent = Spaces 2, confCompare = keyOrder ord}
BS.writeFile file $ encodePretty' cfg ts
-}
main :: IO ()
main = do
ts <- talks
let ts' = filter (not . cancelled . snd) ts
generateRSS ts' "msp101.rss"
generateICS ts' "msp101.ics"
generateHTML ts' "msp101.html"
where cancelled CancelledTalk{} = True
cancelled _ = False