diff options
-rw-r--r-- | Assistant/Threads/WebApp.hs | 26 | ||||
-rw-r--r-- | git-annex.cabal | 2 | ||||
-rw-r--r-- | templates/htmlshim.hamlet | 7 |
3 files changed, 18 insertions, 17 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) diff --git a/git-annex.cabal b/git-annex.cabal index de417a4a1..ec96bdc32 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -76,7 +76,7 @@ Executable git-annex if flag(Webapp) Build-Depends: yesod, yesod-static, yesod-default, case-insensitive, http-types, transformers, wai, wai-logger, warp, blaze-builder, - blaze-html, blaze-markup, crypto-api, hamlet, clientsession, + blaze-html, crypto-api, hamlet, clientsession, template-haskell CPP-Options: -DWITH_WEBAPP diff --git a/templates/htmlshim.hamlet b/templates/htmlshim.hamlet deleted file mode 100644 index 073b69c1b..000000000 --- a/templates/htmlshim.hamlet +++ /dev/null @@ -1,7 +0,0 @@ -$doctype 5 -<html> - <head> - <meta http-equiv="refresh" content="0; URL=#{url}"> - <body> - <p> - <a href="#{url}">Starting webapp... |