summaryrefslogtreecommitdiff
path: root/Assistant/Threads/WebApp.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-29 14:30:10 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-29 14:30:10 -0400
commit48cb08ed2237e0630459e4a70341e129426bded9 (patch)
tree6c8e875628cf797963a367aba81232d858a573b8 /Assistant/Threads/WebApp.hs
parent0b808465e21d667c0826f454bbe88abff79389b7 (diff)
tweak
Diffstat (limited to 'Assistant/Threads/WebApp.hs')
-rw-r--r--Assistant/Threads/WebApp.hs41
1 files changed, 20 insertions, 21 deletions
diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs
index 02911bab9..126c78166 100644
--- a/Assistant/Threads/WebApp.hs
+++ b/Assistant/Threads/WebApp.hs
@@ -75,30 +75,29 @@ webAppThread assistantdata urlrenderer noannex postfirstrun onstartup = thread $
htmlshim <- runThreadState st $ fromRepo gitAnnexHtmlShim
urlfile <- runThreadState st $ fromRepo gitAnnexUrlFile
go port webapp htmlshim (Just urlfile)
- where
- thread = NamedThread thisThread
- getreldir
- | noannex = return Nothing
- | otherwise = Just <$>
- (relHome =<< absPath
- =<< runThreadState (threadState assistantdata) (fromRepo repoPath))
- go port webapp htmlshim urlfile = do
- brokendebug thisThread ["running on port", show port]
- let url = myUrl webapp port
- maybe noop (`writeFile` url) urlfile
- writeHtmlShim url htmlshim
- maybe noop (\a -> a url htmlshim) onstartup
+ where
+ thread = NamedThread thisThread
+ getreldir
+ | noannex = return Nothing
+ | otherwise = Just <$>
+ (relHome =<< absPath
+ =<< runThreadState (threadState assistantdata) (fromRepo repoPath))
+ go port webapp htmlshim urlfile = do
+ let url = myUrl webapp port
+ maybe noop (`writeFile` url) urlfile
+ writeHtmlShim url htmlshim
+ maybe noop (\a -> a url htmlshim) onstartup
{- Creates a html shim file that's used to redirect into the webapp,
- to avoid exposing the secretToken when launching the web browser. -}
writeHtmlShim :: String -> FilePath -> IO ()
writeHtmlShim url file = viaTmp go file $ genHtmlShim url
- where
- go tmpfile content = do
- h <- openFile tmpfile WriteMode
- modifyFileMode tmpfile $ removeModes [groupReadMode, otherReadMode]
- hPutStr h content
- hClose h
+ where
+ go tmpfile content = do
+ h <- openFile tmpfile WriteMode
+ modifyFileMode tmpfile $ removeModes [groupReadMode, otherReadMode]
+ hPutStr h content
+ hClose h
{- TODO: generate this static file using Yesod. -}
genHtmlShim :: String -> String
@@ -117,5 +116,5 @@ genHtmlShim url = unlines
myUrl :: WebApp -> PortNumber -> Url
myUrl webapp port = unpack $ yesodRender webapp urlbase HomeR []
- where
- urlbase = pack $ "http://localhost:" ++ show port
+ where
+ urlbase = pack $ "http://localhost:" ++ show port