Merge remote-tracking branch 'sm/master'
This commit is contained in:
commit
5e3d6d6d3d
@ -1,3 +1,5 @@
|
|||||||
|
# http://docs.haskellstack.org/en/stable/travis_ci.html
|
||||||
|
|
||||||
language: haskell
|
language: haskell
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
@ -19,7 +21,7 @@ cache:
|
|||||||
before_install:
|
before_install:
|
||||||
- mkdir -p ~/.local/bin
|
- mkdir -p ~/.local/bin
|
||||||
- export PATH=~/.local/bin:$PATH
|
- export PATH=~/.local/bin:$PATH
|
||||||
- travis_retry curl -L https://github.com/commercialhaskell/stack/releases/download/v0.1.3.1/stack-0.1.3.1-x86_64-linux.gz | gunzip > ~/.local/bin/stack
|
- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'
|
||||||
- chmod a+x ~/.local/bin/stack
|
- chmod a+x ~/.local/bin/stack
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
|||||||
13
Makefile
13
Makefile
@ -1273,13 +1273,12 @@ tagrelease: \
|
|||||||
# @darcs changes --from-tag $(FROMTAG) |grep '^\w' |cut -c 31- |sort |uniq
|
# @darcs changes --from-tag $(FROMTAG) |grep '^\w' |cut -c 31- |sort |uniq
|
||||||
# @echo
|
# @echo
|
||||||
|
|
||||||
# showloc: \
|
cloc: \
|
||||||
# $(call def-help,showloc,\
|
$(call def-help,cloc, count lines of source code )
|
||||||
# \
|
@echo Lines of code including tests:
|
||||||
# )
|
@cloc --exclude-lang=HTML --exclude-dir=.stack-work,.idea,dist,old,bin,doc,site,.tutorial-data .
|
||||||
# @echo Current lines of code including tests:
|
@echo
|
||||||
# @sloccount `ls $(SOURCEFILES)` | grep haskell:
|
# `ls $(SOURCEFILES)`
|
||||||
# @echo
|
|
||||||
|
|
||||||
# sloc: \
|
# sloc: \
|
||||||
# $(call def-help,sloc,\
|
# $(call def-help,sloc,\
|
||||||
|
|||||||
@ -8,10 +8,12 @@
|
|||||||
-- {-# LANGUAGE TypeSynonymInstances #-}
|
-- {-# LANGUAGE TypeSynonymInstances #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
import Control.Monad.IO.Class
|
||||||
import Control.Monad.Trans.Either
|
import Control.Monad.Trans.Either
|
||||||
import Control.Monad.Trans.Reader
|
import Control.Monad.Trans.Reader
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
@ -19,7 +21,7 @@ import Data.Decimal
|
|||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
import Data.Proxy
|
import Data.Proxy
|
||||||
import Data.Text
|
import Data.Text hiding (map,reverse)
|
||||||
import GHC.Generics
|
import GHC.Generics
|
||||||
import Network.Wai as Wai
|
import Network.Wai as Wai
|
||||||
import Network.Wai.Handler.Warp as Warp
|
import Network.Wai.Handler.Warp as Warp
|
||||||
@ -31,6 +33,7 @@ import System.Exit
|
|||||||
import System.IO
|
import System.IO
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
|
|
||||||
|
import Hledger.Query
|
||||||
import Hledger.Cli hiding (Reader, version)
|
import Hledger.Cli hiding (Reader, version)
|
||||||
|
|
||||||
version="0.27.98"
|
version="0.27.98"
|
||||||
@ -68,42 +71,57 @@ main = do
|
|||||||
|
|
||||||
serveApi :: FilePath -> Int -> Journal -> IO ()
|
serveApi :: FilePath -> Int -> Journal -> IO ()
|
||||||
serveApi f p j = do
|
serveApi f p j = do
|
||||||
printf "Starting web api for %s on port %d\nPress ctrl-c to quit\n" f p >> hFlush stdout
|
printf "Starting web api for %s on port %d\nPress ctrl-c to quit\n" f p
|
||||||
Warp.run p $ hledgerApiApp j
|
Warp.run p $ hledgerApiApp j
|
||||||
|
|
||||||
hledgerApiApp :: Journal -> Wai.Application
|
|
||||||
hledgerApiApp j = Servant.serve hledgerApi hledgerApiServer
|
|
||||||
where
|
|
||||||
hledgerApi :: Proxy HledgerApi
|
|
||||||
hledgerApi = Proxy
|
|
||||||
|
|
||||||
hledgerApiServer :: Servant.Server HledgerApi
|
|
||||||
hledgerApiServer = Servant.enter readerToEither hledgerServerT
|
|
||||||
where
|
|
||||||
readerToEither :: Reader Journal :~> EitherT ServantErr IO
|
|
||||||
readerToEither = Nat $ \r -> return (runReader r j)
|
|
||||||
|
|
||||||
type HledgerApi =
|
type HledgerApi =
|
||||||
"accounts" :> Get '[JSON] [AccountName]
|
"accountnames" :> Get '[JSON] [AccountName]
|
||||||
:<|> "transactions" :> Get '[JSON] [Transaction]
|
:<|> "transactions" :> Get '[JSON] [Transaction]
|
||||||
:<|> "prices" :> Get '[JSON] [MarketPrice]
|
:<|> "prices" :> Get '[JSON] [MarketPrice]
|
||||||
:<|> "commodities" :> Get '[JSON] [Commodity]
|
:<|> "commodities" :> Get '[JSON] [Commodity]
|
||||||
|
:<|> "accounts" :> Get '[JSON] [Account]
|
||||||
|
:<|> "reports" :>
|
||||||
|
"accounttransactions" :> Capture "acct" AccountName :> Get '[JSON] AccountTransactionsReport
|
||||||
|
:<|> Raw
|
||||||
|
|
||||||
hledgerServerT :: ServerT HledgerApi (Reader Journal)
|
hledgerApiApp :: Journal -> Wai.Application
|
||||||
hledgerServerT =
|
hledgerApiApp j = Servant.serve api server
|
||||||
accountsH
|
|
||||||
:<|> transactionsH
|
|
||||||
:<|> pricesH
|
|
||||||
:<|> commoditiesH
|
|
||||||
where
|
where
|
||||||
accountsH = journalAccountNames <$> ask
|
api :: Proxy HledgerApi
|
||||||
transactionsH = jtxns <$> ask
|
api = Proxy
|
||||||
pricesH = jmarketprices <$> ask
|
|
||||||
commoditiesH = (M.keys . jcommoditystyles) <$> ask
|
|
||||||
|
|
||||||
|
server :: Server HledgerApi
|
||||||
|
server =
|
||||||
|
accountnamesH
|
||||||
|
:<|> transactionsH
|
||||||
|
:<|> pricesH
|
||||||
|
:<|> commoditiesH
|
||||||
|
:<|> accountsH
|
||||||
|
:<|> accounttransactionsH
|
||||||
|
:<|> serveDirectory "static"
|
||||||
|
where
|
||||||
|
accountnamesH = return $ journalAccountNames j
|
||||||
|
transactionsH = return $ jtxns j
|
||||||
|
pricesH = return $ jmarketprices j
|
||||||
|
commoditiesH = return $ (M.keys . jcommoditystyles) j
|
||||||
|
accountsH = return $ laccounts $ ledgerFromJournal Hledger.Cli.Any j
|
||||||
|
accounttransactionsH (a::AccountName) = do
|
||||||
|
-- d <- liftIO getCurrentDay
|
||||||
|
let
|
||||||
|
ropts = defreportopts
|
||||||
|
-- ropts' = ropts {depth_=Nothing
|
||||||
|
-- ,balancetype_=HistoricalBalance
|
||||||
|
-- }
|
||||||
|
q = Hledger.Query.Any --filterQuery (not . queryIsDepth) $ queryFromOpts d ropts'
|
||||||
|
thisacctq = Acct $ accountNameToAccountRegex a -- includes subs
|
||||||
|
return $ accountTransactionsReport ropts j q thisacctq
|
||||||
|
|
||||||
instance ToJSON ClearedStatus where toJSON = genericToJSON defaultOptions -- avoid https://github.com/bos/aeson/issues/290
|
-- brief toJSON definitions included to avoid https://github.com/bos/aeson/issues/290
|
||||||
|
-- use toEncoding = genericToEncoding defaultOptions instead ?
|
||||||
|
instance ToJSON ClearedStatus where toJSON = genericToJSON defaultOptions
|
||||||
instance ToJSON GenericSourcePos where toJSON = genericToJSON defaultOptions
|
instance ToJSON GenericSourcePos where toJSON = genericToJSON defaultOptions
|
||||||
|
instance ToJSON Decimal where
|
||||||
|
toJSON = toJSON . show
|
||||||
instance ToJSON Amount where toJSON = genericToJSON defaultOptions
|
instance ToJSON Amount where toJSON = genericToJSON defaultOptions
|
||||||
instance ToJSON AmountStyle where toJSON = genericToJSON defaultOptions
|
instance ToJSON AmountStyle where toJSON = genericToJSON defaultOptions
|
||||||
instance ToJSON Side where toJSON = genericToJSON defaultOptions
|
instance ToJSON Side where toJSON = genericToJSON defaultOptions
|
||||||
@ -111,27 +129,31 @@ instance ToJSON DigitGroupStyle where toJSON = genericToJSON defaultOptions
|
|||||||
instance ToJSON MixedAmount where toJSON = genericToJSON defaultOptions
|
instance ToJSON MixedAmount where toJSON = genericToJSON defaultOptions
|
||||||
instance ToJSON Price where toJSON = genericToJSON defaultOptions
|
instance ToJSON Price where toJSON = genericToJSON defaultOptions
|
||||||
instance ToJSON MarketPrice where toJSON = genericToJSON defaultOptions
|
instance ToJSON MarketPrice where toJSON = genericToJSON defaultOptions
|
||||||
instance ToJSON Posting
|
|
||||||
where
|
|
||||||
toJSON Posting{..} =
|
|
||||||
object
|
|
||||||
["pdate" .= toJSON pdate
|
|
||||||
,"pdate2" .= toJSON pdate2
|
|
||||||
,"pstatus" .= toJSON pstatus
|
|
||||||
,"paccount" .= toJSON paccount
|
|
||||||
,"pamount" .= toJSON pamount
|
|
||||||
,"pcomment" .= toJSON pcomment
|
|
||||||
,"ptype" .= toJSON ptype
|
|
||||||
,"ptags" .= toJSON ptags
|
|
||||||
,"pbalanceassertion" .= toJSON pbalanceassertion
|
|
||||||
-- just show parent transaction's index
|
|
||||||
,"ptransaction" .= toJSON (maybe "" (show.tindex) ptransaction)
|
|
||||||
]
|
|
||||||
instance ToJSON PostingType where toJSON = genericToJSON defaultOptions
|
instance ToJSON PostingType where toJSON = genericToJSON defaultOptions
|
||||||
|
instance ToJSON Posting where
|
||||||
|
toJSON Posting{..} =
|
||||||
|
object
|
||||||
|
["pdate" .= toJSON pdate
|
||||||
|
,"pdate2" .= toJSON pdate2
|
||||||
|
,"pstatus" .= toJSON pstatus
|
||||||
|
,"paccount" .= toJSON paccount
|
||||||
|
,"pamount" .= toJSON pamount
|
||||||
|
,"pcomment" .= toJSON pcomment
|
||||||
|
,"ptype" .= toJSON ptype
|
||||||
|
,"ptags" .= toJSON ptags
|
||||||
|
,"pbalanceassertion" .= toJSON pbalanceassertion
|
||||||
|
,"ptransactionidx" .= toJSON (maybe "" (show.tindex) ptransaction)
|
||||||
|
]
|
||||||
instance ToJSON Transaction where toJSON = genericToJSON defaultOptions
|
instance ToJSON Transaction where toJSON = genericToJSON defaultOptions
|
||||||
instance ToJSON Decimal
|
instance ToJSON Account where
|
||||||
where
|
toJSON a =
|
||||||
-- toJSON (Decimal decimalPlaces decimalMantissa) =
|
object
|
||||||
-- object ["places" .= decimalPlaces, "mantissa" .= decimalMantissa]
|
["aname" .= toJSON (aname a)
|
||||||
-- toEncoding = genericToEncoding defaultOptions
|
,"aebalance" .= toJSON (aebalance a)
|
||||||
toJSON d = toJSON $ show d
|
,"aibalance" .= toJSON (aibalance a)
|
||||||
|
,"anumpostings" .= toJSON (anumpostings a)
|
||||||
|
,"aboring" .= toJSON (aboring a)
|
||||||
|
,"aparentname" .= toJSON (maybe "" aname $ aparent a)
|
||||||
|
,"asubs" .= toJSON (map toJSON $ asubs a)
|
||||||
|
]
|
||||||
|
instance ToJSON AccountTransactionsReport where toJSON = genericToJSON defaultOptions
|
||||||
|
|||||||
1
hledger-api/static/README.txt
Normal file
1
hledger-api/static/README.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Files under this directory are served by hledger-api when no other API route is matched.
|
||||||
@ -1,6 +1,10 @@
|
|||||||
User-visible changes in hledger-ui.
|
User-visible changes in hledger-ui.
|
||||||
See also hledger's change log.
|
See also hledger's change log.
|
||||||
|
|
||||||
|
0.27.3 (2016/1/12)
|
||||||
|
|
||||||
|
- allow brick 0.4
|
||||||
|
|
||||||
0.27.2 (2016/1/11)
|
0.27.2 (2016/1/11)
|
||||||
|
|
||||||
- allow brick 0.3.x
|
- allow brick 0.3.x
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
name: hledger-ui
|
name: hledger-ui
|
||||||
version: 0.27.2
|
version: 0.27.3
|
||||||
stability: beta
|
stability: beta
|
||||||
category: Finance, Console
|
category: Finance, Console
|
||||||
synopsis: Curses-style user interface for the hledger accounting tool
|
synopsis: Curses-style user interface for the hledger accounting tool
|
||||||
@ -25,7 +25,7 @@ homepage: http://hledger.org
|
|||||||
bug-reports: http://bugs.hledger.org
|
bug-reports: http://bugs.hledger.org
|
||||||
cabal-version: >= 1.10
|
cabal-version: >= 1.10
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
tested-with: GHC==7.8.4, GHC==7.10.2
|
tested-with: GHC==7.8.4, GHC==7.10.3
|
||||||
|
|
||||||
extra-source-files:
|
extra-source-files:
|
||||||
CHANGES
|
CHANGES
|
||||||
@ -54,13 +54,13 @@ executable hledger-ui
|
|||||||
ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans
|
ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans
|
||||||
if flag(threaded)
|
if flag(threaded)
|
||||||
ghc-options: -threaded
|
ghc-options: -threaded
|
||||||
cpp-options: -DVERSION="0.27.2"
|
cpp-options: -DVERSION="0.27.3"
|
||||||
build-depends:
|
build-depends:
|
||||||
hledger >= 0.27 && < 0.28
|
hledger >= 0.27 && < 0.28
|
||||||
, hledger-lib >= 0.27 && < 0.28
|
, hledger-lib >= 0.27 && < 0.28
|
||||||
, base >= 3 && < 5
|
, base >= 3 && < 5
|
||||||
, base-compat >= 0.8.1
|
, base-compat >= 0.8.1
|
||||||
, brick >= 0.2 && < 0.4
|
, brick >= 0.2 && < 0.5
|
||||||
, cmdargs >= 0.8
|
, cmdargs >= 0.8
|
||||||
, containers
|
, containers
|
||||||
, data-default
|
, data-default
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
# - conditional blocks
|
# - conditional blocks
|
||||||
|
|
||||||
name : hledger-ui
|
name : hledger-ui
|
||||||
version : '0.27.2'
|
version : '0.27.3'
|
||||||
stability : beta
|
stability : beta
|
||||||
category : Finance, Console
|
category : Finance, Console
|
||||||
synopsis : Curses-style user interface for the hledger accounting tool
|
synopsis : Curses-style user interface for the hledger accounting tool
|
||||||
@ -31,7 +31,7 @@ github : simonmichael/hledger
|
|||||||
homepage : http://hledger.org
|
homepage : http://hledger.org
|
||||||
bug-reports : http://bugs.hledger.org
|
bug-reports : http://bugs.hledger.org
|
||||||
# XXX not supported
|
# XXX not supported
|
||||||
tested-with : GHC==7.10.2
|
tested-with : GHC==7.10.3
|
||||||
|
|
||||||
extra-source-files:
|
extra-source-files:
|
||||||
- CHANGES
|
- CHANGES
|
||||||
@ -54,7 +54,7 @@ ghc-options:
|
|||||||
-fno-warn-type-defaults
|
-fno-warn-type-defaults
|
||||||
-fno-warn-orphans
|
-fno-warn-orphans
|
||||||
|
|
||||||
cpp-options: -DVERSION="0.27.2"
|
cpp-options: -DVERSION="0.27.3"
|
||||||
|
|
||||||
executables:
|
executables:
|
||||||
hledger-ui:
|
hledger-ui:
|
||||||
@ -69,7 +69,7 @@ executables:
|
|||||||
- hledger-lib >= 0.27 && < 0.28
|
- hledger-lib >= 0.27 && < 0.28
|
||||||
- base >= 3 && < 5
|
- base >= 3 && < 5
|
||||||
- base-compat >= 0.8.1
|
- base-compat >= 0.8.1
|
||||||
- brick >= 0.2 && < 0.4
|
- brick >= 0.2 && < 0.5
|
||||||
- cmdargs >= 0.8
|
- cmdargs >= 0.8
|
||||||
- containers
|
- containers
|
||||||
- data-default
|
- data-default
|
||||||
|
|||||||
@ -98,9 +98,7 @@ This is a quick way to help the project and your fellow users!
|
|||||||
<!-- needed if you will be processing >50,000 transactions at once -->
|
<!-- needed if you will be processing >50,000 transactions at once -->
|
||||||
2. `stack setup`
|
2. `stack setup`
|
||||||
(if you need GHC installed. If you're not sure, run the next command and it will tell you.)
|
(if you need GHC installed. If you're not sure, run the next command and it will tell you.)
|
||||||
3. `stack --resolver nightly-2015-11-04 install hledger [hledger-web]` \
|
3. `stack --resolver lts-4 install hledger [hledger-ui] [hledger-web]`
|
||||||
<!-- `stack --resolver nightly-2015-11-02 install hledger-ui` (the curses-style interfaces; [not yet available on Windows](https://github.com/coreyoconnor/vty/pull/1); also installs the CLI), or\ -->
|
|
||||||
*2015/11/3: hledger-ui has [not yet reached stackage](https://github.com/fpco/stackage/issues/938); you must install it from source or with cabal, see below.*
|
|
||||||
4. Ensure `~/.local/bin` or the Windows equivalent is in your `$PATH`,
|
4. Ensure `~/.local/bin` or the Windows equivalent is in your `$PATH`,
|
||||||
so that you can just type `hledger` to run it.
|
so that you can just type `hledger` to run it.
|
||||||
(stack will show the proper directory and will tell you if it is not in $PATH).
|
(stack will show the proper directory and will tell you if it is not in $PATH).
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user