Merge remote-tracking branch 'origin/master' into yesod1.2
Conflicts: yesod-core/yesod-core.cabal yesod-json/yesod-json.cabal
This commit is contained in:
commit
eda98f96db
@ -37,7 +37,7 @@ Isolating an entire project with a virtual machine is also a great idea, you jus
|
||||
cabal-dev creates a sandboxed environment for an individual cabal package.
|
||||
Instead of using the `cabal` command, use the `cabal-dev` command which will use the sandbox.
|
||||
|
||||
Use `yesod-devel --dev` when developing your application.
|
||||
Use `yesod devel --dev` when developing your application.
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-auth-oauth
|
||||
version: 1.1.0.1
|
||||
version: 1.1.0.2
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
author: Hiromi Ishii
|
||||
@ -21,7 +21,7 @@ library
|
||||
else
|
||||
build-depends: base >= 4 && < 4.3
|
||||
build-depends: authenticate-oauth >= 1.4 && < 1.5
|
||||
, bytestring >= 0.9.1.4 && < 0.10
|
||||
, bytestring >= 0.9.1.4
|
||||
, yesod-core >= 1.1 && < 1.2
|
||||
, yesod-auth >= 1.1 && < 1.2
|
||||
, text >= 0.7 && < 0.12
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Yesod.Auth.BrowserId
|
||||
( authBrowserId
|
||||
, authBrowserIdAudience
|
||||
@ -19,6 +20,8 @@ import Control.Exception (throwIO)
|
||||
import Text.Julius (julius, rawJS)
|
||||
import Data.Aeson (toJSON)
|
||||
import Network.URI (uriPath, parseURI)
|
||||
import Data.FileEmbed (embedFile)
|
||||
import Data.ByteString (ByteString)
|
||||
|
||||
pid :: Text
|
||||
pid = "browserid"
|
||||
@ -62,6 +65,10 @@ helper maudience = AuthPlugin
|
||||
, credsIdent = email
|
||||
, credsExtra = []
|
||||
}
|
||||
("GET", ["static", "sign-in.png"]) -> sendResponse
|
||||
( "image/png" :: ByteString
|
||||
, toContent $(embedFile "persona_sign_in_blue.png")
|
||||
)
|
||||
(_, []) -> badMethod
|
||||
_ -> notFound
|
||||
, apLogin = \toMaster -> do
|
||||
@ -76,10 +83,11 @@ helper maudience = AuthPlugin
|
||||
$newline never
|
||||
<p>
|
||||
<a href="javascript:#{onclick}()">
|
||||
<img src="https://browserid.org/i/sign_in_green.png">
|
||||
<img src=@{toMaster loginIcon}>
|
||||
|]
|
||||
}
|
||||
where
|
||||
loginIcon = PluginR pid ["static", "sign-in.png"]
|
||||
stripScheme t = fromMaybe t $ T.stripPrefix "//" $ snd $ T.breakOn "//" t
|
||||
|
||||
-- | Generates a function to handle on-click events, and returns that function
|
||||
|
||||
BIN
yesod-auth/persona_sign_in_blue.png
Normal file
BIN
yesod-auth/persona_sign_in_blue.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
@ -1,5 +1,5 @@
|
||||
name: yesod-auth
|
||||
version: 1.1.4.1
|
||||
version: 1.1.5.3
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman, Patrick Brisbin
|
||||
@ -11,37 +11,39 @@ cabal-version: >= 1.6.0
|
||||
build-type: Simple
|
||||
homepage: http://www.yesodweb.com/
|
||||
description: Authentication for Yesod.
|
||||
extra-source-files: persona_sign_in_blue.png
|
||||
|
||||
library
|
||||
build-depends: base >= 4 && < 5
|
||||
, authenticate >= 1.3 && < 1.4
|
||||
, authenticate >= 1.3
|
||||
, bytestring >= 0.9.1.4
|
||||
, yesod-core >= 1.1 && < 1.2
|
||||
, wai >= 1.3 && < 1.4
|
||||
, wai >= 1.3
|
||||
, template-haskell
|
||||
, pureMD5 >= 2.0 && < 2.2
|
||||
, random >= 1.0.0.2 && < 1.1
|
||||
, text >= 0.7 && < 0.12
|
||||
, mime-mail >= 0.3 && < 0.5
|
||||
, yesod-persistent >= 1.1 && < 1.2
|
||||
, pureMD5 >= 2.0
|
||||
, random >= 1.0.0.2
|
||||
, text >= 0.7
|
||||
, mime-mail >= 0.3
|
||||
, yesod-persistent >= 1.1
|
||||
, hamlet >= 1.1 && < 1.2
|
||||
, shakespeare-css >= 1.0 && < 1.1
|
||||
, shakespeare-js >= 1.0.2 && < 1.2
|
||||
, containers
|
||||
, unordered-containers
|
||||
, yesod-form >= 1.1 && < 1.3
|
||||
, transformers >= 0.2.2 && < 0.4
|
||||
, transformers >= 0.2.2
|
||||
, persistent >= 1.0 && < 1.2
|
||||
, persistent-template >= 1.0 && < 1.2
|
||||
, SHA >= 1.4.1.3 && < 1.7
|
||||
, http-conduit >= 1.5 && < 1.9
|
||||
, SHA >= 1.4.1.3
|
||||
, http-conduit >= 1.5
|
||||
, aeson >= 0.5
|
||||
, pwstore-fast >= 2.2 && < 3
|
||||
, pwstore-fast >= 2.2
|
||||
, lifted-base >= 0.1
|
||||
, blaze-html >= 0.5 && < 0.6
|
||||
, blaze-markup >= 0.5.1 && < 0.6
|
||||
, blaze-html >= 0.5
|
||||
, blaze-markup >= 0.5.1
|
||||
, network
|
||||
, http-types
|
||||
, file-embed
|
||||
|
||||
exposed-modules: Yesod.Auth
|
||||
Yesod.Auth.BrowserId
|
||||
|
||||
@ -1056,10 +1056,16 @@ instance MonadResource (GHandler sub master) where
|
||||
#endif
|
||||
|
||||
instance MonadLogger (GHandler sub master) where
|
||||
#if MIN_VERSION_monad_logger(0, 3, 0)
|
||||
monadLoggerLog a b c d = do
|
||||
hd <- ask
|
||||
liftIO $ handlerLog hd a b c (toLogStr d)
|
||||
#else
|
||||
monadLoggerLog a c d = monadLoggerLogSource a "" c d
|
||||
monadLoggerLogSource a b c d = do
|
||||
hd <- ask
|
||||
liftIO $ handlerLog hd a b c (toLogStr d)
|
||||
#endif
|
||||
|
||||
instance Exception e => Failure e (GHandler sub master) where
|
||||
failure = liftIO . throwIO
|
||||
|
||||
@ -909,6 +909,9 @@ runFakeHandler fakeSessionMap logger master handler = liftIO $ do
|
||||
, W.queryString = []
|
||||
, W.requestBody = mempty
|
||||
, W.vault = mempty
|
||||
#if MIN_VERSION_wai(1, 4, 0)
|
||||
, W.requestBodyLength = W.KnownLength 0
|
||||
#endif
|
||||
}
|
||||
fakeRequest =
|
||||
Request
|
||||
|
||||
@ -313,5 +313,9 @@ instance MonadResource (GWidget sub master) where
|
||||
#endif
|
||||
|
||||
instance MonadLogger (GWidget sub master) where
|
||||
#if MIN_VERSION_monad_logger(0, 3, 0)
|
||||
monadLoggerLog a b c = lift . monadLoggerLog a b c
|
||||
#else
|
||||
monadLoggerLog a b = lift . monadLoggerLog a b
|
||||
monadLoggerLogSource a b c = lift . monadLoggerLogSource a b c
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-core
|
||||
version: 1.1.8
|
||||
version: 1.1.8.2
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -50,7 +50,7 @@ library
|
||||
build-depends: base >= 4.3 && < 5
|
||||
, time >= 1.1.4
|
||||
, yesod-routes >= 1.1 && < 1.2
|
||||
, wai >= 1.3 && < 1.4
|
||||
, wai >= 1.3 && < 1.5
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, bytestring >= 0.9.1.4
|
||||
, text >= 0.7 && < 0.12
|
||||
@ -79,13 +79,13 @@ library
|
||||
, vector >= 0.9 && < 0.11
|
||||
, aeson >= 0.5
|
||||
, fast-logger >= 0.2
|
||||
, monad-logger >= 0.2.1 && < 0.3
|
||||
, conduit >= 0.5 && < 0.6
|
||||
, monad-logger >= 0.2.1 && < 0.4
|
||||
, conduit >= 0.5
|
||||
, resourcet >= 0.3 && < 0.5
|
||||
, lifted-base >= 0.1
|
||||
, blaze-html >= 0.5 && < 0.6
|
||||
, blaze-markup >= 0.5.1 && < 0.6
|
||||
, attoparsec-conduit
|
||||
, blaze-html >= 0.5
|
||||
, blaze-markup >= 0.5.1
|
||||
|
||||
exposed-modules: Yesod.Content
|
||||
Yesod.Core
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-default
|
||||
version: 1.1.3
|
||||
version: 1.1.3.2
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Patrick Brisbin
|
||||
@ -20,7 +20,7 @@ library
|
||||
build-depends: base >= 4 && < 5
|
||||
, yesod-core >= 1.1 && < 1.2
|
||||
, warp >= 1.3 && < 1.4
|
||||
, wai >= 1.3 && < 1.4
|
||||
, wai >= 1.3 && < 1.5
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, bytestring >= 0.9.1.4
|
||||
, transformers >= 0.2.2 && < 0.4
|
||||
@ -30,7 +30,7 @@ library
|
||||
, shakespeare-js >= 1.0 && < 1.2
|
||||
, template-haskell
|
||||
, yaml >= 0.8 && < 0.9
|
||||
, network-conduit >= 0.5 && < 0.7
|
||||
, network-conduit >= 0.5
|
||||
, unordered-containers
|
||||
, hamlet >= 1.1 && < 1.2
|
||||
, data-default
|
||||
|
||||
@ -328,7 +328,7 @@ $newline never
|
||||
<script>if (!('autofocus' in document.createElement('input'))) {document.getElementById('#{theId}').focus();}
|
||||
|]
|
||||
toWidget [cassius|
|
||||
#{theId}
|
||||
##{theId}
|
||||
-webkit-appearance: textfield
|
||||
|]
|
||||
, fieldEnctype = UrlEncoded
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-form
|
||||
version: 1.2.1.1
|
||||
version: 1.2.1.3
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -22,20 +22,20 @@ library
|
||||
, shakespeare-js >= 1.0.2 && < 1.2
|
||||
, persistent >= 1.0 && < 1.2
|
||||
, template-haskell
|
||||
, transformers >= 0.2.2 && < 0.4
|
||||
, transformers >= 0.2.2
|
||||
, data-default
|
||||
, xss-sanitize >= 0.3.0.1 && < 0.4
|
||||
, blaze-builder >= 0.2.1.4 && < 0.4
|
||||
, xss-sanitize >= 0.3.0.1
|
||||
, blaze-builder >= 0.2.1.4
|
||||
, network >= 2.2
|
||||
, email-validate >= 0.2.6
|
||||
, bytestring >= 0.9.1.4
|
||||
, text >= 0.9 && < 1.0
|
||||
, wai >= 1.3 && < 1.4
|
||||
, text >= 0.9
|
||||
, wai >= 1.3
|
||||
, containers >= 0.2
|
||||
, blaze-html >= 0.5 && < 0.6
|
||||
, blaze-markup >= 0.5.1 && < 0.6
|
||||
, attoparsec >= 0.10 && < 0.11
|
||||
, crypto-api >= 0.8 && < 0.11
|
||||
, blaze-html >= 0.5
|
||||
, blaze-markup >= 0.5.1
|
||||
, attoparsec >= 0.10
|
||||
, crypto-api >= 0.8
|
||||
, aeson
|
||||
|
||||
exposed-modules: Yesod.Form
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-newsfeed
|
||||
version: 1.1.0
|
||||
version: 1.1.0.1
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman, Patrick Brisbin
|
||||
@ -18,10 +18,10 @@ library
|
||||
, time >= 1.1.4
|
||||
, hamlet >= 1.1 && < 1.2
|
||||
, bytestring >= 0.9.1.4
|
||||
, text >= 0.9 && < 0.12
|
||||
, xml-conduit >= 1.0 && < 1.1
|
||||
, blaze-html >= 0.5 && < 0.6
|
||||
, blaze-markup >= 0.5.1 && < 0.6
|
||||
, text >= 0.9
|
||||
, xml-conduit >= 1.0
|
||||
, blaze-html >= 0.5
|
||||
, blaze-markup >= 0.5.1
|
||||
, containers
|
||||
|
||||
exposed-modules: Yesod.AtomFeed
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-platform
|
||||
version: 1.1.7.2
|
||||
version: 1.1.8
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -17,33 +17,32 @@ library
|
||||
, ReadArgs == 1.2.1
|
||||
, SHA == 1.6.1
|
||||
, aeson == 0.6.1.0
|
||||
, ansi-terminal == 0.5.5.1
|
||||
, ansi-terminal == 0.6
|
||||
, asn1-data == 0.7.1
|
||||
, attoparsec == 0.10.3.0
|
||||
, attoparsec-conduit == 0.5.0.3
|
||||
, authenticate == 1.3.2
|
||||
, attoparsec == 0.10.4.0
|
||||
, attoparsec-conduit == 1.0.0
|
||||
, authenticate == 1.3.2.6
|
||||
, base-unicode-symbols == 0.2.2.4
|
||||
, base64-bytestring == 1.0.0.0
|
||||
, base64-conduit == 0.5.1
|
||||
, basic-prelude == 0.3.2.0
|
||||
, base64-bytestring == 1.0.0.1
|
||||
, base64-conduit == 1.0.0
|
||||
, basic-prelude == 0.3.4.0
|
||||
, blaze-builder == 0.3.1.0
|
||||
, blaze-builder-conduit == 0.5.0.3
|
||||
, blaze-html == 0.5.1.3
|
||||
, blaze-builder-conduit == 1.0.0
|
||||
, blaze-html == 0.6.0.0
|
||||
, blaze-markup == 0.5.1.4
|
||||
, byteorder == 1.0.3
|
||||
, case-insensitive == 0.4.0.4
|
||||
, case-insensitive == 1.0
|
||||
, cereal == 0.3.5.2
|
||||
, certificate == 1.3.5
|
||||
, cipher-aes == 0.1.7
|
||||
, cipher-rc4 == 0.1.2
|
||||
, classy-prelude == 0.4.3
|
||||
, classy-prelude-conduit == 0.4.3
|
||||
, classy-prelude == 0.5.3
|
||||
, clientsession == 0.8.1
|
||||
, conduit == 0.5.6
|
||||
, conduit == 1.0.2
|
||||
, cookie == 0.4.0.1
|
||||
, cprng-aes == 0.3.4
|
||||
, crypto-api == 0.10.2
|
||||
, crypto-conduit == 0.4.3
|
||||
, crypto-api == 0.11
|
||||
, crypto-conduit == 0.5.0
|
||||
, crypto-numbers == 0.1.3
|
||||
, crypto-pubkey == 0.1.2
|
||||
, crypto-pubkey-types == 0.2.0
|
||||
@ -53,66 +52,65 @@ library
|
||||
, data-default == 0.5.0
|
||||
, date-cache == 0.3.0
|
||||
, dlist == 0.5
|
||||
, email-validate == 0.3.2
|
||||
, email-validate == 1.0.0
|
||||
, entropy == 0.2.1
|
||||
, failure == 0.2.0.1
|
||||
, fast-logger == 0.3.1
|
||||
, file-embed == 0.0.4.7
|
||||
, filesystem-conduit == 0.5.0.2
|
||||
, filesystem-conduit == 1.0.0
|
||||
, fsnotify == 0.0.6
|
||||
, ghc-paths == 0.1.0.9
|
||||
, hamlet == 1.1.3.1
|
||||
, hamlet == 1.1.6.3
|
||||
, hashable == 1.2.0.5
|
||||
, hjsmin == 0.1.4
|
||||
, hspec == 1.4.3
|
||||
, hjsmin == 0.1.4.1
|
||||
, hspec == 1.4.4
|
||||
, hspec-expectations == 0.3.0.3
|
||||
, html-conduit == 0.1.0.4
|
||||
, http-conduit == 1.8.7
|
||||
, html-conduit == 1.1.0
|
||||
, http-conduit == 1.9.0
|
||||
, http-date == 0.0.4
|
||||
, http-reverse-proxy == 0.1.1.1
|
||||
, http-types == 0.7.3.0.1
|
||||
, http-reverse-proxy == 0.1.1.3
|
||||
, http-types == 0.8.0
|
||||
, language-javascript == 0.5.7
|
||||
, largeword == 1.0.4
|
||||
, lifted-base == 0.2.0.2
|
||||
, mime-mail == 0.4.1.2
|
||||
, mime-types == 0.1.0.2
|
||||
, mime-types == 0.1.0.3
|
||||
, monad-control == 0.3.1.4
|
||||
, monad-logger == 0.2.3.2
|
||||
, network-conduit == 0.6.2.2
|
||||
, monad-logger == 0.3.0.1
|
||||
, network-conduit == 1.0.0
|
||||
, optparse-applicative == 0.5.2.1
|
||||
, path-pieces == 0.1.2
|
||||
, pem == 0.1.2
|
||||
, persistent == 1.1.4
|
||||
, persistent-template == 1.1.2.1
|
||||
, persistent == 1.1.5.1
|
||||
, persistent-template == 1.1.2.4
|
||||
, pool-conduit == 0.1.1
|
||||
, primitive == 0.5.0.1
|
||||
, project-template == 0.1.1
|
||||
, project-template == 0.1.3
|
||||
, publicsuffixlist == 0.0.3
|
||||
, pureMD5 == 2.1.2.1
|
||||
, pwstore-fast == 2.3
|
||||
, ranges == 0.2.4
|
||||
, resource-pool == 0.2.1.1
|
||||
, resourcet == 0.4.4
|
||||
, resourcet == 0.4.5
|
||||
, safe == 0.3.3
|
||||
, semigroups == 0.9
|
||||
, setenv == 0.1.0
|
||||
, shakespeare == 1.0.2
|
||||
, shakespeare-css == 1.0.2
|
||||
, shakespeare == 1.0.3.1
|
||||
, shakespeare-css == 1.0.3
|
||||
, shakespeare-i18n == 1.0.0.2
|
||||
, shakespeare-js == 1.1.1
|
||||
, shakespeare-js == 1.1.2.1
|
||||
, shakespeare-text == 1.0.0.5
|
||||
, silently == 1.2.4.1
|
||||
, simple-sendfile == 0.2.10
|
||||
, skein == 0.1.0.11
|
||||
, socks == 0.4.2
|
||||
, split == 0.2.1.1
|
||||
, simple-sendfile == 0.2.11
|
||||
, skein == 0.1.0.12
|
||||
, socks == 0.5.0
|
||||
, split == 0.2.1.2
|
||||
, stringsearch == 0.3.6.4
|
||||
, system-fileio == 0.3.11
|
||||
, system-filepath == 0.4.7
|
||||
, tagged == 0.4.4
|
||||
, tagsoup == 0.12.8
|
||||
, tagstream-conduit == 0.5.3
|
||||
, tagstream-conduit == 0.5.4
|
||||
, tar == 0.4.0.1
|
||||
, tls == 1.1.1
|
||||
, tls == 1.1.2
|
||||
, tls-extra == 0.6.1
|
||||
, transformers-base == 0.4.1
|
||||
, unix-compat == 0.4.1.0
|
||||
@ -122,29 +120,29 @@ library
|
||||
, vault == 0.2.0.4
|
||||
, vector == 0.10.0.1
|
||||
, void == 0.5.11
|
||||
, wai == 1.3.0.1
|
||||
, wai-app-static == 1.3.1
|
||||
, wai-extra == 1.3.2
|
||||
, wai == 1.4.0
|
||||
, wai-app-static == 1.3.1.2
|
||||
, wai-extra == 1.3.2.4
|
||||
, wai-logger == 0.3.0
|
||||
, wai-test == 1.3.0
|
||||
, warp == 1.3.7.1
|
||||
, wai-test == 1.3.0.4
|
||||
, warp == 1.3.7.4
|
||||
, word8 == 0.0.3
|
||||
, xml-conduit == 1.0.3.3
|
||||
, xml-conduit == 1.1.0.3
|
||||
, xml-types == 0.3.3
|
||||
, xss-sanitize == 0.3.3
|
||||
, yaml == 0.8.2
|
||||
, yesod == 1.1.7.2
|
||||
, yesod-auth == 1.1.3
|
||||
, yesod-core == 1.1.7.1
|
||||
, yesod-default == 1.1.3
|
||||
, yesod-form == 1.2.0.2
|
||||
, yesod-json == 1.1.2
|
||||
, yaml == 0.8.2.3
|
||||
, yesod == 1.1.9.2
|
||||
, yesod-auth == 1.1.5.3
|
||||
, yesod-core == 1.1.8.2
|
||||
, yesod-default == 1.1.3.2
|
||||
, yesod-form == 1.2.1.3
|
||||
, yesod-json == 1.1.2.1
|
||||
, yesod-persistent == 1.1.0.1
|
||||
, yesod-routes == 1.1.1.1
|
||||
, yesod-static == 1.1.1.2
|
||||
, yesod-test == 0.3.3
|
||||
, yesod-routes == 1.1.2
|
||||
, yesod-static == 1.1.2.2
|
||||
, yesod-test == 0.3.5
|
||||
, zlib-bindings == 0.1.1.3
|
||||
, zlib-conduit == 0.5.0.3
|
||||
, zlib-conduit == 1.0.0
|
||||
|
||||
exposed-modules: Yesod.Platform
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-sitemap
|
||||
version: 1.1.0
|
||||
version: 1.1.0.1
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -16,7 +16,7 @@ library
|
||||
build-depends: base >= 4 && < 5
|
||||
, yesod-core >= 1.1 && < 1.2
|
||||
, time >= 1.1.4
|
||||
, xml-conduit >= 1.0 && < 1.1
|
||||
, xml-conduit >= 1.0
|
||||
, text
|
||||
, containers
|
||||
exposed-modules: Yesod.Sitemap
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-static
|
||||
version: 1.1.2
|
||||
version: 1.1.2.2
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -31,13 +31,13 @@ library
|
||||
, directory >= 1.0
|
||||
, transformers >= 0.2.2
|
||||
, wai-app-static >= 1.3 && < 1.4
|
||||
, wai >= 1.3 && < 1.4
|
||||
, wai >= 1.3 && < 1.5
|
||||
, text >= 0.9
|
||||
, file-embed >= 0.0.4.1 && < 0.5
|
||||
, http-types >= 0.7
|
||||
, unix-compat >= 0.2
|
||||
, conduit >= 0.5 && < 0.6
|
||||
, crypto-conduit >= 0.4 && < 0.5
|
||||
, conduit >= 0.5
|
||||
, crypto-conduit >= 0.4
|
||||
, cryptohash >= 0.6.1
|
||||
, system-filepath >= 0.4.6 && < 0.5
|
||||
exposed-modules: Yesod.Static
|
||||
|
||||
@ -52,7 +52,7 @@ module Yesod.Test (
|
||||
|
||||
-- * Assertions
|
||||
assertEqual, assertHeader, assertNoHeader, statusIs, bodyEquals, bodyContains,
|
||||
htmlAllContain, htmlCount,
|
||||
htmlAllContain, htmlAnyContain, htmlCount,
|
||||
|
||||
-- * Utils for debugging tests
|
||||
printBody, printMatches,
|
||||
@ -253,6 +253,18 @@ htmlAllContain query search = do
|
||||
_ -> liftIO $ HUnit.assertBool ("Not all "++T.unpack query++" contain "++search) $
|
||||
DL.all (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches)
|
||||
|
||||
-- | Queries the html using a css selector, and passes if any matched
|
||||
-- element contains the given string.
|
||||
--
|
||||
-- Since 0.3.5
|
||||
htmlAnyContain :: HoldsResponse a => Query -> String -> ST.StateT a IO ()
|
||||
htmlAnyContain query search = do
|
||||
matches <- htmlQuery query
|
||||
case matches of
|
||||
[] -> failure $ "Nothing matched css query: " <> query
|
||||
_ -> liftIO $ HUnit.assertBool ("None of "++T.unpack query++" contain "++search) $
|
||||
DL.any (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches)
|
||||
|
||||
-- | Performs a css query on the last response and asserts the matched elements
|
||||
-- are as many as expected.
|
||||
htmlCount :: HoldsResponse a => Query -> Int -> ST.StateT a IO ()
|
||||
@ -437,9 +449,13 @@ doRequestHeaders method url extrahead paramsBuild = do
|
||||
{ requestMethod = method
|
||||
, remoteHost = Sock.SockAddrInet 1 2
|
||||
, requestHeaders = headers
|
||||
, rawPathInfo = url
|
||||
, pathInfo = DL.filter (/="") $ T.split (== '/') $ TE.decodeUtf8 url
|
||||
, rawPathInfo = urlPath
|
||||
, pathInfo = DL.filter (/="") $ T.split (== '/') $ TE.decodeUtf8 urlPath
|
||||
, rawQueryString = urlQuery
|
||||
, queryString = H.parseQuery urlQuery
|
||||
}
|
||||
|
||||
(urlPath, urlQuery) = BS8.break (== '?') url
|
||||
|
||||
-- | Run a persistent db query. For asserting on the results of performed actions
|
||||
-- or setting up pre-conditions. At the moment this part is still very raw.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod-test
|
||||
version: 0.3.3.1
|
||||
version: 0.3.5
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Nubis <nubis@woobiz.com.ar>
|
||||
@ -15,24 +15,24 @@ extra-source-files: README.md, LICENSE, test/main.hs
|
||||
|
||||
library
|
||||
build-depends: base >= 4.3 && < 5
|
||||
, attoparsec >= 0.10 && < 0.11
|
||||
, persistent >= 1.0 && < 1.2
|
||||
, transformers >= 0.2.2 && < 0.4
|
||||
, wai >= 1.3 && < 1.4
|
||||
, wai-test >= 1.3 && < 1.4
|
||||
, attoparsec >= 0.10
|
||||
, persistent >= 1.0
|
||||
, transformers >= 0.2.2
|
||||
, wai >= 1.3
|
||||
, wai-test >= 1.3
|
||||
, network >= 2.2
|
||||
, http-types >= 0.7
|
||||
, HUnit >= 1.2 && < 1.3
|
||||
, HUnit >= 1.2
|
||||
, hspec >= 1.4
|
||||
, bytestring >= 0.9
|
||||
, case-insensitive >= 0.2
|
||||
, text
|
||||
, xml-conduit >= 1.0 && < 1.1
|
||||
, xml-types >= 0.3 && < 0.4
|
||||
, xml-conduit >= 1.0
|
||||
, xml-types >= 0.3
|
||||
, containers
|
||||
, html-conduit >= 0.1 && < 0.2
|
||||
, blaze-html >= 0.5 && < 0.6
|
||||
, blaze-markup >= 0.5.1 && < 0.6
|
||||
, html-conduit >= 0.1
|
||||
, blaze-html >= 0.5
|
||||
, blaze-markup >= 0.5.1
|
||||
, pool-conduit
|
||||
, monad-control
|
||||
, time
|
||||
|
||||
203
yesod/Devel.hs
203
yesod/Devel.hs
@ -9,18 +9,11 @@ module Devel
|
||||
|
||||
|
||||
import qualified Distribution.Compiler as D
|
||||
import qualified Distribution.InstalledPackageInfo as IPI
|
||||
import qualified Distribution.ModuleName as D
|
||||
import qualified Distribution.Package as D
|
||||
import qualified Distribution.PackageDescription as D
|
||||
import qualified Distribution.PackageDescription.Parse as D
|
||||
import qualified Distribution.Simple.Build as D
|
||||
import qualified Distribution.Simple.Compiler as D
|
||||
import qualified Distribution.Simple.Configure as D
|
||||
import qualified Distribution.Simple.LocalBuildInfo as D
|
||||
import qualified Distribution.Simple.Program as D
|
||||
import qualified Distribution.Simple.Register as D
|
||||
import qualified Distribution.Simple.Setup as DSS
|
||||
import qualified Distribution.Simple.Utils as D
|
||||
import qualified Distribution.Verbosity as D
|
||||
|
||||
@ -40,9 +33,6 @@ import qualified Data.List as L
|
||||
import qualified Data.Map as Map
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Set as Set
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.Encoding (decodeUtf8With)
|
||||
import Data.Text.Encoding.Error (lenientDecode)
|
||||
|
||||
import System.Directory
|
||||
import System.Environment (getEnvironment)
|
||||
@ -53,6 +43,7 @@ import System.FilePath (dropExtension,
|
||||
splitDirectories,
|
||||
takeExtension, (</>))
|
||||
import System.FSNotify
|
||||
import System.IO (Handle)
|
||||
import System.IO.Error (isDoesNotExistError)
|
||||
import System.Posix.Types (EpochTime)
|
||||
import System.PosixCompat.Files (getFileStatus,
|
||||
@ -66,9 +57,9 @@ import System.Process (ProcessHandle,
|
||||
import System.Timeout (timeout)
|
||||
|
||||
import Build (getDeps, isNewerThan,
|
||||
recompDeps, safeReadFile)
|
||||
recompDeps)
|
||||
import GhcBuild (buildPackage,
|
||||
getBuildFlags)
|
||||
getBuildFlags, getPackageArgs)
|
||||
|
||||
import qualified Config as GHC
|
||||
import Data.Conduit.Network (HostPreference (HostIPv4),
|
||||
@ -116,6 +107,10 @@ getBuildDir opts = fromMaybe "dist" (buildDir opts)
|
||||
defaultDevelOpts :: DevelOpts
|
||||
defaultDevelOpts = DevelOpts False False False (-1) Nothing Nothing Nothing 3000 10
|
||||
|
||||
cabalProgram :: DevelOpts -> FilePath
|
||||
cabalProgram opts | isCabalDev opts = "cabal-dev"
|
||||
| otherwise = "cabal"
|
||||
|
||||
-- | Run a reverse proxy from port 3000 to 3001. If there is no response on
|
||||
-- 3001, give an appropriate message to the user.
|
||||
reverseProxy :: DevelOpts -> I.IORef Int -> IO ()
|
||||
@ -183,26 +178,34 @@ devel opts passThroughArgs = withSocketsDo $ withManager $ \manager -> do
|
||||
cabal <- liftIO $ D.findPackageDesc "."
|
||||
gpd <- liftIO $ D.readPackageDescription D.normal cabal
|
||||
ldar <- liftIO lookupLdAr
|
||||
(hsSourceDirs, lib) <- liftIO $ checkCabalFile gpd
|
||||
(hsSourceDirs, _) <- liftIO $ checkCabalFile gpd
|
||||
liftIO $ removeFileIfExists (bd </> "setup-config")
|
||||
liftIO $ configure cabal ghcVer gpd opts
|
||||
liftIO $ removeFileIfExists "yesod-devel/ghcargs.txt" -- these files contain the wrong data after
|
||||
liftIO $ removeFileIfExists "yesod-devel/arargs.txt" -- the configure step, remove them to force
|
||||
liftIO $ removeFileIfExists "yesod-devel/ldargs.txt" -- a cabal build first
|
||||
rebuild <- liftIO $ mkRebuild gpd ghcVer cabal opts ldar
|
||||
mainInnerLoop iappPort hsSourceDirs filesModified cabal gpd lib ghcVer rebuild
|
||||
c <- liftIO $ configure opts passThroughArgs
|
||||
if c then do
|
||||
-- these files contain the wrong data after the configure step,
|
||||
-- remove them to force a cabal build first
|
||||
liftIO $ mapM_ removeFileIfExists [ "yesod-devel/ghcargs.txt"
|
||||
, "yesod-devel/arargs.txt"
|
||||
, "yesod-devel/ldargs.txt"
|
||||
]
|
||||
rebuild <- liftIO $ mkRebuild ghcVer cabal opts ldar
|
||||
mainInnerLoop iappPort hsSourceDirs filesModified cabal rebuild
|
||||
else do
|
||||
liftIO (threadDelay 5000000)
|
||||
mainOuterLoop iappPort filesModified
|
||||
|
||||
-- inner loop rebuilds after files change
|
||||
mainInnerLoop iappPort hsSourceDirs filesModified cabal gpd lib ghcVer rebuild = go
|
||||
mainInnerLoop iappPort hsSourceDirs filesModified cabal rebuild = go
|
||||
where
|
||||
go = do
|
||||
_ <- recompDeps hsSourceDirs
|
||||
list <- liftIO $ getFileList hsSourceDirs [cabal]
|
||||
success <- liftIO rebuild
|
||||
pkgArgs <- liftIO $ ghcPackageArgs opts ghcVer (D.packageDescription gpd) lib
|
||||
let devArgs = pkgArgs ++ ["devel.hs"] ++ passThroughArgs
|
||||
pkgArgs <- liftIO (ghcPackageArgs opts)
|
||||
let devArgs = pkgArgs ++ ["devel.hs"]
|
||||
let loop list0 = do
|
||||
(haskellFileChanged, list1) <- liftIO $ watchForChanges filesModified hsSourceDirs [cabal] list0 (eventTimeout opts)
|
||||
(haskellFileChanged, list1) <- liftIO $
|
||||
watchForChanges filesModified hsSourceDirs [cabal] list0 (eventTimeout opts)
|
||||
anyTouched <- recompDeps hsSourceDirs
|
||||
unless (anyTouched || haskellFileChanged) $ loop list1
|
||||
if not success
|
||||
@ -249,53 +252,21 @@ runBuildHook (Just s) = do
|
||||
runBuildHook Nothing = return ()
|
||||
|
||||
{-
|
||||
configure with the built-in Cabal lib for non-cabal-dev, since
|
||||
otherwise we cannot read the configuration later
|
||||
|
||||
cabal-dev uses the command-line tool, we can fall back to
|
||||
cabal-dev buildopts if required
|
||||
run `cabal configure' with our wrappers
|
||||
-}
|
||||
configure :: FilePath -> String -> D.GenericPackageDescription -> DevelOpts -> IO ()
|
||||
configure _cabalFile ghcVer gpd opts = do
|
||||
lbi <- D.configure (gpd, hookedBuildInfo) configFlags
|
||||
D.writePersistBuildConfig (getBuildDir opts) lbi -- fixme we could keep this in memory instead of file
|
||||
where
|
||||
hookedBuildInfo = (Nothing, [])
|
||||
configFlags0 | forceCabal opts = config
|
||||
| otherwise = config
|
||||
{ DSS.configProgramPaths =
|
||||
[ ("ar", "yesod-ar-wrapper")
|
||||
, ("ld", "yesod-ld-wrapper")
|
||||
, ("ghc", "yesod-ghc-wrapper")
|
||||
]
|
||||
, DSS.configHcPkg = DSS.Flag "ghc-pkg"
|
||||
}
|
||||
#if MIN_VERSION_Cabal(1,16,0)
|
||||
configFlags | isCabalDev opts = configFlags0
|
||||
{ DSS.configPackageDBs =
|
||||
[ Nothing
|
||||
, Just D.GlobalPackageDB
|
||||
, Just cabalDevPackageDb
|
||||
]
|
||||
}
|
||||
#else
|
||||
configFlags | isCabalDev opts = configFlags0
|
||||
{ DSS.configPackageDB = DSS.Flag cabalDevPackageDb
|
||||
}
|
||||
#endif
|
||||
| otherwise = configFlags0
|
||||
|
||||
cabalDevPackageDb = D.SpecificPackageDB ("cabal-dev/packages-" ++ ghcVer ++ ".conf")
|
||||
|
||||
|
||||
config = (DSS.defaultConfigFlags D.defaultProgramConfiguration)
|
||||
{ DSS.configConfigurationsFlags =
|
||||
[ (D.FlagName "devel", True) -- legacy
|
||||
, (D.FlagName "library-only", True)
|
||||
]
|
||||
, DSS.configProfLib = DSS.Flag False
|
||||
, DSS.configUserInstall = DSS.Flag True
|
||||
}
|
||||
configure :: DevelOpts -> [String] -> IO Bool
|
||||
configure opts extraArgs =
|
||||
checkExit =<< (createProcess $ proc (cabalProgram opts)
|
||||
([ "configure"
|
||||
, "-flibrary-only"
|
||||
, "-fdevel"
|
||||
, "--disable-library-profiling"
|
||||
, "--with-ld=yesod-ld-wrapper"
|
||||
, "--with-ghc=yesod-ghc-wrapper"
|
||||
, "--with-ar=yesod-ar-wrapper"
|
||||
, "--with-hc-pkg=ghc-pkg"
|
||||
] ++ extraArgs)
|
||||
)
|
||||
|
||||
removeFileIfExists :: FilePath -> IO ()
|
||||
removeFileIfExists file = removeFile file `Ex.catch` handler
|
||||
@ -304,17 +275,17 @@ removeFileIfExists file = removeFile file `Ex.catch` handler
|
||||
handler e | isDoesNotExistError e = return ()
|
||||
| otherwise = Ex.throw e
|
||||
|
||||
mkRebuild :: D.GenericPackageDescription -> String -> FilePath -> DevelOpts -> (FilePath, FilePath) -> IO (IO Bool)
|
||||
mkRebuild gpd ghcVer cabalFile opts (ldPath, arPath)
|
||||
| GHC.cProjectVersion /= ghcVer = failWith "Yesod has been compiled with a different GHC version, please reinstall"
|
||||
| forceCabal opts = return (rebuildCabal gpd opts)
|
||||
mkRebuild :: String -> FilePath -> DevelOpts -> (FilePath, FilePath) -> IO (IO Bool)
|
||||
mkRebuild ghcVer cabalFile opts (ldPath, arPath)
|
||||
| GHC.cProjectVersion /= ghcVer =
|
||||
failWith "Yesod has been compiled with a different GHC version, please reinstall"
|
||||
| forceCabal opts = return (rebuildCabal opts)
|
||||
| otherwise = do
|
||||
return $ do
|
||||
n1 <- cabalFile `isNewerThan` "yesod-devel/ghcargs.txt"
|
||||
n2 <- cabalFile `isNewerThan` "yesod-devel/arargs.txt"
|
||||
n3 <- cabalFile `isNewerThan` "yesod-devel/ldargs.txt"
|
||||
if n1 || n2 || n3
|
||||
then rebuildCabal gpd opts
|
||||
ns <- mapM (cabalFile `isNewerThan`)
|
||||
[ "yesod-devel/ghcargs.txt", "yesod-devel/arargs.txt", "yesod-devel/ldargs.txt" ]
|
||||
if or ns
|
||||
then rebuildCabal opts
|
||||
else do
|
||||
bf <- getBuildFlags
|
||||
rebuildGhc bf ldPath arPath
|
||||
@ -325,18 +296,13 @@ rebuildGhc bf ld ar = do
|
||||
putStrLn "Rebuilding application... (using GHC API)"
|
||||
buildPackage bf ld ar
|
||||
|
||||
rebuildCabal :: D.GenericPackageDescription -> DevelOpts -> IO Bool
|
||||
rebuildCabal _gpd opts = do
|
||||
putStrLn $ "Rebuilding application... (using Cabal library)"
|
||||
lbi <- getPersistBuildConfig opts -- fixme we could cache this from the configure step
|
||||
let buildFlags | verbose opts = DSS.defaultBuildFlags
|
||||
| otherwise = DSS.defaultBuildFlags { DSS.buildVerbosity = DSS.Flag D.silent }
|
||||
tryBool $ D.build (D.localPkgDescr lbi) lbi buildFlags []
|
||||
|
||||
tryBool :: IO a -> IO Bool
|
||||
tryBool a = (a >> return True) `Ex.catch` \(e::Ex.SomeException) -> do
|
||||
putStrLn $ "Exception: " ++ show e
|
||||
return False
|
||||
rebuildCabal :: DevelOpts -> IO Bool
|
||||
rebuildCabal opts = do
|
||||
putStrLn $ "Rebuilding application... (using " ++ cabalProgram opts ++ ")"
|
||||
checkExit =<< createProcess (proc (cabalProgram opts) args)
|
||||
where
|
||||
args | verbose opts = [ "build" ]
|
||||
| otherwise = [ "build", "-v0" ]
|
||||
|
||||
try_ :: forall a. IO a -> IO ()
|
||||
try_ x = (Ex.try x :: IO (Either Ex.SomeException a)) >> return ()
|
||||
@ -421,57 +387,8 @@ ghcVersion = fmap getNumber $ readProcess "runghc" ["--numeric-version", "0"] []
|
||||
where
|
||||
getNumber = filter (\x -> isNumber x || x == '.')
|
||||
|
||||
ghcPackageArgs :: DevelOpts -> String -> D.PackageDescription -> D.Library -> IO [String]
|
||||
ghcPackageArgs opts ghcVer cabal lib = do
|
||||
lbi <- getPersistBuildConfig opts
|
||||
cbi <- fromMaybeErr errCbi (D.libraryConfig lbi)
|
||||
if isCabalDev opts
|
||||
then return ("-hide-all-packages" : "-no-user-package-conf" : inplaceConf
|
||||
: selfPkgArg lbi : cabalDevConf : depArgs lbi cbi)
|
||||
else return ("-hide-all-packages" : inplaceConf : selfPkgArg lbi : depArgs lbi cbi)
|
||||
where
|
||||
selfPkgArg lbi = pkgArg . D.inplacePackageId . D.package . D.localPkgDescr $ lbi
|
||||
pkgArg (D.InstalledPackageId pkgId) = "-package-id" ++ pkgId
|
||||
depArgs lbi cbi = map pkgArg (deps lbi cbi)
|
||||
deps lbi cbi = let pkgInfo = D.inplaceInstalledPackageInfo "." (getBuildDir opts) cabal lib lbi cbi
|
||||
in IPI.depends $ pkgInfo
|
||||
errCbi = "No library ComponentBuildInfo"
|
||||
cabalDevConf = "-package-confcabal-dev/packages-" ++ ghcVer ++ ".conf"
|
||||
inplaceConf = "-package-conf" ++ (getBuildDir opts</>"package.conf.inplace")
|
||||
|
||||
getPersistBuildConfig :: DevelOpts -> IO D.LocalBuildInfo
|
||||
getPersistBuildConfig opts = fromRightErr errLbi =<< getPersistConfigLenient opts -- D.maybeGetPersistBuildConfig path
|
||||
where
|
||||
errLbi = "Could not read BuildInfo file: " ++ D.localBuildInfoFile (getBuildDir opts) ++
|
||||
"\nMake sure that cabal-install has been compiled with the same GHC version as yesod." ++
|
||||
"\nand that the Cabal library used by GHC is the same version"
|
||||
|
||||
-- there can be slight differences in the cabal version, ignore those when loading the file as long as we can parse it
|
||||
getPersistConfigLenient :: DevelOpts -> IO (Either String D.LocalBuildInfo)
|
||||
getPersistConfigLenient opts = do
|
||||
let file = D.localBuildInfoFile (getBuildDir opts)
|
||||
exists <- doesFileExist file
|
||||
if not exists
|
||||
then return (Left $ "file does not exist: " ++ file)
|
||||
else do
|
||||
xs <- safeReadFile file
|
||||
case xs of
|
||||
Left e -> return $ Left $ show e
|
||||
Right bs ->
|
||||
return $ case lines $ T.unpack $ decodeUtf8With lenientDecode bs of
|
||||
[_,l2] -> -- two lines, header and serialized rest
|
||||
case reads l2 of
|
||||
[(bi,_)] -> Right bi
|
||||
_ -> (Left "cannot parse contents")
|
||||
_ -> (Left "not a valid header/content file")
|
||||
|
||||
fromMaybeErr :: String -> Maybe b -> IO b
|
||||
fromMaybeErr err Nothing = failWith err
|
||||
fromMaybeErr _ (Just x) = return x
|
||||
|
||||
fromRightErr :: String -> Either String b -> IO b
|
||||
fromRightErr str (Left err) = failWith (str ++ "\n" ++ err)
|
||||
fromRightErr _ (Right b) = return b
|
||||
ghcPackageArgs :: DevelOpts -> IO [String]
|
||||
ghcPackageArgs opts = getBuildFlags >>= getPackageArgs (buildDir opts)
|
||||
|
||||
lookupDevelLib :: D.GenericPackageDescription -> D.CondTree D.ConfVar c a -> Maybe a
|
||||
lookupDevelLib gpd ct | found = Just (D.condTreeData ct)
|
||||
@ -507,3 +424,7 @@ waitForProcess' pid = go
|
||||
Just ec -> return ec
|
||||
Nothing -> threadDelay 100000 >> go
|
||||
|
||||
-- | wait for process started by @createProcess@, return True for ExitSuccess
|
||||
checkExit :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> IO Bool
|
||||
checkExit (_,_,_,h) = (==ExitSuccess) <$> waitForProcess' h
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
build package with the GHC API
|
||||
-}
|
||||
|
||||
module GhcBuild (getBuildFlags, buildPackage) where
|
||||
module GhcBuild (getBuildFlags, buildPackage, getPackageArgs) where
|
||||
|
||||
import qualified Control.Exception as Ex
|
||||
import Control.Monad (when)
|
||||
@ -26,21 +26,23 @@ import System.Environment (getEnvironment)
|
||||
|
||||
import CmdLineParser
|
||||
import Data.Char (toLower)
|
||||
import Data.List (isPrefixOf, partition)
|
||||
import Data.List (isPrefixOf, isSuffixOf, partition)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import DriverPhases (Phase (..), anyHsc, isHaskellSrcFilename,
|
||||
isSourceFilename, startPhase)
|
||||
import DriverPipeline (compileFile, link, linkBinary, oneShot)
|
||||
import DynFlags (DynFlags, compilerInfo)
|
||||
import qualified DynFlags
|
||||
import qualified DynFlags as DF
|
||||
import qualified GHC
|
||||
import GHC.Paths (libdir)
|
||||
import HscTypes (HscEnv (..), emptyHomePackageTable)
|
||||
import qualified Module
|
||||
import MonadUtils (liftIO)
|
||||
import Panic (ghcError, panic)
|
||||
import SrcLoc (Located, mkGeneralLocated)
|
||||
import StaticFlags (v_Ld_inputs)
|
||||
import qualified StaticFlags
|
||||
import StaticFlags (v_Ld_inputs)
|
||||
import System.FilePath (normalise, (</>))
|
||||
import Util (consIORef, looksLikeModuleName)
|
||||
|
||||
@ -71,6 +73,56 @@ prependHsenvArgv argv = do
|
||||
_ -> hsenvArgv ++ argv
|
||||
where hsenvArgv = words $ fromMaybe "" (lookup "PACKAGE_DB_FOR_GHC" env)
|
||||
|
||||
-- construct a command line for loading the right packages
|
||||
getPackageArgs :: Maybe String -> [Located String] -> IO [String]
|
||||
getPackageArgs buildDir argv2 = do
|
||||
(mode, argv3, modeFlagWarnings) <- parseModeFlags argv2
|
||||
GHC.runGhc (Just libdir) $ do
|
||||
dflags0 <- GHC.getSessionDynFlags
|
||||
(dflags1, _, _) <- GHC.parseDynamicFlags dflags0 argv3
|
||||
let pkgFlags = map convertPkgFlag (GHC.packageFlags dflags1)
|
||||
hideAll | gopt DF.Opt_HideAllPackages dflags1 = [ "-hide-all-packages"]
|
||||
| otherwise = []
|
||||
ownPkg = "-package-id" ++ Module.packageIdString (DF.thisPackage dflags1) ++ "-inplace"
|
||||
return (extra dflags1 ++ hideAll ++ pkgFlags ++ [ownPkg])
|
||||
where
|
||||
convertPkgFlag (DF.ExposePackage p) = "-package" ++ p
|
||||
convertPkgFlag (DF.ExposePackageId p) = "-package-id" ++ p
|
||||
convertPkgFlag (DF.HidePackage p) = "-hide-package" ++ p
|
||||
convertPkgFlag (DF.IgnorePackage p) = "-ignore-package" ++ p
|
||||
convertPkgFlag (DF.TrustPackage p) = "-trust" ++ p
|
||||
convertPkgFlag (DF.DistrustPackage p) ="-distrust" ++ p
|
||||
#if __GLASGOW_HASKELL__ >= 705
|
||||
extra df = inplaceConf ++ extra'
|
||||
where
|
||||
extra' = concatMap convertExtra (extraConfs df)
|
||||
-- old cabal-install sometimes misses the .inplace db, fix it here
|
||||
inplaceConf
|
||||
| any (".inplace" `isSuffixOf`) extra' = []
|
||||
| otherwise = ["-package-db" ++ fromMaybe "dist" buildDir
|
||||
++ "/package.conf.inplace"]
|
||||
extraConfs df = GHC.extraPkgConfs df []
|
||||
convertExtra DF.GlobalPkgConf = [ ]
|
||||
convertExtra DF.UserPkgConf = [ ]
|
||||
convertExtra (DF.PkgConfFile file) = [ "-package-db" ++ file ]
|
||||
#else
|
||||
extra df = inplaceConf ++ extra'
|
||||
where
|
||||
extra' = map ("-package-conf"++) (GHC.extraPkgConfs df)
|
||||
-- old cabal-install sometimes misses the .inplace db, fix it here
|
||||
inplaceConf
|
||||
| any (".inplace" `isSuffixOf`) extra' = []
|
||||
| otherwise = ["-package-conf" ++ fromMaybe "dist" buildDir
|
||||
++ "/package.conf.inplace"]
|
||||
#endif
|
||||
|
||||
#if __GLASGOW_HASKELL__ >= 707
|
||||
gopt = DF.gopt
|
||||
#else
|
||||
gopt = DF.dopt
|
||||
#endif
|
||||
|
||||
|
||||
buildPackage :: [Located String] -> FilePath -> FilePath -> IO Bool
|
||||
buildPackage a ld ar = buildPackage' a ld ar `Ex.catch` \e -> do
|
||||
putStrLn ("exception building package: " ++ show (e :: Ex.SomeException))
|
||||
|
||||
@ -25,7 +25,12 @@ prompt f = do
|
||||
hFlush stdout
|
||||
prompt f
|
||||
|
||||
data Backend = Sqlite | Postgresql | Mysql | MongoDB | Simple
|
||||
data Backend = Sqlite
|
||||
| Postgresql
|
||||
| PostgresqlFay
|
||||
| Mysql
|
||||
| MongoDB
|
||||
| Simple
|
||||
deriving (Eq, Read, Show, Enum, Bounded)
|
||||
|
||||
puts :: LT.Text -> IO ()
|
||||
@ -37,6 +42,7 @@ backends = [minBound .. maxBound]
|
||||
showBackend :: Backend -> String
|
||||
showBackend Sqlite = "s"
|
||||
showBackend Postgresql = "p"
|
||||
showBackend PostgresqlFay = "pf"
|
||||
showBackend Mysql = "mysql"
|
||||
showBackend MongoDB = "mongo"
|
||||
showBackend Simple = "simple"
|
||||
@ -47,6 +53,7 @@ readBackend s = lookup s $ map (showBackend &&& id) backends
|
||||
backendBS :: Backend -> S.ByteString
|
||||
backendBS Sqlite = $(embedFile "hsfiles/sqlite.hsfiles")
|
||||
backendBS Postgresql = $(embedFile "hsfiles/postgres.hsfiles")
|
||||
backendBS PostgresqlFay = $(embedFile "hsfiles/postgres-fay.hsfiles")
|
||||
backendBS Mysql = $(embedFile "hsfiles/mysql.hsfiles")
|
||||
backendBS MongoDB = $(embedFile "hsfiles/mongo.hsfiles")
|
||||
backendBS Simple = $(embedFile "hsfiles/simple.hsfiles")
|
||||
|
||||
@ -26,9 +26,11 @@ import Yesod.Auth
|
||||
import Yesod.Default.Config
|
||||
import Yesod.Default.Main
|
||||
import Yesod.Default.Handlers
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev)
|
||||
import Network.Wai.Middleware.RequestLogger
|
||||
import qualified Database.Persist.Store
|
||||
import Network.HTTP.Conduit (newManager, def)
|
||||
import System.IO (stdout)
|
||||
import System.Log.FastLogger (mkLogger)
|
||||
|
||||
-- Import all relevant handler modules here.
|
||||
-- Don't forget to add new modules to your cabal file!
|
||||
@ -46,12 +48,22 @@ mkYesodDispatch "App" resourcesApp
|
||||
makeApplication :: AppConfig DefaultEnv Extra -> IO Application
|
||||
makeApplication conf = do
|
||||
foundation <- makeFoundation conf
|
||||
|
||||
-- Initialize the logging middleware
|
||||
logWare <- mkRequestLogger def
|
||||
{ outputFormat =
|
||||
if development
|
||||
then Detailed True
|
||||
else Apache FromSocket
|
||||
, destination = Logger $ appLogger foundation
|
||||
}
|
||||
|
||||
-- Create the WAI application and apply middlewares
|
||||
app <- toWaiAppPlain foundation
|
||||
return $ logWare app
|
||||
where
|
||||
logWare = if development then logStdoutDev
|
||||
else logStdout
|
||||
|
||||
-- | Loads up any necessary settings, creates your foundation datatype, and
|
||||
-- performs some initialization.
|
||||
makeFoundation :: AppConfig DefaultEnv Extra -> IO App
|
||||
makeFoundation conf = do
|
||||
manager <- newManager def
|
||||
@ -60,7 +72,10 @@ makeFoundation conf = do
|
||||
Database.Persist.Store.loadConfig >>=
|
||||
Database.Persist.Store.applyEnv
|
||||
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
|
||||
return $ App conf s p manager dbconf
|
||||
logger <- mkLogger True stdout
|
||||
let foundation = App conf s p manager dbconf logger
|
||||
|
||||
return foundation
|
||||
|
||||
-- for yesod devel
|
||||
getApplicationDev :: IO (Int, Application)
|
||||
@ -93,6 +108,7 @@ import Model
|
||||
import Text.Jasmine (minifym)
|
||||
import Web.ClientSession (getKey)
|
||||
import Text.Hamlet (hamletFile)
|
||||
import System.Log.FastLogger (Logger)
|
||||
|
||||
-- | The site argument for your application. This can be a good place to
|
||||
-- keep settings and values requiring initialization before your application
|
||||
@ -104,6 +120,7 @@ data App = App
|
||||
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
|
||||
, httpManager :: Manager
|
||||
, persistConfig :: Settings.PersistConfig
|
||||
, appLogger :: Logger
|
||||
}
|
||||
|
||||
-- Set up i18n messages. See the message folder.
|
||||
@ -190,6 +207,8 @@ instance Yesod App where
|
||||
shouldLog _ _source level =
|
||||
development || level == LevelWarn || level == LevelError
|
||||
|
||||
getLogger = return . appLogger
|
||||
|
||||
-- How to run database actions.
|
||||
instance YesodPersist App where
|
||||
type YesodPersistBackend App = Action
|
||||
@ -394,11 +413,14 @@ library
|
||||
, monad-control >= 0.3 && < 0.4
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, yaml >= 0.8 && < 0.9
|
||||
, http-conduit >= 1.8 && < 1.9
|
||||
, http-conduit >= 1.8 && < 1.10
|
||||
, directory >= 1.1 && < 1.3
|
||||
, warp >= 1.3 && < 1.4
|
||||
, data-default
|
||||
, aeson
|
||||
, conduit >= 1.0
|
||||
, monad-logger >= 0.3
|
||||
, fast-logger >= 0.3
|
||||
|
||||
executable PROJECTNAME
|
||||
if flag(library-only)
|
||||
@ -426,6 +448,7 @@ test-suite test
|
||||
, persistent
|
||||
, persistent-mongoDB
|
||||
, resourcet
|
||||
, monad-logger
|
||||
|
||||
{-# START_FILE Settings.hs #-}
|
||||
-- | Settings are centralized, as much as possible, into this file. This
|
||||
@ -5773,15 +5796,18 @@ import Yesod.Test
|
||||
import Database.Persist hiding (get)
|
||||
import Database.Persist.MongoDB hiding (master)
|
||||
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
|
||||
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
|
||||
|
||||
import Model
|
||||
|
||||
type Specs = SpecsConn Connection
|
||||
|
||||
runDB :: Action (ResourceT IO) a -> OneSpec Connection a
|
||||
runDB :: Action (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
|
||||
runDB = runDBRunner poolRunner
|
||||
where
|
||||
poolRunner query pool = runResourceT $ runMongoDBPoolDef query pool
|
||||
poolRunner query pool = runResourceT
|
||||
$ runNoLoggingT
|
||||
$ runMongoDBPoolDef query pool
|
||||
|
||||
{-# START_FILE tests/main.hs #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
@ -26,10 +26,13 @@ import Yesod.Auth
|
||||
import Yesod.Default.Config
|
||||
import Yesod.Default.Main
|
||||
import Yesod.Default.Handlers
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev)
|
||||
import Network.Wai.Middleware.RequestLogger
|
||||
import qualified Database.Persist.Store
|
||||
import Database.Persist.GenericSql (runMigration)
|
||||
import Network.HTTP.Conduit (newManager, def)
|
||||
import Control.Monad.Logger (runLoggingT)
|
||||
import System.IO (stdout)
|
||||
import System.Log.FastLogger (mkLogger)
|
||||
|
||||
-- Import all relevant handler modules here.
|
||||
-- Don't forget to add new modules to your cabal file!
|
||||
@ -47,12 +50,22 @@ mkYesodDispatch "App" resourcesApp
|
||||
makeApplication :: AppConfig DefaultEnv Extra -> IO Application
|
||||
makeApplication conf = do
|
||||
foundation <- makeFoundation conf
|
||||
|
||||
-- Initialize the logging middleware
|
||||
logWare <- mkRequestLogger def
|
||||
{ outputFormat =
|
||||
if development
|
||||
then Detailed True
|
||||
else Apache FromSocket
|
||||
, destination = Logger $ appLogger foundation
|
||||
}
|
||||
|
||||
-- Create the WAI application and apply middlewares
|
||||
app <- toWaiAppPlain foundation
|
||||
return $ logWare app
|
||||
where
|
||||
logWare = if development then logStdoutDev
|
||||
else logStdout
|
||||
|
||||
-- | Loads up any necessary settings, creates your foundation datatype, and
|
||||
-- performs some initialization.
|
||||
makeFoundation :: AppConfig DefaultEnv Extra -> IO App
|
||||
makeFoundation conf = do
|
||||
manager <- newManager def
|
||||
@ -61,8 +74,15 @@ makeFoundation conf = do
|
||||
Database.Persist.Store.loadConfig >>=
|
||||
Database.Persist.Store.applyEnv
|
||||
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
|
||||
Database.Persist.Store.runPool dbconf (runMigration migrateAll) p
|
||||
return $ App conf s p manager dbconf
|
||||
logger <- mkLogger True stdout
|
||||
let foundation = App conf s p manager dbconf logger
|
||||
|
||||
-- Perform database migration using our application's logging settings.
|
||||
runLoggingT
|
||||
(Database.Persist.Store.runPool dbconf (runMigration migrateAll) p)
|
||||
(messageLoggerSource foundation logger)
|
||||
|
||||
return foundation
|
||||
|
||||
-- for yesod devel
|
||||
getApplicationDev :: IO (Int, Application)
|
||||
@ -95,6 +115,7 @@ import Model
|
||||
import Text.Jasmine (minifym)
|
||||
import Web.ClientSession (getKey)
|
||||
import Text.Hamlet (hamletFile)
|
||||
import System.Log.FastLogger (Logger)
|
||||
|
||||
-- | The site argument for your application. This can be a good place to
|
||||
-- keep settings and values requiring initialization before your application
|
||||
@ -106,6 +127,7 @@ data App = App
|
||||
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
|
||||
, httpManager :: Manager
|
||||
, persistConfig :: Settings.PersistConfig
|
||||
, appLogger :: Logger
|
||||
}
|
||||
|
||||
-- Set up i18n messages. See the message folder.
|
||||
@ -192,6 +214,8 @@ instance Yesod App where
|
||||
shouldLog _ _source level =
|
||||
development || level == LevelWarn || level == LevelError
|
||||
|
||||
getLogger = return . appLogger
|
||||
|
||||
-- How to run database actions.
|
||||
instance YesodPersist App where
|
||||
type YesodPersistBackend App = SqlPersist
|
||||
@ -392,11 +416,14 @@ library
|
||||
, monad-control >= 0.3 && < 0.4
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, yaml >= 0.8 && < 0.9
|
||||
, http-conduit >= 1.8 && < 1.9
|
||||
, http-conduit >= 1.8 && < 1.10
|
||||
, directory >= 1.1 && < 1.3
|
||||
, warp >= 1.3 && < 1.4
|
||||
, data-default
|
||||
, aeson
|
||||
, conduit >= 1.0
|
||||
, monad-logger >= 0.3
|
||||
, fast-logger >= 0.3
|
||||
|
||||
executable PROJECTNAME
|
||||
if flag(library-only)
|
||||
@ -424,6 +451,7 @@ test-suite test
|
||||
, persistent
|
||||
, persistent-mysql
|
||||
, resourcet
|
||||
, monad-logger
|
||||
|
||||
{-# START_FILE Settings.hs #-}
|
||||
-- | Settings are centralized, as much as possible, into this file. This
|
||||
@ -5797,15 +5825,18 @@ import Yesod.Test
|
||||
import Database.Persist hiding (get)
|
||||
import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection)
|
||||
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
|
||||
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
|
||||
|
||||
import Model
|
||||
|
||||
type Specs = SpecsConn Connection
|
||||
|
||||
runDB :: SqlPersist (ResourceT IO) a -> OneSpec Connection a
|
||||
runDB :: SqlPersist (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
|
||||
runDB = runDBRunner poolRunner
|
||||
where
|
||||
poolRunner query pool = runResourceT $ runSqlPool query pool
|
||||
poolRunner query pool = runResourceT
|
||||
$ runNoLoggingT
|
||||
$ runSqlPool query pool
|
||||
|
||||
{-# START_FILE tests/main.hs #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
5947
yesod/hsfiles/postgres-fay.hsfiles
Normal file
5947
yesod/hsfiles/postgres-fay.hsfiles
Normal file
File diff suppressed because it is too large
Load Diff
@ -26,10 +26,13 @@ import Yesod.Auth
|
||||
import Yesod.Default.Config
|
||||
import Yesod.Default.Main
|
||||
import Yesod.Default.Handlers
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev)
|
||||
import Network.Wai.Middleware.RequestLogger
|
||||
import qualified Database.Persist.Store
|
||||
import Database.Persist.GenericSql (runMigration)
|
||||
import Network.HTTP.Conduit (newManager, def)
|
||||
import Control.Monad.Logger (runLoggingT)
|
||||
import System.IO (stdout)
|
||||
import System.Log.FastLogger (mkLogger)
|
||||
|
||||
-- Import all relevant handler modules here.
|
||||
-- Don't forget to add new modules to your cabal file!
|
||||
@ -47,12 +50,22 @@ mkYesodDispatch "App" resourcesApp
|
||||
makeApplication :: AppConfig DefaultEnv Extra -> IO Application
|
||||
makeApplication conf = do
|
||||
foundation <- makeFoundation conf
|
||||
|
||||
-- Initialize the logging middleware
|
||||
logWare <- mkRequestLogger def
|
||||
{ outputFormat =
|
||||
if development
|
||||
then Detailed True
|
||||
else Apache FromSocket
|
||||
, destination = Logger $ appLogger foundation
|
||||
}
|
||||
|
||||
-- Create the WAI application and apply middlewares
|
||||
app <- toWaiAppPlain foundation
|
||||
return $ logWare app
|
||||
where
|
||||
logWare = if development then logStdoutDev
|
||||
else logStdout
|
||||
|
||||
-- | Loads up any necessary settings, creates your foundation datatype, and
|
||||
-- performs some initialization.
|
||||
makeFoundation :: AppConfig DefaultEnv Extra -> IO App
|
||||
makeFoundation conf = do
|
||||
manager <- newManager def
|
||||
@ -61,8 +74,15 @@ makeFoundation conf = do
|
||||
Database.Persist.Store.loadConfig >>=
|
||||
Database.Persist.Store.applyEnv
|
||||
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
|
||||
Database.Persist.Store.runPool dbconf (runMigration migrateAll) p
|
||||
return $ App conf s p manager dbconf
|
||||
logger <- mkLogger True stdout
|
||||
let foundation = App conf s p manager dbconf logger
|
||||
|
||||
-- Perform database migration using our application's logging settings.
|
||||
runLoggingT
|
||||
(Database.Persist.Store.runPool dbconf (runMigration migrateAll) p)
|
||||
(messageLoggerSource foundation logger)
|
||||
|
||||
return foundation
|
||||
|
||||
-- for yesod devel
|
||||
getApplicationDev :: IO (Int, Application)
|
||||
@ -95,6 +115,7 @@ import Model
|
||||
import Text.Jasmine (minifym)
|
||||
import Web.ClientSession (getKey)
|
||||
import Text.Hamlet (hamletFile)
|
||||
import System.Log.FastLogger (Logger)
|
||||
|
||||
-- | The site argument for your application. This can be a good place to
|
||||
-- keep settings and values requiring initialization before your application
|
||||
@ -106,6 +127,7 @@ data App = App
|
||||
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
|
||||
, httpManager :: Manager
|
||||
, persistConfig :: Settings.PersistConfig
|
||||
, appLogger :: Logger
|
||||
}
|
||||
|
||||
-- Set up i18n messages. See the message folder.
|
||||
@ -192,6 +214,8 @@ instance Yesod App where
|
||||
shouldLog _ _source level =
|
||||
development || level == LevelWarn || level == LevelError
|
||||
|
||||
getLogger = return . appLogger
|
||||
|
||||
-- How to run database actions.
|
||||
instance YesodPersist App where
|
||||
type YesodPersistBackend App = SqlPersist
|
||||
@ -392,11 +416,14 @@ library
|
||||
, monad-control >= 0.3 && < 0.4
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, yaml >= 0.8 && < 0.9
|
||||
, http-conduit >= 1.8 && < 1.9
|
||||
, http-conduit >= 1.8 && < 1.10
|
||||
, directory >= 1.1 && < 1.3
|
||||
, warp >= 1.3 && < 1.4
|
||||
, data-default
|
||||
, aeson
|
||||
, conduit >= 1.0
|
||||
, monad-logger >= 0.3
|
||||
, fast-logger >= 0.3
|
||||
|
||||
executable PROJECTNAME
|
||||
if flag(library-only)
|
||||
@ -424,6 +451,7 @@ test-suite test
|
||||
, persistent
|
||||
, persistent-postgresql
|
||||
, resourcet
|
||||
, monad-logger
|
||||
|
||||
{-# START_FILE Settings.hs #-}
|
||||
-- | Settings are centralized, as much as possible, into this file. This
|
||||
@ -5771,15 +5799,18 @@ import Yesod.Test
|
||||
import Database.Persist hiding (get)
|
||||
import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection)
|
||||
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
|
||||
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
|
||||
|
||||
import Model
|
||||
|
||||
type Specs = SpecsConn Connection
|
||||
|
||||
runDB :: SqlPersist (ResourceT IO) a -> OneSpec Connection a
|
||||
runDB :: SqlPersist (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
|
||||
runDB = runDBRunner poolRunner
|
||||
where
|
||||
poolRunner query pool = runResourceT $ runSqlPool query pool
|
||||
poolRunner query pool = runResourceT
|
||||
$ runNoLoggingT
|
||||
$ runSqlPool query pool
|
||||
|
||||
{-# START_FILE tests/main.hs #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
@ -24,8 +24,11 @@ import Import
|
||||
import Yesod.Default.Config
|
||||
import Yesod.Default.Main
|
||||
import Yesod.Default.Handlers
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev)
|
||||
import Network.Wai.Middleware.RequestLogger
|
||||
import Network.HTTP.Conduit (newManager, def)
|
||||
import Control.Monad.Logger (runLoggingT)
|
||||
import System.IO (stdout)
|
||||
import System.Log.FastLogger (mkLogger)
|
||||
|
||||
-- Import all relevant handler modules here.
|
||||
-- Don't forget to add new modules to your cabal file!
|
||||
@ -43,17 +46,30 @@ mkYesodDispatch "App" resourcesApp
|
||||
makeApplication :: AppConfig DefaultEnv Extra -> IO Application
|
||||
makeApplication conf = do
|
||||
foundation <- makeFoundation conf
|
||||
|
||||
-- Initialize the logging middleware
|
||||
logWare <- mkRequestLogger def
|
||||
{ outputFormat =
|
||||
if development
|
||||
then Detailed True
|
||||
else Apache FromSocket
|
||||
, destination = Logger $ appLogger foundation
|
||||
}
|
||||
|
||||
-- Create the WAI application and apply middlewares
|
||||
app <- toWaiAppPlain foundation
|
||||
return $ logWare app
|
||||
where
|
||||
logWare = if development then logStdoutDev
|
||||
else logStdout
|
||||
|
||||
-- | Loads up any necessary settings, creates your foundation datatype, and
|
||||
-- performs some initialization.
|
||||
makeFoundation :: AppConfig DefaultEnv Extra -> IO App
|
||||
makeFoundation conf = do
|
||||
manager <- newManager def
|
||||
s <- staticSite
|
||||
return $ App conf s manager
|
||||
logger <- mkLogger True stdout
|
||||
let foundation = App conf s manager logger
|
||||
|
||||
return foundation
|
||||
|
||||
-- for yesod devel
|
||||
getApplicationDev :: IO (Int, Application)
|
||||
@ -80,6 +96,7 @@ import Settings (widgetFile, Extra (..))
|
||||
import Text.Jasmine (minifym)
|
||||
import Web.ClientSession (getKey)
|
||||
import Text.Hamlet (hamletFile)
|
||||
import System.Log.FastLogger (Logger)
|
||||
|
||||
-- | The site argument for your application. This can be a good place to
|
||||
-- keep settings and values requiring initialization before your application
|
||||
@ -89,6 +106,7 @@ data App = App
|
||||
{ settings :: AppConfig DefaultEnv Extra
|
||||
, getStatic :: Static -- ^ Settings for static file serving.
|
||||
, httpManager :: Manager
|
||||
, appLogger :: Logger
|
||||
}
|
||||
|
||||
-- Set up i18n messages. See the message folder.
|
||||
@ -172,6 +190,8 @@ instance Yesod App where
|
||||
shouldLog _ _source level =
|
||||
development || level == LevelWarn || level == LevelError
|
||||
|
||||
getLogger = return . appLogger
|
||||
|
||||
-- This instance is required to use forms. You can modify renderMessage to
|
||||
-- achieve customized and internationalized form validation messages.
|
||||
instance RenderMessage App FormMessage where
|
||||
@ -320,11 +340,14 @@ library
|
||||
, monad-control >= 0.3 && < 0.4
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, yaml >= 0.8 && < 0.9
|
||||
, http-conduit >= 1.8 && < 1.9
|
||||
, http-conduit >= 1.8 && < 1.10
|
||||
, directory >= 1.1 && < 1.3
|
||||
, warp >= 1.3 && < 1.4
|
||||
, data-default
|
||||
, aeson
|
||||
, conduit >= 1.0
|
||||
, monad-logger >= 0.3
|
||||
, fast-logger >= 0.3
|
||||
|
||||
executable PROJECTNAME
|
||||
if flag(library-only)
|
||||
|
||||
@ -26,10 +26,13 @@ import Yesod.Auth
|
||||
import Yesod.Default.Config
|
||||
import Yesod.Default.Main
|
||||
import Yesod.Default.Handlers
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev)
|
||||
import Network.Wai.Middleware.RequestLogger
|
||||
import qualified Database.Persist.Store
|
||||
import Database.Persist.GenericSql (runMigration)
|
||||
import Network.HTTP.Conduit (newManager, def)
|
||||
import Control.Monad.Logger (runLoggingT)
|
||||
import System.IO (stdout)
|
||||
import System.Log.FastLogger (mkLogger)
|
||||
|
||||
-- Import all relevant handler modules here.
|
||||
-- Don't forget to add new modules to your cabal file!
|
||||
@ -47,12 +50,22 @@ mkYesodDispatch "App" resourcesApp
|
||||
makeApplication :: AppConfig DefaultEnv Extra -> IO Application
|
||||
makeApplication conf = do
|
||||
foundation <- makeFoundation conf
|
||||
|
||||
-- Initialize the logging middleware
|
||||
logWare <- mkRequestLogger def
|
||||
{ outputFormat =
|
||||
if development
|
||||
then Detailed True
|
||||
else Apache FromSocket
|
||||
, destination = Logger $ appLogger foundation
|
||||
}
|
||||
|
||||
-- Create the WAI application and apply middlewares
|
||||
app <- toWaiAppPlain foundation
|
||||
return $ logWare app
|
||||
where
|
||||
logWare = if development then logStdoutDev
|
||||
else logStdout
|
||||
|
||||
-- | Loads up any necessary settings, creates your foundation datatype, and
|
||||
-- performs some initialization.
|
||||
makeFoundation :: AppConfig DefaultEnv Extra -> IO App
|
||||
makeFoundation conf = do
|
||||
manager <- newManager def
|
||||
@ -61,8 +74,15 @@ makeFoundation conf = do
|
||||
Database.Persist.Store.loadConfig >>=
|
||||
Database.Persist.Store.applyEnv
|
||||
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
|
||||
Database.Persist.Store.runPool dbconf (runMigration migrateAll) p
|
||||
return $ App conf s p manager dbconf
|
||||
logger <- mkLogger True stdout
|
||||
let foundation = App conf s p manager dbconf logger
|
||||
|
||||
-- Perform database migration using our application's logging settings.
|
||||
runLoggingT
|
||||
(Database.Persist.Store.runPool dbconf (runMigration migrateAll) p)
|
||||
(messageLoggerSource foundation logger)
|
||||
|
||||
return foundation
|
||||
|
||||
-- for yesod devel
|
||||
getApplicationDev :: IO (Int, Application)
|
||||
@ -95,6 +115,7 @@ import Model
|
||||
import Text.Jasmine (minifym)
|
||||
import Web.ClientSession (getKey)
|
||||
import Text.Hamlet (hamletFile)
|
||||
import System.Log.FastLogger (Logger)
|
||||
|
||||
-- | The site argument for your application. This can be a good place to
|
||||
-- keep settings and values requiring initialization before your application
|
||||
@ -106,6 +127,7 @@ data App = App
|
||||
, connPool :: Database.Persist.Store.PersistConfigPool Settings.PersistConfig -- ^ Database connection pool.
|
||||
, httpManager :: Manager
|
||||
, persistConfig :: Settings.PersistConfig
|
||||
, appLogger :: Logger
|
||||
}
|
||||
|
||||
-- Set up i18n messages. See the message folder.
|
||||
@ -192,6 +214,8 @@ instance Yesod App where
|
||||
shouldLog _ _source level =
|
||||
development || level == LevelWarn || level == LevelError
|
||||
|
||||
getLogger = return . appLogger
|
||||
|
||||
-- How to run database actions.
|
||||
instance YesodPersist App where
|
||||
type YesodPersistBackend App = SqlPersist
|
||||
@ -392,11 +416,14 @@ library
|
||||
, monad-control >= 0.3 && < 0.4
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, yaml >= 0.8 && < 0.9
|
||||
, http-conduit >= 1.8 && < 1.9
|
||||
, http-conduit >= 1.8 && < 1.10
|
||||
, directory >= 1.1 && < 1.3
|
||||
, warp >= 1.3 && < 1.4
|
||||
, data-default
|
||||
, aeson
|
||||
, conduit >= 1.0
|
||||
, monad-logger >= 0.3
|
||||
, fast-logger >= 0.3
|
||||
|
||||
executable PROJECTNAME
|
||||
if flag(library-only)
|
||||
@ -424,6 +451,7 @@ test-suite test
|
||||
, persistent
|
||||
, persistent-sqlite
|
||||
, resourcet
|
||||
, monad-logger
|
||||
|
||||
{-# START_FILE Settings.hs #-}
|
||||
-- | Settings are centralized, as much as possible, into this file. This
|
||||
@ -5767,15 +5795,18 @@ import Yesod.Test
|
||||
import Database.Persist hiding (get)
|
||||
import Database.Persist.GenericSql (runSqlPool, SqlPersist, Connection)
|
||||
import Control.Monad.Trans.Resource (ResourceT, runResourceT)
|
||||
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
|
||||
|
||||
import Model
|
||||
|
||||
type Specs = SpecsConn Connection
|
||||
|
||||
runDB :: SqlPersist (ResourceT IO) a -> OneSpec Connection a
|
||||
runDB :: SqlPersist (NoLoggingT (ResourceT IO)) a -> OneSpec Connection a
|
||||
runDB = runDBRunner poolRunner
|
||||
where
|
||||
poolRunner query pool = runResourceT $ runSqlPool query pool
|
||||
poolRunner query pool = runResourceT
|
||||
$ runNoLoggingT
|
||||
$ runSqlPool query pool
|
||||
|
||||
{-# START_FILE tests/main.hs #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
@ -4,6 +4,7 @@ We recommend starting with SQLite: it has no dependencies.
|
||||
|
||||
s = sqlite
|
||||
p = postgresql
|
||||
pf = postgresql + Fay (experimental)
|
||||
mongo = mongodb
|
||||
mysql = MySQL
|
||||
simple = no database, no auth
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name: yesod
|
||||
version: 1.1.8
|
||||
version: 1.1.9.2
|
||||
license: MIT
|
||||
license-file: LICENSE
|
||||
author: Michael Snoyman <michael@snoyman.com>
|
||||
@ -22,6 +22,7 @@ extra-source-files:
|
||||
hsfiles/mongo.hsfiles
|
||||
hsfiles/mysql.hsfiles
|
||||
hsfiles/postgres.hsfiles
|
||||
hsfiles/postgres-fay.hsfiles
|
||||
hsfiles/simple.hsfiles
|
||||
hsfiles/sqlite.hsfiles
|
||||
|
||||
@ -34,14 +35,14 @@ library
|
||||
, yesod-default >= 1.1.3 && < 1.2
|
||||
, monad-control >= 0.3 && < 0.4
|
||||
, transformers >= 0.2.2 && < 0.4
|
||||
, wai >= 1.3 && < 1.4
|
||||
, wai >= 1.3 && < 1.5
|
||||
, wai-extra >= 1.3 && < 1.4
|
||||
, hamlet >= 1.1 && < 1.2
|
||||
, shakespeare-js >= 1.0.2 && < 1.2
|
||||
, shakespeare-css >= 1.0 && < 1.1
|
||||
, warp >= 1.3 && < 1.4
|
||||
, blaze-html >= 0.5 && < 0.6
|
||||
, blaze-markup >= 0.5.1 && < 0.6
|
||||
, blaze-html >= 0.5
|
||||
, blaze-markup >= 0.5.1
|
||||
, aeson
|
||||
|
||||
exposed-modules: Yesod
|
||||
@ -100,7 +101,7 @@ executable yesod
|
||||
, fsnotify >= 0.0 && < 0.1
|
||||
, split >= 0.2 && < 0.3
|
||||
, file-embed
|
||||
, conduit >= 0.5 && < 0.6
|
||||
, conduit >= 0.5 && < 1.1
|
||||
, resourcet >= 0.3 && < 0.5
|
||||
, base64-bytestring
|
||||
, lifted-base
|
||||
|
||||
Loading…
Reference in New Issue
Block a user