summaryrefslogtreecommitdiff
path: root/Run/Que/Website.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Run/Que/Website.hs')
-rw-r--r--Run/Que/Website.hs64
1 files changed, 31 insertions, 33 deletions
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 ()