diff options
author | Joey Hess <joey@kitenet.net> | 2012-08-01 21:26:36 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-08-01 21:28:37 -0400 |
commit | ffeb060002cd33b7db0fc03b1abacc7b2762b88e (patch) | |
tree | da7f282f24bfdf8fb0c6f1dd72009a3a80543e23 /Assistant/Threads | |
parent | e78b13c42807f598d9dd7e449a5980c26f731f72 (diff) |
don't use hamlet for htmlshim
This allows me to not build-depend on blaze-markup, which was causing
me some trouble when tring to build with cabal on debian. Seems debian
ships Text.Blaze.Renderer.String in two packages.
Diffstat (limited to 'Assistant/Threads')
-rw-r--r-- | Assistant/Threads/WebApp.hs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/Assistant/Threads/WebApp.hs b/Assistant/Threads/WebApp.hs index a5484b5be..e8de408a1 100644 --- a/Assistant/Threads/WebApp.hs +++ b/Assistant/Threads/WebApp.hs @@ -21,16 +21,13 @@ import Assistant.ThreadedMonad import Assistant.DaemonStatus import Assistant.TransferQueue import Utility.WebApp -import Utility.Yesod import Utility.FileMode import Utility.TempFile import Git import Yesod import Yesod.Static -import Text.Hamlet import Network.Socket (PortNumber) -import Text.Blaze.Renderer.String import Data.Text (pack, unpack) thisThread :: String @@ -75,7 +72,7 @@ webAppThread mst dstatus transferqueue postfirstrun onstartup = do else dir go port webapp htmlshim = do writeHtmlShim webapp port htmlshim - maybe noop (\a -> a (myUrl webapp port) htmlshim) onstartup + maybe noop (\a -> a (myUrl webapp port "/") 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. -} @@ -92,10 +89,21 @@ writeHtmlShim webapp port file = do {- TODO: generate this static file using Yesod. -} genHtmlShim :: WebApp -> PortNumber -> String -genHtmlShim webapp port = renderHtml $(shamletFile $ hamletTemplate "htmlshim") +genHtmlShim webapp port = unlines + [ "<html>" + , "<head>" + , "<title>Starting webapp...</title>" + , "<meta http-equiv=\"refresh\" content=\"0; URL="++url++"\">" + , "<body>" + , "<p>" + , "<a href=\"" ++ url ++ "\">Starting webapp...</a>" + , "</p>" + , "</body>" + , "</html>" + ] where - url = myUrl webapp port + url = myUrl webapp port "/" -myUrl :: WebApp -> PortNumber -> Url -myUrl webapp port = "http://localhost:" ++ show port ++ - "/?auth=" ++ unpack (secretToken webapp) +myUrl :: WebApp -> PortNumber -> FilePath -> Url +myUrl webapp port page = "http://localhost:" ++ show port ++ page ++ + "?auth=" ++ unpack (secretToken webapp) |