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.
This commit is contained in:
parent
e78b13c428
commit
ffeb060002
3 changed files with 18 additions and 17 deletions
|
@ -21,16 +21,13 @@ import Assistant.ThreadedMonad
|
||||||
import Assistant.DaemonStatus
|
import Assistant.DaemonStatus
|
||||||
import Assistant.TransferQueue
|
import Assistant.TransferQueue
|
||||||
import Utility.WebApp
|
import Utility.WebApp
|
||||||
import Utility.Yesod
|
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Utility.TempFile
|
import Utility.TempFile
|
||||||
import Git
|
import Git
|
||||||
|
|
||||||
import Yesod
|
import Yesod
|
||||||
import Yesod.Static
|
import Yesod.Static
|
||||||
import Text.Hamlet
|
|
||||||
import Network.Socket (PortNumber)
|
import Network.Socket (PortNumber)
|
||||||
import Text.Blaze.Renderer.String
|
|
||||||
import Data.Text (pack, unpack)
|
import Data.Text (pack, unpack)
|
||||||
|
|
||||||
thisThread :: String
|
thisThread :: String
|
||||||
|
@ -75,7 +72,7 @@ webAppThread mst dstatus transferqueue postfirstrun onstartup = do
|
||||||
else dir
|
else dir
|
||||||
go port webapp htmlshim = do
|
go port webapp htmlshim = do
|
||||||
writeHtmlShim webapp port htmlshim
|
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,
|
{- Creates a html shim file that's used to redirect into the webapp,
|
||||||
- to avoid exposing the secretToken when launching the web browser. -}
|
- 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. -}
|
{- TODO: generate this static file using Yesod. -}
|
||||||
genHtmlShim :: WebApp -> PortNumber -> String
|
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
|
where
|
||||||
url = myUrl webapp port
|
url = myUrl webapp port "/"
|
||||||
|
|
||||||
myUrl :: WebApp -> PortNumber -> Url
|
myUrl :: WebApp -> PortNumber -> FilePath -> Url
|
||||||
myUrl webapp port = "http://localhost:" ++ show port ++
|
myUrl webapp port page = "http://localhost:" ++ show port ++ page ++
|
||||||
"/?auth=" ++ unpack (secretToken webapp)
|
"?auth=" ++ unpack (secretToken webapp)
|
||||||
|
|
|
@ -76,7 +76,7 @@ Executable git-annex
|
||||||
if flag(Webapp)
|
if flag(Webapp)
|
||||||
Build-Depends: yesod, yesod-static, yesod-default, case-insensitive,
|
Build-Depends: yesod, yesod-static, yesod-default, case-insensitive,
|
||||||
http-types, transformers, wai, wai-logger, warp, blaze-builder,
|
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
|
template-haskell
|
||||||
CPP-Options: -DWITH_WEBAPP
|
CPP-Options: -DWITH_WEBAPP
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
$doctype 5
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="refresh" content="0; URL=#{url}">
|
|
||||||
<body>
|
|
||||||
<p>
|
|
||||||
<a href="#{url}">Starting webapp...
|
|
Loading…
Add table
Add a link
Reference in a new issue