From fbaf52d7b852d02ec0b5bfe639715a29024b1a9b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Jan 2013 18:50:30 -0400 Subject: restart UI Browser behavior is not ideal; a new tab is opened on restart. Browsers won't let me redirect to a file:// so I cannot use the old tab. --- Assistant/Threads/WebApp.hs | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'Assistant/Threads') diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs index 58e7de1f6..5ac36f698 100644 --- a/Assistant/Threads/WebApp.hs +++ b/Assistant/Threads/WebApp.hs @@ -29,8 +29,8 @@ import Assistant.WebApp.Control import Assistant.WebApp.OtherRepos import Assistant.Types.ThreadedMonad import Utility.WebApp -import Utility.FileMode import Utility.TempFile +import Utility.FileMode import Git import Yesod @@ -84,36 +84,10 @@ webAppThread assistantdata urlrenderer noannex postfirstrun onstartup = thread $ =<< 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 (`writeFileProtected` url) urlfile + writeHtmlShim "Starting webapp..." 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 - -{- TODO: generate this static file using Yesod. -} -genHtmlShim :: String -> String -genHtmlShim url = unlines - [ "" - , "" - , "Starting webapp..." - , "" - , "" - , "

" - , "Starting webapp..." - , "

" - , "" - , "" - ] - myUrl :: WebApp -> PortNumber -> Url myUrl webapp port = unpack $ yesodRender webapp urlbase HomeR [] where -- cgit v1.2.3