antagonist 0.1.0.9 → 0.1.0.11
raw patch · 3 files changed
+20/−4 lines, 3 files
Files
- antagonist.cabal +1/−1
- play.cass +3/−1
- server/Web/Antagonist/Server.hs +16/−2
antagonist.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.9+version: 0.1.0.11 -- A short (one-line) description of the package. synopsis: A web interface to Antisplice dungeons.
play.cass view
@@ -28,5 +28,7 @@ left: 0px #inp background-color: white-.time+.time, .ftime color: #606060+div+ display: inline
server/Web/Antagonist/Server.hs view
@@ -68,8 +68,19 @@ prepOutput s = do u <- liftIO $ mutctime let t = formatTime defaultTimeLocale "<span class=\"time\">[%R]</span> " u- return (concatMap ((++"<br/>").(t++)) $ lines s)+ ms 0 (' ':sx) = let wc = length $ takeWhile (==' ') sx in " " ++ concat (replicate wc " ") ++ ms 0 (drop wc sx)+ ms n ('<':sx) = '<' : ms (n+1) sx+ ms n ('>':sx) = '>' : ms (n-1) sx+ ms n (x:xs) = x : ms n xs+ ms n [] = []+ return (concatMap ((++"<br/>") . ms 0 . (t++)) $ lines s) +prepFeedback :: MonadIO m => String -> m String+prepFeedback s = do+ u <- liftIO mutctime+ let t = formatTime defaultTimeLocale "<span class=\"ftime\"><%R></span> " u+ return (t++s++"<br/>")+ getPrompt :: MonadIO m => SessionState -> m String getPrompt ss = do u <- liftIO $ mutctime@@ -102,7 +113,10 @@ line <- lift $ runInputPost $ id <$> ireq textField "line" ((_,x),r) <- liftIO $ runRecorderT $ runSession ctor ss $ act $ unpack line putSession ssid x none- nss <- prepOutput (ns <> replay r)+ nss1 <- prepOutput ns+ nss2 <- prepOutput $ replay r+ nssF <- prepFeedback $ unpack line+ let nss = nss1 <> nssF <> nss2 ps <- getPrompt x lift $ return $ object [ "news" .= pack nss, "prompt" .= pack ps ]