made the following changes to resolve deprecated warnings:

replaced hamletToRepHtml with giveUrlRenderer
  updated type RepHtml to Html
  replaced settingsPort with setPort
This commit is contained in:
Ryan Desfosses 2014-05-21 07:30:54 -04:00
parent 38f977fa48
commit b60da51386
9 changed files with 37 additions and 19 deletions

View File

@ -115,7 +115,7 @@ instance Yesod App where
addScript $ StaticR hledger_js addScript $ StaticR hledger_js
$(widgetFile "default-layout") $(widgetFile "default-layout")
hamletToRepHtml $(hamletFile "templates/default-layout-wrapper.hamlet") giveUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet")
-- This is done to provide an optimization for serving static files from -- This is done to provide an optimization for serving static files from
-- a separate domain. Please see the staticRoot setting in Settings.hs -- a separate domain. Please see the staticRoot setting in Settings.hs

View File

@ -10,12 +10,12 @@ import Handler.Utils
-- | The journal editform, no sidebar. -- | The journal editform, no sidebar.
getJournalEditR :: Handler RepHtml getJournalEditR :: Handler Html
getJournalEditR = do getJournalEditR = do
vd <- getViewData vd <- getViewData
defaultLayout $ do defaultLayout $ do
setTitle "hledger-web journal edit form" setTitle "hledger-web journal edit form"
toWidget $ editform vd toWidget $ editform vd
postJournalEditR :: Handler RepHtml postJournalEditR :: Handler Html
postJournalEditR = handlePost postJournalEditR = handlePost

View File

@ -16,7 +16,7 @@ import Hledger.Web.Options
-- | The journal entries view, with sidebar. -- | The journal entries view, with sidebar.
getJournalEntriesR :: Handler RepHtml getJournalEntriesR :: Handler Html
getJournalEntriesR = do getJournalEntriesR = do
vd@VD{..} <- getViewData vd@VD{..} <- getViewData
staticRootUrl <- (staticRoot . settings) <$> getYesod staticRootUrl <- (staticRoot . settings) <$> getYesod
@ -41,6 +41,6 @@ getJournalEntriesR = do
^{importform} ^{importform}
|] |]
postJournalEntriesR :: Handler RepHtml postJournalEntriesR :: Handler Html
postJournalEntriesR = handlePost postJournalEntriesR = handlePost

View File

@ -14,7 +14,7 @@ import Hledger.Cli.Options
import Hledger.Web.Options import Hledger.Web.Options
-- | The formatted journal view, with sidebar. -- | The formatted journal view, with sidebar.
getJournalR :: Handler RepHtml getJournalR :: Handler Html
getJournalR = do getJournalR = do
vd@VD{..} <- getViewData vd@VD{..} <- getViewData
staticRootUrl <- (staticRoot . settings) <$> getYesod staticRootUrl <- (staticRoot . settings) <$> getYesod
@ -48,6 +48,6 @@ getJournalR = do
^{importform} ^{importform}
|] |]
postJournalR :: Handler RepHtml postJournalR :: Handler Html
postJournalR = handlePost postJournalR = handlePost

View File

@ -20,7 +20,7 @@ import Hledger.Cli
-- | Handle a post from any of the edit forms. -- | Handle a post from any of the edit forms.
handlePost :: Handler RepHtml handlePost :: Handler Html
handlePost = do handlePost = do
action <- lookupPostParam "action" action <- lookupPostParam "action"
case action of Just "add" -> handleAdd case action of Just "add" -> handleAdd
@ -29,7 +29,7 @@ handlePost = do
_ -> invalidArgs ["invalid action"] _ -> invalidArgs ["invalid action"]
-- | Handle a post from the transaction add form. -- | Handle a post from the transaction add form.
handleAdd :: Handler RepHtml handleAdd :: Handler Html
handleAdd = do handleAdd = do
VD{..} <- getViewData VD{..} <- getViewData
-- get form input values. M means a Maybe value. -- get form input values. M means a Maybe value.
@ -91,7 +91,7 @@ handleAdd = do
redirect (RegisterR, [("add","1")]) redirect (RegisterR, [("add","1")])
-- | Handle a post from the journal edit form. -- | Handle a post from the journal edit form.
handleEdit :: Handler RepHtml handleEdit :: Handler Html
handleEdit = do handleEdit = do
VD{..} <- getViewData VD{..} <- getViewData
-- get form input values, or validation errors. -- get form input values, or validation errors.
@ -137,7 +137,7 @@ handleEdit = do
jE jE
-- | Handle a post from the journal import form. -- | Handle a post from the journal import form.
handleImport :: Handler RepHtml handleImport :: Handler Html
handleImport = do handleImport = do
setMessage "can't handle file upload yet" setMessage "can't handle file upload yet"
redirect JournalR redirect JournalR

