p7/Main.hs

69 lines
1.8 KiB
Haskell
Raw Normal View History

2018-06-24 21:18:15 -04:00
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses, TemplateHaskell, OverloadedStrings #-}
2018-06-22 00:23:58 -04:00
module Main where
2018-06-21 22:24:42 -04:00
2018-07-01 18:41:33 -04:00
import Data.Time
2018-06-24 21:18:15 -04:00
import Data.List
2018-06-24 19:21:29 -04:00
import Data.Maybe
2018-06-21 22:24:42 -04:00
import Packs
2018-06-24 17:26:43 -04:00
import State
2018-06-24 19:21:29 -04:00
import Format
import Timestamp
2018-06-24 19:47:53 -04:00
import Preview
2018-06-24 21:18:15 -04:00
import Yesod
import Config
2018-06-28 22:20:08 -04:00
import Nrdb
2018-07-01 16:47:13 -04:00
import Text.Lucius
import Utils
2018-06-22 00:23:58 -04:00
2018-06-27 22:49:32 -04:00
data ProtocolSeven = ProtocolSeven
2018-06-24 21:18:15 -04:00
io :: MonadIO io => IO a -> io a
io = liftIO
putStrLnIO :: MonadIO io => String -> io ()
putStrLnIO = io . putStrLn
2018-06-27 22:49:32 -04:00
mkYesod "ProtocolSeven" [parseRoutes|
2018-06-24 21:18:15 -04:00
/ HomeR GET
|]
2018-06-27 22:49:32 -04:00
instance Yesod ProtocolSeven
2018-06-24 21:18:15 -04:00
getHomeR :: Handler Html
2018-06-26 22:43:47 -04:00
getHomeR = defaultLayout $ do
2018-07-01 18:41:33 -04:00
-- Date / Time stuff
sTimeDate <- io $ getZonedTime >>= return . (formatTime defaultTimeLocale "%y %m %d")
let (year, month, day) = (\[a,b,c] -> (a,b,c)) $ map (\x -> read x :: Integer) $ words sTimeDate
2018-06-26 22:43:47 -04:00
let nextMonth = (month + 1) `mod` 12
let ts = toTS (year, month, day)
2018-07-01 18:41:33 -04:00
-- Release Order Big Boxes
let (_,ib,_) = initialRotation
-- Current Format
2018-06-24 21:18:15 -04:00
let ((i,o),b,r) = currentFormat ts
let bx = (\(Bq x) -> x)
let bbout = map show $ catMaybes $ inBoth (bx ib) (tail $ bx b)
2018-07-01 18:41:33 -04:00
let dpout = sort $ map show $ map (\(Ir n) -> n) i
-- Preview
2018-06-24 21:18:15 -04:00
let pr = getPreview ts
2018-06-28 22:20:08 -04:00
let (pdi,pdo,bbi,bbo) = extractPreview pr
let nrdbFormat = nrdbSearch (((map (\(Ir n) -> n) i) ++ (map (\(Or n _) -> n) o)),(catMaybes (bx b)))
let nrdbIn = nrdbSearch (pdi,catMaybes [bbi])
let nrdbOut = nrdbSearch (pdo,catMaybes [bbo])
2018-07-01 18:41:33 -04:00
-- Build Site
2018-06-26 22:43:47 -04:00
setTitle "Protocol Seven"
addScriptRemote "https://fonts.googleapis.com/css?family=Inconsolata"
2018-07-01 16:47:13 -04:00
toWidget $(whamletFile "header.hamlet")
toWidget $(whamletFile "format.hamlet")
toWidget $(whamletFile "about.hamlet")
toWidget $(whamletFile "footer.hamlet")
toWidget $(luciusFile "style.lucius")
2018-06-24 21:18:15 -04:00
main :: IO ()
2018-06-27 22:49:32 -04:00
main = warp 80 ProtocolSeven
2018-06-24 19:21:29 -04:00