hledger-web 0.21.3 → 0.22
raw patch · 5 files changed
+52/−30 lines, 5 filesdep +http-clientdep ~hledgerdep ~hledger-libdep ~wai-handler-launch
Dependencies added: http-client
Dependency ranges changed: hledger, hledger-lib, wai-handler-launch, warp, yesod
Files
- Application.hs +21/−2
- Handler/Common.hs +7/−6
- Hledger/Web/Main.hs +4/−4
- Hledger/Web/Options.hs +3/−3
- hledger-web.cabal +17/−15
Application.hs view
@@ -11,8 +11,22 @@ import Yesod.Default.Main import Yesod.Default.Handlers import Network.Wai.Middleware.RequestLogger (logStdoutDev, logStdout)-import Network.HTTP.Conduit (newManager, def)+import Network.HTTP.Conduit (newManager) +-- adapt to http-conduit 1.x or 2.x when cabal macros are available, otherwise assume 2.x+#ifdef MIN_VERSION_http_conduit+#if MIN_VERSION_http_conduit(2,0,0)+#define http_conduit_2+#endif+#else+#define http_conduit_2+#endif+#ifdef http_conduit_2+import Network.HTTP.Client (defaultManagerSettings)+#else+import Network.HTTP.Conduit (def)+#endif+ -- Import all relevant handler modules here. -- Don't forget to add new modules to your cabal file! import Handler.RootR@@ -49,7 +63,12 @@ makeFoundation :: AppConfig DefaultEnv Extra -> IO App makeFoundation conf = do- manager <- newManager def+ manager <- newManager+#ifdef http_conduit_2+ defaultManagerSettings+#else+ def+#endif s <- staticSite jref <- newIORef nulljournal return $ App conf s manager defwebopts jref
Handler/Common.hs view
@@ -48,7 +48,7 @@ -- | The sidebar used on most views. sidebar :: ViewData -> HtmlUrl AppRoute-sidebar vd@VD{..} = accountsReportAsHtml opts vd $ accountsReport (reportopts_ $ cliopts_ opts){empty_=True} am j+sidebar vd@VD{..} = balanceReportAsHtml opts vd $ balanceReport (reportopts_ $ cliopts_ opts){empty_=True} am j -- -- | Navigation link, preserving parameters and possibly highlighted. -- navlink :: ViewData -> String -> AppRoute -> String -> HtmlUrl AppRoute@@ -103,7 +103,8 @@ status:*, status:!, status: (cleared status), # real:BOOL (real/virtual-ness), # empty:BOOL (is amount zero), #- amt:<N, amt:=N, amt:>N (test magnitude of single-commodity amount).+ amt:N, amt:<N, amt:>N (test magnitude of single-commodity amount).+ sym:REGEXP (commodity symbol), # <br> Prepend not: to negate, enclose multi-word patterns in quotes, multiple search terms are AND'ed. |]@@ -284,9 +285,9 @@ ---------------------------------------------------------------------- -- hledger report renderers --- | Render an "AccountsReport" as html.-accountsReportAsHtml :: WebOpts -> ViewData -> AccountsReport -> HtmlUrl AppRoute-accountsReportAsHtml _ vd@VD{..} (items',total) =+-- | Render an "BalanceReport" as html.+balanceReportAsHtml :: WebOpts -> ViewData -> BalanceReport -> HtmlUrl AppRoute+balanceReportAsHtml _ vd@VD{..} (items',total) = [hamlet| <div#accountsheading> <a#accounts-toggle-link.togglelink href="#" title="Toggle sidebar">[+]@@ -328,7 +329,7 @@ inacctmatcher = inAccountQuery qopts allaccts = isNothing inacctmatcher items = items' -- maybe items' (\m -> filter (matchesAccount m . \(a,_,_,_)->a) items') showacctmatcher- itemAsHtml :: ViewData -> AccountsReportItem -> HtmlUrl AppRoute+ itemAsHtml :: ViewData -> BalanceReportItem -> HtmlUrl AppRoute itemAsHtml _ (acct, adisplay, aindent, abal) = [hamlet| <tr.item.#{inacctclass}> <td.account.#{depthclass}>
Hledger/Web/Main.hs view
@@ -35,14 +35,14 @@ main :: IO () main = do opts <- getHledgerWebOpts- when (debug_ $ cliopts_ opts) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts)+ when (debug_ (cliopts_ opts) > 0) $ printf "%s\n" prognameandversion >> printf "opts: %s\n" (show opts) runWith opts runWith :: WebOpts -> IO () runWith opts- | "help" `in_` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp webmode) >> exitSuccess- | "version" `in_` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess- | "binary-filename" `in_` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname)+ | "help" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStr (showModeHelp webmode) >> exitSuccess+ | "version" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn prognameandversion >> exitSuccess+ | "binary-filename" `inRawOpts` (rawopts_ $ cliopts_ opts) = putStrLn (binaryfilename progname) | otherwise = do requireJournalFileExists =<< journalFilePathFromOpts (cliopts_ opts) withJournalDo' opts web
Hledger/Web/Options.hs view
@@ -31,11 +31,11 @@ webmode :: Mode [([Char], [Char])] webmode = (mode "hledger-web" [("command","web")] "start serving the hledger web interface"- mainargsflag []){+ (argsFlag "[PATTERNS]") []){ modeGroupFlags = Group { groupUnnamed = webflags ,groupHidden = [flagNone ["binary-filename"] (setboolopt "binary-filename") "show the download filename for this executable, and exit"]- ,groupNamed = [(generalflagstitle, generalflags1)]+ ,groupNamed = [generalflagsgroup1] } ,modeHelpSuffix=[ -- "Reads your ~/.hledger.journal file, or another specified by $LEDGER_FILE or -f, and starts the full-window curses ui."@@ -61,7 +61,7 @@ toWebOpts :: RawOpts -> IO WebOpts toWebOpts rawopts = do- cliopts <- toCliOpts rawopts+ cliopts <- rawOptsToCliOpts rawopts let p = fromMaybe defport $ maybeintopt "port" rawopts return defwebopts { port_ = p
hledger-web.cabal view
@@ -1,5 +1,6 @@ name: hledger-web-version: 0.21.3+version: 0.22+stability: beta category: Finance synopsis: A web interface for the hledger accounting tool. description: @@ -16,8 +17,7 @@ maintainer: Simon Michael <simon@joyful.com> homepage: http://hledger.org bug-reports: http://hledger.org/bugs-stability: beta-tested-with: GHC==7.4.2, GHC==7.6.1+tested-with: GHC==7.4.2, GHC==7.6.3 cabal-version: >= 1.8 build-type: Simple extra-tmp-files:@@ -66,7 +66,7 @@ Default: False library- cpp-options: -DVERSION="0.21.3"+ cpp-options: -DVERSION="0.22" if flag(dev) || flag(library-only) cpp-options: -DDEVELOPMENT @@ -109,8 +109,8 @@ Hledger.Web.Options -- Setup -- stops yesod devel complaining, requires build-depends: Cabal build-depends:- hledger == 0.21.3- , hledger-lib == 0.21.3+ hledger == 0.22+ , hledger-lib == 0.22 , base >= 4 && < 5 , bytestring , clientsession@@ -121,6 +121,7 @@ , hamlet , hjsmin , http-conduit+ , http-client >= 0.2 && < 0.3 , HUnit , network-conduit , old-locale@@ -134,10 +135,10 @@ , transformers , wai , wai-extra- , wai-handler-launch >= 1.3 && < 1.4- , warp+ , wai-handler-launch >= 1.3 && < 2.1+ , warp >= 1.3 && < 2.1 , yaml- , yesod+ , yesod >= 1.2 && < 1.3 , yesod-core , yesod-static , json@@ -156,7 +157,7 @@ if flag(library-only) Buildable: False - cpp-options: -DVERSION="0.21.3"+ cpp-options: -DVERSION="0.22" if flag(dev) cpp-options: -DDEVELOPMENT @@ -200,8 +201,8 @@ Hledger.Web.Options build-depends:- hledger == 0.21.3- , hledger-lib == 0.21.3+ hledger == 0.22+ , hledger-lib == 0.22 , base >= 4 && < 5 , bytestring , clientsession@@ -212,6 +213,7 @@ , hamlet , hjsmin , http-conduit+ , http-client >= 0.2 && < 0.3 , HUnit , network-conduit , old-locale@@ -225,10 +227,10 @@ , transformers , wai , wai-extra- , wai-handler-launch >= 1.3 && < 1.4- , warp+ , wai-handler-launch >= 1.3 && < 2.1+ , warp >= 1.3 && < 2.1 , yaml- , yesod+ , yesod >= 1.2 && < 1.3 , yesod-core , yesod-static , json