summaryrefslogtreecommitdiff
path: root/Run/Que/Website.hs
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2020-03-31 20:48:56 -0700
committerBen Sima <ben@bsima.me>2020-03-31 20:51:59 -0700
commit744b673f20c6993038e10a480bd746db2c1dccb3 (patch)
tree6b4372e0b9ecb160974a55a88a32b41e4a835e58 /Run/Que/Website.hs
parent492ba39739c869d3f2b9766112232d384a145e38 (diff)
Add tutorial and apidocs to website
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 ()