View File

@ -16,7 +16,7 @@ import Hledger.Cli.Options
import Hledger.Web.Options import Hledger.Web.Options
-- | The main journal/account register view, with accounts sidebar. -- | The main journal/account register view, with accounts sidebar.
getRegisterR :: Handler RepHtml getRegisterR :: Handler Html
getRegisterR = do getRegisterR = do
vd@VD{..} <- getViewData vd@VD{..} <- getViewData
staticRootUrl <- (staticRoot . settings) <$> getYesod staticRootUrl <- (staticRoot . settings) <$> getYesod
@ -46,5 +46,5 @@ getRegisterR = do
^{importform} ^{importform}
|] |]
postRegisterR :: Handler RepHtml postRegisterR :: Handler Html
postRegisterR = handlePost postRegisterR = handlePost

View File

@ -4,5 +4,5 @@ module Handler.RootR where
import Import import Import
getRootR :: Handler RepHtml getRootR :: Handler Html
getRootR = redirect defaultroute where defaultroute = RegisterR getRootR = redirect defaultroute where defaultroute = RegisterR

View File

@ -16,8 +16,8 @@ import Yesod.Default.Config --(fromArgs)
import Settings -- (parseExtra) import Settings -- (parseExtra)
import Application (makeApplication) import Application (makeApplication)
import Data.String import Data.String
import Data.Conduit.Network import Data.Conduit.Network hiding (setPort)
import Network.Wai.Handler.Warp (runSettings, defaultSettings, settingsPort) import Network.Wai.Handler.Warp (runSettings, defaultSettings, setPort)
import Network.Wai.Handler.Launch (runUrlPort) import Network.Wai.Handler.Launch (runUrlPort)
-- --
import Prelude hiding (putStrLn) import Prelude hiding (putStrLn)
@ -61,19 +61,19 @@ web opts j = do
let j' = filterJournalTransactions (queryFromOpts d $ reportopts_ $ cliopts_ opts) j let j' = filterJournalTransactions (queryFromOpts d $ reportopts_ $ cliopts_ opts) j
p = port_ opts p = port_ opts
u = base_url_ opts u = base_url_ opts
staticRoot = pack <$> static_root_ opts staticRoot' = pack <$> static_root_ opts
_ <- printf "Starting web app on port %d with base url %s\n" p u _ <- printf "Starting web app on port %d with base url %s\n" p u
app <- makeApplication opts j' AppConfig{appEnv = Development app <- makeApplication opts j' AppConfig{appEnv = Development
,appPort = p ,appPort = p
,appRoot = pack u ,appRoot = pack u
,appHost = fromString "*4" ,appHost = fromString "*4"
,appExtra = Extra "" Nothing staticRoot ,appExtra = Extra "" Nothing staticRoot'
} }
if server_ opts if server_ opts
then do then do
putStrLn "Press ctrl-c to quit" putStrLn "Press ctrl-c to quit"
hFlush stdout hFlush stdout
runSettings defaultSettings{settingsPort=p} app runSettings (setPort p defaultSettings) app
else do else do
putStrLn "Starting web browser if possible" putStrLn "Starting web browser if possible"
putStrLn "Web app will auto-exit after a few minutes with no browsers (or press ctrl-c)" putStrLn "Web app will auto-exit after a few minutes with no browsers (or press ctrl-c)"

View File

@ -197,3 +197,21 @@ test-suite tests
, wizards == 1.0.* , wizards == 1.0.*
if impl(ghc >= 7.4) if impl(ghc >= 7.4)
build-depends: pretty-show >= 1.6.4 build-depends: pretty-show >= 1.6.4
benchmark bench
type: exitcode-stdio-1.0
-- hs-source-dirs: src
main-is: ../tools/simplebench.hs
ghc-options: -Wall
default-language: Haskell2010
build-depends: hledger-lib,
hledger,
base >= 4.3 && < 5,
old-locale,
time,
html,
tabular >= 0.2 && < 0.3,
process,
filepath,
directory