parent
7bc077cd8e
commit
13ebf18d24
@ -102,7 +102,21 @@ type Form a = Html -> MForm Handler (FormResult a, Widget)
|
|||||||
-- Please see the documentation for the Yesod typeclass. There are a number
|
-- Please see the documentation for the Yesod typeclass. There are a number
|
||||||
-- of settings which can be configured by overriding methods here.
|
-- of settings which can be configured by overriding methods here.
|
||||||
instance Yesod App where
|
instance Yesod App where
|
||||||
approot = guessApprootOr (ApprootMaster $ appRoot . settings)
|
|
||||||
|
-- Configure the app root, AKA base url, which is prepended to relative hyperlinks.
|
||||||
|
-- Broadly, we'd like this:
|
||||||
|
-- 1. when --base-url has been specified, use that;
|
||||||
|
-- 2. otherwise, guess it from request headers, which helps us respond from the
|
||||||
|
-- same hostname/IP address when hledger-web is accessible at multiple IPs;
|
||||||
|
-- 3. otherwise, leave it empty (relative links stay relative).
|
||||||
|
-- But it's hard to see how to achieve this.
|
||||||
|
-- For now we do (I believe) 1 or 3, with 2 unfortunately not supported.
|
||||||
|
-- Issues include: #2099, #2100, #2127
|
||||||
|
approot =
|
||||||
|
-- ApprootRelative
|
||||||
|
-- ApprootMaster $ appRoot . settings
|
||||||
|
-- guessApprootOr (ApprootMaster $ appRoot . settings)
|
||||||
|
ApprootMaster $ \(App{settings=AppConfig{appRoot=r}, appOpts=WebOpts{base_url_=bu}}) -> if null bu then r else T.pack bu
|
||||||
|
|
||||||
makeSessionBackend _ = do
|
makeSessionBackend _ = do
|
||||||
hledgerdata <- getXdgDirectory XdgCache "hledger"
|
hledgerdata <- getXdgDirectory XdgCache "hledger"
|
||||||
|
|||||||
@ -144,19 +144,23 @@ hledgerWebTest = do
|
|||||||
bodyContains "id=\"transaction-2-1\""
|
bodyContains "id=\"transaction-2-1\""
|
||||||
bodyContains "id=\"transaction-2-2\""
|
bodyContains "id=\"transaction-2-2\""
|
||||||
|
|
||||||
runTests "hledger-web with --base-url"
|
-- #2127
|
||||||
[("base-url","https://base")] nulljournal $ do
|
-- XXX I'm pretty sure this test lies, ie does not match production behaviour.
|
||||||
|
-- (test with curl -s http://localhost:5000/journal | rg '(href)="[\w/].*?"' -o )
|
||||||
yit "hyperlinks respect --base-url" $ do
|
-- App root setup is a maze of twisty passages, all alike.
|
||||||
get JournalR
|
-- runTests "hledger-web with --base-url"
|
||||||
statusIs 200
|
-- [("base-url","https://base")] nulljournal $ do
|
||||||
bodyContains "href=\"https://base"
|
-- yit "hyperlinks respect --base-url" $ do
|
||||||
bodyContains "src=\"https://base"
|
-- get JournalR
|
||||||
|
-- statusIs 200
|
||||||
|
-- bodyContains "href=\"https://base"
|
||||||
|
-- bodyContains "src=\"https://base"
|
||||||
|
|
||||||
-- #2139
|
-- #2139
|
||||||
|
-- XXX Not passing.
|
||||||
|
-- Static root setup is a maze of twisty passages, all different.
|
||||||
-- runTests "hledger-web with --base-url, --file-url"
|
-- runTests "hledger-web with --base-url, --file-url"
|
||||||
-- [("base-url","https://base"), ("file-url","https://files")] nulljournal $ do
|
-- [("base-url","https://base"), ("file-url","https://files")] nulljournal $ do
|
||||||
|
|
||||||
-- yit "static file hyperlinks respect --file-url, others respect --base-url" $ do
|
-- yit "static file hyperlinks respect --file-url, others respect --base-url" $ do
|
||||||
-- get JournalR
|
-- get JournalR
|
||||||
-- statusIs 200
|
-- statusIs 200
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user