From 744b673f20c6993038e10a480bd746db2c1dccb3 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 31 Mar 2020 20:48:56 -0700 Subject: Add tutorial and apidocs to website --- Run/Que/Website.hs | 64 ++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'Run/Que/Website.hs') diff --git a/Run/Que/Website.hs b/Run/Que/Website.hs index 8681678..910d97b 100644 --- a/Run/Que/Website.hs +++ b/Run/Que/Website.hs @@ -28,6 +28,8 @@ main = do , client = src "client.py" , quescripts = src "quescripts.md" , style = src "style.css" + , apidocs = src "apidocs.md" + , tutorial = src "tutorial.md" } data Sources = Sources @@ -35,42 +37,38 @@ data Sources = Sources , quescripts :: FilePath , client :: FilePath , style :: FilePath + , tutorial :: FilePath + , apidocs :: FilePath } loop :: Text -> Sources -> IO () -loop ns pages@Sources {..} = do - _ <- - Async.runConcurrently - $ (,,,) - <$> Async.Concurrently - (toHtml style index >>= serve (https "que.run" /: ns /: "index")) - <*> Async.Concurrently - ( BS.readFile client - >>= serve (https "que.run" /: ns /: "client") - ) - <*> Async.Concurrently - ( toHtml style quescripts - >>= serve (https "que.run" /: ns /: "quescripts") - ) - loop ns pages - - -toHtml :: FilePath -> FilePath -> IO ByteString -toHtml style md = - BS.pack - <$> Process.readProcess - "pandoc" - [ "--self-contained" - , "--css" - , style - , "-i" - , md - , "--from" - , "markdown" - , "--to" - , "html" - ] - [] +loop ns pages@Sources {..} = Async.runConcurrently actions >> loop ns pages + where + actions = traverse + Async.Concurrently + [ toHtml index >>= srv "index" + , toHtml quescripts >>= srv "quescripts" + , BS.readFile client >>= srv "client" + , toHtml tutorial >>= srv "tutorial" + , toHtml apidocs >>= srv "apidocs" + ] + srv p = serve $ https "que.run" /: ns /: p + toHtml :: FilePath -> IO ByteString + toHtml md = + BS.pack + <$> Process.readProcess + "pandoc" + [ "--self-contained" + , "--css" + , style + , "-i" + , md + , "--from" + , "markdown" + , "--to" + , "html" + ] + [] -- TODO: recover from 502 errors serve :: Url scheme -> ByteString -> IO () -- cgit v1.2.3