web: require yesod 1.2, cabal file cleanup

This commit is contained in:
Simon Michael 2013-05-14 15:36:44 -07:00
parent 4ff2635bf8
commit 19d55076a4
7 changed files with 170 additions and 197 deletions

View File

@ -62,6 +62,6 @@ getApplicationDev = do
j <- either error' id `fmap` readJournalFile Nothing Nothing f j <- either error' id `fmap` readJournalFile Nothing Nothing f
defaultDevelApp loader (makeApplication defwebopts j) defaultDevelApp loader (makeApplication defwebopts j)
where where
loader = loadConfig (configSettings Development) loader = Yesod.Default.Config.loadConfig (configSettings Development)
{ csParseExtra = parseExtra { csParseExtra = parseExtra
} }

View File

@ -23,7 +23,6 @@ import Settings (widgetFile, Extra (..))
import Settings (staticDir) import Settings (staticDir)
import Text.Jasmine (minifym) import Text.Jasmine (minifym)
#endif #endif
import Web.ClientSession (getKey)
import Text.Hamlet (hamletFile) import Text.Hamlet (hamletFile)
import Hledger.Web.Options import Hledger.Web.Options
@ -72,7 +71,7 @@ mkYesodData "App" $(parseRoutesFile "config/routes")
-- | A convenience alias. -- | A convenience alias.
type AppRoute = Route App type AppRoute = Route App
type Form x = Html -> MForm App App (FormResult x, Widget) type Form x = Html -> MForm (HandlerT App IO) (FormResult x, 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.
@ -81,11 +80,9 @@ instance Yesod App where
-- Store session data on the client in encrypted cookies, -- Store session data on the client in encrypted cookies,
-- default session idle timeout is 120 minutes -- default session idle timeout is 120 minutes
makeSessionBackend _ = do makeSessionBackend _ = fmap Just $ defaultClientSessionBackend
key <- getKey ".hledger-web_client_session_key.aes" (120 * 60)
let timeout = fromIntegral (120 * 60 :: Int) -- 120 minutes ".hledger-web_client_session_key.aes"
(getCachedDate, _closeDateCacher) <- clientSessionDateCacher timeout
return . Just $ clientSessionBackend2 key getCachedDate
defaultLayout widget = do defaultLayout widget = do
master <- getYesod master <- getYesod

View File

@ -4,7 +4,6 @@ module Handler.Utils where
import Prelude import Prelude
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
import Control.Monad.IO.Class (liftIO)
import Data.IORef import Data.IORef
import Data.Maybe import Data.Maybe
import Data.Text(pack,unpack) import Data.Text(pack,unpack)
@ -12,11 +11,6 @@ import Data.Time.Calendar
import Data.Time.Clock import Data.Time.Clock
import Data.Time.Format import Data.Time.Format
import System.Locale (defaultTimeLocale) import System.Locale (defaultTimeLocale)
#if BLAZE_HTML_0_4
import Text.Blaze (toHtml)
#else
import Text.Blaze.Html (toHtml)
#endif
import Text.Hamlet import Text.Hamlet
import Yesod.Core import Yesod.Core

View File

@ -1,6 +1,5 @@
name: hledger-web name: hledger-web
-- also in cpp-options below version: 0.20.98
version: 0.20.98
category: Finance category: Finance
synopsis: A web interface for the hledger accounting tool. synopsis: A web interface for the hledger accounting tool.
description: description:
@ -46,22 +45,17 @@ extra-source-files:
templates/normalize.lucius templates/normalize.lucius
source-repository head source-repository head
type: git type: git
location: https://github.com/simonmichael/hledger location: https://github.com/simonmichael/hledger
-- Flag production
-- Description: Build fully optimised and with web files embedded (not loaded from ./static/)
-- Default: True
flag threaded flag threaded
Description: Build with support for multithreaded execution. Description: Build with support for multithreaded execution.
Default: True Default: True
flag blaze_html_0_4 flag blaze_html_0_4
description: Use the older 0.4 version of blaze-html. description: Use the older 0.4 version of blaze-html. No longer well tested.
default: False default: False
flag dev flag dev
Description: Turn on development settings, like auto-reload templates. Description: Turn on development settings, like auto-reload templates.
Default: False Default: False
@ -70,38 +64,12 @@ flag library-only
Description: Build for use with "yesod devel" Description: Build for use with "yesod devel"
Default: False Default: False
library library
hs-source-dirs: . app
exposed-modules: Application
Foundation
Import
Settings
Settings.StaticFiles
Settings.Development
Handler.Common
Handler.JournalEditR
Handler.JournalEntriesR
Handler.JournalR
Handler.Post
Handler.RegisterR
Handler.RootR
Handler.Utils
other-modules:
Hledger.Web
Hledger.Web.Main
Hledger.Web.Options
-- if flag(library-only)
-- Buildable: True
-- else
-- Buildable: False
ghc-options: -Wall -fno-warn-unused-do-bind
cpp-options: -DVERSION="0.20.98" cpp-options: -DVERSION="0.20.98"
if flag(dev) || flag(library-only) if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT cpp-options: -DDEVELOPMENT
ghc-options: -Wall -fno-warn-unused-do-bind
extensions: TemplateHaskell extensions: TemplateHaskell
QuasiQuotes QuasiQuotes
@ -117,161 +85,167 @@ library
NoMonomorphismRestriction NoMonomorphismRestriction
RecordWildCards RecordWildCards
build-depends: base >= 4 && < 5 hs-source-dirs: . app
, yesod-platform >= 1.2 && < 1.3 exposed-modules: Application
-- , yesod >= 1.1.3 && < 1.2 Foundation
-- , yesod-core >= 1.1.7 && < 1.2 Import
-- , yesod-static >= 1.1 && < 1.2 Settings
-- , yesod-default >= 1.1 && < 1.2 Settings.StaticFiles
-- , yesod-form >= 1.1 && < 1.3 Settings.Development
-- , clientsession Handler.Common
-- , bytestring >= 0.9 && < 0.11 Handler.JournalEditR
-- , text >= 0.11 && < 0.12 Handler.JournalEntriesR
-- , template-haskell Handler.JournalR
-- , hamlet >= 1.1 && < 1.2 Handler.Post
-- , shakespeare-css >= 1.0 && < 1.1 Handler.RegisterR
-- , shakespeare-js >= 1.0 && < 1.2 Handler.RootR
-- , shakespeare-text >= 1.0 && < 1.1 Handler.Utils
-- , hjsmin >= 0.1 && < 0.2 other-modules:
-- , monad-control >= 0.3 && < 0.4 Hledger.Web
-- , wai-extra >= 1.3 && < 1.4 Hledger.Web.Main
-- , yaml >= 0.8 && < 0.9 Hledger.Web.Options
-- , http-conduit >= 1.8 && < 1.10 -- Setup -- stops yesod devel complaining, requires build-depends: Cabal
-- , directory >= 1.1 && < 1.3 build-depends:
-- , warp >= 1.3 && < 1.4 hledger == 0.20.98
-- , data-default , hledger-lib == 0.20.98
, base >= 4 && < 5
, hledger == 0.20.98 , bytestring
, hledger-lib == 0.20.98 , clientsession
, cmdargs >= 0.10 && < 0.11 , cmdargs >= 0.10 && < 0.11
, data-default
, directory , directory
, filepath , filepath
, hamlet
, hjsmin
, http-conduit
, HUnit , HUnit
, network-conduit , network-conduit
, old-locale , old-locale
, parsec , parsec
, regexpr >= 0.5.1 , regexpr >= 0.5.1
, safe >= 0.2 , safe >= 0.2
, shakespeare-text
, template-haskell
, text
, time , time
, transformers , transformers
, wai , wai
, wai-extra , wai-extra
, wai-handler-launch >= 1.3 && < 1.4 , wai-handler-launch >= 1.3 && < 1.4
, warp , warp
, yaml , yaml
, yesod
-- if flag(blaze_html_0_4) , yesod-core
-- cpp-options: -DBLAZE_HTML_0_4 , yesod-platform >= 1.2 && < 1.3
-- build-depends: , yesod-static
-- blaze-html >= 0.4 && < 0.5 if flag(blaze_html_0_4)
-- else cpp-options: -DBLAZE_HTML_0_4
build-depends: build-depends:
blaze-html >= 0.4 && < 0.5
else
build-depends:
blaze-html >= 0.5 && < 0.7 blaze-html >= 0.5 && < 0.7
, blaze-markup >= 0.5.1 && < 0.7 , blaze-markup >= 0.5.1 && < 0.7
-- executable hledger-web executable hledger-web
-- cpp-options: -DVERSION="0.20.98" if flag(library-only)
Buildable: False
-- if flag(library-only) cpp-options: -DVERSION="0.20.98"
-- Buildable: False if flag(dev)
cpp-options: -DDEVELOPMENT
-- if flag(dev) ghc-options: -Wall -fno-warn-unused-do-bind
-- cpp-options: -DDEVELOPMENT if flag(threaded)
-- ghc-options: -O0 -Wall -fno-warn-unused-do-bind ghc-options: -threaded
-- else if flag(dev)
-- ghc-options: -O2 -Wall -fno-warn-unused-do-bind ghc-options: -O0
else
ghc-options: -O2
-- if flag(threaded) extensions: TemplateHaskell
-- ghc-options: -threaded QuasiQuotes
OverloadedStrings
NoImplicitPrelude
CPP
OverloadedStrings
MultiParamTypeClasses
TypeFamilies
RecordWildCards
-- extensions: TemplateHaskell hs-source-dirs: . app
-- QuasiQuotes main-is: main.hs
-- OverloadedStrings other-modules:
-- NoImplicitPrelude Application
-- CPP Foundation
-- OverloadedStrings Import
-- MultiParamTypeClasses Settings
-- TypeFamilies Settings.StaticFiles
-- RecordWildCards Settings.Development
Handler.Common
Handler.JournalEditR
Handler.JournalEntriesR
Handler.JournalR
Handler.Post
Handler.RegisterR
Handler.RootR
Handler.Utils
Hledger.Web
Hledger.Web.Main
Hledger.Web.Options
-- hs-source-dirs: . app build-depends:
hledger == 0.20.98
, hledger-lib == 0.20.98
, base >= 4 && < 5
, bytestring
, clientsession
, cmdargs >= 0.10 && < 0.11
, data-default
, directory
, filepath
, hamlet
, hjsmin
, http-conduit
, HUnit
, network-conduit
, old-locale
, parsec
, regexpr >= 0.5.1
, safe >= 0.2
, shakespeare-text
, template-haskell
, text
, time
, transformers
, wai
, wai-extra
, wai-handler-launch >= 1.3 && < 1.4
, warp
, yaml
, yesod
, yesod-core
, yesod-platform >= 1.2 && < 1.3
, yesod-static
-- main-is: main.hs if flag(blaze_html_0_4)
-- other-modules: cpp-options: -DBLAZE_HTML_0_4
-- Application build-depends:
-- Foundation blaze-html >= 0.4 && < 0.5
-- Import else
-- Settings build-depends:
-- Settings.StaticFiles blaze-html >= 0.5 && < 0.7
-- Settings.Development , blaze-markup >= 0.5.1 && < 0.7
-- Handler.Common
-- Handler.JournalEditR
-- Handler.JournalEntriesR
-- Handler.JournalR
-- Handler.Post
-- Handler.RegisterR
-- Handler.RootR
-- Handler.Utils
-- Hledger.Web
-- Hledger.Web.Main
-- Hledger.Web.Options
-- build-depends: test-suite test
-- hledger-web type: exitcode-stdio-1.0
-- , hledger == 0.20.0.1 ghc-options: -Wall
-- , hledger-lib == 0.20.0.1 hs-source-dirs: tests
-- , base >= 4.3 && < 5 main-is: main.hs
-- , cmdargs >= 0.10 && < 0.11 build-depends:
-- , directory hledger-web
-- , filepath , base
-- , HUnit , hspec
-- , old-locale , yesod >= 1.2 && < 1.3
-- , parsec , yesod-test >= 1.2 && < 1.3
-- , regexpr >= 0.5.1
-- , safe >= 0.2
-- , time
-- -- , yesod-platform == 1.1.*
-- , yesod >= 1.1.3 && < 1.2
-- , yesod-core >= 1.1.7 && < 1.2
-- , yesod-default
-- , yesod-static
-- , clientsession
-- , hamlet
-- , network-conduit
-- , shakespeare-text
-- , template-haskell
-- , text
-- , transformers
-- , wai
-- , wai-extra
-- , wai-handler-launch >= 1.3 && < 1.4
-- , warp
-- , yaml
-- , hjsmin >= 0.1 && < 0.2
-- , http-conduit >= 1.8 && < 1.10
-- , data-default
-- if flag(blaze_html_0_4)
-- cpp-options: -DBLAZE_HTML_0_4
-- build-depends:
-- blaze-html >= 0.4 && < 0.5
-- else
-- build-depends:
-- blaze-html >= 0.5 && < 0.7
-- , blaze-markup >= 0.5.1 && < 0.7
-- test-suite test
-- type: exitcode-stdio-1.0
-- main-is: main.hs
-- hs-source-dirs: tests
-- ghc-options: -Wall
-- build-depends:
-- base
-- , hledger-web
-- , yesod-test >= 0.3 && < 0.4
-- , yesod-default
-- , yesod-core >= 1.1.7 && < 1.2

View File

@ -7,11 +7,12 @@ import TestImport
homeSpecs :: Specs homeSpecs :: Specs
homeSpecs = homeSpecs =
describe "These are some example tests" $ ydescribe "Some hledger-web tests" $
it "loads the index and checks it looks right" $ do
get_ "/register" yit "serves a reasonable-looking register page" $ do
get RegisterR
statusIs 200 statusIs 200
-- htmlAllContain "h1" "hledger" bodyContains "accounts"
-- post "/" $ do -- post "/" $ do
-- addNonce -- addNonce

View File

@ -1,9 +1,12 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module TestImport module TestImport
( module Yesod.Test ( module Yesod.Test
, module Foundation
, Specs , Specs
) where ) where
import Yesod.Test import Yesod.Test
type Specs = SpecsConn () import Foundation
type Specs = YesodSpec App

View File

@ -7,13 +7,17 @@ module Main where
import Import import Import
import Yesod.Default.Config import Yesod.Default.Config
import Yesod.Test import Yesod.Test
import Test.Hspec (hspec)
import Application (makeFoundation) import Application (makeFoundation)
import HomeTest import HomeTest
main :: IO () main :: IO ()
main = do main = do
conf <- loadConfig $ (configSettings Testing) { csParseExtra = parseExtra } conf <- Yesod.Default.Config.loadConfig $ (configSettings Testing)
{ csParseExtra = parseExtra
}
foundation <- makeFoundation conf foundation <- makeFoundation conf
app <- toWaiAppPlain foundation hspec $ do
runTests app (error "No database available") homeSpecs yesodSpec foundation $ do
homeSpecs